From 633ad4bf1e9bb56ec1f9360980ed78d3df60feeb Mon Sep 17 00:00:00 2001 From: Grace Rehn Date: Mon, 2 Dec 2024 12:49:28 +1000 Subject: [PATCH] chore: remove subject keys which are not needed --- .../resource.tf | 4 +--- .../resource_generic_oidc_account_test.go | 14 ++++-------- octopusdeploy/schema_generic_oidc_account.go | 22 ++++--------------- 3 files changed, 9 insertions(+), 31 deletions(-) diff --git a/examples/resources/octopusdeploy_generic_openid_connect_account/resource.tf b/examples/resources/octopusdeploy_generic_openid_connect_account/resource.tf index 11893d6c..d03a1dd8 100644 --- a/examples/resources/octopusdeploy_generic_openid_connect_account/resource.tf +++ b/examples/resources/octopusdeploy_generic_openid_connect_account/resource.tf @@ -1,7 +1,5 @@ resource "octopusdeploy_azure_openid_connect" "example" { name = "Generic OpenID Connect Account (OK to Delete)" execution_subject_keys = ["space", "project"] - health_subject_keys = ["space", "target", "type"] - account_test_subject_keys = ["space", "type"] - audience = "api://Default" + audience = "api://default" } \ No newline at end of file diff --git a/octopusdeploy/resource_generic_oidc_account_test.go b/octopusdeploy/resource_generic_oidc_account_test.go index 2f88daca..0062e7ba 100644 --- a/octopusdeploy/resource_generic_oidc_account_test.go +++ b/octopusdeploy/resource_generic_oidc_account_test.go @@ -20,8 +20,6 @@ func TestAccOctopusDeployGenericOpenIDConnectAccountBasic(t *testing.T) { tenantedDeploymentMode := core.TenantedDeploymentModeTenantedOrUntenanted executionKeys := []string{"space"} - healthKeys := []string{"target"} - accountKeys := []string{"type"} audience := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) newDescription := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) @@ -38,11 +36,9 @@ func TestAccOctopusDeployGenericOpenIDConnectAccountBasic(t *testing.T) { resource.TestCheckResourceAttr(prefix, "name", name), resource.TestCheckResourceAttr(prefix, "tenanted_deployment_participation", string(tenantedDeploymentMode)), resource.TestCheckResourceAttr(prefix, "execution_subject_keys.0", executionKeys[0]), - resource.TestCheckResourceAttr(prefix, "health_subject_keys.0", healthKeys[0]), - resource.TestCheckResourceAttr(prefix, "account_test_subject_keys.0", accountKeys[0]), resource.TestCheckResourceAttr(prefix, "audience", audience), ), - Config: testGenericOpenIDConnectAccountBasic(localName, name, description, tenantedDeploymentMode, executionKeys, healthKeys, accountKeys, audience), + Config: testGenericOpenIDConnectAccountBasic(localName, name, description, tenantedDeploymentMode, executionKeys, audience), }, { Check: resource.ComposeTestCheckFunc( @@ -51,17 +47,15 @@ func TestAccOctopusDeployGenericOpenIDConnectAccountBasic(t *testing.T) { resource.TestCheckResourceAttr(prefix, "name", name), resource.TestCheckResourceAttr(prefix, "tenanted_deployment_participation", string(tenantedDeploymentMode)), resource.TestCheckResourceAttr(prefix, "execution_subject_keys.0", executionKeys[0]), - resource.TestCheckResourceAttr(prefix, "health_subject_keys.0", healthKeys[0]), - resource.TestCheckResourceAttr(prefix, "account_test_subject_keys.0", accountKeys[0]), resource.TestCheckResourceAttr(prefix, "audience", audience), ), - Config: testGenericOpenIDConnectAccountBasic(localName, name, newDescription, tenantedDeploymentMode, executionKeys, healthKeys, accountKeys, audience), + Config: testGenericOpenIDConnectAccountBasic(localName, name, newDescription, tenantedDeploymentMode, executionKeys, audience), }, }, }) } -func testGenericOpenIDConnectAccountBasic(localName string, name string, description string, tenantedDeploymentParticipation core.TenantedDeploymentMode, execution_subject_keys []string, health_subject_keys []string, account_test_subject_keys []string, audience string) string { +func testGenericOpenIDConnectAccountBasic(localName string, name string, description string, tenantedDeploymentParticipation core.TenantedDeploymentMode, execution_subject_keys []string, audience string) string { return fmt.Sprintf(`resource "octopusdeploy_generic_openid_connect_account" "%s" { description = "%s" name = "%s" @@ -74,5 +68,5 @@ func testGenericOpenIDConnectAccountBasic(localName string, name string, descrip data "octopusdeploy_accounts" "test" { ids = [octopusdeploy_generic_openid_connect_account.%s.id] - }`, localName, description, name, tenantedDeploymentParticipation, StringArrayToTerraformArrayFormat(execution_subject_keys), StringArrayToTerraformArrayFormat(health_subject_keys), StringArrayToTerraformArrayFormat(account_test_subject_keys), audience, localName) + }`, localName, description, name, tenantedDeploymentParticipation, StringArrayToTerraformArrayFormat(execution_subject_keys), audience, localName) } diff --git a/octopusdeploy/schema_generic_oidc_account.go b/octopusdeploy/schema_generic_oidc_account.go index ea4c34b8..03136abe 100644 --- a/octopusdeploy/schema_generic_oidc_account.go +++ b/octopusdeploy/schema_generic_oidc_account.go @@ -42,16 +42,12 @@ func expandGenericOpenIDConnectAccount(d *schema.ResourceData) *accounts.Generic account.TenantIDs = getSliceFromTerraformTypeList(v) } - if v, ok := d.GetOk("execution_subject_keys"); ok { - account.DeploymentSubjectKeys = getSliceFromTerraformTypeList(v) + if v, ok := d.GetOk("audience"); ok { + account.Audience = v.(string) } - if v, ok := d.GetOk("health_subject_keys"); ok { - account.HealthCheckSubjectKeys = getSliceFromTerraformTypeList(v) - } - - if v, ok := d.GetOk("account_test_subject_keys"); ok { - account.AccountTestSubjectKeys = getSliceFromTerraformTypeList(v) + if v, ok := d.GetOk("execution_subject_keys"); ok { + account.DeploymentSubjectKeys = getSliceFromTerraformTypeList(v) } return account @@ -68,8 +64,6 @@ func getGenericOpenIdConnectAccountSchema() map[string]*schema.Schema { "tenants": getTenantsSchema(), "tenant_tags": getTenantTagsSchema(), "execution_subject_keys": getSubjectKeysSchema(SchemaSubjectKeysDescriptionExecution), - "health_subject_keys": getSubjectKeysSchema(SchemaSubjectKeysDescriptionHealth), - "account_test_subject_keys": getSubjectKeysSchema(SchemaSubjectKeysDescriptionAccountTest), "audience": getOidcAudienceSchema(), } } @@ -98,13 +92,5 @@ func setGenericOpenIDConnectAccount(ctx context.Context, d *schema.ResourceData, return fmt.Errorf("error setting execution_subject_keys: %s", err) } - if err := d.Set("health_subject_keys", account.HealthCheckSubjectKeys); err != nil { - return fmt.Errorf("error setting health_subject_keys: %s", err) - } - - if err := d.Set("account_test_subject_keys", account.AccountTestSubjectKeys); err != nil { - return fmt.Errorf("error setting account_test_subject_keys: %s", err) - } - return nil }