diff --git a/task/oci-copy/0.1/oci-copy.yaml b/task/oci-copy/0.1/oci-copy.yaml index ab21991de3..2390406173 100644 --- a/task/oci-copy/0.1/oci-copy.yaml +++ b/task/oci-copy/0.1/oci-copy.yaml @@ -99,36 +99,75 @@ spec: set -u + echo "Selecting auth for $IMAGE" + select-oci-auth $IMAGE > auth.json + + echo "Extracting artifact_type" + ARTIFACT_TYPE=$(cat "$(pwd)/source/$OCI_COPY_FILE" | yq '.artifact_type') + + REPO=$(echo ${IMAGE} | awk -F ':' '{print $1}') + echo "Found that ${REPO} is the repository for ${IMAGE}" + + cat >artifact-manifest.json < descriptor.json - echo "Selecting auth for $IMAGE" - select-oci-auth $IMAGE > auth.json + echo "Setting mediaType to ${OCI_ARTIFACT_TYPE}" + yq -oj -i '.mediaType = "'${OCI_ARTIFACT_TYPE}'"' descriptor.json + + echo "Inserting org.opencontainers.image.title = ${OCI_FILENAME} annotation" + yq -oj -i '.annotations."org.opencontainers.image.title" = "'${OCI_FILENAME}'"' descriptor.json + + echo "Appending blob descriptor for ${OCI_FILENAME} to the overall artifact manifest for ${IMAGE}" + yq -oj -i ".layers += $(cat descriptor.json)" artifact-manifest.json + + echo "Done with ${OCI_FILENAME}." + done - echo "Pushing contents to ${IMAGE}" - oras push --no-tty --registry-config auth.json --artifact-type ${ARTIFACT_TYPE} "${IMAGE}" "${args[@]}" + echo "Pushing complete artifact manifest to ${IMAGE}" + oras manifest push --no-tty --registry-config auth.json "${IMAGE}" artifact-manifest.json - IMAGE_INDEX_DIGEST=$(oras resolve --registry-config auth.json "${IMAGE}") - echo -n "$IMAGE_INDEX_DIGEST" | tee "$(results.IMAGE_DIGEST.path)" + RESULTING_DIGEST=$(oras resolve --registry-config auth.json "${IMAGE}") + echo -n "$RESULTING_DIGEST" | tee "$(results.IMAGE_DIGEST.path)" echo -n "$IMAGE" | tee "$(results.IMAGE_URL.path)" volumeMounts: - mountPath: /var/lib/containers