MCPcopy
hub / github.com/slimtoolkit/slim / OnPushCommand

Function OnPushCommand

pkg/app/master/command/registry/handler_push.go:24–110  ·  view source on GitHub ↗

OnPushCommand implements the 'registry push' command

(
	xc *app.ExecutionContext,
	gparams *command.GenericParams,
	cparams *PushCommandParams)

Source from the content-addressed store, hash-verified

22
23// OnPushCommand implements the 'registry push' command
24func 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()

Callers 1

cli.goFile · 0.85

Calls 14

NewRegistryCommandFunction · 0.92
NewFunction · 0.92
ExeDirFunction · 0.92
ConfigureAuthFunction · 0.85
uniqueTarFilePathFunction · 0.85
saveDockerImageFunction · 0.85
pushImageFromTarFunction · 0.85
ExitMethod · 0.80
FailOnMethod · 0.80
ReportLocationMethod · 0.80
fullCmdNameFunction · 0.70
StateMethod · 0.65

Tested by

no test coverage detected