(cmd *cobra.Command, args []string)
| 25 | } |
| 26 | |
| 27 | func 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 | } |
nothing calls this directly
no test coverage detected