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

Function newReferrerDiscoverCmd

app/cli/cmd/referrer_discover.go:27–68  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25)
26
27func newReferrerDiscoverCmd() *cobra.Command {
28 var digest, kind string
29 var fromPublicIndex bool
30 paginationOpts := &options.PaginationOpts{DefaultLimit: 20}
31
32 cmd := &cobra.Command{
33 Use: "discover",
34 Short: "(Preview) inspect pieces of evidence or artifacts stored through Chainloop",
35 RunE: func(cmd *cobra.Command, args []string) error {
36 pagination := &action.PaginationOpts{
37 Limit: paginationOpts.Limit,
38 NextCursor: paginationOpts.NextCursor,
39 }
40
41 var res *action.ReferrerDiscoverResult
42 var err error
43
44 if fromPublicIndex {
45 res, err = action.NewReferrerDiscoverPublicIndex(ActionOpts).Run(context.Background(), digest, kind, pagination)
46 } else {
47 res, err = action.NewReferrerDiscoverPrivate(ActionOpts).Run(context.Background(), digest, kind, pagination)
48 }
49
50 if err != nil {
51 return err
52 }
53
54 // NOTE: this is a preview/beta command, for now we only return JSON format
55 return output.EncodeJSON(res)
56 },
57 }
58
59 cmd.Flags().StringVarP(&digest, "digest", "d", "", "hash of the attestation, piece of evidence or artifact, i.e sha256:deadbeef")
60 err := cmd.MarkFlagRequired("digest")
61 cobra.CheckErr(err)
62 cmd.Flags().StringVarP(&kind, "kind", "k", "", "optional kind of the referrer, used to disambiguate between multiple referrers with the same digest")
63 cobra.CheckErr(err)
64 cmd.Flags().BoolVar(&fromPublicIndex, "public", false, "discover from public shared index instead of your organizations'")
65 paginationOpts.AddFlags(cmd)
66
67 return cmd
68}

Callers 1

NewRootCmdFunction · 0.85

Calls 5

AddFlagsMethod · 0.95
EncodeJSONFunction · 0.92
RunMethod · 0.45

Tested by

no test coverage detected