@@ -10,47 +10,58 @@ import (
1010 "github.com/spf13/cobra"
1111)
1212
13+ type inspectOptions struct {
14+ parametersOptions
15+ registryOptions
16+ pull bool
17+ }
18+
1319func inspectCmd (dockerCli command.Cli ) * cobra.Command {
14- var opts parametersOptions
20+ var opts inspectOptions
1521 cmd := & cobra.Command {
1622 Use : "inspect [<app-name>] [-s key=value...] [-f parameters-file...]" ,
1723 Short : "Shows metadata, parameters and a summary of the compose file for a given application" ,
1824 Args : cli .RequiresMaxArgs (1 ),
1925 RunE : func (cmd * cobra.Command , args []string ) error {
20- muteDockerCli (dockerCli )
21- appname := firstOrEmpty (args )
26+ return runInspect (dockerCli , firstOrEmpty (args ), opts )
27+ },
28+ }
29+ opts .parametersOptions .addFlags (cmd .Flags ())
30+ opts .registryOptions .addFlags (cmd .Flags ())
31+ cmd .Flags ().BoolVar (& opts .pull , "pull" , false , "Pull the bundle" )
32+ return cmd
33+ }
2234
23- c , err := claim .New ("inspect" )
24- if err != nil {
25- return err
26- }
27- driverImpl , err := prepareDriver (dockerCli )
28- if err != nil {
29- return err
30- }
31- bundle , err := resolveBundle (dockerCli , appname )
32- if err != nil {
33- return err
34- }
35- c .Bundle = bundle
35+ func runInspect (dockerCli command.Cli , appname string , opts inspectOptions ) error {
36+ muteDockerCli (dockerCli )
3637
37- parameters , err := mergeBundleParameters (c .Bundle ,
38- withFileParameters (opts .parametersFiles ),
39- withCommandLineParameters (opts .overrides ),
40- )
41- if err != nil {
42- return err
43- }
44- c .Parameters = parameters
38+ c , err := claim .New ("inspect" )
39+ if err != nil {
40+ return err
41+ }
42+ driverImpl , err := prepareDriver (dockerCli )
43+ if err != nil {
44+ return err
45+ }
46+ bundle , err := resolveBundle (dockerCli , appname , opts .pull , opts .insecureRegistries )
47+ if err != nil {
48+ return err
49+ }
50+ c .Bundle = bundle
4551
46- a := & action.RunCustom {
47- Action : internal .Namespace + "inspect" ,
48- Driver : driverImpl ,
49- }
50- err = a .Run (c , map [string ]string {"docker.context" : "" }, dockerCli .Out ())
51- return errors .Wrap (err , "Inspect failed" )
52- },
52+ parameters , err := mergeBundleParameters (c .Bundle ,
53+ withFileParameters (opts .parametersFiles ),
54+ withCommandLineParameters (opts .overrides ),
55+ )
56+ if err != nil {
57+ return err
5358 }
54- opts .addFlags (cmd .Flags ())
55- return cmd
59+ c .Parameters = parameters
60+
61+ a := & action.RunCustom {
62+ Action : internal .Namespace + "inspect" ,
63+ Driver : driverImpl ,
64+ }
65+ err = a .Run (c , map [string ]string {"docker.context" : "" }, dockerCli .Out ())
66+ return errors .Wrap (err , "Inspect failed" )
5667}
0 commit comments