MCPcopy Create free account
hub / github.com/rilldata/rill / SetCmd

Function SetCmd

cli/cmd/sudo/annotations/set.go:9–48  ·  view source on GitHub ↗
(ch *cmdutil.Helper)

Source from the content-addressed store, hash-verified

7)
8
9func SetCmd(ch *cmdutil.Helper) *cobra.Command {
10 var annotations map[string]string
11
12 setCmd := &cobra.Command{
13 Use: "set <organization> <project>",
14 Args: cobra.ExactArgs(2),
15 Short: "Set annotations for a project",
16 RunE: func(cmd *cobra.Command, args []string) error {
17 ctx := cmd.Context()
18
19 client, err := ch.Client()
20 if err != nil {
21 return err
22 }
23
24 if len(annotations) == 0 {
25 ch.PrintfWarn("Setting an empty annotation list will remove all annotations from the project.\n")
26 if ch.Interactive {
27 if err := cmdutil.ConfirmPrompt("Do you want to continue?", false); err != nil {
28 return err
29 }
30 }
31 }
32
33 _, err = client.SudoUpdateAnnotations(ctx, &adminv1.SudoUpdateAnnotationsRequest{
34 Org: args[0],
35 Project: args[1],
36 Annotations: annotations,
37 })
38 if err != nil {
39 return err
40 }
41
42 return nil
43 },
44 }
45 setCmd.Flags().StringToStringVar(&annotations, "annotation", nil, "Annotation(s) to set on project")
46
47 return setCmd
48}

Callers 1

AnnotationsCmdFunction · 0.70

Calls 5

ConfirmPromptFunction · 0.92
PrintfWarnMethod · 0.80
ContextMethod · 0.65
SudoUpdateAnnotationsMethod · 0.65
ClientMethod · 0.45

Tested by

no test coverage detected