Skip to content

Commit

Permalink
fix: ensure the secret for pulling image is created
Browse files Browse the repository at this point in the history
Signed-off-by: Niccolò Fei <[email protected]>
  • Loading branch information
NiccoloFei committed Sep 5, 2023
1 parent c7b680d commit 557fcc3
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions hack/e2e/run-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,23 @@ notinpath () {
esac
}

ensure_image_pull_secret() {
if [ -n "${DOCKER_SERVER-}" ] && [ -n "${DOCKER_USERNAME-}" ] && [ -n "${DOCKER_PASSWORD-}" ]; then
if ! kubectl get secret cnpg-pull-secret -n cnpg-system >/dev/null 2>&1; then
kubectl create secret docker-registry \
-n cnpg-system \
cnpg-pull-secret \
--docker-server="${DOCKER_SERVER}" \
--docker-username="${DOCKER_USERNAME}" \
--docker-password="${DOCKER_PASSWORD}"
fi
fi
}

# Process the e2e templates
export E2E_PRE_ROLLING_UPDATE_IMG=${E2E_PRE_ROLLING_UPDATE_IMG:-${POSTGRES_IMG%.*}}
export AZURE_STORAGE_ACCOUNT=${AZURE_STORAGE_ACCOUNT:-''}

# Getting the operator images need a pull secret
kubectl delete namespace cnpg-system || :
kubectl create namespace cnpg-system
if [ -n "${DOCKER_SERVER-}" ] && [ -n "${DOCKER_USERNAME-}" ] && [ -n "${DOCKER_PASSWORD-}" ]; then
kubectl create secret docker-registry \
-n cnpg-system \
cnpg-pull-secret \
--docker-server="${DOCKER_SERVER}" \
--docker-username="${DOCKER_USERNAME}" \
--docker-password="${DOCKER_PASSWORD}"
fi

go_bin="$(go env GOPATH)/bin"
if notinpath "${go_bin}"; then
export PATH="${go_bin}:${PATH}"
Expand All @@ -74,6 +75,10 @@ echo "E2E tests are running with the following filters: ${LABEL_FILTERS}"
RC=0
RC_GINKGO1=0
if [[ "${TEST_UPGRADE_TO_V1}" != "false" ]]; then
# Getting the operator images need a pull secret
kubectl delete namespace postgresql-operator-system || :
kubectl create namespace postgresql-operator-system
ensure_image_pull_secret
# Generate a manifest for the operator after the api upgrade
# TODO: this is almost a "make deploy". Refactor.
make manifests kustomize
Expand Down Expand Up @@ -103,6 +108,11 @@ if [[ "${TEST_UPGRADE_TO_V1}" != "false" ]]; then
jq -e -c -f "${ROOT_DIR}/hack/e2e/test-report.jq" "${ROOT_DIR}/tests/e2e/out/upgrade_report.json" || RC=$?
fi

# Getting the operator images need a pull secret
kubectl delete namespace postgresql-operator-system || :
kubectl create namespace postgresql-operator-system
ensure_image_pull_secret

CONTROLLER_IMG="${CONTROLLER_IMG}" \
POSTGRES_IMAGE_NAME="${POSTGRES_IMG}" \
make -C "${ROOT_DIR}" deploy
Expand Down

0 comments on commit 557fcc3

Please sign in to comment.