detached 265ee4d

fix: strip Docker network IDs and labels from networks response

commit
265ee4deaaa356f17a19aea0480e1a460a89b79d
author
brice · · 2026-03-14 03:47 UTC
parent
43d0817
signature
unsigned
3 files · +5 -16
M docs/cli/networks.md +3 -5
@@ -37,11 +37,9 @@ gordon networks list --remote https://gordon.mydomain.com --token $TOKEN
3737 ```json
3838 [
3939 {
40- "ID": "abc123...",
41- "Name": "gordon_myapp",
42- "Driver": "bridge",
43- "Containers": ["container1", "container2"],
44- "Labels": {"gordon.managed": "true"}
40+ "Name": "gordon_myapp",
41+ "Driver": "bridge",
42+ "Containers": ["container1", "container2"]
4543 }
4644 ]
4745 ```
@@ -37,11 +37,9 @@ gordon networks list --remote https://gordon.mydomain.com --token $TOKEN
37 ```json37 ```json
38 [38 [
39 {39 {
40- "ID": "abc123...",40+ "Name": "gordon_myapp",
41- "Name": "gordon_myapp",41+ "Driver": "bridge",
42- "Driver": "bridge",42+ "Containers": ["container1", "container2"]
43- "Containers": ["container1", "container2"],
44- "Labels": {"gordon.managed": "true"}
45 }43 }
46 ]44 ]
47 ```45 ```
M internal/adapters/dto/admin_networks.go +2 -2
@@ -2,11 +2,11 @@ package dto
22
33 // Network represents a network in API responses.
44 type Network struct {
5- ID string `json:"id"`
5+ ID string `json:"id,omitempty"`
66 Name string `json:"name"`
77 Driver string `json:"driver"`
88 Containers []string `json:"containers"`
9- Labels map[string]string `json:"labels"`
9+ Labels map[string]string `json:"labels,omitempty"`
1010 }
1111
1212 // NetworksResponse represents a list of networks.
@@ -2,11 +2,11 @@ package dto
2 2
3 // Network represents a network in API responses.3 // Network represents a network in API responses.
4 type Network struct {4 type Network struct {
5- ID string `json:"id"`5+ ID string `json:"id,omitempty"`
6 Name string `json:"name"`6 Name string `json:"name"`
7 Driver string `json:"driver"`7 Driver string `json:"driver"`
8 Containers []string `json:"containers"`8 Containers []string `json:"containers"`
9- Labels map[string]string `json:"labels"`9+ Labels map[string]string `json:"labels,omitempty"`
10 }10 }
11 11
12 // NetworksResponse represents a list of networks.12 // NetworksResponse represents a list of networks.
M internal/adapters/in/http/admin/handler.go +0 -9
@@ -671,19 +671,10 @@ func (h *Handler) handleNetworks(w http.ResponseWriter, r *http.Request) {
671671 if network == nil {
672672 continue
673673 }
674- var labelsCopy map[string]string
675- if network.Labels != nil {
676- labelsCopy = make(map[string]string, len(network.Labels))
677- for key, value := range network.Labels {
678- labelsCopy[key] = value
679- }
680- }
681674 response = append(response, dto.Network{
682- ID: network.ID,
683675 Name: network.Name,
684676 Driver: network.Driver,
685677 Containers: append([]string{}, network.Containers...),
686- Labels: labelsCopy,
687678 })
688679 }
689680
@@ -671,19 +671,10 @@ func (h *Handler) handleNetworks(w http.ResponseWriter, r *http.Request) {
671 if network == nil {671 if network == nil {
672 continue672 continue
673 }673 }
674- var labelsCopy map[string]string
675- if network.Labels != nil {
676- labelsCopy = make(map[string]string, len(network.Labels))
677- for key, value := range network.Labels {
678- labelsCopy[key] = value
679- }
680- }
681 response = append(response, dto.Network{674 response = append(response, dto.Network{
682- ID: network.ID,
683 Name: network.Name,675 Name: network.Name,
684 Driver: network.Driver,676 Driver: network.Driver,
685 Containers: append([]string{}, network.Containers...),677 Containers: append([]string{}, network.Containers...),
686- Labels: labelsCopy,
687 })678 })
688 }679 }
689 680

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