From 5e98f99a0c3272e1db25e8ee17f4c19240ef4609 Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Mon, 21 Oct 2024 14:00:14 +0200 Subject: [PATCH] fix: Find out operator subscription name and namespace (#2803) (#2804) Signed-off-by: Anatolii Bazko --- antora.yml | 1 - .../pages/concealing-editors-definitions.adoc | 25 ++++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/antora.yml b/antora.yml index f783d2a5b5..5036a638d1 100644 --- a/antora.yml +++ b/antora.yml @@ -87,7 +87,6 @@ asciidoc: prod-operator-index: registry.access.redhat.com/redhat/community-operator-index:v{ocp4-ver} prod-operator-package-name: eclipse-che prod-operator: che-operator - prod-operator-subscription: eclipse-che prod-prev-short: Che prod-prev-id-short: che prod-prev-ver: "previous minor version" diff --git a/modules/administration-guide/pages/concealing-editors-definitions.adoc b/modules/administration-guide/pages/concealing-editors-definitions.adoc index da49fc692a..b38f0cb894 100644 --- a/modules/administration-guide/pages/concealing-editors-definitions.adoc +++ b/modules/administration-guide/pages/concealing-editors-definitions.adoc @@ -63,15 +63,16 @@ CHE_EDITOR_CONCEAL_CONFIGMAP_NAME=che-conceal-$CHE_EDITOR_CONCEAL_FILE_NAME --from-literal=$CHE_EDITOR_CONCEAL_FILE_NAME="" ---- -. Find out the Operator subscription namespace (if it exists): +. Find out the Operator subscription name and namespace (if it exists): + [source,subs="+attributes"] ---- -SUBSCRIPTION_NAMESPACE=$({orch-cli} get subscription \ +SUBSCRIPTION=$({orch-cli} get subscriptions \ --all-namespaces \ - --field-selector=metadata.name={prod-operator-subscription} \ - --output jsonpath='{.items[0].metadata.namespace}' 2>/dev/null -) + --output json \ + | jq -r '.items[] | select(.spec.name=="{prod-operator-package-name}")') +SUBSCRIPTION_NAMESPACE=$(echo $SUBSCRIPTION | jq -r '.metadata.namespace') +SUBSCRIPTION_NAME=$(echo $SUBSCRIPTION | jq -r '.metadata.name') ---- . Patch the {kubernetes} resource to mount the ConfigMap with the empty editor definition. The resource to patch depends on the existence of the Operator subscription. If the subscription exists, then the subscription should be patched. If not, patch the Operator deployment: @@ -79,8 +80,8 @@ SUBSCRIPTION_NAMESPACE=$({orch-cli} get subscription \ [source,subs="+attributes"] ---- if [[ -n $SUBSCRIPTION_NAMESPACE ]]; then - if [[ $({orch-cli} get subscription {prod-operator-subscription} --namespace $SUBSCRIPTION_NAMESPACE --output jsonpath='{.spec.config}') == "" ]]; then - {orch-cli} patch subscription {prod-operator-subscription} \ + if [[ $({orch-cli} get subscription $SUBSCRIPTION_NAME --namespace $SUBSCRIPTION_NAMESPACE --output jsonpath='{.spec.config}') == "" ]]; then + {orch-cli} patch subscription $SUBSCRIPTION_NAME \ --namespace $SUBSCRIPTION_NAMESPACE \ --type json \ --patch '[{ @@ -90,8 +91,8 @@ if [[ -n $SUBSCRIPTION_NAMESPACE ]]; then }]' fi - if [[ $({orch-cli} get subscription {prod-operator-subscription} --namespace $SUBSCRIPTION_NAMESPACE --output jsonpath='{.spec.config.volumes}') == "" ]]; then - {orch-cli} patch subscription {prod-operator-subscription} \ + if [[ $({orch-cli} get subscription $SUBSCRIPTION_NAME --namespace $SUBSCRIPTION_NAMESPACE --output jsonpath='{.spec.config.volumes}') == "" ]]; then + {orch-cli} patch subscription $SUBSCRIPTION_NAME \ --namespace $SUBSCRIPTION_NAMESPACE \ --type json \ --patch '[{ @@ -101,8 +102,8 @@ if [[ -n $SUBSCRIPTION_NAMESPACE ]]; then }]' fi - if [[ $({orch-cli} get subscription {prod-operator-subscription} --namespace $SUBSCRIPTION_NAMESPACE --output jsonpath='{.spec.config.volumeMounts}') == "" ]]; then - {orch-cli} patch subscription {prod-operator-subscription} \ + if [[ $({orch-cli} get subscription $SUBSCRIPTION_NAME --namespace $SUBSCRIPTION_NAMESPACE --output jsonpath='{.spec.config.volumeMounts}') == "" ]]; then + {orch-cli} patch subscription $SUBSCRIPTION_NAME \ --namespace $SUBSCRIPTION_NAMESPACE \ --type json \ --patch '[{ @@ -112,7 +113,7 @@ if [[ -n $SUBSCRIPTION_NAMESPACE ]]; then }]' fi - {orch-cli} patch subscription {prod-operator-subscription} \ + {orch-cli} patch subscription $SUBSCRIPTION_NAME \ --namespace $SUBSCRIPTION_NAMESPACE \ --type json \ --patch '[{