#!/bin/sh #function to provide help #desc: this function provide help menu #argument: -h for help, -p for path, -r for repository #calling syntax: options options() { cat < parse_yaml () { local prefix prefix=$2 local s s='[[:space:]]*' local w w='[a-zA-Z0-9_]*' local fs fs=$(echo @|tr @ '\034') sed -ne "s|^\($s\):|\1|" \ -e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \ -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 | awk -F$fs '{ indent = length($1)/2; vname[indent] = $2; for (i in vname) {if (i > indent) {delete vname[i]}} if (length($3) > 0) { vn=""; for (i=0; i/dev/null; then #find all image subtag inside converted values.yaml file's lines if echo $line | grep -q $IMAGE_TEXT ; then #find imageName inside line imageName=`echo $line | awk -F "=" '{print $2}'` #remove attional prefix and postfix imageNameFinal=`echo "$imageName" | sed -e 's/^"//' -e 's/"$//' ` #check if line contain Version as a subtag in lines if yes then call docker pull with version if echo $line | grep -q $IMAGE_VERSION_TEXT ; then echo docker pull "$imageNameWithVersion":"$imageNameFinal" docker pull $imageNameWithVersion:$imageNameFinal & imageNameWithVersion=" " else #check Version is not in subtag and old scanned value is present then call docker pull without version if [ "$imageNameWithVersion" != " " ]; then echo docker pull "$imageNameWithVersion" docker pull $imageNameWithVersion & imageNameWithVersion=$imageNameFinal else imageNameWithVersion=$imageNameFinal fi fi fi fi done done # complete processing echo "finished launching pulls" #MAX_WAIT_INTERVALS=300 INTERVAL_COUNT=300 while [ $(ps -ef | grep docker | grep pull | grep -v $0 | wc -l) -gt 0 ]; do sleep 10 INTERVAL_COUNT=$((INTERVAL_COUNT - 1)) echo "waiting for last pull" if [ "$INTERVAL_COUNT" -eq 0 ]; then break fi done