Skip to content

Commit

Permalink
swap-image-csv.sh updates and minor fixes to set-plugin-image (#535)
Browse files Browse the repository at this point in the history
* set DOWNSTREAM_DEPLOYMENT for CSV

* plugin make target fix
  • Loading branch information
memodi authored Jan 25, 2024
1 parent 08af617 commit 33456e0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
7 changes: 5 additions & 2 deletions .mk/development.mk
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,15 @@ endif
@echo -e "\n==> Redeploying..."
kubectl rollout status -n $(OPERATOR_NS) --timeout=60s deployment netobserv-controller-manager
kubectl wait -n $(OPERATOR_NS) --timeout=60s --for condition=Available=True deployment netobserv-controller-manager
kubectl rollout status -n $(NAMESPACE) --timeout=60s deployment netobserv-plugin
kubectl wait -n $(NAMESPACE) --timeout=60s --for condition=Available=True deployment netobserv-plugin
@echo -e "\n==> Wait a moment before plugin pod is fully redeployed"

.PHONY: set-release-kind-downstream
set-release-kind-downstream:
ifeq ("", "$(CSV)")
kubectl -n $(NAMESPACE) set env deployment netobserv-controller-manager -c "manager" DOWNSTREAM_DEPLOYMENT=true
else
./hack/swap-image-csv.sh $(CSV) $(OPERATOR_NS) "" DOWNSTREAM_DEPLOYMENT true
endif
@echo -e "\n==> Redeploying..."
kubectl rollout status -n $(NAMESPACE) --timeout=60s deployment netobserv-controller-manager
kubectl wait -n $(NAMESPACE) --timeout=60s --for condition=Available=True deployment netobserv-controller-manager
Expand Down
12 changes: 9 additions & 3 deletions hack/swap-image-csv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@ rel_name=$3
env_name=$4
new_image=$5

idx_rel=$(oc get csv $csv_name -n $namespace -o json | jq --arg NAME "$rel_name" '.spec.relatedImages | map(.name == $NAME) | index(true)')
patch1="{'op': 'replace', 'path': '/spec/relatedImages/$idx_rel', 'value': {'name': '$rel_name', 'image': '$new_image'}}"
if [[ ! -z $rel_name ]]; then
idx_rel=$(oc get csv $csv_name -n $namespace -o json | jq --arg NAME "$rel_name" '.spec.relatedImages | map(.name == $NAME) | index(true)')
patch1="{'op': 'replace', 'path': '/spec/relatedImages/$idx_rel', 'value': {'name': '$rel_name', 'image': '$new_image'}}"
fi

idx_env=$(oc get csv $csv_name -n $namespace -o json | jq --arg NAME "$env_name" '.spec.install.spec.deployments[0].spec.template.spec.containers[0].env | map(.name == $NAME) | index(true)')
patch2="{'op': 'replace', 'path': '/spec/install/spec/deployments/0/spec/template/spec/containers/0/env/$idx_env', 'value': {'name': '$env_name', 'value': '$new_image'}}"

oc patch csv $csv_name -n $namespace --type='json' -p "[$patch1, $patch2]"
if [[ ! -z ${patch1+x} ]] ; then
oc patch csv $csv_name -n $namespace --type='json' -p "[$patch1, $patch2]"
else
oc patch csv $csv_name -n $namespace --type='json' -p "[$patch2]"
fi

if [ $? -eq 0 ]; then
echo "Patch succeeded"
Expand Down

0 comments on commit 33456e0

Please sign in to comment.