Skip to content

fix(containertool): reject image digests in destination --repository - #192

Open
utkarshpatwa393-sys wants to merge 1 commit into
apple:mainfrom
utkarshpatwa393-sys:fix/reject-destination-digest
Open

utkarshpatwa393-sys wants to merge 1 commit into
apple:mainfrom
utkarshpatwa393-sys:fix/reject-destination-digest

Conversation

@utkarshpatwa393-sys

Copy link
Copy Markdown

Motivation

Addresses #130.

containertool parses both --from and --repository using ImageReference. While a base image reference can validly specify a digest (@sha256:...), pushing an image to a destination reference containing a digest is invalid — destinations only support an optional tag.

Modifications

  • Add ContainerTool.parseDestinationImage(_:defaultRegistry:) to validate that the parsed destination ImageReference does not use an ImageReference.Digest, throwing a ValidationError if a digest is specified.
  • Update ContainerTool.run() to parse destinationImage via parseDestinationImage.
  • Add unit tests in Tests/containertoolTests/RepositoryOptionsTests.swift covering tagged, untagged, and digest-qualified destination references.

Result

Passing a digest in --repository (or CONTAINERTOOL_REPOSITORY / containertool.json) now fails immediately with a clear validation error while preserving digest support for --from.

Test Plan

  • swift format lint --recursive Sources Tests passed.
  • swift test --no-parallel --filter RepositoryOptionsTests --filter ReferenceTests --filter DigestTests --filter AuthTests --filter ElfDetectUnitTests --filter ZlibTests --filter TarUnitTests passed (44 tests in 7 suites).

Source --from image references may specify either a tag or a digest, whereas the destination --repository reference can only be pushed to a tag. Validate destinationImage after parsing and fail cleanly with a ValidationError when a digest is provided.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant