diff --git a/tests/scripts/load_test_data.py b/tests/scripts/load_test_data.py index e0840ac2..ccddbc78 100755 --- a/tests/scripts/load_test_data.py +++ b/tests/scripts/load_test_data.py @@ -60,8 +60,19 @@ def pull_modify_push_image(logger, registry, image_name, tag, cosign_password, metafile = '{}_{}_metadata.json'.format(image_name, tag) metafile = os.path.join(meta_dir_name, metafile) - cmd = [image_update_script_path, "-r", registry, "-i", image_name, "-t", tag, "-c", cosign_password, - "-f", metafile, "-m", multiarch, "-u", username, "-p", password, "--data-dir", data_dir] + cmd = [image_update_script_path, "-r", registry, "-i", image_name, "-t", tag, "-f", metafile] + + if data_dir: + cmd.extend(["--data-dir", data_dir]) + + if username: + cmd.extend(["-u", username, "-p", password]) + + if cosign_password: + cmd.extend(["-c", cosign_password]) + + if multiarch: + cmd.extend(["-m", multiarch]) if debug: cmd.append("-d") diff --git a/tests/scripts/pull_update_push_image.sh b/tests/scripts/pull_update_push_image.sh index 021e4e62..2f3122c0 100755 --- a/tests/scripts/pull_update_push_image.sh +++ b/tests/scripts/pull_update_push_image.sh @@ -11,27 +11,91 @@ username="" debug=0 data_dir=$(pwd) -options=$(getopt -o dr:i:t:u:p:c:m:f: -l debug,registry:,image:,tag:,username:,password:,cosign-password:,multiarch:,file:,data-dir: -- "$@") -if [ $? -ne 0 ]; then - usage $0 - exit 0 -fi - -eval set -- "$options" -while :; do - case "$1" in - -r|--registry) registry=$2; shift 2;; - -i|--image) image=$2; shift 2;; - -t|--tag) tag=$2; shift 2;; - -u|--username) username=$2; shift 2;; - -p|--password) username=$2; shift 2;; - -c|--cosign-password) cosign_password=$2; shift 2;; - -m|--multiarch) multiarch=$2; shift 2;; - -f|--file) metafile=$2; shift 2;; - --data-dir) data_dir=$2; shift 2;; - -d|--debug) debug=1; shift 1;; - --) shift 1; break;; - *) usage $0; exit 1;; +while (( "$#" )); do + case $1 in + -r|--registry) + if [ -z "$2" ]; then + echo "Option registry requires an argument" + exit 1 + fi + registry=$2; + shift 2 + ;; + -i|--image) + if [ -z "$2" ]; then + echo "Option image requires an argument" + exit 1 + fi + image=$2 + shift 2 + ;; + -t|--tag) + if [ -z "$2" ]; then + echo "Option tag requires an argument" + exit 1 + fi + tag=$2 + shift 2 + ;; + -u|--username) + if [ -z "$2" ]; then + echo "Option username requires an argument" + exit 1 + fi + username=$2 + shift 2 + ;; + -p|--password) + if [ -z "$2" ]; then + echo "Option password requires an argument" + exit 1 + fi + password=$2 + shift 2 + ;; + -c|--cosign-password) + if [ -z "$2" ]; then + echo "Option cosign-password requires an argument" + exit 1 + fi + cosign_password=$2 + shift 2 + ;; + -m|--multiarch) + if [ -z "$2" ]; then + echo "Option multiarch requires an argument" + exit 1 + fi + multiarch=$2 + shift 2 + ;; + -f|--file) + if [ -z "$2" ]; then + echo "Option metafile requires an argument" + exit 1 + fi + metafile=$2 + shift 2 + ;; + --data-dir) + if [ -z "$2" ]; then + echo "Option data-dir requires an argument" + exit 1 + fi + data_dir=$2 + shift 2 + ;; + -d|--debug) + debug=1 + shift 1 + ;; + --) + shift 1 + break + ;; + *) + break + ;; esac done @@ -90,8 +154,8 @@ license="$(cat ${docker_docs_dir}/${image}/license.md)" vendor="$(cat ${docker_docs_dir}/${image}/maintainer.md)" logo=$(base64 -w 0 ${docker_docs_dir}/${image}/logo.png) echo ${repo} -sed -i "s|%%GITHUB-REPO%%|${repo}|g" ${docker_docs_dir}/${image}/maintainer.md -sed -i "s|%%IMAGE%%|${image}|g" ${docker_docs_dir}/${image}/content.md +sed -i.bak "s|%%GITHUB-REPO%%|${repo}|g" ${docker_docs_dir}/${image}/maintainer.md; rm ${docker_docs_dir}/${image}/maintainer.md.bak +sed -i.bak "s|%%IMAGE%%|${image}|g" ${docker_docs_dir}/${image}/content.md; rm ${docker_docs_dir}/${image}/content.md.bak doc=$(cat ${docker_docs_dir}/${image}/content.md) local_image_ref_skopeo=oci:${images_dir}:${image}-${tag}