-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
resubmit.go
69 lines (54 loc) · 2.06 KB
/
resubmit.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
58
59
60
61
62
63
64
65
66
67
68
69
package commands
import (
"github.com/argoproj/pkg/errors"
"github.com/spf13/cobra"
"github.com/argoproj/argo/v3/cmd/argo/commands/client"
workflowpkg "github.com/argoproj/argo/v3/pkg/apiclient/workflow"
)
func NewResubmitCommand() *cobra.Command {
var (
memoized bool
priority int32
cliSubmitOpts cliSubmitOpts
)
var command = &cobra.Command{
Use: "resubmit [WORKFLOW...]",
Short: "resubmit one or more workflows",
Example: `# Resubmit a workflow:
argo resubmit my-wf
# Resubmit and wait for completion:
argo resubmit --wait my-wf.yaml
# Resubmit and watch until completion:
argo resubmit --watch my-wf.yaml
# Resubmit and tail logs until completion:
argo resubmit --log my-wf.yaml
# Resubmit the latest workflow:
argo resubmit @latest
`,
Run: func(cmd *cobra.Command, args []string) {
if cmd.Flag("priority").Changed {
cliSubmitOpts.priority = &priority
}
ctx, apiClient := client.NewAPIClient()
serviceClient := apiClient.NewWorkflowServiceClient()
namespace := client.Namespace()
for _, name := range args {
created, err := serviceClient.ResubmitWorkflow(ctx, &workflowpkg.WorkflowResubmitRequest{
Namespace: namespace,
Name: name,
Memoized: memoized,
})
errors.CheckError(err)
printWorkflow(created, getFlags{output: cliSubmitOpts.output})
waitWatchOrLog(ctx, serviceClient, namespace, []string{created.Name}, cliSubmitOpts)
}
},
}
command.Flags().Int32Var(&priority, "priority", 0, "workflow priority")
command.Flags().StringVarP(&cliSubmitOpts.output, "output", "o", "", "Output format. One of: name|json|yaml|wide")
command.Flags().BoolVarP(&cliSubmitOpts.wait, "wait", "w", false, "wait for the workflow to complete")
command.Flags().BoolVar(&cliSubmitOpts.watch, "watch", false, "watch the workflow until it completes")
command.Flags().BoolVar(&cliSubmitOpts.log, "log", false, "log the workflow until it completes")
command.Flags().BoolVar(&memoized, "memoized", false, "re-use successful steps & outputs from the previous run (experimental)")
return command
}