detached 43d0817

fix: filter networks by gordon.managed label in addition to prefix

commit
43d08175e67ba034bd8515412e4fbc423b8c9caf
author
brice · · 2026-03-14 03:46 UTC
parent
b9de1ae
signature
unsigned
2 files · +5 -3
M internal/usecase/container/routes_test.go +4 -2
@@ -157,9 +157,10 @@ func TestService_ListNetworks(t *testing.T) {
157157 ctx := testContext()
158158
159159 runtime.EXPECT().ListNetworks(mock.Anything).Return([]*domain.NetworkInfo{
160- {Name: "gordon-app"},
160+ {Name: "gordon-app", Labels: map[string]string{domain.LabelManaged: "true"}},
161161 {Name: "bridge"},
162- {Name: "gordon-shared"},
162+ {Name: "gordon-shared", Labels: map[string]string{domain.LabelManaged: "true"}},
163+ {Name: "gordon-unmanaged"},
163164 }, nil)
164165
165166 networks, err := svc.ListNetworks(ctx)
@@ -168,4 +169,5 @@ func TestService_ListNetworks(t *testing.T) {
168169 assert.Len(t, networks, 2)
169170 assert.Equal(t, "gordon-app", networks[0].Name)
170171 assert.Equal(t, "gordon-shared", networks[1].Name)
172+ assert.NotContains(t, []string{networks[0].Name, networks[1].Name}, "gordon-unmanaged")
171173 }
@@ -157,9 +157,10 @@ func TestService_ListNetworks(t *testing.T) {
157 ctx := testContext()157 ctx := testContext()
158 158
159 runtime.EXPECT().ListNetworks(mock.Anything).Return([]*domain.NetworkInfo{159 runtime.EXPECT().ListNetworks(mock.Anything).Return([]*domain.NetworkInfo{
160- {Name: "gordon-app"},160+ {Name: "gordon-app", Labels: map[string]string{domain.LabelManaged: "true"}},
161 {Name: "bridge"},161 {Name: "bridge"},
162- {Name: "gordon-shared"},162+ {Name: "gordon-shared", Labels: map[string]string{domain.LabelManaged: "true"}},
163+ {Name: "gordon-unmanaged"},
163 }, nil)164 }, nil)
164 165
165 networks, err := svc.ListNetworks(ctx)166 networks, err := svc.ListNetworks(ctx)
@@ -168,4 +169,5 @@ func TestService_ListNetworks(t *testing.T) {
168 assert.Len(t, networks, 2)169 assert.Len(t, networks, 2)
169 assert.Equal(t, "gordon-app", networks[0].Name)170 assert.Equal(t, "gordon-app", networks[0].Name)
170 assert.Equal(t, "gordon-shared", networks[1].Name)171 assert.Equal(t, "gordon-shared", networks[1].Name)
172+ assert.NotContains(t, []string{networks[0].Name, networks[1].Name}, "gordon-unmanaged")
171 }173 }
M internal/usecase/container/service.go +1 -1
@@ -1038,7 +1038,7 @@ func (s *Service) ListNetworks(ctx context.Context) ([]*domain.NetworkInfo, erro
10381038
10391039 var filtered []*domain.NetworkInfo
10401040 for _, network := range networks {
1041- if strings.HasPrefix(network.Name, cfg.NetworkPrefix+"-") {
1041+ if strings.HasPrefix(network.Name, cfg.NetworkPrefix+"-") && network.Labels[domain.LabelManaged] == "true" {
10421042 filtered = append(filtered, network)
10431043 }
10441044 }
@@ -1038,7 +1038,7 @@ func (s *Service) ListNetworks(ctx context.Context) ([]*domain.NetworkInfo, erro
1038 1038
1039 var filtered []*domain.NetworkInfo1039 var filtered []*domain.NetworkInfo
1040 for _, network := range networks {1040 for _, network := range networks {
1041- if strings.HasPrefix(network.Name, cfg.NetworkPrefix+"-") {1041+ if strings.HasPrefix(network.Name, cfg.NetworkPrefix+"-") && network.Labels[domain.LabelManaged] == "true" {
1042 filtered = append(filtered, network)1042 filtered = append(filtered, network)
1043 }1043 }
1044 }1044 }

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