Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,29 @@ Changelog for the Cortex terraform provider.

## Unreleased

## 0.4.7
* Updates to `cortex_catalog_entity` resource to force resource recreation when the type is changed.

## 0.4.6
* Version bump in Makefile

## 0.4.5
* Fix acceptance tests
* Enhance team data source to return team members and slack channels
* Fix readme provider source and version pinning
* Bump github.com/life4/genesis from 1.8.1 to 1.10.2

## 0.4.4
* Fix for broken integration test
* Add support for an Open API specification to be associated with an Entity

## 0.4.3
* Remove category usage in tests, add deprecation for scorecard category field
* Make `draft` optional for scorecards
* Update test requirements for PRs and `main` branch
* Fix CI Suite, support CircleCI stanza for catalog entities
* Move CI suite to Terraform 1.10

## 0.4.2
* Fixes `cortex_scorecard` resource so that `rules` are a set. Order doesn't matter.

Expand All @@ -10,7 +33,7 @@ Changelog for the Cortex terraform provider.

## 0.4.0
* Deprecate `x-cortex-parents` and use `x-cortex-parents` instead
- Bump Go version 1.20 -> 1.22
* Bump Go version 1.20 -> 1.22

## 0.3.1
* Fix serialization for `git` / `sonarqube` / `codecov`
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ HOSTNAME=github.com
NAMESPACE=cortexapps
NAME=cortex
BINARY=terraform-provider-${NAME}
VERSION=0.4.6-dev
VERSION=0.4.7-dev

GOOS?=$(shell go env | grep GOOS | cut -d '=' -f2 | tr -d "'")
GOARCH?=$(shell go env | grep GOARCH | cut -d '=' -f2 | tr -d "'")
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/catalog_entity.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Catalog Entity
- `snyk` (Attributes) Snyk configuration for the entity. (see [below for nested schema](#nestedatt--snyk))
- `static_analysis` (Attributes) Static analysis configuration for the entity. (see [below for nested schema](#nestedatt--static_analysis))
- `team` (Attributes) Team configuration for the entity. Only used for entities of type `TEAM`. (see [below for nested schema](#nestedatt--team))
- `type` (String) Set when the entity is a Resource or Team. This must match a tag of a valid Resource Definition or be "team" or "domain".
- `type` (String) Set when the entity is a Resource or Team. This must match a tag of a valid Resource Definition or be "team" or "domain". **Note:** Changing this attribute will force replacement of the resource.
- `wiz` (Attributes) Wiz configuration for the entity. (see [below for nested schema](#nestedatt--wiz))

### Read-Only
Expand Down
5 changes: 4 additions & 1 deletion internal/provider/catalog_entity_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ func (r *CatalogEntityResource) Schema(ctx context.Context, req resource.SchemaR
},
},
"type": schema.StringAttribute{
MarkdownDescription: "Set when the entity is a Resource or Team. This must match a tag of a valid Resource Definition or be \"team\" or \"domain\".",
MarkdownDescription: "Set when the entity is a Resource or Team. This must match a tag of a valid Resource Definition or be \"team\" or \"domain\". **Note:** Changing this attribute will force replacement of the resource.",
Optional: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
},
"definition": schema.StringAttribute{
MarkdownDescription: "Set when the entity is a Resource. These are the properties defined by the Resource Definition, in JSON format in a string (use the `jsonencode` function to convert a JSON object to a string).",
Expand Down
44 changes: 44 additions & 0 deletions internal/provider/catalog_entity_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -679,3 +679,47 @@ resource "cortex_catalog_entity" "test-unmanaged-metadata" {
})
}`, tag, name, description)
}

func TestAccCatalogEntityResourceTypeRequiresReplace(t *testing.T) {
tag := "test-type-requires-replace"
resourceName := "cortex_catalog_entity.test-type-requires-replace"
name := "Type Requires Replace Test Entity"
description := "Entity to test type attribute RequiresReplace behavior"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
// Create with type "team"
{
Config: testAccCatalogEntityResourceTypeRequiresReplace(tag, name, description, "team"),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "tag", tag),
resource.TestCheckResourceAttr(resourceName, "name", name),
resource.TestCheckResourceAttr(resourceName, "description", description),
resource.TestCheckResourceAttr(resourceName, "type", "team"),
),
},
// Update type to "domain" - should trigger replace
{
Config: testAccCatalogEntityResourceTypeRequiresReplace(tag, name, description, "domain"),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "tag", tag),
resource.TestCheckResourceAttr(resourceName, "name", name),
resource.TestCheckResourceAttr(resourceName, "description", description),
resource.TestCheckResourceAttr(resourceName, "type", "domain"),
),
},
// Delete testing automatically occurs in TestCase
},
})
}

func testAccCatalogEntityResourceTypeRequiresReplace(tag string, name string, description string, entityType string) string {
return fmt.Sprintf(`
resource "cortex_catalog_entity" "test-type-requires-replace" {
tag = %[1]q
name = %[2]q
description = %[3]q
type = %[4]q
}`, tag, name, description, entityType)
}