Skip to content

Commit

Permalink
chore: Deprecate type field for boundary_account_password (hashicorp#396
Browse files Browse the repository at this point in the history
)

* Deprecate type field for boundary_account_password
  • Loading branch information
elimt authored and grantorchard committed Jul 24, 2023
1 parent e3fb347 commit bad41fc
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
1 change: 0 additions & 1 deletion examples/resources/boundary_account_password/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
4 changes: 3 additions & 1 deletion internal/provider/resource_account_password.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
30 changes: 30 additions & 0 deletions internal/provider/resource_account_password_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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"),
},
})
}

0 comments on commit bad41fc

Please sign in to comment.