Skip to content
This repository has been archived by the owner on May 15, 2023. It is now read-only.

artifactregistry: add docker tag immutability config #1536

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
29 changes: 29 additions & 0 deletions converters/google/resources/artifactregistry_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ func GetArtifactRegistryRepositoryApiObject(d TerraformResourceData, config *Con
} else if v, ok := d.GetOkExists("kms_key_name"); !isEmptyValue(reflect.ValueOf(kmsKeyNameProp)) && (ok || !reflect.DeepEqual(v, kmsKeyNameProp)) {
obj["kmsKeyName"] = kmsKeyNameProp
}
dockerConfigProp, err := expandArtifactRegistryRepositoryDockerConfig(d.Get("docker_config"), d, config)
if err != nil {
return nil, err
} else if v, ok := d.GetOkExists("docker_config"); !isEmptyValue(reflect.ValueOf(dockerConfigProp)) && (ok || !reflect.DeepEqual(v, dockerConfigProp)) {
obj["dockerConfig"] = dockerConfigProp
}
mavenConfigProp, err := expandArtifactRegistryRepositoryMavenConfig(d.Get("maven_config"), d, config)
if err != nil {
return nil, err
Expand Down Expand Up @@ -123,6 +129,29 @@ func expandArtifactRegistryRepositoryKmsKeyName(v interface{}, d TerraformResour
return v, nil
}

func expandArtifactRegistryRepositoryDockerConfig(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 || l[0] == nil {
return nil, nil
}
raw := l[0]
original := raw.(map[string]interface{})
transformed := make(map[string]interface{})

transformedImmutableTags, err := expandArtifactRegistryRepositoryDockerConfigImmutableTags(original["immutable_tags"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedImmutableTags); val.IsValid() && !isEmptyValue(val) {
transformed["immutableTags"] = transformedImmutableTags
}

return transformed, nil
}

func expandArtifactRegistryRepositoryDockerConfigImmutableTags(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}

func expandArtifactRegistryRepositoryMavenConfig(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 || l[0] == nil {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ require (
github.com/hashicorp/terraform-json v0.14.0
github.com/hashicorp/terraform-plugin-framework v1.1.1
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.0
github.com/hashicorp/terraform-provider-google v1.20.1-0.20230404191740-8cd7bc556074
github.com/hashicorp/terraform-provider-google v1.20.1-0.20230404202156-cf6bc6b50787
github.com/mitchellh/go-homedir v1.1.0
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus 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 @@ -532,8 +532,8 @@ github.com/hashicorp/terraform-plugin-mux v0.8.0 h1:WCTP66mZ+iIaIrCNJnjPEYnVjawT
github.com/hashicorp/terraform-plugin-mux v0.8.0/go.mod h1:vdW0daEi8Kd4RFJmet5Ot+SIVB/B8SwQVJiYKQwdCy8=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.0 h1:FtCLTiTcykdsURXPt/ku7fYXm3y19nbzbZcUxHx9RbI=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.0/go.mod h1:80wf5oad1tW+oLnbXS4UTYmDCrl7BuN1Q+IA91X1a4Y=
github.com/hashicorp/terraform-provider-google v1.20.1-0.20230404191740-8cd7bc556074 h1:QJSw6o1FEr7rUhYGnNQF4+Mmo63sikbXNTJR+9udsAQ=
github.com/hashicorp/terraform-provider-google v1.20.1-0.20230404191740-8cd7bc556074/go.mod h1:DLNZyxCBMAuTFiqYiitv+CH0v8C+OLMClalomSbsLsc=
github.com/hashicorp/terraform-provider-google v1.20.1-0.20230404202156-cf6bc6b50787 h1:MyTP8xprsyZfQL0yZPtM8kizKafO1KBAs47HYYk8kHg=
github.com/hashicorp/terraform-provider-google v1.20.1-0.20230404202156-cf6bc6b50787/go.mod h1:DLNZyxCBMAuTFiqYiitv+CH0v8C+OLMClalomSbsLsc=
github.com/hashicorp/terraform-registry-address v0.1.0 h1:W6JkV9wbum+m516rCl5/NjKxCyTVaaUBbzYcMzBDO3U=
github.com/hashicorp/terraform-registry-address v0.1.0/go.mod h1:EnyO2jYO6j29DTHbJcm00E5nQTFeTtyZH3H5ycydQ5A=
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0=
Expand Down