Skip to content

Commit 7346c81

Browse files
committed
chore: improve error handling when building release bundle
1 parent 885f4af commit 7346c81

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

dev/tasks/build-release-bundle

+15-4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ mkdir -p "${BIN_DIR}"
3434

3535
LICENSING_SCRIPT=${REPO_ROOT}/scripts/add-license-header-to-yaml.sh
3636

37+
function add_license() {
38+
file=$1
39+
$LICENSING_SCRIPT ${file} > ${file}.tmp
40+
mv ${file}.tmp ${file}
41+
}
42+
3743
GOBIN=${BIN_DIR}/ go install sigs.k8s.io/kustomize/kustomize/[email protected]
3844
export PATH=${BIN_DIR}/:$PATH
3945

@@ -102,17 +108,22 @@ sed -i "s/0.0.0-dev/${VERSION}/g" ${AUTOPILOT_WORKLOAD_IDENTITY_BUNDLE_DIR}/*
102108
# Build the namespaced-mode install bundle (uses workload identity)
103109
NAMESPACED_BUNDLE_DIR=${BUNDLE_DIR}/install-bundle-namespaced
104110
mkdir -p ${NAMESPACED_BUNDLE_DIR}
105-
$LICENSING_SCRIPT <(kustomize build config/installbundle/releases/scopes/namespaced/shared-components) > ${NAMESPACED_BUNDLE_DIR}/0-cnrm-system.yaml
106-
$LICENSING_SCRIPT <(kustomize build config/installbundle/releases/scopes/namespaced/per-namespace-components) |\
111+
kustomize build config/installbundle/releases/scopes/namespaced/shared-components > ${NAMESPACED_BUNDLE_DIR}/0-cnrm-system.yaml
112+
add_license ${NAMESPACED_BUNDLE_DIR}/0-cnrm-system.yaml
113+
kustomize build config/installbundle/releases/scopes/namespaced/per-namespace-components |\
107114
sed -e 's/mynamespace/${NAMESPACE?}/g' > ${NAMESPACED_BUNDLE_DIR}/per-namespace-components.yaml
115+
add_license ${NAMESPACED_BUNDLE_DIR}/per-namespace-components.yaml
108116
cp $CRDS_FILE ${NAMESPACED_BUNDLE_DIR}/crds.yaml
109117
sed -i "s/0.0.0-dev/${VERSION}/g" ${NAMESPACED_BUNDLE_DIR}/*
118+
110119
# Create the autopilot variant of the namespaced-mode install bundle
111120
AUTOPILOT_NAMESPACED_BUNDLE_DIR=${BUNDLE_DIR}/install-bundle-autopilot-namespaced
112121
mkdir -p ${AUTOPILOT_NAMESPACED_BUNDLE_DIR}
113-
$LICENSING_SCRIPT <(kustomize build config/installbundle/releases/scopes/namespaced/autopilot-shared-components) > ${AUTOPILOT_NAMESPACED_BUNDLE_DIR}/0-cnrm-system.yaml
114-
$LICENSING_SCRIPT <(kustomize build config/installbundle/releases/scopes/namespaced/per-namespace-components) |\
122+
kustomize build config/installbundle/releases/scopes/namespaced/autopilot-shared-components > ${AUTOPILOT_NAMESPACED_BUNDLE_DIR}/0-cnrm-system.yaml
123+
add_license ${AUTOPILOT_NAMESPACED_BUNDLE_DIR}/0-cnrm-system.yaml
124+
kustomize build config/installbundle/releases/scopes/namespaced/per-namespace-components |\
115125
sed -e 's/mynamespace/${NAMESPACE?}/g' > ${AUTOPILOT_NAMESPACED_BUNDLE_DIR}/per-namespace-components.yaml
126+
add_license ${AUTOPILOT_NAMESPACED_BUNDLE_DIR}/per-namespace-components.yaml
116127
cp $CRDS_FILE ${AUTOPILOT_NAMESPACED_BUNDLE_DIR}/crds.yaml
117128
sed -i "s/0.0.0-dev/${VERSION}/g" ${AUTOPILOT_NAMESPACED_BUNDLE_DIR}/*
118129

scripts/add-license-header-to-yaml.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ set -o pipefail
2121
REPO_ROOT="$(git rev-parse --show-toplevel)"
2222

2323
FILE=${1:-}
24-
[[ -z "${FILE:-}" ]] && { echo "Error: file not specified"; exit 1; }
24+
[[ -z "${FILE:-}" ]] && { echo "Error: file not specified" >&2; exit 1; }
2525

2626
LICENSE_HEADER=${REPO_ROOT}/scripts/license-header.yaml
2727

0 commit comments

Comments
 (0)