X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=blobdiff_plain;f=shell%2Fopenstack-protect-in-use-images.sh;h=08727f61cd0eb8ad62a272894afd180a2f0ef34f;hb=2a10c83b2d506008cc6c01c134515fb6328e1f3a;hp=fe0bc0f193a3d63629696721b7f38be9acd22756;hpb=399343540de75a62321e715057798a19d8054abf;p=releng%2Fglobal-jjb.git diff --git a/shell/openstack-protect-in-use-images.sh b/shell/openstack-protect-in-use-images.sh index fe0bc0f1..08727f61 100644 --- a/shell/openstack-protect-in-use-images.sh +++ b/shell/openstack-protect-in-use-images.sh @@ -21,18 +21,17 @@ os_cloud="${OS_CLOUD:-vex}" set -eu -o pipefail -declare -a images -images+=("$(grep -r IMAGE_NAME --include \*.cfg jenkins-config \ - | awk -F'=' '{print $2}' | sort -u)") -set +o pipefail # Not all projects have images in YAML files and grep returns non-zero on 0 results -# Ignore SC2179 since we do not want () to result in an empty array item. -#shellcheck disable=SC2179 -images+="$(grep -r 'ZZCI - ' --include \*.yaml jjb \ - | awk -F": " '{print $3}' | sed "s:'::;s:'$::;/^$/d" | sort -u)" -set -o pipefail -readarray -t images <<< "$(for i in "${images[@]}"; do echo "$i"; done | sort)" +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"