From 6c06a3c94d9c4b285b4375a5208f6b0d8ee85f92 Mon Sep 17 00:00:00 2001 From: Darren <75614232+dmurray-lacework@users.noreply.github.com> Date: Wed, 7 Dec 2022 20:15:43 +0000 Subject: [PATCH] fix: upgrade issue with limit_by_labels (#428) Signed-off-by: Darren Murray --- lacework/resource_lacework_integration_docker_hub.go | 4 +++- lacework/resource_lacework_integration_docker_v2.go | 4 +++- lacework/resource_lacework_integration_gar.go | 4 +++- lacework/resource_lacework_integration_gcr.go | 4 +++- lacework/resource_lacework_integration_ghcr.go | 4 +++- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lacework/resource_lacework_integration_docker_hub.go b/lacework/resource_lacework_integration_docker_hub.go index c0c85d0b6..0a09943ea 100644 --- a/lacework/resource_lacework_integration_docker_hub.go +++ b/lacework/resource_lacework_integration_docker_hub.go @@ -185,7 +185,9 @@ func resourceLaceworkIntegrationDockerHubRead(d *schema.ResourceData, meta inter d.Set("limit_num_imgs", response.Data.Data.LimitNumImg) d.Set("limit_by_tags", response.Data.Data.LimitByTag) d.Set("limit_by_repositories", response.Data.Data.LimitByRep) - d.Set("limit_by_label", castArrayOfStringKeyMapOfStringsToLimitByLabelSet(response.Data.Data.LimitByLabel)) + if limitByLabelsLength(response.Data.Data.LimitByLabel) != 0 { + d.Set("limit_by_label", castArrayOfStringKeyMapOfStringsToLimitByLabelSet(response.Data.Data.LimitByLabel)) + } log.Printf("[INFO] Read %s registry type with guid: %v\n", api.DockerhubContainerRegistry.String(), integration.IntgGuid) return nil diff --git a/lacework/resource_lacework_integration_docker_v2.go b/lacework/resource_lacework_integration_docker_v2.go index b06e8c026..281088c0d 100644 --- a/lacework/resource_lacework_integration_docker_v2.go +++ b/lacework/resource_lacework_integration_docker_v2.go @@ -183,7 +183,9 @@ func resourceLaceworkIntegrationDockerV2Read(d *schema.ResourceData, meta interf d.Set("non_os_package_support", integration.Data.NonOSPackageEval) d.Set("notifications", integration.Data.RegistryNotifications) d.Set("limit_by_tags", response.Data.Data.LimitByTag) - d.Set("limit_by_label", castArrayOfStringKeyMapOfStringsToLimitByLabelSet(response.Data.Data.LimitByLabel)) + if limitByLabelsLength(response.Data.Data.LimitByLabel) != 0 { + d.Set("limit_by_label", castArrayOfStringKeyMapOfStringsToLimitByLabelSet(response.Data.Data.LimitByLabel)) + } log.Printf("[INFO] Read %s registry type with guid: %v\n", api.DockerhubV2ContainerRegistry.String(), integration.IntgGuid) return nil diff --git a/lacework/resource_lacework_integration_gar.go b/lacework/resource_lacework_integration_gar.go index 8673306fc..db23aab5e 100644 --- a/lacework/resource_lacework_integration_gar.go +++ b/lacework/resource_lacework_integration_gar.go @@ -273,7 +273,9 @@ func resourceLaceworkIntegrationGarRead(d *schema.ResourceData, meta interface{} d.Set("limit_num_imgs", response.Data.Data.LimitNumImg) d.Set("limit_by_tags", response.Data.Data.LimitByTag) d.Set("limit_by_repositories", response.Data.Data.LimitByRep) - d.Set("limit_by_label", castArrayOfStringKeyMapOfStringsToLimitByLabelSet(response.Data.Data.LimitByLabel)) + if limitByLabelsLength(response.Data.Data.LimitByLabel) != 0 { + d.Set("limit_by_label", castArrayOfStringKeyMapOfStringsToLimitByLabelSet(response.Data.Data.LimitByLabel)) + } log.Printf("[INFO] Read ContVulnCfg integration for %s registry type with guid %s\n", api.GcpGarContainerRegistry.String(), response.Data.IntgGuid) diff --git a/lacework/resource_lacework_integration_gcr.go b/lacework/resource_lacework_integration_gcr.go index ec36d1a3b..2e530e2fc 100644 --- a/lacework/resource_lacework_integration_gcr.go +++ b/lacework/resource_lacework_integration_gcr.go @@ -239,7 +239,9 @@ func resourceLaceworkIntegrationGcrRead(d *schema.ResourceData, meta interface{} d.Set("non_os_package_support", integration.Data.NonOSPackageEval) d.Set("limit_by_tags", response.Data.Data.LimitByTag) d.Set("limit_by_repositories", response.Data.Data.LimitByRep) - d.Set("limit_by_label", castArrayOfStringKeyMapOfStringsToLimitByLabelSet(response.Data.Data.LimitByLabel)) + if limitByLabelsLength(response.Data.Data.LimitByLabel) != 0 { + d.Set("limit_by_label", castArrayOfStringKeyMapOfStringsToLimitByLabelSet(response.Data.Data.LimitByLabel)) + } log.Printf("[INFO] Read %s registry type with guid: %v\n", api.GcpGcrContainerRegistry.String(), integration.IntgGuid) return nil diff --git a/lacework/resource_lacework_integration_ghcr.go b/lacework/resource_lacework_integration_ghcr.go index 04f36aa0f..86c0cc36f 100644 --- a/lacework/resource_lacework_integration_ghcr.go +++ b/lacework/resource_lacework_integration_ghcr.go @@ -207,7 +207,9 @@ func resourceLaceworkIntegrationGhcrRead(d *schema.ResourceData, meta interface{ d.Set("limit_num_imgs", response.Data.Data.LimitNumImg) d.Set("limit_by_tags", response.Data.Data.LimitByTag) d.Set("limit_by_repositories", response.Data.Data.LimitByRep) - d.Set("limit_by_label", castArrayOfStringKeyMapOfStringsToLimitByLabelSet(response.Data.Data.LimitByLabel)) + if limitByLabelsLength(response.Data.Data.LimitByLabel) != 0 { + d.Set("limit_by_label", castArrayOfStringKeyMapOfStringsToLimitByLabelSet(response.Data.Data.LimitByLabel)) + } log.Printf("[INFO] Read ContVulnCfg integration for %s registry type with guid %s\n", api.GhcrContainerRegistry.String(), response.Data.IntgGuid)