3 # Copyright © 2020 Samsung Electronics
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 BASE_URL="https://nexus3.onap.org/repository/docker.release"
19 if [ "$GERRIT_BRANCH" = "staging" ]; then
23 USED_IMAGES=$(grep -r -E -o -h ':\s*onap/.*:.*' | sed -e 's/^: //' -e 's/^ //' | sort | uniq)
24 REPO_IMAGES=$(curl -s $BASE_URL/v2/_catalog | jq -r '.repositories[]')
25 NOT_AVAILABLE_IMAGES=$(echo "$USED_IMAGES" | grep -vE "$(echo "$REPO_IMAGES" | tr "\n" "|" | sed 's/|$//')")
26 USED_IMAGES=$(echo "$USED_IMAGES" | grep -E "$(echo "$REPO_IMAGES" | tr "\n" "|" | sed 's/|$//')")
27 for i in $USED_IMAGES; do
28 TMP_IMG=$(echo "$i" | cut -d ":" -f1)
29 TMP_TAG=$(echo "$i" | cut -d ":" -f2)
30 if [ "$LAST_IMG" != "$TMP_IMG" ]; then
31 AVAILABLE_TAGS=$(curl -s $BASE_URL/v2/$TMP_IMG/tags/list | jq -r '.tags[]')
33 if ! echo "$AVAILABLE_TAGS" | grep "$TMP_TAG" > /dev/null; then
34 NOT_AVAILABLE_IMAGES="$NOT_AVAILABLE_IMAGES\n$i"
40 if [ -n "$NOT_AVAILABLE_IMAGES" ]; then
41 echo "[ERROR] Only release images are allowed in helm charts."
42 echo "[ERROR] Images not found in release repo:"
43 printf "%b$NOT_AVAILABLE_IMAGES\n"