(ch *cmdutil.Helper)
| 7 | ) |
| 8 | |
| 9 | func 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 | } |
no test coverage detected