Skip to content

Commit

Permalink
Update kustdiff
Browse files Browse the repository at this point in the history
  • Loading branch information
swade1987 authored Oct 15, 2024
1 parent 5ed2e69 commit 147d772
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions kustdiff
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
set -eux

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

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

function build {
Expand All @@ -16,10 +16,10 @@ function build {
for envpath in $(get_targets); do
local build_dir
if ! [ -d "$envpath" ]; then continue; fi
build_dir="$TMP_DIR/$ref/${envpath#*kustomize/}"
local build_dir="$TMP_DIR/$ref/${envpath#$ROOT_DIR/}"
printf "\n\nCreating build directory: %s\n" "$build_dir"
mkdir -p "$build_dir"
echo "Running kustomize"
printf "Running kustomize\n"
kustomize build "$envpath" -o "$build_dir"
done
}
Expand All @@ -44,4 +44,12 @@ function main {
printf "\n\nOutput: %s\n" "$escaped_output"
}

# Check if a directory is provided as an argument
if [ $# -ge 1 ]; then
ROOT_DIR="$1"
fi

echo "Using root directory: $ROOT_DIR"
main

main

0 comments on commit 147d772

Please sign in to comment.