-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathoperator-update-images.sh
executable file
·47 lines (42 loc) · 2.11 KB
/
operator-update-images.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env bash
# Update images from project.yaml to "generated" files
ENVIRONMENT=${1:-"devel"}
case "$ENVIRONMENT" in
"devel")
TARGET_REGISTRY="quay.io/openshift-pipeline"
;;
"staging")
TARGET_REGISTRY="registry.stage.redhat.io/openshift-pipelines"
;;
"production")
TARGET_REGISTRY="registry.redhat.io/openshift-pipelines"
;;
*)
echo "Invalid selection!"
exit 1
;;
esac
function update_image_reference() {
SOURCE_PATTEN="quay.io/.*/(pipeline-)?(.*@sha256:.+)"
TARGET_PATTEN="${TARGET_REGISTRY}/pipelines-\2"
input=$1
output=$(echo "$input" | sed -E "s|$SOURCE_PATTEN|$TARGET_PATTEN|g")
#Update Operator Image operator-operator to operator
output=$(echo "$output" | sed -E "s/operator-operator-rhel9/rhel9-operator/g")
echo "$output"
}
CSV_FILE=".konflux/olm-catalog/bundle/manifests/openshift-pipelines-operator-rh.clusterserviceversion.yaml"
LENGTH=$(yq e '.images | length' project.yaml)
for i in $(seq 0 $((${LENGTH}-1))); do
NAME=$(yq e ".images.${i}.name" project.yaml)
REFERENCE=$(update_image_reference "$(yq e ".images.${i}.value" project.yaml)")
echo "${NAME}: ${REFERENCE}"
yq eval --inplace "(.spec.install.spec.deployments[] | select(.name == \"openshift-pipelines-operator\")| .spec.template.spec.containers[].env[] | select(.name == \"${NAME}\") | .value) = \"${REFERENCE}\"" $CSV_FILE
yq eval --inplace "(.spec.relatedImages[] | select(.name == \"${NAME}\") | .image) = \"${REFERENCE}\"" $CSV_FILE
done
#
## Operator's specifics
REFERENCE=$(update_image_reference "$(yq e '.images[] | select(.name == "OPENSHIFT_PIPELINES_OPERATOR_LIFECYCLE") | .value' project.yaml)")
yq eval --inplace "(.spec.install.spec.deployments[] | select(.name == \"openshift-pipelines-operator\")| .spec.template.spec.containers[].image) = \"${REFERENCE}\"" $CSV_FILE
REFERENCE=$(update_image_reference "$(yq e '.images[] | select(.name == "TEKTON_OPERATOR_WEBHOOK") | .value' project.yaml)")
yq eval --inplace "(.spec.install.spec.deployments[] | select(.name == \"tekton-operator-webhook\")| .spec.template.spec.containers[].image) = \"${REFERENCE}\"" $CSV_FILE