From 557fcc31f4ada6d2be657995cbb23fdfc26bca93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Fei?= Date: Tue, 5 Sep 2023 15:55:27 +0200 Subject: [PATCH] fix: ensure the secret for pulling image is created MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Niccolò Fei --- hack/e2e/run-e2e.sh | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/hack/e2e/run-e2e.sh b/hack/e2e/run-e2e.sh index fb0b28709b..e275ad6d9e 100755 --- a/hack/e2e/run-e2e.sh +++ b/hack/e2e/run-e2e.sh @@ -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}" @@ -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 @@ -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