(ch *cmdutil.Helper)
| 11 | ) |
| 12 | |
| 13 | func EditCmd(ch *cmdutil.Helper) *cobra.Command { |
| 14 | var orgName, displayName, description, defaultProjectRole, billingEmail string |
| 15 | |
| 16 | editCmd := &cobra.Command{ |
| 17 | Use: "edit [<org-name>]", |
| 18 | Args: cobra.MaximumNArgs(1), |
| 19 | Short: "Edit organization details", |
| 20 | RunE: func(cmd *cobra.Command, args []string) error { |
| 21 | ctx := cmd.Context() |
| 22 | |
| 23 | client, err := ch.Client() |
| 24 | if err != nil { |
| 25 | return err |
| 26 | } |
| 27 | |
| 28 | if len(args) > 0 { |
| 29 | orgName = args[0] |
| 30 | } |
| 31 | if orgName == "" { |
| 32 | return fmt.Errorf("must specify an organization name") |
| 33 | } |
| 34 | |
| 35 | resp, err := client.GetOrganization(ctx, &adminv1.GetOrganizationRequest{Org: orgName}) |
| 36 | if err != nil { |
| 37 | if st, ok := status.FromError(err); ok { |
| 38 | if st.Code() != codes.NotFound { |
| 39 | return err |
| 40 | } |
| 41 | } |
| 42 | fmt.Printf("Org name %q doesn't exist, please run `rill org list` to list available orgs\n", orgName) |
| 43 | return nil |
| 44 | } |
| 45 | |
| 46 | org := resp.Organization |
| 47 | req := &adminv1.UpdateOrganizationRequest{ |
| 48 | Org: org.Name, |
| 49 | } |
| 50 | |
| 51 | var flagSet bool |
| 52 | if cmd.Flags().Changed("display-name") { |
| 53 | flagSet = true |
| 54 | req.DisplayName = &displayName |
| 55 | } |
| 56 | |
| 57 | if cmd.Flags().Changed("description") { |
| 58 | flagSet = true |
| 59 | req.Description = &description |
| 60 | } |
| 61 | |
| 62 | if cmd.Flags().Changed("default-project-role") { |
| 63 | if defaultProjectRole == "none" { |
| 64 | defaultProjectRole = "" |
| 65 | } |
| 66 | req.DefaultProjectRole = &defaultProjectRole |
| 67 | } |
| 68 | |
| 69 | if cmd.Flags().Changed("billing-email") { |
| 70 | flagSet = true |
no test coverage detected