Skip to content

Commit 147d772

Browse files
authored
Update kustdiff
1 parent 5ed2e69 commit 147d772

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

kustdiff

+12-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
set -eux
44

55
TMP_DIR="$(mktemp -d)"
6+
ROOT_DIR="${1:-./clusters}" # Default to ./clusters if no argument is provided
67

78
function get_targets {
8-
find . -maxdepth 4 -name kustomization.yaml -exec dirname {} \;
9-
find . -mindepth 4 -maxdepth 4 -name kustomization.yaml -exec dirname {} \; | sort | uniq | grep variant
9+
find "$ROOT_DIR" -maxdepth 4 -name kustomization.yaml -exec dirname {} \;
1010
}
1111

1212
function build {
@@ -16,10 +16,10 @@ function build {
1616
for envpath in $(get_targets); do
1717
local build_dir
1818
if ! [ -d "$envpath" ]; then continue; fi
19-
build_dir="$TMP_DIR/$ref/${envpath#*kustomize/}"
19+
local build_dir="$TMP_DIR/$ref/${envpath#$ROOT_DIR/}"
2020
printf "\n\nCreating build directory: %s\n" "$build_dir"
2121
mkdir -p "$build_dir"
22-
echo "Running kustomize"
22+
printf "Running kustomize\n"
2323
kustomize build "$envpath" -o "$build_dir"
2424
done
2525
}
@@ -44,4 +44,12 @@ function main {
4444
printf "\n\nOutput: %s\n" "$escaped_output"
4545
}
4646

47+
# Check if a directory is provided as an argument
48+
if [ $# -ge 1 ]; then
49+
ROOT_DIR="$1"
50+
fi
51+
52+
echo "Using root directory: $ROOT_DIR"
53+
main
54+
4755
main

0 commit comments

Comments
 (0)