Skip to content

Commit 78fe138

Browse files
committed
01_install_requirements: use set -euxo pipefail
Replace set -ex with set -euxo pipefail for consistency with 02_configure_host.sh and 04_setup_ironic.sh. Guard optional environment variables with :- defaults to avoid nounset errors and fix a $ARCH typo that should be $GOARCH. Also fix common.sh to handle the case where Go is not yet installed when sourced by 01_install_requirements.sh — skip 'go env' and GOPATH-dependent assignments when the go binary is absent.
1 parent 2f483b9 commit 78fe138

2 files changed

Lines changed: 13 additions & 10 deletions

File tree

01_install_requirements.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
set -ex
2+
set -euxo pipefail
33

44

55
source logging.sh
@@ -10,7 +10,7 @@ source validation.sh
1010

1111
early_deploy_validation true
1212

13-
if [ -z "${METAL3_DEV_ENV}" ]; then
13+
if [ -z "${METAL3_DEV_ENV:-}" ]; then
1414
export REPO_PATH=${WORKING_DIR}
1515
sync_repo_and_patch metal3-dev-env https://github.com/metal3-io/metal3-dev-env.git
1616
pushd ${METAL3_DEV_ENV_PATH}
@@ -153,7 +153,7 @@ GO_CHECKSUM="$(
153153
)"
154154

155155
if [ -z "$GO_CHECKSUM" ]; then
156-
echo "Error: Could not find checksum for $VERSION ($OS/$ARCH)" >&2
156+
echo "Error: Could not find checksum for $VERSION ($OS/$GOARCH)" >&2
157157
else
158158
echo "Checksum: $GO_CHECKSUM"
159159
fi
@@ -180,17 +180,17 @@ ANSIBLE_FORCE_COLOR=true ansible-playbook \
180180
-b -vvv vm-setup/install-package-playbook.yml
181181
popd
182182

183-
if [ -n "${KNI_INSTALL_FROM_GIT}" ]; then
183+
if [ -n "${KNI_INSTALL_FROM_GIT:-}" ]; then
184184
# zip is required for building the installer from source
185185
sudo dnf -y install zip
186186
fi
187187

188188
# Install nfs for persistent volumes
189-
if [ "${PERSISTENT_IMAGEREG}" == true ] ; then
189+
if [ "${PERSISTENT_IMAGEREG:-}" == true ] ; then
190190
sudo dnf -y install nfs-utils
191191
fi
192192

193-
if [[ "${NODES_PLATFORM}" == "baremetal" ]] ; then
193+
if [[ "${NODES_PLATFORM:-}" == "baremetal" ]] ; then
194194
sudo dnf -y install ipmitool
195195
fi
196196

common.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ export PATH="/usr/local/go/bin:$HOME/.local/bin:$PATH"
66
# Set a PS4 value which logs the script name and line #.
77
export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
88

9-
eval "$(go env)"
10-
11-
export PATH="${GOPATH}/bin:$PATH"
9+
if command -v go &>/dev/null; then
10+
eval "$(go env)"
11+
export PATH="${GOPATH}/bin:$PATH"
12+
fi
1213

1314
# Ensure if a go program crashes we get a coredump
1415
#
@@ -169,7 +170,9 @@ if [ -z "${OPENSHIFT_RELEASE_IMAGE:-}" ]; then
169170
fi
170171
fi
171172
export OPENSHIFT_RELEASE_IMAGE="${OPENSHIFT_RELEASE_IMAGE:-$LATEST_CI_IMAGE}"
172-
export OPENSHIFT_INSTALL_PATH="${OPENSHIFT_INSTALL_PATH:-$GOPATH/src/github.com/openshift/installer}"
173+
if [[ -n "${GOPATH:-}" ]]; then
174+
export OPENSHIFT_INSTALL_PATH="${OPENSHIFT_INSTALL_PATH:-$GOPATH/src/github.com/openshift/installer}"
175+
fi
173176

174177
# Override the image to use for installing hive
175178
export HIVE_DEPLOY_IMAGE="${HIVE_DEPLOY_IMAGE:-registry.ci.openshift.org/openshift/hive-v4.0:hive}"

0 commit comments

Comments
 (0)