OnPullCommand implements the 'registry pull' command
( xc *app.ExecutionContext, gparams *command.GenericParams, cparams *PullCommandParams)
| 27 | |
| 28 | // OnPullCommand implements the 'registry pull' command |
| 29 | func OnPullCommand( |
| 30 | xc *app.ExecutionContext, |
| 31 | gparams *command.GenericParams, |
| 32 | cparams *PullCommandParams) { |
| 33 | cmdName := fullCmdName(PullCmdName) |
| 34 | logger := log.WithFields(log.Fields{ |
| 35 | "app": appName, |
| 36 | "cmd": cmdName, |
| 37 | "sub": PullCmdName}) |
| 38 | |
| 39 | viChan := version.CheckAsync(gparams.CheckVersion, gparams.InContainer, gparams.IsDSImage) |
| 40 | |
| 41 | cmdReport := report.NewRegistryCommand(gparams.ReportLocation, gparams.InContainer) |
| 42 | cmdReport.State = cmd.StateStarted |
| 43 | cmdReport.TargetReference = cparams.TargetRef |
| 44 | |
| 45 | xc.Out.State(cmd.StateStarted) |
| 46 | xc.Out.Info("params", |
| 47 | ovars{ |
| 48 | "cmd.params": fmt.Sprintf("%+v", cparams), |
| 49 | }) |
| 50 | |
| 51 | client, err := dockerclient.New(gparams.ClientConfig) |
| 52 | if err == dockerclient.ErrNoDockerInfo { |
| 53 | exitMsg := "missing Docker connection info" |
| 54 | if gparams.InContainer && gparams.IsDSImage { |
| 55 | exitMsg = "make sure to pass the Docker connect parameters to the docker-slim container" |
| 56 | } |
| 57 | |
| 58 | xc.Out.Info("docker.connect.error", |
| 59 | ovars{ |
| 60 | "message": exitMsg, |
| 61 | }) |
| 62 | |
| 63 | exitCode := command.ECTCommon | command.ECCNoDockerConnectInfo |
| 64 | xc.Out.State("exited", |
| 65 | ovars{ |
| 66 | "exit.code": exitCode, |
| 67 | "version": v.Current(), |
| 68 | "location": fsutil.ExeDir(), |
| 69 | }) |
| 70 | xc.Exit(exitCode) |
| 71 | } |
| 72 | errutil.FailOn(err) |
| 73 | |
| 74 | if gparams.Debug { |
| 75 | version.Print(xc, cmdName, logger, client, false, gparams.InContainer, gparams.IsDSImage) |
| 76 | } |
| 77 | |
| 78 | remoteOpts := []remote.Option{ |
| 79 | remote.WithContext(context.Background()), |
| 80 | } |
| 81 | remoteOpts, err = ConfigureAuth(cparams.CommonCommandParams, remoteOpts) |
| 82 | xc.FailOn(err) |
| 83 | |
| 84 | nameOpts := []name.Option{ |
| 85 | name.WeakValidation, |
| 86 | name.Insecure, |
no test coverage detected