4 # ============LICENSE_START================================================
6 # =========================================================================
7 # Copyright (C) 2021-2022 Nordix Foundation.
8 # =========================================================================
9 # Licensed under the Apache License, Version 2.0 (the "License");
10 # you may not use this file except in compliance with the License.
11 # You may obtain a copy of the License at
13 # http://www.apache.org/licenses/LICENSE-2.0
15 # Unless required by applicable law or agreed to in writing, software
16 # distributed under the License is distributed on an "AS IS" BASIS,
17 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 # See the License for the specific language governing permissions and
19 # limitations under the License.
20 # ============LICENSE_END==================================================
25 SCRIPT_NAME=`basename $0`
27 release_data_file="./pf_release_data.csv"
42 "policy/drools-applications"
48 echo "$SCRIPT_NAME - generate an OOM commit to update the versions of Policy Framework images in values.yaml files"
50 echo " usage: $SCRIPT_NAME [-options]"
53 echo " -h - this help message"
54 echo " -d data_file - the policy release data file to use, defaults to '$release_data_file'"
55 echo " -l location - the location of the OOM repo on the file system,"
56 echo " defaults to '$repo_location'"
57 echo " -i issue-id - issue ID in the format POLICY-nnnn"
60 echo " $SCRIPT_NAME -l /home/user/onap -d /home/user/data/pf_release_data.csv -i POLICY-1234"
61 echo " update the version of policy framework images at location '/home/user/onap/oom' using the release data"
62 echo " in the file '/home/user/data/pf_release_data.csv'"
66 while getopts "hd:l:i:" opt
73 release_data_file=$OPTARG
90 echo "no arguments were specified"
94 if [[ -z "$repo_location" ]]
96 echo "OOM repo location not specified on -l flag"
100 if ! [ -d "$repo_location" ]
102 echo "OOM repo location '$repo_location' not found"
106 if [[ -z "$release_data_file" ]]
108 echo "policy release data file not specified on -d flag"
112 if ! [ -f "$release_data_file" ]
114 echo "policy release data file '$release_data_file' not found"
118 if [ -z "$issue_id" ]
120 echo "issue_id not specified on -i flag"
124 if ! echo "$issue_id" | grep -Eq '^POLICY-[0-9]*$'
126 echo "issue ID is invalid, it should be of form 'POLICY-nnnn'"
130 for specified_repo in "${pf_repos[@]}"
133 latest_released_tag \
134 latest_snapshot_tag \
135 changed_files docker_images \
136 <<< $( grep $specified_repo $release_data_file | tr ',' ' ' )
138 if [ ! "$repo" = "$specified_repo" ]
140 echo "repo '$specified_repo' not found in file 'pf_release_data.csv'"
144 if [ "$docker_images" = "" ]
149 for docker_image in `echo $docker_images | tr ':' ' '`
151 new_image="$docker_image:$latest_released_tag"
153 echo "updating OOM image $new_image . . ."
154 find $repo_location/oom/kubernetes/policy/components \
158 "s/^image:[ |\t]*onap\/$docker_image:[0-9]*\.[0-9]*\.[0-9]*$/image: onap\/$new_image/" {} \;
159 echo "OOM image $docker_image:$latest_released_tag updated"
164 echo "generating OOM commit to update policy framework docker image versions . . ."
170 -e "[POLICY] Update docker images to latest versions" \
171 -m "The image versions in policy values.yaml files have been updated"
173 echo "OOM commit to update policy framework docker image versions generated"