@@ -111,7 +111,7 @@ func ImageInspect(out io.Writer, app *types.App, argParameters map[string]string
111
111
}
112
112
113
113
outputFormat := os .Getenv (internal .DockerInspectFormatEnvVar )
114
- return printImageAppInfo (out , appInfo , outputFormat )
114
+ return printImageAppInfo (out , appInfo , outputFormat , true )
115
115
}
116
116
117
117
func ImageInspectCNAB (out io.Writer , bndl * bundle.Bundle , outputFormat string ) error {
@@ -138,6 +138,7 @@ func ImageInspectCNAB(out io.Writer, bndl *bundle.Bundle, outputFormat string) e
138
138
params [v .Definition ] = ""
139
139
}
140
140
}
141
+ sort .Strings (paramKeys )
141
142
142
143
services := []Service {}
143
144
for k , v := range bndl .Images {
@@ -146,6 +147,9 @@ func ImageInspectCNAB(out io.Writer, bndl *bundle.Bundle, outputFormat string) e
146
147
Image : v .Image ,
147
148
})
148
149
}
150
+ sort .SliceStable (services , func (i , j int ) bool {
151
+ return services [i ].Name < services [j ].Name
152
+ })
149
153
150
154
appInfo := ImageAppInfo {
151
155
Metadata : meta ,
@@ -154,7 +158,7 @@ func ImageInspectCNAB(out io.Writer, bndl *bundle.Bundle, outputFormat string) e
154
158
Services : services ,
155
159
}
156
160
157
- return printImageAppInfo (out , appInfo , outputFormat )
161
+ return printImageAppInfo (out , appInfo , outputFormat , false )
158
162
}
159
163
160
164
func printAppInfo (out io.Writer , app AppInfo , format string ) error {
@@ -168,10 +172,10 @@ func printAppInfo(out io.Writer, app AppInfo, format string) error {
168
172
}
169
173
}
170
174
171
- func printImageAppInfo (out io.Writer , app ImageAppInfo , format string ) error {
175
+ func printImageAppInfo (out io.Writer , app ImageAppInfo , format string , isApp bool ) error {
172
176
switch format {
173
177
case "pretty" :
174
- return printTable (out , app )
178
+ return printTable (out , app , isApp )
175
179
case "json" :
176
180
return printJSON (out , app )
177
181
default :
@@ -209,16 +213,24 @@ func printAppTable(out io.Writer, info AppInfo) error {
209
213
return nil
210
214
}
211
215
212
- func printTable (out io.Writer , appInfo ImageAppInfo ) error {
216
+ func printTable (out io.Writer , appInfo ImageAppInfo , isApp bool ) error {
213
217
// Add Meta data
214
218
printYAML (out , appInfo .Metadata )
215
219
216
220
// Add Service section
217
- printSection (out , len (appInfo .Services ), func (w io.Writer ) {
218
- for _ , service := range appInfo .Services {
219
- fmt .Fprintf (w , "%s\t %d\t %s\t %s\n " , service .Name , service .Replicas , service .Ports , service .Image )
220
- }
221
- }, "SERVICE" , "REPLICAS" , "PORTS" , "IMAGE" )
221
+ if isApp {
222
+ printSection (out , len (appInfo .Services ), func (w io.Writer ) {
223
+ for _ , service := range appInfo .Services {
224
+ fmt .Fprintf (w , "%s\t %d\t %s\t %s\n " , service .Name , service .Replicas , service .Ports , service .Image )
225
+ }
226
+ }, "SERVICE" , "REPLICAS" , "PORTS" , "IMAGE" )
227
+ } else {
228
+ printSection (out , len (appInfo .Services ), func (w io.Writer ) {
229
+ for _ , service := range appInfo .Services {
230
+ fmt .Fprintf (w , "%s\t %s\n " , service .Name , service .Image )
231
+ }
232
+ }, "SERVICE" , "IMAGE" )
233
+ }
222
234
223
235
// Add Network section
224
236
printSection (out , len (appInfo .Networks ), func (w io.Writer ) {
@@ -369,7 +381,7 @@ func extractParameters(app *types.App, argParameters map[string]string) ([]strin
369
381
for k := range allParameters {
370
382
parametersKeys = append (parametersKeys , k )
371
383
}
372
- sort .Slice (parametersKeys , func ( i , j int ) bool { return parametersKeys [ i ] < parametersKeys [ j ] } )
384
+ sort .Strings (parametersKeys )
373
385
return parametersKeys , allParameters , nil
374
386
}
375
387
0 commit comments