@@ -27,6 +27,18 @@ if [[ ${2:-} == "remove-dummy" ]]; then
2727 rm -f cmd/repo-init/frontend/dist/dummy
2828fi
2929
30+ # BUILD_IMAGES is an allow-list: if set, only these binaries are built.
31+ # SKIPPED_IMAGES is a deny-list: if set, these binaries are skipped.
32+ # BUILD_IMAGES takes precedence over SKIPPED_IMAGES.
33+ declare -A build_images_map
34+ if [[ -n " ${BUILD_IMAGES:- } " ]]; then
35+ echo " Building only: ${BUILD_IMAGES} "
36+ IFS=' ,' read -ra build_array <<< " ${BUILD_IMAGES}"
37+ for img in " ${build_array[@]} " ; do
38+ build_images_map[" ${img} " ]=1
39+ done
40+ fi
41+
3042declare -A skipped_images_map
3143if [[ -n " ${SKIPPED_IMAGES:- } " ]]; then
3244 echo " Skipping images: ${SKIPPED_IMAGES} "
@@ -36,11 +48,44 @@ if [[ -n "${SKIPPED_IMAGES:-}" ]]; then
3648 done
3749fi
3850
39- for dir in $( find ./cmd/ -mindepth 1 -maxdepth 1 -type d -not \( -name ' *ipi-deprovison*' \) ) ; do
51+ MAX_PARALLEL=" ${MAX_PARALLEL:- 4} "
52+ pids=()
53+ failures=()
54+
55+ for dir in $( find ./cmd/ -mindepth 1 -maxdepth 1 -type d -not \( -name ' *ipi-deprovison*' \) | sort ) ; do
4056 command=" $( basename " ${dir} " ) "
41- if [[ -n " ${skipped_images_map[${command}]:- } " ]]; then
42- echo " Skipping install for ${command} (in SKIPPED_IMAGES)"
57+
58+ # If BUILD_IMAGES is set, only build listed binaries
59+ if [[ -n " ${BUILD_IMAGES:- } " ]]; then
60+ if [[ -z " ${build_images_map[${command}]:- } " ]]; then
4361 continue
62+ fi
63+ elif [[ -n " ${skipped_images_map[${command}]:- } " ]]; then
64+ echo " Skipping install for ${command} (in SKIPPED_IMAGES)"
65+ continue
66+ fi
67+
68+ echo " Building ${command} ..."
69+ go install -v $RACE_FLAG -ldflags " -X 'sigs.k8s.io/prow/pkg/version.Name=${command} ' -X 'sigs.k8s.io/prow/pkg/version.Version=${version} '" " ./cmd/${command} /..." &
70+ pids+=($! )
71+
72+ # Throttle: wait for a slot when we hit the limit
73+ if [[ ${# pids[@]} -ge $MAX_PARALLEL ]]; then
74+ if ! wait " ${pids[0]} " ; then
75+ failures+=(" ${pids[0]} " )
76+ fi
77+ pids=(" ${pids[@]: 1} " )
78+ fi
79+ done
80+
81+ # Wait for remaining builds
82+ for pid in " ${pids[@]} " ; do
83+ if ! wait " $pid " ; then
84+ failures+=(" $pid " )
4485 fi
45- go install -v $RACE_FLAG -ldflags " -X 'sigs.k8s.io/prow/pkg/version.Name=${command} ' -X 'sigs.k8s.io/prow/pkg/version.Version=${version} '" " ./cmd/${command} /..."
4686done
87+
88+ if [[ ${# failures[@]} -gt 0 ]]; then
89+ echo " ERROR: ${# failures[@]} build(s) failed"
90+ exit 1
91+ fi
0 commit comments