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
28 -d) DOCKER_REGISTRY=$2
32 -p) IMAGE_DIRECTORY_PATH=$2
36 *) echo "Option $1 not recognized. Please specify the docker registry path with the -d option and specify the directory path of the images with the -p option."
37 ;; # In case you typed a different option other than -d or -p
45 if [ -z $DOCKER_REGISTRY ]; then
46 echo "Please specify the docker registry path with the -d option."
50 if [ -z $IMAGE_DIRECTORY_PATH ]; then
51 echo "Please specify the directory path of the images with the -p option."
58 for image in $IMAGE_DIRECTORY_PATH/*; do
59 OUTPUT=$(docker load -i $image)
60 IMAGE_PATH_ORIGINAL=$(echo $OUTPUT | grep image: | awk '{print $3}' )
61 IMAGENAME=$(echo $IMAGE_PATH_ORIGINAL | awk '{ n=split($0, a, "/"); print a[n] }')
62 echo "************************************************************"
63 echo "Loading image $IMAGENAME"
64 docker tag $IMAGE_PATH_ORIGINAL $DOCKER_REGISTRY/$IMAGENAME
65 RESULT=$(docker push $DOCKER_REGISTRY/$IMAGENAME 2>&1)
66 LOGIN_ERROR=$(echo $RESULT |& grep "no basic auth credentials" )
67 if [ ! -z "$LOGIN_ERROR" ]; then
68 echo "You are not logined to $DOCKER_REGISTRY. Please login by running \"docker login $DOCKER_REGISTRY\""
71 ACCESS_ERROR=$(echo $RESULT |& grep "denied: requested access to the resource is denied" )
72 if [ ! -z "$ACCESS_ERROR" ]; then
73 echo "Failed to push image to docker registry: <$DOCKER_REGISTRY>. Please check if it is a typo."