Skip to content

fix: keep the repository path when an image digest replaces the tag - #7069

Open
ItsDeadlyProgrammer wants to merge 1 commit into
devtron-labs:mainfrom
ItsDeadlyProgrammer:fix/image-digest-registry-port
Open

ItsDeadlyProgrammer wants to merge 1 commit into
devtron-labs:mainfrom
ItsDeadlyProgrammer:fix/image-digest-registry-port

Conversation

@ItsDeadlyProgrammer

Copy link
Copy Markdown

Description

When an image digest policy applies to a pre/post-CD stage, ReplaceImageTagWithDigest built the image reference with strings.Split(image, ":")[0]. A registry host with a port made that cut the reference at the port colon, so registry.local:5000/team/app:v1 became registry.local@sha256:... and the repository path was lost.

The function now looks for the tag or the digest only in the last path segment of the image. The new TestReplaceImageTagWithDigest covers a tag, a repository path, a registry, a registry with a port (with and without a tag), and an image that already carries a digest. The four registry-with-port cases fail on the old code and pass now.

Fixes #7068

How Has This Been Tested?

  • go test ./pkg/deployment/trigger/devtronApps/ -run TestReplaceImageTagWithDigest

Checklist:

  • The title of the PR states what changed and the related issues number (used for the release note).
  • I have performed a self-review of my own code.
  • I have added all the required unit/api test cases.

Does this PR introduce a user-facing change?

Image digest policy no longer drops the repository path of an image on a registry with a port.

ReplaceImageTagWithDigest cut the image at its first colon, so a registry with a port lost its repository path: registry.local:5000/team/app:v1 became registry.local@sha256:.... Look for the tag or digest only in the last path segment.

Signed-off-by: ItsDeadlyProgrammer <hvsr29march2004@gmail.com>
@bito-code-review

Copy link
Copy Markdown

Bito Review Skipped - Source Branch Not Found

Bito didn't review this change because the pull request is no longer valid. It may have been merged, or the source/target branch may no longer exist.

@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
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.

Bug: image digest policy builds a wrong image reference for registries with a port

1 participant