Skip to content

Fix container image parsing for images with registry port or digest - #7513

Open
neo0007777 wants to merge 2 commits into
pipe-cd:masterfrom
neo0007777:fix-k8s-parse-container-image
Open

neo0007777 wants to merge 2 commits into
pipe-cd:masterfrom
neo0007777:fix-k8s-parse-container-image

Conversation

@neo0007777

Copy link
Copy Markdown

What this PR does:

Fixes parseContainerImage in both pipedv1/plugin/kubernetes and pipedv1/plugin/kubernetes_multicluster to properly parse container images containing registry port numbers (e.g. localhost:5000/app:v1.0.0, kind-registry:5000/app:latest) and digests (e.g. app@sha256:...).

This ports the parser logic already implemented in the ECS plugin (pkg/app/pipedv1/plugin/ecs/deployment/determine.go) and adds comprehensive test cases covering ports in registry domains and digests.

Why we need it:

Previously, parseContainerImage split the image string by : first before extracting the path segments. This caused:

  1. Images from registries with port numbers (e.g., localhost:5000/my-app:1.0) to have their tags discarded (len(parts) == 3), while setting img.name incorrectly to "localhost".
  2. Images from registries with port numbers and no tag (localhost:5000/my-app) to parse name: "localhost" and tag: "5000/my-app".
  3. Images with digests (app@sha256:...) to corrupt the name with @sha256 and drop the digest scheme.
  4. False positives in determineStrategy where different applications hosted on the same registry port matched on beforeImg.name == afterImg.name ("localhost" == "localhost").

Which issue(s) this PR fixes:

Fixes #7511

Does this PR introduce a user-facing change?:

  • How are users affected by this change: Kubernetes deployments referencing container images with registry ports or digests will now accurately display artifact versions and correctly calculate sync strategies.
  • Is this breaking change: No
  • How to migrate (if breaking change): N/A

Screenshots/Videos (for documentation or website changes):
N/A

Signed-off-by: Shiva Sharma <shivaumj@gmail.com>
@neo0007777
neo0007777 requested review from a team as code owners October 22, 2026 09:02
@neo0007777
neo0007777 requested review from Warashi, ffjlabo and mohammedfirdouss and a balanced review from Copilot October 22, 2026 09:02
@netlify

netlify Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for pipecd-site canceled.

Name Link
🔨 Latest commit 906c0be
🔍 Latest deploy log https://app.netlify.com/projects/pipecd-site/deploys/6ad9d4b9bc816a9dc51b8f41

@github-actions

Copy link
Copy Markdown
Contributor

👋 Hi @neo0007777, welcome to PipeCD and thanks for opening your first pull request!

We’re really happy to have you here

Before your PR gets merged, please check a few important things below.


Helpful resources


DCO Sign-off

All commits must include a Signed-off-by line to comply with the Developer Certificate of Origin (DCO).

In case you forget to sign-off your commit(s), follow these steps:

For the last commit:

git commit --amend --signoff
git push --force-with-lease

For multiple commits:

git rebase --signoff origin/master
git push --force-with-lease

Run checks locally

Before pushing updates, please run:

make check

This runs the same checks as CI and helps catch issues early.


💬 Need help?

If anything is unclear, feel free to ask in this PR or join us on the CNCF Slack in the #pipecd channel.
You can get your Slack invite from: https://communityinviter.com/apps/cloud-native/cncf

Thanks for contributing to PipeCD! ❤️

@neo0007777

Copy link
Copy Markdown
Author

Hello maintainers @pipe-cd/pipecd-approvers-plugins @armistcxy, could you please review this PR when you have a moment? It addresses #7511 by bringing the container image parsing in the Kubernetes and Kubernetes Multicluster plugins into alignment with the parser logic previously implemented for the ECS plugin in #6670, adding support for custom registry ports and digests. All unit tests are passing. Thank you!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Both parsers still include the tag in the image name for valid references containing both a tag and a digest.

2 open issues
What changed in this PR

Addresses #7511 by adapting the ECS image parser for PipeCD’s Kubernetes and Kubernetes Multicluster plugins, improving handling of registry ports and digests.

Changes:

  • Parses registry ports separately from image tags and preserves digests.
  • Uses digests as fallback versions in artifact records and deployment summaries.
  • Adds parser tests covering registry ports, digests, and nested paths.
File Description
pkg/​app/​pipedv1/​plugin/​kubernetes/​deployment/​determine.go Updates image parsing, artifact versions, and deployment summaries.
pkg/​app/​pipedv1/​plugin/​kubernetes/​deployment/​determine_test.go Adds registry-port and digest parsing cases.
pkg/​app/​pipedv1/​plugin/​kubernetes_multicluster/​deployment/​determine.go Applies equivalent parsing and version handling to multicluster deployments.
pkg/​app/​pipedv1/​plugin/​kubernetes_multicluster/​deployment/​determine_test.go Adds matching multicluster parser coverage.

Review effort: Balanced

Comment thread pkg/app/pipedv1/plugin/kubernetes/deployment/determine.go Outdated
Comment thread pkg/app/pipedv1/plugin/kubernetes_multicluster/deployment/determine.go Outdated
Signed-off-by: Shiva Sharma <shivaumj@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused changes consistently address the reported parsing defects and prior feedback, with regression coverage and no identified blocking issues.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: parseContainerImage in Kubernetes plugins fails on images with registry port or digest

2 participants