MCPcopy
hub / github.com/docker/docker-agent / runPushCommand

Function runPushCommand

cmd/root/push.go:27–64  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

25}
26
27func runPushCommand(cmd *cobra.Command, args []string) (commandErr error) {
28 ctx := cmd.Context()
29 telemetry.TrackCommand(ctx, "share", append([]string{"push"}, args...))
30 defer func() { // do not inline this defer so that commandErr is not resolved early
31 telemetry.TrackCommandError(ctx, "share", append([]string{"push"}, args...), commandErr)
32 }()
33
34 agentFilename := args[0]
35 tag := args[1]
36 out := cli.NewPrinter(cmd.OutOrStdout())
37
38 store, err := content.NewStore()
39 if err != nil {
40 return err
41 }
42
43 agentSource, err := config.Resolve(agentFilename, nil)
44 if err != nil {
45 return fmt.Errorf("resolving agent file: %w", err)
46 }
47
48 _, err = oci.PackageFileAsOCIToStore(ctx, agentSource, tag, store)
49 if err != nil {
50 return fmt.Errorf("failed to build artifact: %w", err)
51 }
52
53 slog.DebugContext(ctx, "Starting push", "registry_ref", tag)
54
55 out.Printf("Pushing agent %s to %s\n", agentFilename, tag)
56
57 err = remote.Push(ctx, tag)
58 if err != nil {
59 return fmt.Errorf("failed to push artifact: %w", err)
60 }
61
62 out.Printf("Successfully pushed artifact to %s\n", tag)
63 return nil
64}

Callers

nothing calls this directly

Calls 9

PrintfMethod · 0.95
TrackCommandFunction · 0.92
TrackCommandErrorFunction · 0.92
NewPrinterFunction · 0.92
NewStoreFunction · 0.92
ResolveFunction · 0.92
PackageFileAsOCIToStoreFunction · 0.92
PushFunction · 0.92
ContextMethod · 0.80

Tested by

no test coverage detected