3
3
set -eux
4
4
5
5
TMP_DIR=" $( mktemp -d) "
6
- # Allow root directory to be set via environment variable or command line argument
7
6
ROOT_DIR=" ${INPUT_ROOT_DIR:- ${1:- ./ kustomize} } " # First check env var, then argument, then default
7
+ MAX_DEPTH=" ${INPUT_MAX_DEPTH:- 2} " # Default to 2 if not specified
8
8
DEBUG=" ${DEBUG:- true} "
9
9
10
10
function debug_log() {
@@ -20,8 +20,15 @@ function validate_root_dir() {
20
20
fi
21
21
}
22
22
23
+ function validate_max_depth() {
24
+ if ! [[ " $MAX_DEPTH " =~ ^[0-9]+$ ]]; then
25
+ echo " Error: max_depth must be a positive integer, got: $MAX_DEPTH "
26
+ exit 1
27
+ fi
28
+ }
29
+
23
30
function get_targets {
24
- find " $ROOT_DIR " -maxdepth 4 -name kustomization.yaml -exec dirname {} \;
31
+ find " $ROOT_DIR " -maxdepth " $MAX_DEPTH " -name kustomization.yaml -exec dirname {} \;
25
32
}
26
33
27
34
function safe_dirname() {
@@ -44,12 +51,18 @@ function build {
44
51
local output_file=" $TMP_DIR /$safe_ref /${safe_path} .yaml"
45
52
echo " Running kustomize for $envpath "
46
53
kustomize build " $envpath " -o " $output_file "
54
+
55
+ # debug_log "Contents of $output_file:"
56
+ # debug_log "$(cat "$output_file")"
57
+ # debug_log "End of $output_file"
58
+ # debug_log "------------------------------------"
47
59
done
48
60
}
49
61
50
62
function main {
51
- # Validate root directory before proceeding
63
+ # Validate inputs before proceeding
52
64
validate_root_dir
65
+ validate_max_depth
53
66
54
67
git config --global --add safe.directory " $GITHUB_WORKSPACE "
55
68
local diff escaped_output output
@@ -89,6 +102,7 @@ function main {
89
102
# Print initial configuration
90
103
echo " Configuration:"
91
104
echo " ROOT_DIR: $ROOT_DIR "
105
+ echo " MAX_DEPTH: $MAX_DEPTH "
92
106
echo " DEBUG: $DEBUG "
93
107
debug_log " Debug mode is enabled"
94
108
0 commit comments