HighwayofLife/kubernetes-validation-tools

add yq to image

bjartek opened this issue · 0 comments

Is it possible to add yq to the generated image. We are planning to use this for validating manfiseste using kustomize/kubeconform and that script uses yq.

Script is attached blow for reference

#!/usr/bin/env bash

set -eo pipefail

find . -type f -name '*.yaml' -print0 | while IFS= read -r -d $'\0' file;
  do
    yq e 'true' "$file" > /dev/null || error_exit "found when validating file $file"
done

k="kustomization.yaml"
kustomize_flags="--load-restrictor=LoadRestrictionsNone"
find . -type f -name $k -print0 |  while IFS= read -r -d $'\0' file;
  do
    [[ $file == ./base/* ]] && continue
    echo "================================"
    echo "INFO - Validating kustomization ${file/%$k} with kubeconform"

    kustomize build "${file/%$k}" $kustomize_flags | kubeconform -exit-on-error -kubernetes-version 1.21.2 -strict -ignore-missing-schemas -schema-location default -schema-location 'policy/{{ .ResourceKind }}{{ .KindSuffix }}.json' --verbose
done