From bad41fc7a83cd9d61b4e7329d926d66bd1c75ee1 Mon Sep 17 00:00:00 2001 From: Elim Tsiagbey Date: Tue, 9 May 2023 09:55:17 -0400 Subject: [PATCH] chore: Deprecate type field for boundary_account_password (#396) * Deprecate type field for boundary_account_password --- .../boundary_account_password/resource.tf | 1 - .../provider/resource_account_password.go | 4 ++- .../resource_account_password_test.go | 30 +++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/examples/resources/boundary_account_password/resource.tf b/examples/resources/boundary_account_password/resource.tf index 45f7a979..0d920518 100644 --- a/examples/resources/boundary_account_password/resource.tf +++ b/examples/resources/boundary_account_password/resource.tf @@ -13,7 +13,6 @@ resource "boundary_auth_method" "password" { resource "boundary_account_password" "jeff" { auth_method_id = boundary_auth_method.password.id - type = "password" login_name = "jeff" password = "$uper$ecure" } diff --git a/internal/provider/resource_account_password.go b/internal/provider/resource_account_password.go index 75f7ce9d..de6ab792 100644 --- a/internal/provider/resource_account_password.go +++ b/internal/provider/resource_account_password.go @@ -56,7 +56,9 @@ func resourceAccountPassword() *schema.Resource { TypeKey: { Description: "The resource type.", Type: schema.TypeString, - Required: true, + Deprecated: "The value for this field will be infered since 'password' is the only possible value.", + Default: accountTypePassword, + Optional: true, ForceNew: true, }, accountLoginNameKey: { diff --git a/internal/provider/resource_account_password_test.go b/internal/provider/resource_account_password_test.go index dd60263a..9e81f2ca 100644 --- a/internal/provider/resource_account_password_test.go +++ b/internal/provider/resource_account_password_test.go @@ -53,6 +53,23 @@ resource "boundary_account_password" "foo" { password = "foofoofoo" auth_method_id = boundary_auth_method.foo.id }`, fooAccountPasswordDescUpdate) + + fooAccountPasswordWithoutTypeField = fmt.Sprintf(` + resource "boundary_auth_method" "foo" { + name = "test" + description = "test account" + type = "password" + scope_id = boundary_scope.org1.id + depends_on = [boundary_role.org1_admin] + } + + resource "boundary_account_password" "foo" { + name = "test" + description = "%s" + login_name = "foo" + password = "foofoofoo" + auth_method_id = boundary_auth_method.foo.id + }`, fooAccountPasswordDescUpdate) ) func TestAccAccount(t *testing.T) { @@ -92,6 +109,19 @@ func TestAccAccount(t *testing.T) { ), }, importStep("boundary_account_password.foo", "password"), + { + // update without passing type field + Config: testConfig(url, fooOrg, fooAccountPasswordWithoutTypeField), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("boundary_account_password.foo", "description", fooAccountPasswordDescUpdate), + resource.TestCheckResourceAttr("boundary_account_password.foo", "name", "test"), + resource.TestCheckResourceAttr("boundary_account_password.foo", "type", "password"), + resource.TestCheckResourceAttr("boundary_account_password.foo", "login_name", "foo"), + resource.TestCheckResourceAttr("boundary_account_password.foo", "password", "foofoofoo"), + testAccCheckAccountResourceExists(provider, "boundary_account_password.foo"), + ), + }, + importStep("boundary_account_password.foo", "password"), }, }) }