MCPcopy Index your code
hub / github.com/rilldata/rill / EditCmd

Function EditCmd

cli/cmd/sudo/project/edit.go:11–86  ·  view source on GitHub ↗
(ch *cmdutil.Helper)

Source from the content-addressed store, hash-verified

9)
10
11func EditCmd(ch *cmdutil.Helper) *cobra.Command {
12 var prodSlots, devSlots int
13 var prodVersion string
14 var overrideDiskGB int64
15
16 editCmd := &cobra.Command{
17 Use: "edit <org> <project>",
18 Args: cobra.ExactArgs(2),
19 Short: "Edit the project details",
20 RunE: func(cmd *cobra.Command, args []string) error {
21 ctx := cmd.Context()
22
23 req := &adminv1.UpdateProjectRequest{
24 Org: args[0],
25 Project: args[1],
26 SuperuserForceAccess: true,
27 }
28
29 isEditRequested := false
30 if cmd.Flags().Changed("prod-slots") {
31 if prodSlots <= 0 {
32 return fmt.Errorf("--prod-slots must be greater than zero")
33 }
34 prodSlotsInt64 := int64(prodSlots)
35 req.ProdSlots = &prodSlotsInt64
36 isEditRequested = true
37 }
38 if cmd.Flags().Changed("prod-version") {
39 req.ProdVersion = &prodVersion
40 isEditRequested = true
41 }
42 if cmd.Flags().Changed("dev-slots") {
43 if devSlots <= 0 {
44 return fmt.Errorf("--dev-slots must be greater than zero")
45 }
46 devSlotsInt64 := int64(devSlots)
47 req.DevSlots = &devSlotsInt64
48 isEditRequested = true
49 }
50 if cmd.Flags().Changed("override-disk-gb") {
51 if overrideDiskGB < 0 {
52 return fmt.Errorf("--override-disk-gb must be >= 0 (use 0 to clear the override)")
53 }
54 v := overrideDiskGB
55 req.OverrideDiskGb = &v
56 isEditRequested = true
57 }
58
59 if !isEditRequested {
60 ch.Printf("No edit requested\n")
61 return nil
62 }
63
64 client, err := ch.Client()
65 if err != nil {
66 return err
67 }
68

Callers 1

ProjectCmdFunction · 0.70

Calls 7

PrintfMethod · 0.80
PrintfSuccessMethod · 0.80
PrintProjectsMethod · 0.80
ContextMethod · 0.65
ErrorfMethod · 0.65
UpdateProjectMethod · 0.65
ClientMethod · 0.45

Tested by

no test coverage detected