From ba9ff0577e5012381eac0f1c903324295e81b6ee Mon Sep 17 00:00:00 2001 From: Frederic Gurr Date: Tue, 24 Oct 2023 11:28:11 +0200 Subject: [PATCH] Fix create_gerrit_ssh_keys_secret.sh script for webdev instance --- secrets/create_gerrit_ssh_keys_secret.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/secrets/create_gerrit_ssh_keys_secret.sh b/secrets/create_gerrit_ssh_keys_secret.sh index 2f629e6c8..4e08d9aed 100755 --- a/secrets/create_gerrit_ssh_keys_secret.sh +++ b/secrets/create_gerrit_ssh_keys_secret.sh @@ -49,15 +49,21 @@ if [[ -z "${project_name}" ]]; then exit 1 fi +if [[ "${short_name}" == "webdev" ]]; then + namespace="foundation-internal-${short_name}" +else + namespace="${short_name}" +fi + add_gerrit_secret() { - if [[ -f "${PASSWORD_STORE_DIR}/${pw_store_path}/id_rsa.gpg" ]]; then - oc create secret generic gerrit-ssh-keys --namespace="${short_name}" --from-file="id_rsa=/dev/stdin" <<<"$(pass "${pw_store_path}/id_rsa")" + if [[ -f "${PASSWORD_STORE_DIR}/${pw_store_path}/id_rsa.gpg" ]]; then + oc create secret generic gerrit-ssh-keys --namespace="${namespace}" --from-file="id_rsa=/dev/stdin" <<<"$(pass "${pw_store_path}/id_rsa")" else echo "WARNING: Project does not have a pass entry '${PASSWORD_STORE_DIR}/${pw_store_path}/id_rsa'." fi } -if oc get secrets --namespace="${short_name}" | grep -q "gerrit-ssh-keys"; then +if oc get secrets --namespace="${namespace}" | grep -q "gerrit-ssh-keys"; then printf "Secret gerrit-ssh-keys already exists. Skipping creation...\n" else add_gerrit_secret