forked from argoproj/argo-workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
suspend.go
35 lines (31 loc) · 1.01 KB
/
suspend.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
package cron
import (
"fmt"
"github.com/argoproj/pkg/errors"
"github.com/spf13/cobra"
"github.com/svnshing/argo-workflows/v3/cmd/argo/commands/client"
cronworkflowpkg "github.com/svnshing/argo-workflows/v3/pkg/apiclient/cronworkflow"
)
// NewSuspendCommand returns a new instance of an `argo suspend` command
func NewSuspendCommand() *cobra.Command {
command := &cobra.Command{
Use: "suspend CRON_WORKFLOW...",
Short: "suspend zero or more cron workflows",
Run: func(cmd *cobra.Command, args []string) {
ctx, apiClient := client.NewAPIClient(cmd.Context())
serviceClient, err := apiClient.NewCronWorkflowServiceClient()
errors.CheckError(err)
namespace := client.Namespace()
for _, name := range args {
cronWf, err := serviceClient.SuspendCronWorkflow(ctx, &cronworkflowpkg.CronWorkflowSuspendRequest{
Name: name,
Namespace: namespace,
})
errors.CheckError(err)
cronWf.Spec.Suspend = true
fmt.Printf("CronWorkflow '%s' suspended\n", name)
}
},
}
return command
}