Check for kind when detecting Kubernetes files (#2612)

* Check for kind when detecting Kubernetes files

* Fix condition

* Check conditions one by one

* Formatting

* Formatting
This commit is contained in:
Marco Ferrari 2022-03-14 15:22:58 +01:00 committed by GitHub
parent d7cefe279b
commit f26ace31b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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