summaryrefslogtreecommitdiffstats
path: root/integration/src/release_scripts/updateOomImages.sh
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2021-12-16 12:56:37 +0000
committerliamfallon <liam.fallon@est.tech>2022-01-06 11:27:22 +0000
commit81c2c515c4c92cb77d7bc31eb2f2771ca2063216 (patch)
treeded78462b4a59aaa2d7503ce414a95a00bac0bf0 /integration/src/release_scripts/updateOomImages.sh
parent1daae3e877d5446c7ec5dac4ca5f28ca1637e393 (diff)
Release scripts for repos, images, OOM, refs
bumpSnapshots.sh: Steps the patch version of snapshot images based on the data in the policy release data file. generateCommit.sh: At the suggestion of OOM, the order of the generated messages is changed. releaseRepo.sh: Generates the release yaml file and the commit to release the maven artifacts of a repo releaseRepoImages.sh: Generates the release yaml fole and the commit to release the docker images from a repo updateOomImages.sh: Generates a commit that updats the references to Policy Framework docker images in OOM updateRefs.sh: Updates the parent. common, models., drools-pdp, and Docker base images in Docker files for reselases or snapshots. Issue-ID: POLICY-3835 Change-Id: I0766a779c2217a57a33ed37725f11acdfb07a16d Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'integration/src/release_scripts/updateOomImages.sh')
-rwxr-xr-xintegration/src/release_scripts/updateOomImages.sh174
1 files changed, 174 insertions, 0 deletions
diff --git a/integration/src/release_scripts/updateOomImages.sh b/integration/src/release_scripts/updateOomImages.sh
new file mode 100755
index 00000000..df6f6781
--- /dev/null
+++ b/integration/src/release_scripts/updateOomImages.sh
@@ -0,0 +1,174 @@
+#!/bin/bash
+
+#
+# ============LICENSE_START================================================
+# ONAP
+# =========================================================================
+# Copyright (C) 2021-2022 Nordix Foundation.
+# =========================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END==================================================
+#
+
+set -e
+
+SCRIPT_NAME=`basename $0`
+repo_location="./"
+release_data_file="./pf_release_data.csv"
+
+declare -a pf_repos=(
+ "policy/parent"
+ "policy/docker"
+ "policy/common"
+ "policy/models"
+ "policy/api"
+ "policy/pap"
+ "policy/drools-pdp"
+ "policy/apex-pdp"
+ "policy/xacml-pdp"
+ "policy/distribution"
+ "policy/gui"
+ "policy/clamp"
+ "policy/drools-applications"
+)
+
+usage()
+{
+ echo ""
+ echo "$SCRIPT_NAME - generate an OOM commit to update the versions of Policy Framework images in values.yaml files"
+ echo ""
+ echo " usage: $SCRIPT_NAME [-options]"
+ echo ""
+ echo " options"
+ echo " -h - this help message"
+ echo " -d data_file - the policy release data file to use, defaults to '$release_data_file'"
+ echo " -l location - the location of the OOM repo on the file system,"
+ echo " defaults to '$repo_location'"
+ echo " -i issue-id - issue ID in the format POLICY-nnnn"
+ echo ""
+ echo " examples:"
+ echo " $SCRIPT_NAME -l /home/user/onap -d /home/user/data/pf_release_data.csv -i POLICY-1234"
+ echo " update the version of policy framework images at location '/home/user/onap/oom' using the release data"
+ echo " in the file '/home/user/data/pf_release_data.csv'"
+ exit 255;
+}
+
+while getopts "hd:l:i:" opt
+do
+ case $opt in
+ h)
+ usage
+ ;;
+ d)
+ release_data_file=$OPTARG
+ ;;
+ l)
+ repo_location=$OPTARG
+ ;;
+ i)
+ issue_id=$OPTARG
+ ;;
+ \?)
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+if [ $OPTIND -eq 1 ]
+then
+ echo "no arguments were specified"
+ usage
+fi
+
+if [[ -z "$repo_location" ]]
+then
+ echo "OOM repo location not specified on -l flag"
+ exit 1
+fi
+
+if ! [ -d "$repo_location" ]
+then
+ echo "OOM repo location '$repo_location' not found"
+ exit 1
+fi
+
+if [[ -z "$release_data_file" ]]
+then
+ echo "policy release data file not specified on -d flag"
+ exit 1
+fi
+
+if ! [ -f "$release_data_file" ]
+then
+ echo "policy release data file '$release_data_file' not found"
+ exit 1
+fi
+
+if [ -z "$issue_id" ]
+then
+ echo "issue_id not specified on -i flag"
+ exit 1
+fi
+
+if ! echo "$issue_id" | grep -Eq '^POLICY-[0-9]*$'
+then
+ echo "issue ID is invalid, it should be of form 'POLICY-nnnn'"
+ exit 1
+fi
+
+for specified_repo in "${pf_repos[@]}"
+do
+ read repo \
+ latest_released_tag \
+ latest_snapshot_tag \
+ changed_files docker_images \
+ <<< $( grep $specified_repo $release_data_file | tr ',' ' ' )
+
+ if [ ! "$repo" = "$specified_repo" ]
+ then
+ echo "repo '$specified_repo' not found in file 'pf_release_data.csv'"
+ continue
+ fi
+
+ if [ "$docker_images" = "" ]
+ then
+ continue
+ fi
+
+ for docker_image in `echo $docker_images | tr ':' ' '`
+ do
+ new_image="$docker_image:$latest_released_tag"
+
+ echo "updating OOM image $new_image . . ."
+ find $repo_location/oom/kubernetes/policy/components \
+ -name values.yaml \
+ -exec \
+ sed -i '' \
+ "s/^image:[ |\t]*onap\/$docker_image:[0-9]*\.[0-9]*\.[0-9]*$/image: onap\/$new_image/" {} \;
+ echo "OOM image $docker_image:$latest_released_tag updated"
+ done
+done
+
+
+echo "generating OOM commit to update policy framework docker image versions . . ."
+
+generateCommit.sh \
+ -l $repo_location \
+ -r oom \
+ -i $issue_id \
+ -e "[POLICY] Update docker images to latest versions" \
+ -m "The image versions in policy values.yaml files have been updated"
+
+echo "OOM commit to update policy framework docker image versions generated"
+