Skip to content

Commit

Permalink
Added Support for additional ARGS
Browse files Browse the repository at this point in the history
  • Loading branch information
Aneesh-M-Bhat authored and openshift-merge-bot[bot] committed Nov 13, 2024
1 parent e398d7e commit 0246101
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ E2E_SC_PARAMS_SOURCE_IMAGE_URL ?= docker://docker.io/library/busybox:latest
E2E_SC_IMAGE_TAG ?= busybox:latest
# end-to-end test fully qualified destination image name
E2E_SC_PARAMS_DESTINATION_IMAGE_URL ?= docker://$(IMAGE_BASE)/${E2E_SC_IMAGE_TAG}
# --all argument for skopeo copy command
E2E_SC_PARAMS_ARGS ?= --all

# setting tls-verify as false disables the HTTPS client as well, something we need for e2e testing
# using the internal container registry (HTTP based)
Expand Down
1 change: 1 addition & 0 deletions scripts/skopeo-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ declare -rx PARAMS_DESTINATION_IMAGE_URL="${PARAMS_DESTINATION_IMAGE_URL:-}"
declare -rx PARAMS_SRC_TLS_VERIFY="${PARAMS_SRC_TLS_VERIFY:-}"
declare -rx PARAMS_DEST_TLS_VERIFY="${PARAMS_DEST_TLS_VERIFY:-}"
declare -rx PARAMS_VERBOSE="${PARAMS_VERBOSE:-}"
declare -rx PARAMS_ARGS="${PARAMS_ARGS:-}"

declare -rx WORKSPACES_IMAGES_URL_PATH="${WORKSPACES_IMAGES_URL_PATH:-}"
declare -rx WORKSPACES_IMAGES_URL_BOUND="${WORKSPACES_IMAGES_URL_BOUND:-}"
Expand Down
3 changes: 2 additions & 1 deletion scripts/skopeo-copy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ if [ -n "${PARAMS_SOURCE_IMAGE_URL}" ] && [ -n "${PARAMS_DESTINATION_IMAGE_URL}"
skopeo copy ${SKOPEO_DEBUG_FLAG} \
--src-tls-verify="${PARAMS_SRC_TLS_VERIFY}" \
--dest-tls-verify="${PARAMS_DEST_TLS_VERIFY}" \
${PARAMS_ARGS:+${PARAMS_ARGS}} \
"${PARAMS_SOURCE_IMAGE_URL}" \
"${PARAMS_DESTINATION_IMAGE_URL}"
elif [ "${WORKSPACES_IMAGES_URL_BOUND}" == "true" ]; then
Expand All @@ -27,7 +28,7 @@ elif [ "${WORKSPACES_IMAGES_URL_BOUND}" == "true" ]; then
while IFS= read -r line || [ -n "$line" ]
do
read -ra SOURCE <<<"${line}"
skopeo copy "${SOURCE[@]}" ${SKOPEO_DEBUG_FLAG} --src-tls-verify="${PARAMS_SRC_TLS_VERIFY}" --dest-tls-verify="${PARAMS_DEST_TLS_VERIFY}"
skopeo copy "${SOURCE[@]}" ${SKOPEO_DEBUG_FLAG} --src-tls-verify="${PARAMS_SRC_TLS_VERIFY}" --dest-tls-verify="${PARAMS_DEST_TLS_VERIFY}" ${PARAMS_ARGS:+${PARAMS_ARGS}}
echo "$line"
done < "$filename"
}
Expand Down
6 changes: 6 additions & 0 deletions templates/task-skopeo-copy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ spec:
default: "false"
description: |
Shows a more verbose (debug) output.
- name: ARGS
default: ""
type: string
description: |
Additional args for skopeo copy command
results:
- name: SOURCE_DIGEST
Expand All @@ -73,6 +78,7 @@ spec:
"params.SRC_TLS_VERIFY"
"params.DEST_TLS_VERIFY"
"params.VERBOSE"
"params.ARGS"
"workspaces.images_url.bound"
"workspaces.images_url.path"
"results.SOURCE_DIGEST.path"
Expand Down
72 changes: 72 additions & 0 deletions test/e2e/e2e-skopeo-copy.bats
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ declare -rx E2E_SC_PARAMS_DESTINATION_IMAGE_URL="${E2E_SC_PARAMS_DESTINATION_IMA
--param="DEST_TLS_VERIFY=${E2E_PARAMS_DEST_TLS_VERIFY}" \
--param="VERBOSE=true" \
--workspace name=images_url,volumeClaimTemplateFile=./test/e2e/resources/workspace-template.yaml \
--use-param-defaults \
--showlog
assert_success

Expand Down Expand Up @@ -62,6 +63,7 @@ declare -rx E2E_SC_PARAMS_DESTINATION_IMAGE_URL="${E2E_SC_PARAMS_DESTINATION_IMA
--param="DEST_TLS_VERIFY=${E2E_PARAMS_DEST_TLS_VERIFY}" \
--param="VERBOSE=false" \
--workspace name=images_url,volumeClaimTemplateFile=./test/e2e/resources/workspace-template.yaml \
--use-param-defaults \
--showlog
assert_success

Expand Down Expand Up @@ -119,3 +121,73 @@ declare -rx E2E_SC_PARAMS_DESTINATION_IMAGE_URL="${E2E_SC_PARAMS_DESTINATION_IMA
# asserting the latest taskrun instacne to inspect the resources against a regular expression
assert_tekton_resource "taskrun" --regexp $'\S+\n?DESTINATION_DIGEST=\S+\nSOURCE_DIGEST=\S+'
}

# Testing the skopeo-copy task, args = "--all"
@test "[e2e] skopeo-copy task copying a image from source to destination registry with args set to '--all' " {
# asserting all required configuration is informed
[ -n "${E2E_SC_PARAMS_SOURCE_IMAGE_URL}" ]
[ -n "${E2E_SC_PARAMS_DESTINATION_IMAGE_URL}" ]
[ -n "${E2E_PARAMS_SRC_TLS_VERIFY}" ]
[ -n "${E2E_PARAMS_DEST_TLS_VERIFY}" ]

# cleaning up all the existing resources before starting a new taskrun, the test assertion
# will describe the objects on the current namespace
run kubectl delete taskrun --all
assert_success

#
# E2E TaskRun
#

run tkn task start skopeo-copy \
--param="SOURCE_IMAGE_URL=${E2E_SC_PARAMS_SOURCE_IMAGE_URL}" \
--param="DESTINATION_IMAGE_URL=${E2E_SC_PARAMS_DESTINATION_IMAGE_URL}" \
--param="SRC_TLS_VERIFY=${E2E_PARAMS_SRC_TLS_VERIFY}" \
--param="DEST_TLS_VERIFY=${E2E_PARAMS_DEST_TLS_VERIFY}" \
--param="VERBOSE=true" \
--param="ARGS=${E2E_SC_PARAMS_ARGS}" \
--workspace name=images_url,volumeClaimTemplateFile=./test/e2e/resources/workspace-template.yaml \
--use-param-defaults \
--showlog
assert_success

# asserting the taskrun status, making sure all steps have been successful
assert_tekton_resource "taskrun" --partial 'All Steps have completed executing'
# asserting the latest taskrun instance to inspect the resources against a regular expression
assert_tekton_resource "taskrun" --regexp $'\S+\n?DESTINATION_DIGEST=\S+\nSOURCE_DIGEST=\S+'
}

# Testing the skopeo-copy task, args = "--all --preserve-digests"
@test "[e2e] skopeo-copy task copying a image from source to destination registry with args set to '--all --preserve-digests'" {
# asserting all required configuration is informed
[ -n "${E2E_SC_PARAMS_SOURCE_IMAGE_URL}" ]
[ -n "${E2E_SC_PARAMS_DESTINATION_IMAGE_URL}" ]
[ -n "${E2E_PARAMS_SRC_TLS_VERIFY}" ]
[ -n "${E2E_PARAMS_DEST_TLS_VERIFY}" ]

# cleaning up all the existing resources before starting a new taskrun, the test assertion
# will describe the objects on the current namespace
run kubectl delete taskrun --all
assert_success

#
# E2E TaskRun
#

run tkn task start skopeo-copy \
--param="SOURCE_IMAGE_URL=${E2E_SC_PARAMS_SOURCE_IMAGE_URL}" \
--param="DESTINATION_IMAGE_URL=${E2E_SC_PARAMS_DESTINATION_IMAGE_URL}" \
--param="SRC_TLS_VERIFY=${E2E_PARAMS_SRC_TLS_VERIFY}" \
--param="DEST_TLS_VERIFY=${E2E_PARAMS_DEST_TLS_VERIFY}" \
--param="VERBOSE=true" \
--param="ARGS=--all --preserve-digests" \
--workspace name=images_url,volumeClaimTemplateFile=./test/e2e/resources/workspace-template.yaml \
--use-param-defaults \
--showlog
assert_success

# asserting the taskrun status, making sure all steps have been successful
assert_tekton_resource "taskrun" --partial 'All Steps have completed executing'
# asserting the latest taskrun instance to inspect the resources against a regular expression
assert_tekton_resource "taskrun" --regexp $'\S+\n?DESTINATION_DIGEST=\S+\nSOURCE_DIGEST=\S+'
}

0 comments on commit 0246101

Please sign in to comment.