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