Skip to content

Commit

Permalink
Rebased
Browse files Browse the repository at this point in the history
  • Loading branch information
mbovo committed Jul 11, 2023
1 parent 060bf57 commit 5e2e5d5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
description : "Run Kubeconform on yaml files"
entry: ./kubeconform.sh
language: script
files: \.(yaml|yml)$
19 changes: 13 additions & 6 deletions kubeconform.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@


#!/bin/bash

usage() { echo "Usage: ${0} [-p <string>]"; exit 1; }

check() {
which kubeconform
if [[ $? -gt 0 ]]; then
echo "kubeconform not found, please install it from https://github.com/yannh/kubeconform/releases/latest"
exit 255
fi
}

check

kpath=""
while getopts "p:" arg; do
case ${arg} in
Expand All @@ -20,13 +28,12 @@ shift $((OPTIND-1))

for arg in "$@"
do
if [[ $arg == *".yaml" ]]; then
if [[ $path != "" ]]; then
if [[ $arg != *"$path"* ]]; then
if [[ $kpath != "" ]]; then
echo ${arg} | grep -q ${kpath}
if [[ $? -gt 0 ]]; then
continue
fi
fi
echo "Running kubeconform on $arg"
kubeconform -strict -ignore-missing-schemas -summary -schema-location default -schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' $arg
fi
done

0 comments on commit 5e2e5d5

Please sign in to comment.