/
submit.go
43 lines (35 loc) · 948 Bytes
/
submit.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
package cmd
import (
"fmt"
"github.com/spf13/cobra"
"github.com/G-Research/armada/internal/armadactl"
)
func submitCmd() *cobra.Command {
a := armadactl.New()
cmd := &cobra.Command{
Use: "submit ./path/to/jobs.yaml",
Short: "Submit jobs to armada",
Long: `Submit jobs to armada from file.
Example jobs.yaml:
jobs:
- queue: test
priority: 0
jobSetId: set1
podSpec:
... kubernetes pod spec ...`,
Args: cobra.ExactArgs(1),
PreRunE: func(cmd *cobra.Command, args []string) error {
return initParams(cmd, a.Params)
},
RunE: func(cmd *cobra.Command, args []string) error {
dryRun, err := cmd.Flags().GetBool("dry-run")
if err != nil {
return fmt.Errorf("error reading flag dry-run: %s", err)
}
path := args[0]
return a.Submit(path, dryRun)
},
}
cmd.Flags().Bool("dry-run", false, "Performs basic validation on the submitted file. Does no actual submission of jobs to the server.")
return cmd
}