Skip to content

Commit

Permalink
Add support for regional secret version datasource `google_secret_man…
Browse files Browse the repository at this point in the history
…ager_regional_secret_version` (#11730) (#2818)

[upstream:863df2f34711963eed91d45053ee3e6927070fcd]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Sep 18, 2024
1 parent 0f5b74f commit b8d90d8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/hashicorp/hcl/v2 v2.20.1
github.com/hashicorp/terraform-json v0.22.1
github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240917232130-e489947c6967
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240918003708-3b27c2e71981
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.9.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 h1:qHprzXy/As0rxedphECBEQAh
github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0/go.mod h1:H+8tjs9TjV2w57QFVSMBQacf8k/E1XwLXGCARgViC6A=
github.com/hashicorp/terraform-plugin-testing v1.5.1 h1:T4aQh9JAhmWo4+t1A7x+rnxAJHCDIYW9kXyo4sVO92c=
github.com/hashicorp/terraform-plugin-testing v1.5.1/go.mod h1:dg8clO6K59rZ8w9EshBmDp1CxTIPu3yA4iaDpX1h5u0=
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240917232130-e489947c6967 h1:ytslCcm2dwjtVoG3B+KgGw/gGwtyFw46YkyWylmMrys=
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240917232130-e489947c6967/go.mod h1:KmhH9vkbqTNYp9g+1yBfb4iK9CCbKNnakASns8SHzXU=
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240918003708-3b27c2e71981 h1:lVdP23TDYkB/Ng/FXi5IUJNX8iJzEbYCc4IdmU92268=
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240918003708-3b27c2e71981/go.mod h1:KmhH9vkbqTNYp9g+1yBfb4iK9CCbKNnakASns8SHzXU=
github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI=
github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM=
github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ func GetSecretManagerRegionalRegionalSecretCaiObject(d tpgresource.TerraformReso

func GetSecretManagerRegionalRegionalSecretApiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]interface{}, error) {
obj := make(map[string]interface{})
versionAliasesProp, err := expandSecretManagerRegionalRegionalSecretVersionAliases(d.Get("version_aliases"), d, config)
if err != nil {
return nil, err
} else if v, ok := d.GetOkExists("version_aliases"); !tpgresource.IsEmptyValue(reflect.ValueOf(versionAliasesProp)) && (ok || !reflect.DeepEqual(v, versionAliasesProp)) {
obj["versionAliases"] = versionAliasesProp
}
customerManagedEncryptionProp, err := expandSecretManagerRegionalRegionalSecretCustomerManagedEncryption(d.Get("customer_managed_encryption"), d, config)
if err != nil {
return nil, err
Expand Down Expand Up @@ -106,6 +112,17 @@ func GetSecretManagerRegionalRegionalSecretApiObject(d tpgresource.TerraformReso
return obj, nil
}

func expandSecretManagerRegionalRegionalSecretVersionAliases(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) {
if v == nil {
return map[string]string{}, nil
}
m := make(map[string]string)
for k, val := range v.(map[string]interface{}) {
m[k] = val.(string)
}
return m, nil
}

func expandSecretManagerRegionalRegionalSecretCustomerManagedEncryption(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 || l[0] == nil {
Expand Down

0 comments on commit b8d90d8

Please sign in to comment.