22
33set -euox pipefail
44
5- SOCAT_PID=" "
5+ OLM_INSTALL_SCRIPT=$( mktemp)
6+
7+ # Keep track of the last run command line number on error
8+ trap ' last_line=${LINENO}' ERR
9+
10+ cleanup_and_exit () {
11+ # Capture the exact exit code of the last executed command
12+ local exit_code=${?}
613
7- function handle_error {
8- echo " Error occurred at line $1 "
9- if [ -n " ${SOCAT_PID} " ] ; then
10- kill ${SOCAT_PID}
14+ echo " 🧹 Cleaning up..."
15+ if [ -e ${OLM_INSTALL_SCRIPT} ] ; then
16+ rm -vf ${OLM_INSTALL_SCRIPT}
1117 fi
12- kill 0 # kill the master shell and all subshells
18+
19+ if [ " ${exit_code} " -ne 0 ]; then
20+ echo " ❌ Failed with exit code ${exit_code} at line ${last_line} "
21+ fi
22+
23+ kill $( jobs -p) 2> /dev/null || true
24+ exit " ${exit_code} "
1325}
1426
15- trap ' handle_error $LINENO ' ERR
27+ trap cleanup_and_exit EXIT
1628
17- OLM_VERSION=" v0.42 .0"
29+ OLM_VERSION=" v0.45 .0"
1830OLM_SCRIPT_SHA256=" 1e8065cb503d2ee94ce82dd2591618022852f53a43df908b9f8c7d314cff3532"
1931
32+ IMAGE_REGISTRY=' localhost:5000'
33+ IMAGE_GROUP=' streamshub'
34+ IMAGE_PREFIX=" ${IMAGE_REGISTRY} /${IMAGE_GROUP} "
35+
2036if [ -n " ${MINIKUBE_PROFILE:- } " ] ; then
2137 MK_PROFILE_ARG=" --profile=${MINIKUBE_PROFILE} "
2238else
@@ -30,7 +46,7 @@ if ! minikube status ${MK_PROFILE_ARG} >/dev/null 2>&1 ; then
3046 --memory=${MINIKUBE_MEMORY:- 16384} \
3147 --container-runtime=${MINIKUBE_CONTAINER_RUNTIME:- docker} \
3248 --addons=registry,storage,ingress,ingress-dns,metrics-server \
33- --insecure-registry=" localhost:5000 ,10.0.0.0/24" \
49+ --insecure-registry=" ${IMAGE_REGISTRY} ,10.0.0.0/24" \
3450 --extra-config=kubeadm.ignore-preflight-errors=SystemVerification \
3551 --extra-config=apiserver.authorization-mode=RBAC,Node
3652fi
@@ -44,15 +60,12 @@ if [ "$(kubectl get deployment -n ingress-nginx ingress-nginx-controller -ojson
4460fi
4561
4662# Setup OLM -----------------------------------------------------
47- OLM_INSTALL_SCRIPT=$( mktemp)
48-
4963curl --proto " =https" -o ${OLM_INSTALL_SCRIPT} -sL \
5064 https://github.com/operator-framework/operator-lifecycle-manager/releases/download/${OLM_VERSION} /install.sh
5165
5266echo " ${OLM_SCRIPT_SHA256} ${OLM_INSTALL_SCRIPT} " | sha256sum --check --status || { echo " Hash verification failed" ; exit 1; }
5367chmod +x ${OLM_INSTALL_SCRIPT}
5468${OLM_INSTALL_SCRIPT} ${OLM_VERSION} || true
55- rm -v ${OLM_INSTALL_SCRIPT}
5669
5770# Build and push Console images ---------------------------------
5871PROJECT_VERSION=$( mvn help:evaluate -Dexpression=project.version -q -DforceStdout | tr ' [:upper:]' ' [:lower:]' )
87100
88101mvn clean package -Pcontainer-image -B --no-transfer-progress -DskipTests \
89102 -Dquarkus.kubernetes.namespace=' $${NAMESPACE}' \
103+ -Dcontainer-image.registry=" ${IMAGE_REGISTRY} " \
104+ -Dcontainer-image.group=" ${IMAGE_GROUP} " \
90105 -Dcontainer-image.tag=${PROJECT_VERSION} \
91- -Dcontainer-image.registry=' localhost:5000' \
92106 -Dcontainer-image.push=false
93107
94108./operator/bin/modify-bundle-metadata.sh \
@@ -97,27 +111,28 @@ mvn clean package -Pcontainer-image -B --no-transfer-progress -DskipTests \
97111 " PLATFORMS=${PLATFORMS} "
98112
99113${CONTAINER_RUNTIME} build \
100- -t localhost:5000/streamshub /console-operator-bundle:${PROJECT_VERSION} \
114+ -t ${IMAGE_PREFIX} /console-operator-bundle:${PROJECT_VERSION} \
101115 -f operator/target/bundle/streamshub-console-operator/bundle.Dockerfile \
102116 operator/target/bundle/streamshub-console-operator
103117
104118./operator/bin/generate-catalog.sh ./operator/target/bundle/streamshub-console-operator true
105119
106120${CONTAINER_RUNTIME} build \
107- -t localhost:5000/streamshub /console-operator-catalog:${PROJECT_VERSION} \
121+ -t ${IMAGE_PREFIX} /console-operator-catalog:${PROJECT_VERSION} \
108122 -f operator/src/main/docker/catalog.Dockerfile \
109123 operator/
110124
111125socat TCP-LISTEN:5000,reuseaddr,fork TCP:$( minikube ip ${MK_PROFILE_ARG} ) :5000 &
112- SOCAT_PID= ${ ! }
126+
113127# Wait for socat to warm up
114- sleep 5
128+ for i in $( seq 1 30) ; do
129+ nc -z localhost 5000 && break
130+ sleep 1
131+ done
115132
116133for img in console-api console-operator console-operator-bundle console-operator-catalog ; do
134+ # TODO: deeper evaluation of `minikube image load`
117135 skopeo copy --preserve-digests --dest-tls-verify=false \
118- ${SKOPEO_LOCAL} localhost:5000/streamshub /${img} :${PROJECT_VERSION} \
119- docker://localhost:5000/streamshub /${img} :${PROJECT_VERSION}
136+ ${SKOPEO_LOCAL}${IMAGE_PREFIX} /${img} :${PROJECT_VERSION} \
137+ docker://${IMAGE_PREFIX} /${img} :${PROJECT_VERSION}
120138done
121-
122- kill ${SOCAT_PID}
123- SOCAT_PID=" "
0 commit comments