liamfallon | e84250c | 2022-06-17 11:11:55 +0100 | [diff] [blame] | 1 | #! /bin/bash |
| 2 | |
Taka Cho | 6d188af | 2021-01-11 16:48:33 -0500 | [diff] [blame] | 3 | # ============LICENSE_START==================================================== |
| 4 | # Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. |
rameshiyer27 | b15eda6 | 2024-02-14 10:13:16 +0000 | [diff] [blame] | 5 | # Modification Copyright 2021-2024 Nordix Foundation. |
a.sreekumar | d00369a | 2021-10-19 12:38:04 +0100 | [diff] [blame] | 6 | # Modifications Copyright (C) 2021 Bell Canada. All rights reserved. |
Taka Cho | 6d188af | 2021-01-11 16:48:33 -0500 | [diff] [blame] | 7 | # ============================================================================= |
| 8 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 | # you may not use this file except in compliance with the License. |
| 10 | # You may obtain a copy of the License at |
| 11 | # |
| 12 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | # |
| 14 | # Unless required by applicable law or agreed to in writing, software |
| 15 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | # See the License for the specific language governing permissions and |
| 18 | # limitations under the License. |
| 19 | # |
| 20 | # SPDX-License-Identifier: Apache-2.0 |
| 21 | # ============LICENSE_END====================================================== |
| 22 | |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 23 | if [ -z "${WORKSPACE}" ]; then |
| 24 | WORKSPACE=$(git rev-parse --show-toplevel) |
| 25 | export WORKSPACE |
liamfallon | e84250c | 2022-06-17 11:11:55 +0100 | [diff] [blame] | 26 | fi |
Taka Cho | 6d188af | 2021-01-11 16:48:33 -0500 | [diff] [blame] | 27 | |
adheli.tavares | d802fd9 | 2024-08-15 12:39:19 +0100 | [diff] [blame^] | 28 | LOCAL_IMAGES=false |
| 29 | |
adheli.tavares | daecbb9 | 2024-07-19 13:50:04 +0100 | [diff] [blame] | 30 | #default values |
liamfallon | 0a85ebf | 2022-12-18 02:24:07 +0000 | [diff] [blame] | 31 | export POLICY_MARIADB_VER=10.10.2 |
Taka Cho | 6d188af | 2021-01-11 16:48:33 -0500 | [diff] [blame] | 32 | echo POLICY_MARIADB_VER=${POLICY_MARIADB_VER} |
| 33 | |
adheli.tavares | d802fd9 | 2024-08-15 12:39:19 +0100 | [diff] [blame^] | 34 | export POLICY_POSTGRES_VER=16.4 |
waynedunican | 7450119 | 2022-03-16 08:10:54 +0000 | [diff] [blame] | 35 | echo POLICY_POSTGRES_VER=${POLICY_POSTGRES_VER} |
| 36 | |
adheli.tavares | daecbb9 | 2024-07-19 13:50:04 +0100 | [diff] [blame] | 37 | if [ -n "$LOCAL_IMAGES" ] && [ "$LOCAL_IMAGES" = "true" ]; then |
| 38 | echo "Running with local images." |
| 39 | export POLICY_DOCKER_VERSION="latest" |
| 40 | export POLICY_MODELS_VERSION="latest" |
| 41 | export POLICY_API_VERSION="latest" |
| 42 | export POLICY_PAP_VERSION="latest" |
| 43 | export POLICY_APEX_PDP_VERSION="latest" |
| 44 | export POLICY_DROOLS_PDP_VERSION="latest" |
| 45 | export POLICY_XACML_PDP_VERSION="latest" |
| 46 | export POLICY_DISTRIBUTION_VERSION="latest" |
| 47 | export POLICY_CLAMP_VERSION="latest" |
| 48 | export POLICY_CLAMP_PPNT_VERSION=$POLICY_CLAMP_VERSION |
| 49 | export POLICY_DROOLS_APPS_VERSION="latest" |
adheli.tavares | d802fd9 | 2024-08-15 12:39:19 +0100 | [diff] [blame^] | 50 | export CONTAINER_LOCATION="" |
liamfallon | f66c683 | 2022-06-28 15:55:29 +0100 | [diff] [blame] | 51 | |
adheli.tavares | daecbb9 | 2024-07-19 13:50:04 +0100 | [diff] [blame] | 52 | else |
adheli.tavares | d802fd9 | 2024-08-15 12:39:19 +0100 | [diff] [blame^] | 53 | export CONTAINER_LOCATION="nexus3.onap.org:10001/" |
adheli.tavares | daecbb9 | 2024-07-19 13:50:04 +0100 | [diff] [blame] | 54 | GERRIT_BRANCH=$(awk -F= '$1 == "defaultbranch" { print $2 }' \ |
| 55 | "${WORKSPACE}"/.gitreview) |
liamfallon | f66c683 | 2022-06-28 15:55:29 +0100 | [diff] [blame] | 56 | |
adheli.tavares | daecbb9 | 2024-07-19 13:50:04 +0100 | [diff] [blame] | 57 | echo GERRIT_BRANCH="${GERRIT_BRANCH}" |
liamfallon | f66c683 | 2022-06-28 15:55:29 +0100 | [diff] [blame] | 58 | |
adheli.tavares | daecbb9 | 2024-07-19 13:50:04 +0100 | [diff] [blame] | 59 | function getDockerVersion |
| 60 | { |
| 61 | REPO=${1} |
| 62 | DEFAULT_DOCKER_IMAGE_NAME=${2:-} |
| 63 | DEFAULT_DOCKER_IMAGE_VERSION=${3:-} |
| 64 | |
| 65 | REPO_RELEASE_DATA=$( |
| 66 | curl -qL --silent \ |
| 67 | "https://github.com/onap/policy-parent/raw/$GERRIT_BRANCH/integration/src/main/resources/release/pf_release_data.csv" | |
| 68 | grep "^policy/$REPO" |
| 69 | ) |
| 70 | |
| 71 | # shellcheck disable=SC2034 |
| 72 | read -r repo \ |
| 73 | latest_released_tag \ |
| 74 | latest_snapshot_tag \ |
| 75 | changed_files \ |
| 76 | docker_images \ |
| 77 | <<< "$(echo "$REPO_RELEASE_DATA" | tr ',' ' ' )" |
| 78 | |
| 79 | if [[ -z "$docker_images" ]] |
liamfallon | f66c683 | 2022-06-28 15:55:29 +0100 | [diff] [blame] | 80 | then |
adheli.tavares | daecbb9 | 2024-07-19 13:50:04 +0100 | [diff] [blame] | 81 | if [[ -z "$DEFAULT_DOCKER_IMAGE_NAME" ]] |
| 82 | then |
| 83 | echo "repo $REPO does not produce a docker image, execution terminated" |
| 84 | exit 1 |
| 85 | else |
| 86 | docker_images="$DEFAULT_DOCKER_IMAGE_NAME" |
| 87 | fi |
liamfallon | f66c683 | 2022-06-28 15:55:29 +0100 | [diff] [blame] | 88 | fi |
liamfallon | f66c683 | 2022-06-28 15:55:29 +0100 | [diff] [blame] | 89 | |
adheli.tavares | daecbb9 | 2024-07-19 13:50:04 +0100 | [diff] [blame] | 90 | # docker_image_version=$(echo "$latest_snapshot_tag" | awk -F \. '{print $1"."$2"-SNAPSHOT-latest"}') |
| 91 | docker_image_version=$latest_snapshot_tag |
| 92 | docker_image_name=$(echo "$docker_images" | sed -e "s/^.*://" -e "s/^.//" -e "s/.$//") |
liamfallon | f66c683 | 2022-06-28 15:55:29 +0100 | [diff] [blame] | 93 | |
adheli.tavares | daecbb9 | 2024-07-19 13:50:04 +0100 | [diff] [blame] | 94 | if \ |
| 95 | curl -qL --silent \ |
| 96 | "https://nexus3.onap.org/service/rest/repository/browse/docker.snapshot/v2/onap/$docker_image_name/tags/" | |
| 97 | grep -q "$docker_image_version" |
| 98 | then |
| 99 | echo "using \"$docker_image_name:$docker_image_version\" docker image for repo \"$repo\"" |
| 100 | return |
| 101 | fi |
liamfallon | f66c683 | 2022-06-28 15:55:29 +0100 | [diff] [blame] | 102 | |
adheli.tavares | daecbb9 | 2024-07-19 13:50:04 +0100 | [diff] [blame] | 103 | docker_image_version="$latest_released_tag" |
| 104 | if \ |
| 105 | curl -qL --silent \ |
| 106 | "https://nexus3.onap.org/service/rest/repository/browse/docker.release/v2/onap/$docker_image_name/tags/" | |
| 107 | grep -q "$docker_image_version" |
| 108 | then |
| 109 | echo "using \"$docker_image_name:$docker_image_version\" docker image for repo \"$repo\"" |
| 110 | return |
| 111 | fi |
liamfallon | f66c683 | 2022-06-28 15:55:29 +0100 | [diff] [blame] | 112 | |
adheli.tavares | daecbb9 | 2024-07-19 13:50:04 +0100 | [diff] [blame] | 113 | docker_image_version="$DEFAULT_DOCKER_IMAGE_VERSION" |
| 114 | if \ |
| 115 | curl -qL --silent \ |
| 116 | "https://nexus3.onap.org/service/rest/repository/browse/docker.release/v2/onap/$docker_image_name/tags/" | |
| 117 | grep -q "$docker_image_version" |
| 118 | then |
| 119 | echo "using \"$docker_image_name:$docker_image_version\" docker image for repo \"$repo\"" |
| 120 | return |
| 121 | else |
| 122 | echo "docker image \"$docker_image_name:$docker_image_version\" not found for repo \"$repo\"" |
| 123 | exit 1 |
| 124 | fi |
| 125 | } |
Jim Hahn | cfc44f0 | 2021-04-08 15:28:15 -0400 | [diff] [blame] | 126 | |
adheli.tavares | daecbb9 | 2024-07-19 13:50:04 +0100 | [diff] [blame] | 127 | getDockerVersion docker |
| 128 | export POLICY_DOCKER_VERSION="$docker_image_version" |
Taka Cho | 6d188af | 2021-01-11 16:48:33 -0500 | [diff] [blame] | 129 | |
adheli.tavares | d802fd9 | 2024-08-15 12:39:19 +0100 | [diff] [blame^] | 130 | getDockerVersion models |
adheli.tavares | daecbb9 | 2024-07-19 13:50:04 +0100 | [diff] [blame] | 131 | export POLICY_MODELS_VERSION="$docker_image_version" |
Taka Cho | 6d188af | 2021-01-11 16:48:33 -0500 | [diff] [blame] | 132 | |
adheli.tavares | daecbb9 | 2024-07-19 13:50:04 +0100 | [diff] [blame] | 133 | getDockerVersion api |
| 134 | export POLICY_API_VERSION="$docker_image_version" |
Taka Cho | 6d188af | 2021-01-11 16:48:33 -0500 | [diff] [blame] | 135 | |
adheli.tavares | daecbb9 | 2024-07-19 13:50:04 +0100 | [diff] [blame] | 136 | getDockerVersion pap |
| 137 | export POLICY_PAP_VERSION="$docker_image_version" |
Taka Cho | 6d188af | 2021-01-11 16:48:33 -0500 | [diff] [blame] | 138 | |
adheli.tavares | daecbb9 | 2024-07-19 13:50:04 +0100 | [diff] [blame] | 139 | getDockerVersion apex-pdp |
| 140 | export POLICY_APEX_PDP_VERSION="$docker_image_version" |
Taka Cho | 6d188af | 2021-01-11 16:48:33 -0500 | [diff] [blame] | 141 | |
adheli.tavares | daecbb9 | 2024-07-19 13:50:04 +0100 | [diff] [blame] | 142 | getDockerVersion drools-pdp |
| 143 | export POLICY_DROOLS_PDP_VERSION="$docker_image_version" |
Taka Cho | 6d188af | 2021-01-11 16:48:33 -0500 | [diff] [blame] | 144 | |
adheli.tavares | daecbb9 | 2024-07-19 13:50:04 +0100 | [diff] [blame] | 145 | getDockerVersion xacml-pdp |
| 146 | export POLICY_XACML_PDP_VERSION="$docker_image_version" |
Taka Cho | 6d188af | 2021-01-11 16:48:33 -0500 | [diff] [blame] | 147 | |
adheli.tavares | daecbb9 | 2024-07-19 13:50:04 +0100 | [diff] [blame] | 148 | getDockerVersion distribution |
| 149 | export POLICY_DISTRIBUTION_VERSION="$docker_image_version" |
Sirisha_Manchikanti | 4d0a1d7 | 2021-06-08 09:28:21 +0100 | [diff] [blame] | 150 | |
adheli.tavares | daecbb9 | 2024-07-19 13:50:04 +0100 | [diff] [blame] | 151 | getDockerVersion clamp |
| 152 | export POLICY_CLAMP_VERSION="$docker_image_version" |
| 153 | export POLICY_CLAMP_PPNT_VERSION=$POLICY_CLAMP_VERSION |
ktimoney | 88a991b | 2021-08-09 17:23:35 +0100 | [diff] [blame] | 154 | |
adheli.tavares | daecbb9 | 2024-07-19 13:50:04 +0100 | [diff] [blame] | 155 | getDockerVersion drools-applications |
| 156 | export POLICY_DROOLS_APPS_VERSION="$docker_image_version" |
| 157 | fi |