Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 17f66a5

Browse files
committed
Make image inspect more in line with other tables
Signed-off-by: Djordje Lukic <[email protected]>
1 parent ab69992 commit 17f66a5

File tree

3 files changed

+22
-44
lines changed

3 files changed

+22
-44
lines changed

internal/inspect/inspect.go

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -92,43 +92,43 @@ func printTable(out io.Writer, appInfo appInfo) error {
9292
for _, service := range appInfo.Services {
9393
fmt.Fprintf(w, "%s\t%d\t%s\t%s\n", service.Name, service.Replicas, service.Ports, service.Image)
9494
}
95-
}, "Service", "Replicas", "Ports", "Image")
95+
}, "SERVICE", "REPLICAS", "PORTS", "IMAGE")
9696

9797
// Add Network section
9898
printSection(out, len(appInfo.Networks), func(w io.Writer) {
9999
for _, name := range appInfo.Networks {
100100
fmt.Fprintln(w, name)
101101
}
102-
}, "Network")
102+
}, "NETWORK")
103103

104104
// Add Volume section
105105
printSection(out, len(appInfo.Volumes), func(w io.Writer) {
106106
for _, name := range appInfo.Volumes {
107107
fmt.Fprintln(w, name)
108108
}
109-
}, "Volume")
109+
}, "VOLUME")
110110

111111
// Add Secret section
112112
printSection(out, len(appInfo.Secrets), func(w io.Writer) {
113113
for _, name := range appInfo.Secrets {
114114
fmt.Fprintln(w, name)
115115
}
116-
}, "Secret")
116+
}, "SECRET")
117117

118118
// Add Parameter section
119119
printSection(out, len(appInfo.parametersKeys), func(w io.Writer) {
120120
for _, k := range appInfo.parametersKeys {
121121
fmt.Fprintf(w, "%s\t%s\n", k, appInfo.Parameters[k])
122122
}
123-
}, "Parameter", "Value")
123+
}, "PARAMETER", "VALUE")
124124

125125
// Add Attachments section
126126
printSection(out, len(appInfo.Attachments), func(w io.Writer) {
127127
for _, attachment := range appInfo.Attachments {
128128
sizeString := units.HumanSize(float64(attachment.Size))
129129
fmt.Fprintf(w, "%s\t%s\n", attachment.Path, sizeString)
130130
}
131-
}, "Attachment", "Size")
131+
}, "ATTACHMENT", "SIZE")
132132
return nil
133133
}
134134

@@ -146,25 +146,11 @@ func printSection(out io.Writer, len int, printer func(io.Writer), headers ...st
146146
}
147147
fmt.Fprintln(out)
148148
w := tabwriter.NewWriter(out, 0, 0, 1, ' ', 0)
149-
var plural string
150-
if len > 1 {
151-
plural = "s"
152-
}
153-
headers[0] = fmt.Sprintf("%s%s (%d)", headers[0], plural, len)
154-
printHeaders(w, headers...)
149+
fmt.Fprintln(w, strings.Join(headers, "\t"))
155150
printer(w)
156151
w.Flush()
157152
}
158153

159-
func printHeaders(w io.Writer, headers ...string) {
160-
fmt.Fprintln(w, strings.Join(headers, "\t"))
161-
dashes := make([]string, len(headers))
162-
for i, h := range headers {
163-
dashes[i] = strings.Repeat("-", len(h))
164-
}
165-
fmt.Fprintln(w, strings.Join(dashes, "\t"))
166-
}
167-
168154
func getAppInfo(app *types.App, config *composetypes.Config, argParameters map[string]string) (appInfo, error) {
169155
services := []service{}
170156
for _, s := range config.Services {

internal/inspect/testdata/inspect-full.golden

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,25 @@ maintainers:
66
77

88

9-
Services (2) Replicas Ports Image
10-
------------ -------- ----- -----
11-
web1 2 8080-8100 nginx:latest
12-
web2 2 9080-9100 nginx:latest
9+
SERVICE REPLICAS PORTS IMAGE
10+
web1 2 8080-8100 nginx:latest
11+
web2 2 9080-9100 nginx:latest
1312

14-
Networks (2)
15-
------------
13+
NETWORK
1614
my-network1
1715
my-network2
1816

19-
Volumes (2)
20-
-----------
17+
VOLUME
2118
my-volume1
2219
my-volume2
2320

24-
Secrets (2)
25-
-----------
21+
SECRET
2622
my-secret1
2723
my-secret2
2824

29-
Parameters (2) Value
30-
-------------- -----
31-
port 8080
32-
text hello
25+
PARAMETER VALUE
26+
port 8080
27+
text hello
3328

34-
Attachment (1) Size
35-
-------------- ----
36-
config.cfg 9B
29+
ATTACHMENT SIZE
30+
config.cfg 9B

internal/inspect/testdata/inspect-overridden.golden

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ description: ""
44
maintainers: []
55

66

7-
Service (1) Replicas Ports Image
8-
----------- -------- ----- -----
9-
web 1 80 nginx
7+
SERVICE REPLICAS PORTS IMAGE
8+
web 1 80 nginx
109

11-
Parameter (1) Value
12-
------------- -----
13-
web.port 80
10+
PARAMETER VALUE
11+
web.port 80

0 commit comments

Comments
 (0)