detached 74c9522

fix(preview): fall back to route config when image has no domain label

The preview handler only resolved base route domains from gordon.domain
image labels. Most images don't have this label — the route is configured
in gordon.toml instead. Now the handler falls back to FindRoutesByImage
from the config service, matching how the push CLI resolves domains.
commit
74c9522086607ef96e67a3ad7d09cc9df49fd342
author
brice · · 2026-03-18 18:00 UTC
committer
brice · · 2026-03-18 22:55 UTC
parent
83b82b4
signature
unsigned
3 files · +12 -2
M internal/usecase/auto/dispatcher.go +1 -0
@@ -17,6 +17,7 @@ type AutoConfigProvider interface {
1717 GetPreviewTagPatterns() []string
1818 GetPreviewConfig() domain.PreviewConfig
1919 GetAllowedDomains() []string
20+ FindRoutesByImage(ctx context.Context, imageName string) []domain.Route
2021 }
2122
2223 // ImagePushDispatcher classifies image push events and delegates
@@ -17,6 +17,7 @@ type AutoConfigProvider interface {
17 GetPreviewTagPatterns() []string17 GetPreviewTagPatterns() []string
18 GetPreviewConfig() domain.PreviewConfig18 GetPreviewConfig() domain.PreviewConfig
19 GetAllowedDomains() []string19 GetAllowedDomains() []string
20+ FindRoutesByImage(ctx context.Context, imageName string) []domain.Route
20 }21 }
21 22
22 // ImagePushDispatcher classifies image push events and delegates23 // ImagePushDispatcher classifies image push events and delegates
M internal/usecase/auto/dispatcher_test.go +3 -0
@@ -32,6 +32,9 @@ func (m *mockAutoConfig) IsPreviewEnabled() bool { return m.prev
3232 func (m *mockAutoConfig) GetPreviewTagPatterns() []string { return m.tagPatterns }
3333 func (m *mockAutoConfig) GetPreviewConfig() domain.PreviewConfig { return domain.PreviewConfig{} }
3434 func (m *mockAutoConfig) GetAllowedDomains() []string { return nil }
35+func (m *mockAutoConfig) FindRoutesByImage(_ context.Context, _ string) []domain.Route {
36+ return nil
37+}
3538
3639 func TestDispatcher_PreviewTag_DelegatesToPreview(t *testing.T) {
3740 route := &mockHandler{}
@@ -32,6 +32,9 @@ func (m *mockAutoConfig) IsPreviewEnabled() bool { return m.prev
32 func (m *mockAutoConfig) GetPreviewTagPatterns() []string { return m.tagPatterns }32 func (m *mockAutoConfig) GetPreviewTagPatterns() []string { return m.tagPatterns }
33 func (m *mockAutoConfig) GetPreviewConfig() domain.PreviewConfig { return domain.PreviewConfig{} }33 func (m *mockAutoConfig) GetPreviewConfig() domain.PreviewConfig { return domain.PreviewConfig{} }
34 func (m *mockAutoConfig) GetAllowedDomains() []string { return nil }34 func (m *mockAutoConfig) GetAllowedDomains() []string { return nil }
35+func (m *mockAutoConfig) FindRoutesByImage(_ context.Context, _ string) []domain.Route {
36+ return nil
37+}
35 38
36 func TestDispatcher_PreviewTag_DelegatesToPreview(t *testing.T) {39 func TestDispatcher_PreviewTag_DelegatesToPreview(t *testing.T) {
37 route := &mockHandler{}40 route := &mockHandler{}
M internal/usecase/auto/preview/handler.go +8 -2
@@ -62,10 +62,16 @@ func (h *AutoPreviewHandler) Handle(ctx context.Context, event domain.Event) err
6262 previewConfig := h.config.GetPreviewConfig()
6363 previewName := ExtractPreviewName(payload.Reference, previewConfig.TagPatterns)
6464
65- // Resolve base route from labels
65+ // Resolve base route: labels first, then route config fallback
6666 domains := collectDomains(labels)
6767 if len(domains) == 0 {
68- log.Debug().Str("image", payload.Name).Msg("no gordon.domain label found, skipping preview handler")
68+ routes := h.config.FindRoutesByImage(ctx, payload.Name)
69+ for _, r := range routes {
70+ domains = append(domains, r.Domain)
71+ }
72+ }
73+ if len(domains) == 0 {
74+ log.Debug().Str("image", payload.Name).Msg("no domain found from labels or routes, skipping preview")
6975 return nil
7076 }
7177 baseRouteDomain := domains[0]
@@ -62,10 +62,16 @@ func (h *AutoPreviewHandler) Handle(ctx context.Context, event domain.Event) err
62 previewConfig := h.config.GetPreviewConfig()62 previewConfig := h.config.GetPreviewConfig()
63 previewName := ExtractPreviewName(payload.Reference, previewConfig.TagPatterns)63 previewName := ExtractPreviewName(payload.Reference, previewConfig.TagPatterns)
64 64
65- // Resolve base route from labels65+ // Resolve base route: labels first, then route config fallback
66 domains := collectDomains(labels)66 domains := collectDomains(labels)
67 if len(domains) == 0 {67 if len(domains) == 0 {
68- log.Debug().Str("image", payload.Name).Msg("no gordon.domain label found, skipping preview handler")68+ routes := h.config.FindRoutesByImage(ctx, payload.Name)
69+ for _, r := range routes {
70+ domains = append(domains, r.Domain)
71+ }
72+ }
73+ if len(domains) == 0 {
74+ log.Debug().Str("image", payload.Name).Msg("no domain found from labels or routes, skipping preview")
69 return nil75 return nil
70 }76 }
71 baseRouteDomain := domains[0]77 baseRouteDomain := domains[0]

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