Skip to content

fix: sanitize colon in container name for tag+digest package refs#313

Merged
jcogilvie merged 1 commit into
crossplane-contrib:mainfrom
cahillsf:stephen.cahill/fix-container-name-tag-digest
May 5, 2026
Merged

fix: sanitize colon in container name for tag+digest package refs#313
jcogilvie merged 1 commit into
crossplane-contrib:mainfrom
cahillsf:stephen.cahill/fix-container-name-tag-digest

Conversation

@cahillsf
Copy link
Copy Markdown
Contributor

@cahillsf cahillsf commented May 5, 2026

Description of your changes

When a function package ref contains both a tag and a digest (e.g. registry.io/path/function-auto-ready:v0.6.1-0@sha256:751a4afb...), the tag's colon was leaking into the generated Docker container name, producing names like function-auto-ready:v0.6.1-0-751a4afb65f1-comp-test1234. Docker rejects colons in container names.

This sanitizes the function-name portion (before @sha256:) by replacing : with - so the resulting container name is valid for refs that carry both a tag and a digest.

Fixes #

I have:

  • Read and followed Crossplane's contribution process.
  • Run earthly -P +reviewable to ensure this PR is ready for review.
  • Added or updated unit tests.
  • Added or updated e2e tests.
  • Documented this change as needed.
  • Followed the API promotion workflow if this PR introduces, removes, or promotes an API.

Need help with this checklist? See the cheat sheet.

@cahillsf cahillsf force-pushed the stephen.cahill/fix-container-name-tag-digest branch from 39d745b to 0efc56b Compare May 5, 2026 14:47
@cahillsf cahillsf marked this pull request as ready for review May 5, 2026 15:16
Copilot AI review requested due to automatic review settings May 5, 2026 15:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes invalid Docker container names generated for function package references that include both a tag and a SHA256 digest (e.g. name:tag@sha256:...) by sanitizing the tag separator (:) into a hyphen in the digest-handling code path.

Changes:

  • Replace : with - in the name:tag portion when building container names for @sha256: references.
  • Add a unit test covering tag+digest package refs to prevent regressions.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
cmd/diff/diffprocessor/function_provider.go Sanitizes name:tag to name-tag when generating container names for @sha256: package refs.
cmd/diff/diffprocessor/function_provider_test.go Adds coverage for tag+digest refs ensuring generated container names contain no : and match the expected format.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jcogilvie
Copy link
Copy Markdown
Collaborator

Thanks again @cahillsf! Can you do a quick rebase so I can merge? (DCO checker doesn't like it if I do that for you.)

…st package refs

When a function package ref has both a tag and a digest
(e.g., func:v0.6.1-0@sha256:751a...), the SHA256 branch of
generateContainerName split on @sha256: but left the colon from the
tag in the function name, producing an invalid Docker container name.

Signed-off-by: Stephen Cahill <cahillsf9@gmail.com>
@cahillsf cahillsf force-pushed the stephen.cahill/fix-container-name-tag-digest branch from 0efc56b to cc93bda Compare May 5, 2026 17:04
@jcogilvie jcogilvie enabled auto-merge (squash) May 5, 2026 17:13
@jcogilvie jcogilvie merged commit f6e115a into crossplane-contrib:main May 5, 2026
12 checks passed
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.

3 participants