OnCommand implements the 'version' command
( xc *app.ExecutionContext, doDebug, inContainer, isDSImage bool, clientConfig *config.DockerClient)
| 18 | |
| 19 | // OnCommand implements the 'version' command |
| 20 | func OnCommand( |
| 21 | xc *app.ExecutionContext, |
| 22 | doDebug, inContainer, isDSImage bool, |
| 23 | clientConfig *config.DockerClient) { |
| 24 | logger := log.WithFields(log.Fields{"app": "slim", "cmd": cmd.Version}) |
| 25 | |
| 26 | client, err := dockerclient.New(clientConfig) |
| 27 | if err == dockerclient.ErrNoDockerInfo { |
| 28 | exitMsg := "missing Docker connection info" |
| 29 | if inContainer && isDSImage { |
| 30 | exitMsg = "make sure to pass the Docker connect parameters to the slim app container" |
| 31 | } |
| 32 | |
| 33 | xc.Out.Info("docker.connect.error", |
| 34 | ovars{ |
| 35 | "message": exitMsg, |
| 36 | }) |
| 37 | |
| 38 | exitCode := -777 |
| 39 | xc.Out.State("exited", |
| 40 | ovars{ |
| 41 | "exit.code": exitCode, |
| 42 | "version": v.Current(), |
| 43 | "location": fsutil.ExeDir(), |
| 44 | }) |
| 45 | xc.Exit(exitCode) |
| 46 | } |
| 47 | errutil.FailOn(err) |
| 48 | |
| 49 | version.Print(xc, Name, logger, client, true, inContainer, isDSImage) |
| 50 | } |