echo " -o - update policy/drools-pdp references"
echo " -x - update policy/apex-pdp references"
echo " -k - update docker base images in Dockerfiles"
- echo " -f - update release data in policy parent"
- echo " -t tag - tag the release data file with the given tag"
+ echo " -t tag - update release data in policy parent and"
+ echo " tag the release data file with the given tag"
echo " -s - update release references to snapshot references,"
echo " if omitted, snapshot references are updated to release references"
echo ""
update_apex_pdp=false
update_snapshot=false
update_docker=false
-update_file=false
+update_release_file=false
-while getopts "hd:l:r:pcmoxkft:s" opt
+while getopts "hd:l:r:pcmoxkt:s" opt
do
case $opt in
h)
k)
update_docker=true
;;
- f)
- update_file=true
- ;;
t)
- release_data_file_tag="$OPTARG"_
+ update_release_file=true
+ release_data_file_tag="$OPTARG"
;;
s)
update_snapshot=true
exit 1
fi
+if [ "$update_release_file" = true ] && [ -z "$release_data_file_tag" ]
+then
+ echo "tag not specified on -t flag"
+ exit 1
+fi
+
# shellcheck disable=SC2034
# shellcheck disable=SC2046
read -r parent_repo \
if [ "$update_docker" = true ] && [ "$target_docker_images" != "" ]
then
- if [ "$update_snapshot" == true ]
+ if [ "$specified_repo" = "policy/docker" ]
then
- echo "updating docker base images to version $docker_latest_snapshot_tag on repo $repo_location/$target_repo . . ."
- find "$repo_location/$target_repo" \
- -name '*Docker*' \
- -exec $SED -r -i "s/^(FROM onap\/policy-j[d|r][k|e]-alpine:)[0-9]*.[0-9]*.[0-9].*$/\1$docker_latest_snapshot_tag/" {} \;
- result_code=$?
+ if [ "$update_snapshot" = true ]
+ then
+ major_version=$(echo "$docker_latest_released_tag" | $SED -E 's/^([0-9]*)\.[0-9]*\.[0-9]*$/\1/')
+ minor_version=$(echo "$docker_latest_released_tag" | $SED -E 's/^[0-9]*\.([0-9]*)\.[0-9]*$/\1/')
+ patch_version=$(echo "$docker_latest_released_tag" | $SED -E 's/^[0-9]*\.[0-9]*\.([0-9]*)$/\1/')
+
+ new_patch_version=$((patch_version+1))
+ new_snapshot_tag="$major_version"."$minor_version"."$new_patch_version"-SNAPSHOT
+
+ echo "updating docker base images to version $new_snapshot_tag on repo $repo_location/$target_repo . . ."
+ find "$repo_location/$target_repo" \
+ -name '*Docker*' \
+ -exec $SED -r -i "s/^(FROM onap\/policy-j[d|r][k|e]-alpine:)[0-9]*.[0-9]*.[0-9].*$/\1$new_snapshot_tag/" {} \;
+ result_code=$?
+ else
+ next_release_version=${docker_latest_snapshot_tag%-*}
+
+ echo "updating docker base images to version $next_release_version on repo $repo_location/$target_repo . . ."
+ find "$repo_location/$target_repo" \
+ -name '*Docker*' \
+ -exec $SED -r -i "s/^(FROM onap\/policy-j[d|r][k|e]-alpine:)[0-9]*.[0-9]*.[0-9].*$/\1$next_release_version/" {} \;
+ result_code=$?
+ fi
else
- echo "updating docker base images to version $docker_latest_released_tag on repo $repo_location/$target_repo . . ."
- find "$repo_location/$target_repo" \
- -name '*Docker*' \
- -exec $SED -r -i "s/^(FROM onap\/policy-j[d|r][k|e]-alpine:)[0-9]*.[0-9]*.[0-9].*$/\1$docker_latest_released_tag/" {} \;
- result_code=$?
+ if [ "$update_snapshot" == true ]
+ then
+ echo "updating docker base images to version $docker_latest_snapshot_tag on repo $repo_location/$target_repo . . ."
+ find "$repo_location/$target_repo" \
+ -name '*Docker*' \
+ -exec $SED -r -i "s/^(FROM onap\/policy-j[d|r][k|e]-alpine:)[0-9]*.[0-9]*.[0-9].*$/\1$docker_latest_snapshot_tag/" {} \;
+ result_code=$?
+ else
+ echo "updating docker base images to version $docker_latest_released_tag on repo $repo_location/$target_repo . . ."
+ find "$repo_location/$target_repo" \
+ -name '*Docker*' \
+ -exec $SED -r -i "s/^(FROM onap\/policy-j[d|r][k|e]-alpine:)[0-9]*.[0-9]*.[0-9].*$/\1$docker_latest_released_tag/" {} \;
+ result_code=$?
+ fi
fi
if [[ "$result_code" -eq 0 ]]
fi
fi
-if [ "$update_file" = true ]
+if [ "$update_release_file" = true ]
then
if [ ! "$target_repo" = "policy/parent" ]
then
exit 1
fi
- release_data_file_name="$release_data_file_tag$release_data_file"
+ release_data_file_name="$release_data_file_tag"_"$release_data_file"
echo \
"updating release data at" \
"$repo_location/$target_repo/integration/src/main/resources/release/$release_data_file_name"
+ # Update the latest release file
+ cp \
+ "$release_data_file" \
+ "$repo_location/$target_repo/integration/src/main/resources/release/$release_data_file"
+ # Update the tagged release file
cp \
"$release_data_file" \
"$repo_location/$target_repo/integration/src/main/resources/release/$release_data_file_name"