From d975791bb91e5607d1ca5c379e68dc58d8d85a33 Mon Sep 17 00:00:00 2001 From: Pascal Bourdier Date: Fri, 9 Oct 2020 09:02:09 +0200 Subject: [PATCH 1/2] ignore kustomize file with kubeval currently, kubeval doesn't support kustomize file so kubeval returns a false-positive about a missing `metadata` key: ``` 2020-10-09 06:19:19 [ERROR ] Found errors in [kubeval] linter! 2020-10-09 06:19:19 [ERROR ] [ERR - .../kustomization.yml: Missing 'metadata' key] 2020-10-09 06:19:19 [ERROR ] Linter CMD:[kubeval --strict .../kustomization.yml] ``` --- lib/linter.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/linter.sh b/lib/linter.sh index 43a06a91..0f7ed1fb 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -559,6 +559,11 @@ DetectKubernetesFile() { FILE="${1}" # File that we need to validate debug "Checking if ${FILE} is a Kubernetes descriptor..." + if grep -q -E 'apiVersion:\s*kustomize.config.k8s.io' "${FILE}" >/dev/null; then + debug "${FILE} is NOT a Kubernetes descriptor (Kustomize only)" + return 1 + fi + if grep -q -E '(apiVersion):' "${FILE}" >/dev/null; then debug "${FILE} is a Kubernetes descriptor" return 0 From 32a5945dd8e8ce63fc628ae19483aa6edd8bb422 Mon Sep 17 00:00:00 2001 From: Pascal Bourdier Date: Fri, 9 Oct 2020 11:53:34 +0200 Subject: [PATCH 2/2] embedding the negation in the existing if --- lib/linter.sh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 0f7ed1fb..e53f1d46 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -559,12 +559,7 @@ DetectKubernetesFile() { FILE="${1}" # File that we need to validate debug "Checking if ${FILE} is a Kubernetes descriptor..." - if grep -q -E 'apiVersion:\s*kustomize.config.k8s.io' "${FILE}" >/dev/null; then - debug "${FILE} is NOT a Kubernetes descriptor (Kustomize only)" - return 1 - fi - - if grep -q -E '(apiVersion):' "${FILE}" >/dev/null; then + if grep -v 'kustomize.config.k8s.io' "${FILE}" | grep -q -E '(apiVersion):'; then debug "${FILE} is a Kubernetes descriptor" return 0 fi