From 9a5e3a0689d92ad560282760a7a858149af57381 Mon Sep 17 00:00:00 2001 From: The Magician Date: Mon, 4 Mar 2024 13:59:46 -0800 Subject: [PATCH] fix permadiff by reading empty docker_config field (#10113) (#17484) [upstream:c4d1efa32fa9aec82c1951a596f115b2ac443d88] Signed-off-by: Modular Magician --- .changelog/10113.txt | 3 +++ .../resource_artifact_registry_repository.go | 10 ++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 .changelog/10113.txt diff --git a/.changelog/10113.txt b/.changelog/10113.txt new file mode 100644 index 00000000000..1c94bb4bc1d --- /dev/null +++ b/.changelog/10113.txt @@ -0,0 +1,3 @@ +```release-note:bug +artifactregistry: fixed docker_config permadiff +``` \ No newline at end of file diff --git a/google/services/artifactregistry/resource_artifact_registry_repository.go b/google/services/artifactregistry/resource_artifact_registry_repository.go index ac982306a48..f1a56029b23 100644 --- a/google/services/artifactregistry/resource_artifact_registry_repository.go +++ b/google/services/artifactregistry/resource_artifact_registry_repository.go @@ -1079,9 +1079,6 @@ func flattenArtifactRegistryRepositoryDockerConfig(v interface{}, d *schema.Reso return nil } original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } transformed := make(map[string]interface{}) transformed["immutable_tags"] = flattenArtifactRegistryRepositoryDockerConfigImmutableTags(original["immutableTags"], d, config) @@ -1525,9 +1522,14 @@ func expandArtifactRegistryRepositoryKmsKeyName(v interface{}, d tpgresource.Ter func expandArtifactRegistryRepositoryDockerConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { + if len(l) == 0 { return nil, nil } + + if l[0] == nil { + transformed := make(map[string]interface{}) + return transformed, nil + } raw := l[0] original := raw.(map[string]interface{}) transformed := make(map[string]interface{})