MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / newArtifactUploadCmd

Function newArtifactUploadCmd

app/cli/cmd/artifact_upload.go:25–66  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23)
24
25func newArtifactUploadCmd() *cobra.Command {
26 var filePath string
27 var artifactCASConn *grpc.ClientConn
28
29 cmd := &cobra.Command{
30 Use: "upload",
31 Short: "upload an artifact",
32 PreRunE: func(cmd *cobra.Command, args []string) error {
33 var err error
34
35 // Retrieve temporary credentials for uploading
36 artifactCASConn, err = wrappedArtifactConn(ActionOpts.CPConnection, pb.CASCredentialsServiceGetRequest_ROLE_UPLOADER, "")
37 if err != nil {
38 return err
39 }
40
41 return nil
42 },
43 RunE: func(cmd *cobra.Command, args []string) error {
44 opts := &action.ArtifactUploadOpts{
45 ActionsOpts: ActionOpts,
46 ArtifactsCASConn: artifactCASConn,
47 }
48
49 _, err := action.NewArtifactUpload(opts).Run(filePath)
50 return err
51 },
52 PostRunE: func(cmd *cobra.Command, args []string) error {
53 if artifactCASConn != nil {
54 return artifactCASConn.Close()
55 }
56
57 return nil
58 },
59 }
60
61 cmd.Flags().StringVarP(&filePath, "file", "f", "", "path to file to upload")
62 err := cmd.MarkFlagRequired("file")
63 cobra.CheckErr(err)
64
65 return cmd
66}

Callers 1

newArtifactCmdFunction · 0.85

Calls 4

NewArtifactUploadFunction · 0.92
wrappedArtifactConnFunction · 0.85
RunMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected