2 ##############################################################################
4 # Copyright (c) 2019 AT&T Intellectual Property.
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
10 # http://www.apache.org/licenses/LICENSE-2.0
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.
18 ##############################################################################
20 # Installs well-known RIC charts then verifies specified helm chart
21 # Requires chart tgz archives in /tmp
24 while [ -n "$1" ]; do # while loop starts
33 -d) IMAGE_DIRECTORY_PATH=$2
38 *) echo "Option $1 not recognized. Please use -f to specify the recipe path." ;; # In case you typed a different option other than a,b,c
46 if [ -z $OVERRIDEYAML ]; then
47 echo "Deploy recipe is missing. Please use -f to specify the recipe path."
51 if [ -z $IMAGE_DIRECTORY_PATH ]; then
52 IMAGE_DIRECTORY_PATH=/tmp/ric_image
53 rm -rf $IMAGE_DIRECTORY_PATH
54 mkdir -p $IMAGE_DIRECTORY_PATH
58 ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
60 rm -rf $TEMP_DIR/imagelist
61 touch $TEMP_DIR/imagelist
63 while IFS= read -r -d $'\0'; do
64 CHART_ARRAY+=("$REPLY")
65 done < <(find $ROOT_DIR/../ -name Chart.yaml -printf '%h\0')
67 rm -fr $TEMP_DIR/ric-common*.tgz
69 helm package -d $TEMP_DIR $ROOT_DIR/../ric-common/Common-Template/helm/ric-common
70 echo "***************************************"
74 for dir in "${CHART_ARRAY[@]}"
79 echo "Analyzing Chart $(echo $dir | awk '{n=split($0, a, "/"); print a[n]}')"
82 cp $TEMP_DIR/ric-common*.tgz $dir/charts/
84 helm dep up $dir > /dev/null 2>&1
87 if [ -z $OVERRIDEYAML ]; then
88 IMAGE_ARRAY=$(helm template $dir | grep "image:" | awk '{ gsub(/.*image: /, "", $0); gsub(/"/, "", $0); print $0}')
90 IMAGE_ARRAY=$(helm template -f $OVERRIDEYAML $dir | grep "image:" | awk '{ gsub(/.*image: /, "", $0); gsub(/"/, "", $0); print $0}' )
93 for f in $IMAGE_ARRAY; do
95 FOUND=$(grep $f $TEMP_DIR/imagelist)
96 if [ -z $FOUND ]; then
97 echo "Found unique docker image $f."
98 echo $f >> $TEMP_DIR/imagelist
103 echo "***************************************"
107 while IFS= read -r image
109 IMAGENAME=$(echo $image | awk '{ n=split($0, a, "/"); print a[n] }')
111 echo "Pulling image $image"
112 RESULT=$(docker pull $image |& grep "no basic auth credentials" )
113 if [ ! -z "$RESULT" ]; then
114 echo "You are not logined to docker registry. Please login by running \"docker login DOCKER_REGISTRY\""
118 echo "Saving image $image"
119 docker save $image -o $IMAGE_DIRECTORY_PATH/$IMAGENAME
121 echo "************************************************************"
124 done < "$TEMP_DIR/imagelist"