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
31 *) 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
39 if [ -z $OVERRIDEYAML ]; then
40 echo "Deploy recipe is missing. Please use -f to specify the recipe path."
45 ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
48 # Start Helm local repo if there isn't one
49 HELM_REPO_PID=$(ps -x | grep "helm serve" | grep -v "grep" | awk '{print $1}')
50 if [ -z "$HELM_REPO_PID" ]; then
51 nohup helm serve >& /dev/null &
54 # Package ric-common and serve it using Helm local repo
55 HELM_HOME=$(helm home)
56 COMMON_CHART_VERSION=$(cat $ROOT_DIR/../ric-common/Common-Template/helm/ric-common/Chart.yaml | grep version | awk '{print $2}')
57 helm package -d /tmp $ROOT_DIR/../ric-common/Common-Template/helm/ric-common
58 cp /tmp/ric-common-$COMMON_CHART_VERSION.tgz $HELM_HOME/repository/local/
59 helm repo index $HELM_HOME/repository/local/
62 # Make sure that helm local repo is added
63 helm repo remove local
64 helm repo add local http://127.0.0.1:8879/charts
70 rm -rf $TEMP_DIR/imagelist
71 touch $TEMP_DIR/imagelist
73 while IFS= read -r -d $'\0'; do
74 CHART_ARRAY+=("$REPLY")
75 done < <(find $ROOT_DIR/../ -name Chart.yaml -printf '%h\0')
78 echo "***************************************"
82 for dir in "${CHART_ARRAY[@]}"
85 echo "Analyzing Chart $(echo $dir | awk '{n=split($0, a, "/"); print a[n]}')"
88 #helm dep up $dir > /dev/null 2>&1
91 IMAGE_ARRAY=$(helm template -f $OVERRIDEYAML $dir | grep "image:" | awk '{ gsub(/.*image: /, "", $0); gsub(/"/, "", $0); print $0}' )
94 for f in $IMAGE_ARRAY; do
96 FOUND=$(grep $f $TEMP_DIR/imagelist)
97 if [ -z $FOUND ]; then
98 echo "Found unique docker image $f."
99 echo $f >> $TEMP_DIR/imagelist
104 echo "***************************************"
109 echo "Your image list is available here: $TEMP_DIR/imagelist"