Skip to content

Commit

Permalink
fix: Find out operator subscription name and namespace (#2803) (#2804)
Browse files Browse the repository at this point in the history
Signed-off-by: Anatolii Bazko <[email protected]>
  • Loading branch information
tolusha authored Oct 21, 2024
1 parent 34aa0be commit 5e98f99
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
1 change: 0 additions & 1 deletion antora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,25 @@ 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:
+
[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 '[{
Expand All @@ -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 '[{
Expand All @@ -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 '[{
Expand All @@ -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 '[{
Expand Down

0 comments on commit 5e98f99

Please sign in to comment.