From 3e98c3eb7c46c4ebbf6d14b7996e9dee69d236be Mon Sep 17 00:00:00 2001 From: Gaurav Gogia <16029099+gaurav-gogia@users.noreply.github.com> Date: Fri, 8 Jul 2022 15:27:37 +0530 Subject: [PATCH 1/3] container funcs to return dev friendly warnings --- .../terraform/commons/extract-container-images.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/iac-providers/terraform/commons/extract-container-images.go b/pkg/iac-providers/terraform/commons/extract-container-images.go index 535694db0..3efb4e0af 100644 --- a/pkg/iac-providers/terraform/commons/extract-container-images.go +++ b/pkg/iac-providers/terraform/commons/extract-container-images.go @@ -100,7 +100,7 @@ func fetchContainersFromAwsResource(resource jsonObj, hclBody *hclsyntax.Body, r } fileData, err := ioutil.ReadFile(fileLocation) if err != nil { - zap.S().Errorf("error fetching containers from aws resource: %v", err) + zap.S().Warnf("error fetching containers from aws resource: %v", err) return results } def = string(fileData) @@ -108,7 +108,7 @@ func fetchContainersFromAwsResource(resource jsonObj, hclBody *hclsyntax.Body, r containers := []jsonObj{} err := json.Unmarshal([]byte(def), &containers) if err != nil { - zap.S().Errorf("error fetching containers from aws resource: %v", err) + zap.S().Warnf("error fetching containers from aws resource: %v", err) return results } results = getContainers(containers) @@ -126,7 +126,7 @@ func getContainersFromhclBody(hclBody *hclsyntax.Body) (results []output.Contain for _, arg := range funcExp.Args { re, diags := arg.Value(nil) if diags.HasErrors() { - zap.S().Errorf("error fetching containers from aws resource: %v", getErrorMessagesFromDiagnostics(diags)) + zap.S().Warnf("error fetching containers from aws resource: %v", getErrorMessagesFromDiagnostics(diags)) return } if !re.CanIterateElements() { @@ -137,7 +137,7 @@ func getContainersFromhclBody(hclBody *hclsyntax.Body) (results []output.Contain _, val := it.Element() containerTemp, err := convertCtyToGoNative(val) if err != nil { - zap.S().Errorf("error fetching containers from aws resource: %v", err) + zap.S().Warnf("error fetching containers from aws resource: %v", err) return } var ( From a1bb8b623e034985892f10d1dd5dd06a3ca52e58 Mon Sep 17 00:00:00 2001 From: Gaurav Gogia <16029099+gaurav-gogia@users.noreply.github.com> Date: Mon, 25 Jul 2022 11:47:33 +0530 Subject: [PATCH 2/3] rm error keyword --- .../terraform/commons/extract-container-images.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/iac-providers/terraform/commons/extract-container-images.go b/pkg/iac-providers/terraform/commons/extract-container-images.go index 3efb4e0af..2db69db60 100644 --- a/pkg/iac-providers/terraform/commons/extract-container-images.go +++ b/pkg/iac-providers/terraform/commons/extract-container-images.go @@ -100,7 +100,7 @@ func fetchContainersFromAwsResource(resource jsonObj, hclBody *hclsyntax.Body, r } fileData, err := ioutil.ReadFile(fileLocation) if err != nil { - zap.S().Warnf("error fetching containers from aws resource: %v", err) + zap.S().Warnf("failed to fetch containers from aws resource: %v", err) return results } def = string(fileData) @@ -108,7 +108,7 @@ func fetchContainersFromAwsResource(resource jsonObj, hclBody *hclsyntax.Body, r containers := []jsonObj{} err := json.Unmarshal([]byte(def), &containers) if err != nil { - zap.S().Warnf("error fetching containers from aws resource: %v", err) + zap.S().Warnf("failed to fetch containers from aws resource: %v", err) return results } results = getContainers(containers) From 25af6887746e34eed38b9e3443cbf638db84c88b Mon Sep 17 00:00:00 2001 From: Gaurav Gogia <16029099+gaurav-gogia@users.noreply.github.com> Date: Tue, 26 Jul 2022 14:48:28 +0530 Subject: [PATCH 3/3] warning message change --- .../terraform/commons/extract-container-images.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/iac-providers/terraform/commons/extract-container-images.go b/pkg/iac-providers/terraform/commons/extract-container-images.go index 2db69db60..2f5afe16b 100644 --- a/pkg/iac-providers/terraform/commons/extract-container-images.go +++ b/pkg/iac-providers/terraform/commons/extract-container-images.go @@ -126,7 +126,7 @@ func getContainersFromhclBody(hclBody *hclsyntax.Body) (results []output.Contain for _, arg := range funcExp.Args { re, diags := arg.Value(nil) if diags.HasErrors() { - zap.S().Warnf("error fetching containers from aws resource: %v", getErrorMessagesFromDiagnostics(diags)) + zap.S().Warnf("failed to fetch the container from aws resource: %v", getErrorMessagesFromDiagnostics(diags)) return } if !re.CanIterateElements() { @@ -137,7 +137,7 @@ func getContainersFromhclBody(hclBody *hclsyntax.Body) (results []output.Contain _, val := it.Element() containerTemp, err := convertCtyToGoNative(val) if err != nil { - zap.S().Warnf("error fetching containers from aws resource: %v", err) + zap.S().Warnf("failed to fetch the container from aws resource: %v", err) return } var (