-
Notifications
You must be signed in to change notification settings - Fork 127
/
commands.go
57 lines (50 loc) · 1.38 KB
/
commands.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package cmd
import (
"github.com/armadaproject/armada/internal/armadactl"
"github.com/spf13/cobra"
)
func createCmd(a *armadactl.App) *cobra.Command {
cmd := &cobra.Command{
Use: "create",
Short: "Create Armada resource. Supported: queue",
PreRunE: func(cmd *cobra.Command, args []string) error {
return initParams(cmd, a.Params)
},
RunE: func(cmd *cobra.Command, args []string) error {
filePath, _ := cmd.Flags().GetString("file")
dryRun, _ := cmd.Flags().GetBool("dry-run")
return a.CreateResource(filePath, dryRun)
},
}
cmd.Flags().StringP("file", "f", "", "specify file for resource creation.")
if err := cmd.MarkFlagRequired("file"); err != nil {
panic(err)
}
cmd.Flags().Bool("dry-run", false, "Validate the input file and exit without making any changes.")
cmd.AddCommand(queueCreateCmd())
return cmd
}
func deleteCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "delete",
Short: "Delete Armada resource. Supported: queue",
}
cmd.AddCommand(queueDeleteCmd())
return cmd
}
func updateCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "update",
Short: "Update Armada resource. Supported: queue",
}
cmd.AddCommand(queueUpdateCmd())
return cmd
}
func getCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "get",
Short: "Retrieve information about armada resource. Supported: queue",
}
cmd.AddCommand(queueGetCmd())
return cmd
}