|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +#Find most recent version |
| 4 | +export OADPVERSION=$(ls deploy/olm-catalog/bundle/manifests/oadp-operator.v* | awk -F '.' '{out=""; for(i=2;i<4;i++){out=out$i"."}{out=out$4}; print out}') |
| 5 | +export OADPTAG=$(git branch --show-current) |
| 6 | +git checkout origin/$(git branch --show-current) -- Dockerfile |
| 7 | +git checkout origin/$(git branch --show-current) -- .gitignore |
| 8 | +for file in $(git status --porcelain -- render_templates* | awk '{print $2}'); do |
| 9 | + git checkout origin/$(git branch --show-current) -- "${file}" |
| 10 | +done |
| 11 | + |
| 12 | + |
| 13 | +#Declare image information |
| 14 | +IMAGES=( |
| 15 | + "operator" |
| 16 | + "plugin" |
| 17 | + "velero" |
| 18 | + "helper" |
| 19 | + "csiplugin" |
| 20 | + "gcpplugin" |
| 21 | + "awsplugin" |
| 22 | + "azureplugin" |
| 23 | + "registry" |
| 24 | +) |
| 25 | + |
| 26 | +declare -A IMG_MAP |
| 27 | +IMG_MAP[operator_repo]="oadp-operator" |
| 28 | +IMG_MAP[plugin_repo]="openshift-velero-plugin" |
| 29 | +IMG_MAP[velero_repo]="velero" |
| 30 | +IMG_MAP[helper_repo]="velero-restic-restore-helper" |
| 31 | +IMG_MAP[csiplugin_repo]="velero-plugin-for-csi" |
| 32 | +IMG_MAP[gcpplugin_repo]="velero-plugin-for-gcp" |
| 33 | +IMG_MAP[awsplugin_repo]="velero-plugin-for-aws" |
| 34 | +IMG_MAP[azureplugin_repo]="velero-plugin-for-microsoft-azure" |
| 35 | +IMG_MAP[registry_repo]="registry" |
| 36 | + |
| 37 | +#Get latest images |
| 38 | +for i in ${IMAGES[@]}; do |
| 39 | + docker pull quay.io/konveyor/${IMG_MAP[${i}_repo]}:${OADPTAG} >/dev/null 2>&1 |
| 40 | + DOCKER_STAT=$? |
| 41 | + RETRIES=10 |
| 42 | + while [ "$DOCKER_STAT" -ne 0 ] && [ $RETRIES -gt 0 ]; do |
| 43 | + docker pull quay.io/konveyor/${IMG_MAP[${i}_repo]}:${OADPTAG} >/dev/null 2>&1 |
| 44 | + DOCKER_STAT=$? |
| 45 | + let RETRIES=RETRIES-1 |
| 46 | + done |
| 47 | + |
| 48 | + if [ $RETRIES -le 0 ]; then |
| 49 | + echo "Failed to pull new images" |
| 50 | + exit 1 |
| 51 | + fi |
| 52 | +done |
| 53 | + |
| 54 | +#oc mirror images to get correct shas |
| 55 | +for i in ${IMAGES[@]}; do |
| 56 | + RETRIES=10 |
| 57 | + while [ -z "${IMG_MAP[${i}_sha]}" ] && [ $RETRIES -gt 0 ]; do |
| 58 | + IMG_MAP[${i}_sha]=$(oc image mirror --keep-manifest-list=true --dry-run=true quay.io/konveyor/${IMG_MAP[${i}_repo]}:${OADPTAG}=quay.io/foobar/${IMG_MAP[${i}_repo]}:${OADPTAG} 2>&1 | grep "\->" | awk -F'[: ]' '{ print $8 }') |
| 59 | + let RETRIES=RETRIES-1 |
| 60 | + done |
| 61 | + |
| 62 | + if [ $RETRIES -le 0 ]; then |
| 63 | + echo "Failed to mirror images to obtain SHAs" |
| 64 | + exit 1 |
| 65 | + fi |
| 66 | +done |
| 67 | + |
| 68 | + |
| 69 | +# Make CSV Changes check for OADP version inf csv file name |
| 70 | +for f in deploy/olm-catalog/bundle/manifests/oadp-operator.${OADPVERSION}.clusterserviceversion.yaml |
| 71 | + do |
| 72 | + sed -i "s,oadp-operator:.*,oadp-operator@sha256:${IMG_MAP[operator_sha]},g" ${f} |
| 73 | + sed -i "s,/velero:.*,/velero@sha256:${IMG_MAP[velero_sha]},g" ${f} |
| 74 | + sed -i "s,/velero-restic-restore-helper:.*,/velero-restic-restore-helper@sha256:${IMG_MAP[helper_sha]},g" ${f} |
| 75 | + sed -i "s,/openshift-velero-plugin:.*,/openshift-velero-plugin@sha256:${IMG_MAP[plugin_sha]},g" ${f} |
| 76 | + sed -i "s,/velero-plugin-for-aws:.*,/velero-plugin-for-aws@sha256:${IMG_MAP[awsplugin_sha]},g" ${f} |
| 77 | + sed -i "s,/velero-plugin-for-microsoft-azure:.*,/velero-plugin-for-microsoft-azure@sha256:${IMG_MAP[azureplugin_sha]},g" ${f} |
| 78 | + sed -i "s,/velero-plugin-for-csi:.*,/velero-plugin-for-csi@sha256:${IMG_MAP[csiplugin_sha]},g" ${f} |
| 79 | + sed -i "s,/velero-plugin-for-gcp:.*,/velero-plugin-for-gcp@sha256:${IMG_MAP[gcpplugin_sha]},g" ${f} |
| 80 | + sed -i "s,/registry:.*,/registry@sha256:${IMG_MAP[registry_sha]},g" ${f} |
| 81 | + sed -i 's,value: velero-restic-restore-helper,value: velero-restic-restore-helper@sha256,g' ${f} |
| 82 | + sed -i 's,value: velero-plugin-for-csi,value: velero-plugin-for-csi@sha256,g' ${f} |
| 83 | + sed -i 's,value: velero-plugin-for-gcp,value: velero-plugin-for-gcp@sha256,g' ${f} |
| 84 | + sed -i 's,value: velero-plugin-for-aws,value: velero-plugin-for-aws@sha256,g' ${f} |
| 85 | + sed -i 's,value: velero-plugin-for-microsoft-azure,value: velero-plugin-for-microsoft-azure@sha256,g' ${f} |
| 86 | + sed -i 's,value: velero$,value: velero@sha256,g' ${f} |
| 87 | + sed -i 's,value: openshift-velero-plugin$,value: openshift-velero-plugin@sha256,g' ${f} |
| 88 | + sed -i 's,value: registry$,value: registry@sha256,g' ${f} |
| 89 | + sed -i "/VELERO_OPENSHIFT_PLUGIN_TAG/,/^ *[^:]*:/s/value: .*/value: ${IMG_MAP[plugin_sha]}/" ${f} |
| 90 | + sed -i "/VELERO_TAG/,/^ *[^:]*:/s/value: .*/value: ${IMG_MAP[velero_sha]}/" ${f} |
| 91 | + sed -i "/VELERO_RESTIC_RESTORE_HELPER_TAG/,/^ *[^:]*:/s/value: .*/value: ${IMG_MAP[helper_sha]}/" ${f} |
| 92 | + sed -i "/VELERO_CSI_PLUGIN_TAG/,/^ *[^:]*:/s/value: .*/value: ${IMG_MAP[csiplugin_sha]}/" ${f} |
| 93 | + sed -i "/VELERO_GCP_PLUGIN_TAG/,/^ *[^:]*:/s/value: .*/value: ${IMG_MAP[gcpplugin_sha]}/" ${f} |
| 94 | + sed -i "/VELERO_AWS_PLUGIN_TAG/,/^ *[^:]*:/s/value: .*/value: ${IMG_MAP[awsplugin_sha]}/" ${f} |
| 95 | + sed -i "/VELERO_AZURE_PLUGIN_TAG/,/^ *[^:]*:/s/value: .*/value: ${IMG_MAP[azureplugin_sha]}/" ${f} |
| 96 | + sed -i "/VELERO_REGISTRY_TAG/,/^ *[^:]*:/s/value: .*/value: ${IMG_MAP[registry_sha]}/" ${f} |
| 97 | +if [[ "$f" =~ .*clusterserviceversion.* ]] && ! grep -q infrastructure-features ${f}; then |
| 98 | + sed -i '/^spec:/i\ \ \ \ operators.openshift.io/infrastructure-features: \x27[\"Disconnected\"]\x27' ${f} |
| 99 | +fi |
| 100 | +if [[ "$f" =~ .*clusterserviceversion.* ]] && ! grep -q cluster-monitoring ${f}; then |
| 101 | + sed -i '/^spec:/i\ \ \ \ operatorframework.io/cluster-monitoring: "true"' ${f} |
| 102 | +fi |
| 103 | +done |
0 commit comments