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"
29 # Use the bash internal OSTYPE variable to check for MacOS
30 if [[ "$OSTYPE" == "darwin"* ]]
50 "policy/drools-applications"
56 echo "$SCRIPT_NAME - generate an OOM commit to update the versions of Policy Framework images in values.yaml files"
58 echo " usage: $SCRIPT_NAME [-options]"
61 echo " -h - this help message"
62 echo " -d data_file - the policy release data file to use, defaults to '$release_data_file'"
63 echo " -l location - the location of the OOM repo on the file system,"
64 echo " defaults to '$repo_location'"
65 echo " -i issue-id - issue ID in the format POLICY-nnnn"
68 echo " $SCRIPT_NAME -l /home/user/onap -d /home/user/data/pf_release_data.csv -i POLICY-1234"
69 echo " update the version of policy framework images at location '/home/user/onap/oom' using the release data"
70 echo " in the file '/home/user/data/pf_release_data.csv'"
74 while getopts "hd:l:i:" opt
81 release_data_file=$OPTARG
98 echo "no arguments were specified"
102 if [[ -z "$repo_location" ]]
104 echo "OOM repo location not specified on -l flag"
108 if ! [ -d "$repo_location" ]
110 echo "OOM repo location '$repo_location' not found"
114 if [[ -z "$release_data_file" ]]
116 echo "policy release data file not specified on -d flag"
120 if ! [ -f "$release_data_file" ]
122 echo "policy release data file '$release_data_file' not found"
126 if [ -z "$issue_id" ]
128 echo "issue_id not specified on -i flag"
132 if ! echo "$issue_id" | grep -Eq '^POLICY-[0-9]*$'
134 echo "issue ID is invalid, it should be of form 'POLICY-nnnn'"
138 for specified_repo in "${pf_repos[@]}"
140 # shellcheck disable=SC2034
141 # shellcheck disable=SC2046
143 latest_released_tag \
144 latest_snapshot_tag \
145 changed_files docker_images \
146 <<< $(grep "$specified_repo" "$release_data_file" | tr ',' ' ' )
148 if [ ! "$repo" = "$specified_repo" ]
150 echo "repo '$specified_repo' not found in file 'pf_release_data.csv'"
154 if [ "$docker_images" = "" ]
159 for docker_image in $(echo "$docker_images" | sed -e "s/'//g" -e "s/:/ /g")
161 new_image="$docker_image:$latest_released_tag"
163 echo "updating OOM image $new_image . . ."
164 find "$repo_location/oom/kubernetes/policy/components" \
168 "s/^image:[ |\t]*onap\/$docker_image:[0-9]*\.[0-9]*\.[0-9]*$/image: onap\/$new_image/" {} \;
169 echo "OOM image $docker_image:$latest_released_tag updated"
173 echo "generating OOM commit to update policy framework docker image versions . . ."
176 -l "$repo_location" \
179 -e "[POLICY] Update docker images to latest versions" \
180 -m "The image versions in policy values.yaml files have been updated"
182 echo "OOM commit to update policy framework docker image versions generated"