From f26ace31b963266504a9840cb5ce560a2aa77e07 Mon Sep 17 00:00:00 2001 From: Marco Ferrari Date: Mon, 14 Mar 2022 15:22:58 +0100 Subject: [PATCH] Check for kind when detecting Kubernetes files (#2612) * Check for kind when detecting Kubernetes files * Fix condition * Check conditions one by one * Formatting * Formatting --- lib/functions/detectFiles.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/functions/detectFiles.sh b/lib/functions/detectFiles.sh index b8e77d2f..a771d931 100755 --- a/lib/functions/detectFiles.sh +++ b/lib/functions/detectFiles.sh @@ -181,8 +181,10 @@ DetectKubernetesFile() { ################ FILE="${1}" # File that we need to validate debug "Checking if ${FILE} is a Kubernetes descriptor..." - - if grep -v 'kustomize.config.k8s.io' "${FILE}" | grep -v tekton | grep -q -E '(apiVersion):'; then + if grep -q -v 'kustomize.config.k8s.io' "${FILE}" && + grep -q -v "tekton" "${FILE}" && + grep -q -E '(apiVersion):' "${FILE}" && + grep -q -E '(kind):' "${FILE}"; then debug "${FILE} is a Kubernetes descriptor" return 0 fi