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