bcgov-nr/action-deployer-openshift

Deployer Issue on multiple imagestream from 2nd pass onwards

Closed this issue · 1 comments

as reported by @barrfalk
there's an issue if there are more than one "kind" of an object of the same kind in the "openshift.deploy.yml" file. For example, if there are multiple ImageStream objects (as there is in the backend "openshift.deploy.yml"), then the action-deployer-openshift script won't have the desired effect.

More precisely, this line of code has an issue: https://github.com/bcgov-nr/action-deployer-openshift/blob/c13ef63aae98b3fc45b494d41d77e89ce6f4dbe5/action.yml#LL74C9-L74C9

IS=$(jq -rn "${TEMPLATE} | .items[] | select(.kind=="ImageStream").metadata.name //empty")

If there are multiple ImageStream objects, then this will return a string that concatenates the name of the two ImageStreams.

Then, on lines 102-106, I believe the intent is to iterate through an array of ImageStreams that should be deleted so that they can be recreated in OpenShift.

IS="${{ steps.vars.outputs.imageStream }}"
for i in "${IS}"
do
[ ! $(oc get is -o name | grep ^imagestream.image.openshift.io/${i}$) ]|| oc delete is/${i}
done

It's this last part that won't work, since IS isn't an array, the image streams will never be replaced.

Here's why this can be easily overlooked: The first PR will work, and the images will be created. Any subsequent PR won't replace the backend image.

Resolved by #28 (review).