X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=blobdiff_plain;f=shell%2Fopenstack-protect-in-use-images.sh;h=08727f61cd0eb8ad62a272894afd180a2f0ef34f;hb=b55451a53da28d40c62de5cae462302a32fe4c31;hp=4d9a2cc8badde81acab57ca7f7565b8b28685d69;hpb=0913c6350d626ce69174a05657988f753e6ea5ad;p=releng%2Fglobal-jjb.git diff --git a/shell/openstack-protect-in-use-images.sh b/shell/openstack-protect-in-use-images.sh index 4d9a2cc8..08727f61 100644 --- a/shell/openstack-protect-in-use-images.sh +++ b/shell/openstack-protect-in-use-images.sh @@ -21,17 +21,17 @@ os_cloud="${OS_CLOUD:-vex}" set -eu -o pipefail -declare -a images -declare -a cfg_images -declare -a yaml_images -readarray -t cfg_images <<< "$(grep -r IMAGE_NAME --include \*.cfg jenkins-config \ - | awk -F'=' '{print $2}' | sort -u)" -readarray -t yaml_images <<< "$(grep -r 'ZZCI - ' --include \*.yaml jjb \ - | awk -F": " '{print $3}' | sed "s:'::;s:'$::;/^$/d" | sort -u)" -mapfile -t images < <(for R in "${cfg_images[@]}" "${yaml_images[@]}" ; do echo "$R" ; done | sort -u) - +conf_images=("$(grep -r IMAGE_NAME --include \*.cfg jenkins-config \ + | awk -F'=' '{print $2}' | sort -u)") +# If there are no yaml files the 'grep' will fail, which is OK +yaml_images=("$(grep -r 'ZZCI - ' --include \*.yaml jjb \ + | awk -F": " '{print $3}' | sed "s:'::;s:'$::;/^$/d" \ + | sort -u)") || true +readarray -t images <<< "$(for i in "${conf_images[@]}" "${yaml_images[@]}"; do \ + echo "$i"; done | sort)" for image in "${images[@]}"; do + [[ -z $image ]] && continue os_image_protected=$(openstack --os-cloud "$os_cloud" \ image show "$image" -f value -c protected) echo "Protected setting for $image: $os_image_protected"