@@ -111,7 +111,7 @@ func ImageInspect(out io.Writer, app *types.App, argParameters map[string]string
111111 }
112112
113113 outputFormat := os .Getenv (internal .DockerInspectFormatEnvVar )
114- return printImageAppInfo (out , appInfo , outputFormat )
114+ return printImageAppInfo (out , appInfo , outputFormat , true )
115115}
116116
117117func 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
138138 params [v .Definition ] = ""
139139 }
140140 }
141+ sort .Strings (paramKeys )
141142
142143 services := []Service {}
143144 for k , v := range bndl .Images {
@@ -146,6 +147,9 @@ func ImageInspectCNAB(out io.Writer, bndl *bundle.Bundle, outputFormat string) e
146147 Image : v .Image ,
147148 })
148149 }
150+ sort .SliceStable (services , func (i , j int ) bool {
151+ return services [i ].Name < services [j ].Name
152+ })
149153
150154 appInfo := ImageAppInfo {
151155 Metadata : meta ,
@@ -154,7 +158,7 @@ func ImageInspectCNAB(out io.Writer, bndl *bundle.Bundle, outputFormat string) e
154158 Services : services ,
155159 }
156160
157- return printImageAppInfo (out , appInfo , outputFormat )
161+ return printImageAppInfo (out , appInfo , outputFormat , false )
158162}
159163
160164func printAppInfo (out io.Writer , app AppInfo , format string ) error {
@@ -168,10 +172,10 @@ func printAppInfo(out io.Writer, app AppInfo, format string) error {
168172 }
169173}
170174
171- func printImageAppInfo (out io.Writer , app ImageAppInfo , format string ) error {
175+ func printImageAppInfo (out io.Writer , app ImageAppInfo , format string , isApp bool ) error {
172176 switch format {
173177 case "pretty" :
174- return printTable (out , app )
178+ return printTable (out , app , isApp )
175179 case "json" :
176180 return printJSON (out , app )
177181 default :
@@ -209,16 +213,24 @@ func printAppTable(out io.Writer, info AppInfo) error {
209213 return nil
210214}
211215
212- func printTable (out io.Writer , appInfo ImageAppInfo ) error {
216+ func printTable (out io.Writer , appInfo ImageAppInfo , isApp bool ) error {
213217 // Add Meta data
214218 printYAML (out , appInfo .Metadata )
215219
216220 // 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+ }
222234
223235 // Add Network section
224236 printSection (out , len (appInfo .Networks ), func (w io.Writer ) {
@@ -369,7 +381,7 @@ func extractParameters(app *types.App, argParameters map[string]string) ([]strin
369381 for k := range allParameters {
370382 parametersKeys = append (parametersKeys , k )
371383 }
372- sort .Slice (parametersKeys , func ( i , j int ) bool { return parametersKeys [ i ] < parametersKeys [ j ] } )
384+ sort .Strings (parametersKeys )
373385 return parametersKeys , allParameters , nil
374386}
375387
0 commit comments