fix(wfctl): imageRefForContainer resolves registry name to path#422
Merged
fix(wfctl): imageRefForContainer resolves registry name to path#422
Conversation
imageRefForContainer was using ctr.PushTo[0] (the registry name, e.g. "docr") as the image ref prefix. This caused images to be tagged as "docr/buymywishlist:sha" but pushed to "registry.digitalocean.com/bmw-registry/buymywishlist:sha", resulting in push failures because the local tag didn't match the push target. Fix mirrors buildExternalImageRef: scan ci.registries[] to resolve the name to its path, falling back to the raw name for backward compat. Also threads registries through buildWithDockerfile.
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes wfctl build image Dockerfile builds to tag images using the configured registry path (from ci.registries[].path) when containers[].push_to references a registry name, matching the behavior already used for external image refs and preventing failed pushes due to mismatched local tags.
Changes:
- Thread
cfg.CI.Registriesinto Dockerfile builds and updateimageRefForContainerto resolvepush_toentries viaci.registries. - Add unit tests covering registry name→path resolution and fallback behaviors.
- Add an integration-ish dry-run test asserting output uses the resolved registry path.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
cmd/wfctl/build_image.go |
Passes CI registries into Dockerfile builds and resolves registry names to registry paths when constructing image refs. |
cmd/wfctl/build_image_test.go |
Adds targeted tests for image ref construction and a dry-run assertion verifying resolved registry paths appear in output. |
Comment on lines
+241
to
+245
| func imageRefForContainer(ctr config.CIContainerTarget, tag string, registries []config.CIRegistry) string { | ||
| for _, regName := range ctr.PushTo { | ||
| for _, reg := range registries { | ||
| if reg.Name == regName { | ||
| return reg.Path + "/" + ctr.Name + ":" + tag |
Comment on lines
+241
to
+246
| func imageRefForContainer(ctr config.CIContainerTarget, tag string, registries []config.CIRegistry) string { | ||
| for _, regName := range ctr.PushTo { | ||
| for _, reg := range registries { | ||
| if reg.Name == regName { | ||
| return reg.Path + "/" + ctr.Name + ":" + tag | ||
| } |
⏱ Benchmark Results✅ No significant performance regressions detected. benchstat comparison (baseline → PR)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
imageRefForContainerincmd/wfctl/build_image.gowas usingctr.PushTo[0](the registry name, e.g.docr) as the image ref prefix. This produced tags likedocr/buymywishlist:sha, while the actual push target resolved toregistry.digitalocean.com/bmw-registry/buymywishlist:sha. Docker push failed because the local image didn't exist under the push target name.The symptom in BMW: images were built, retag + manual push was needed on every deploy.
Fix
imageRefForContainersignature to acceptregistries []config.CIRegistrybuildExternalImageRef: scanci.registries[]for aNamematch, usePath, fall back to raw name for backward compatcfg.CI.RegistriesthroughbuildWithDockerfileto the new signatureTest plan
TestImageRefForContainer_RegistryNameResolvesToPath— name match → uses pathTestImageRefForContainer_NoMatchFallback— no match → falls back to raw nameTestImageRefForContainer_EmptyPushTo— no push_to → returnsname:tagTestImageRefForContainer_MultiplePushTo— multiple push_to → first resolvable path usedTestRunBuildImage_ImageRefUsesRegistryPath— integration: dry-run output shows registry path, not registry nameGOWORK=off go test ./cmd/wfctl/...🤖 Generated with Claude Code