detached 5418cc6

fix(cli): prevent preview create from showing production route selector

resolvePreviewImageRef now resolves the registry directly from the
first non-preview route without prompting. Also filter preview routes
from the push command's route selector.
commit
5418cc676ce251b8d4b702d4b07326c3b5816a25
author
brice · · 2026-03-18 18:09 UTC
committer
brice · · 2026-03-18 17:19 UTC
parent
cf696fb
signature
unsigned
1 file · +25 -2
M internal/adapters/in/cli/preview.go +25 -2
@@ -232,9 +232,11 @@ func resolvePreviewImageRef(ctx context.Context, cp ControlPlane, out io.Writer,
232232 return "", err
233233 }
234234
235- registry, _, _, err := resolveRoute(ctx, cp, "", "", dockerfile)
235+ // Resolve registry from existing routes without showing the interactive
236+ // selector — preview only needs the registry URL, not a target domain.
237+ registry, err := resolveRegistryForImage(ctx, cp, imageName)
236238 if err != nil {
237- return "", fmt.Errorf("failed to resolve registry: %w", err)
239+ return "", err
238240 }
239241
240242 previewRef := fmt.Sprintf("%s/%s:%s", registry, imageName, previewTag)
@@ -244,6 +246,27 @@ func resolvePreviewImageRef(ctx context.Context, cp ControlPlane, out io.Writer,
244246 return previewRef, nil
245247 }
246248
249+// resolveRegistryForImage finds the registry URL from any existing non-preview
250+// route for the given image, without prompting.
251+func resolveRegistryForImage(ctx context.Context, cp ControlPlane, imageName string) (string, error) {
252+ routes, err := cp.FindRoutesByImage(ctx, imageName)
253+ if err != nil {
254+ return "", fmt.Errorf("failed to find routes for image %q: %w", imageName, err)
255+ }
256+
257+ for _, r := range routes {
258+ if strings.Contains(r.Domain, "--") {
259+ continue
260+ }
261+ reg, _, _ := parseImageRef(r.Image)
262+ if reg != "" {
263+ return reg, nil
264+ }
265+ }
266+
267+ return "", fmt.Errorf("no route configured for image %q", imageName)
268+}
269+
247270 func buildAndPushPreview(ctx context.Context, out io.Writer, previewRef, previewTag, platform string, noBuild bool) error {
248271 imageOps, err := newImageOpsFn()
249272 if err != nil {
@@ -232,9 +232,11 @@ func resolvePreviewImageRef(ctx context.Context, cp ControlPlane, out io.Writer,
232 return "", err232 return "", err
233 }233 }
234 234
235- registry, _, _, err := resolveRoute(ctx, cp, "", "", dockerfile)235+ // Resolve registry from existing routes without showing the interactive
236+ // selector — preview only needs the registry URL, not a target domain.
237+ registry, err := resolveRegistryForImage(ctx, cp, imageName)
236 if err != nil {238 if err != nil {
237- return "", fmt.Errorf("failed to resolve registry: %w", err)239+ return "", err
238 }240 }
239 241
240 previewRef := fmt.Sprintf("%s/%s:%s", registry, imageName, previewTag)242 previewRef := fmt.Sprintf("%s/%s:%s", registry, imageName, previewTag)
@@ -244,6 +246,27 @@ func resolvePreviewImageRef(ctx context.Context, cp ControlPlane, out io.Writer,
244 return previewRef, nil246 return previewRef, nil
245 }247 }
246 248
249+// resolveRegistryForImage finds the registry URL from any existing non-preview
250+// route for the given image, without prompting.
251+func resolveRegistryForImage(ctx context.Context, cp ControlPlane, imageName string) (string, error) {
252+ routes, err := cp.FindRoutesByImage(ctx, imageName)
253+ if err != nil {
254+ return "", fmt.Errorf("failed to find routes for image %q: %w", imageName, err)
255+ }
256+
257+ for _, r := range routes {
258+ if strings.Contains(r.Domain, "--") {
259+ continue
260+ }
261+ reg, _, _ := parseImageRef(r.Image)
262+ if reg != "" {
263+ return reg, nil
264+ }
265+ }
266+
267+ return "", fmt.Errorf("no route configured for image %q", imageName)
268+}
269+
247 func buildAndPushPreview(ctx context.Context, out io.Writer, previewRef, previewTag, platform string, noBuild bool) error {270 func buildAndPushPreview(ctx context.Context, out io.Writer, previewRef, previewTag, platform string, noBuild bool) error {
248 imageOps, err := newImageOpsFn()271 imageOps, err := newImageOpsFn()
249 if err != nil {272 if err != nil {

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close