Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions scripts/test-kubeval-validation
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/sh

set -o errexit
trap 'echo "Aborting due to errexit on line $LINENO. Exit code: $?" >&2' ERR
set -o errtrace
set -o pipefail

# In CI test changes only
if [ ! -z "$PULL_BASE_SHA" ] && [ ! -z "$PULL_PULL_SHA" ]; then
echo "Checking changes in range $PULL_BASE_SHA..$PULL_PULL_SHA only."
bases=$(git diff --name-status $PULL_BASE_SHA $PULL_PULL_SHA | grep -Po "^[^DR]\s+\K.*?(?=/)|^R\w*\s+.*\s+\K.*?(?=/)" | sort | uniq)
else
echo "Checking all overlays."
bases="."
fi

# Let's ignore the secrets...

export KUSTOMIZE_PLUGIN_HOME=/tmp/new_plugin_dir

mkdir -p $KUSTOMIZE_PLUGIN_HOME/viaduct.ai/v1/ksops/
echo '#!/bin/sh' >$KUSTOMIZE_PLUGIN_HOME/viaduct.ai/v1/ksops/ksops
chmod +x $KUSTOMIZE_PLUGIN_HOME/viaduct.ai/v1/ksops/ksops

# User can specify custom include/exclude regex
if [ -z "$INCLUDE" ]; then
INCLUDE=".*/overlays/.*kustomization.yaml"
fi
if [ -z "$EXCLUDE" ]; then
EXCLUDE="*odh-manifests*"
fi
# and check all the sub directories with manifests...
k=$(for i in $(echo "$bases"); do find $i -regex "$INCLUDE"; done)

for d in $k; do
if [[ $(dirname $d) == $EXCLUDE ]]; then
echo skipping $(dirname $d)
continue
fi

echo checking $(dirname $d)
kustomize build --enable-alpha-plugins $(dirname $d) | kubeval --strict --ignore-missing-schemas --schema-location=https://raw.githubusercontent.com/operate-first/schema-store/main/schemas 2>&1
done

#end.