Repository navigation
Fix Kptfile pipeline merge for function images from a registry with a port - #4889
bhavishyajain545 wants to merge 3 commits into
Conversation
… port The merge key of a function without a name is its image without the tag. It was taken as the text before the first colon, so every image from a registry with a port, such as registry.example.com:5000/krm/apply-setters:v0.2, got the key "registry.example.com". With two such functions the keys collided, no merge keys were used, and kpt pkg update replaced the local pipeline with the upstream one, dropping local changes. Strip the tag after the last colon that follows the last slash, and strip a digest. Signed-off-by: Bhavishya Jain <65864699+bhavishyajain545@users.noreply.github.com>
✅ Deploy Preview for kptdocs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the registry-port pipeline merge fix.
No open issues 🎉
What changed in this PR
This PR fixes pipeline merging during kpt pkg update for unnamed functions whose images come from registries with ports, preserving local configuration changes alongside upstream updates.
Changes:
- Adds a shared image merge-key helper that preserves registry ports while removing tags and digests.
- Uses the helper for duplicate detection and synthesized function names.
- Adds a merge regression test and table-driven tests for image formats.
| File | Description |
|---|---|
pkg/kptfile/kptfileutil/util.go |
Centralizes image merge-key generation and preserves registry ports. |
pkg/kptfile/kptfileutil/util_test.go |
Adds registry-port merge coverage and image merge-key tests; updates the copyright year range. |
Review effort: Balanced
|
The failing The root |
…-registry-port Signed-off-by: Bhavishya Jain <65864699+bhavishyajain545@users.noreply.github.com>
Signed-off-by: Bhavishya Jain <65864699+bhavishyajain545@users.noreply.github.com>
|
@bhavishyajain545 Thanks for the fix and your contribution. Could you please join our slack and one of the weekly community meetings to talk about your PR briefly? (See https://github.com/kptdev/kpt#contact on how to join) |
|
|
Thanks! I have requested an invite to the Kubernetes Slack and it is still pending; I will join #kpt as soon as it comes through, and I will join one of the weekly community meetings to talk about the PR. If the invite takes long, is there another way to reach you before the meeting? |



Description
When the functions in a Kptfile pipeline have no
name,MergeKptfiles(used bykpt pkg update) merges them by a synthesized key: the function image without its tag.shouldAddFnKeyUtilandaddNameinpkg/kptfile/kptfileutil/util.gotook that key as the text before the first colon:For an image from a registry with a port, such as
registry.example.com:5000/krm/apply-setters:v0.2, the key isregistry.example.com. Two functions from that registry get the same key,shouldAddFnKeyUtilsees a duplicate and returns false, and no merge keys are used at all.This PR adds
imageMergeKey, which strips the tag only when its colon comes after the last/, and also strips a digest. Results for images without a registry port are unchanged.Motivation
Without merge keys the local pipeline is replaced by the upstream one, so local changes are lost on
kpt pkg update. The newTestMergecase shows it: two functions fromregistry.example.com:5000, upstream adds a setter, local changestagto1.2.0. On main the result hastag: 1.0.1(the local change is gone); with this PR it has the upstream setter andtag: 1.2.0, the same as the existingghcr.iocase.Fixes
No linked issue. I searched the issues and PRs for this and found no report.
Tests
TestMergecasefunctions from a registry with a port are merged by image name(fails on main, passes with the fix).TestImageMergeKeytable test.go vet ./pkg/kptfile/kptfileutil/andgo test ./pkg/kptfile/...pass locally.Use of AI
I have used AI in the creation of this PR.
I have used the following AI tools: