Skip to content

Commit 5e2e5d5

Browse files
committed
Rebased
1 parent 060bf57 commit 5e2e5d5

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

.pre-commit-hooks.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
description : "Run Kubeconform on yaml files"
44
entry: ./kubeconform.sh
55
language: script
6+
files: \.(yaml|yml)$

kubeconform.sh

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1-
2-
31
#!/bin/bash
42

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

5+
check() {
6+
which kubeconform
7+
if [[ $? -gt 0 ]]; then
8+
echo "kubeconform not found, please install it from https://github.com/yannh/kubeconform/releases/latest"
9+
exit 255
10+
fi
11+
}
12+
13+
check
14+
715
kpath=""
816
while getopts "p:" arg; do
917
case ${arg} in
@@ -20,13 +28,12 @@ shift $((OPTIND-1))
2028

2129
for arg in "$@"
2230
do
23-
if [[ $arg == *".yaml" ]]; then
24-
if [[ $path != "" ]]; then
25-
if [[ $arg != *"$path"* ]]; then
31+
if [[ $kpath != "" ]]; then
32+
echo ${arg} | grep -q ${kpath}
33+
if [[ $? -gt 0 ]]; then
2634
continue
2735
fi
2836
fi
2937
echo "Running kubeconform on $arg"
3038
kubeconform -strict -ignore-missing-schemas -summary -schema-location default -schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' $arg
31-
fi
3239
done

0 commit comments

Comments
 (0)