MCPcopy
hub / github.com/genuinetools/img / Run

Method Run

push.go:53–92  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

51}
52
53func (cmd *pushCommand) Run(args []string) (err error) {
54 reexec()
55
56 // Get the specified image.
57 cmd.image = args[0]
58
59 // Create the client.
60 c, err := client.New(stateDir, backend, nil)
61 if err != nil {
62 return err
63 }
64 defer c.Close()
65
66 fmt.Printf("Pushing %s...\n", cmd.image)
67
68 // Create the context.
69 ctx := appcontext.Context()
70 sess, sessDialer, err := c.Session(ctx)
71 if err != nil {
72 return err
73 }
74 ctx = session.NewContext(ctx, sess.ID())
75 ctx = namespaces.WithNamespace(ctx, "buildkit")
76 eg, ctx := errgroup.WithContext(ctx)
77
78 eg.Go(func() error {
79 return sess.Run(ctx, sessDialer)
80 })
81 eg.Go(func() error {
82 defer sess.Close()
83 return c.Push(ctx, cmd.image, cmd.insecure)
84 })
85 if err := eg.Wait(); err != nil {
86 return err
87 }
88
89 fmt.Printf("Successfully pushed %s\n", cmd.image)
90
91 return nil
92}

Callers 1

newPushCommandFunction · 0.95

Calls 6

NewFunction · 0.92
reexecFunction · 0.85
CloseMethod · 0.80
ContextMethod · 0.80
SessionMethod · 0.80
PushMethod · 0.80

Tested by

no test coverage detected