Skip to content

Commit

Permalink
feat: add terminate event (argoproj#1268)
Browse files Browse the repository at this point in the history
* add terminate operation for argo workflows

Signed-off-by: nilsorbat <nils@orbat.sh>

* improve docs for terminating a workflow

Signed-off-by: nilsorbat <nils@orbat.sh>
  • Loading branch information
orbatschow authored Jun 28, 2021
1 parent 3f7a628 commit 37d5d0d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion controllers/sensor/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func validateArgoWorkflowTrigger(trigger *v1alpha1.ArgoWorkflowTrigger) error {
return errors.New("must provide group, version and resource for the resource")
}
switch trigger.Operation {
case v1alpha1.Submit, v1alpha1.Suspend, v1alpha1.Retry, v1alpha1.Resume, v1alpha1.Resubmit:
case v1alpha1.Submit, v1alpha1.Suspend, v1alpha1.Retry, v1alpha1.Resume, v1alpha1.Resubmit, v1alpha1.Terminate:
default:
return errors.Errorf("unknown operation type %s", string(trigger.Operation))
}
Expand Down
2 changes: 1 addition & 1 deletion docs/sensors/triggers/argo-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ To make use of Argo CLI operations, The sensor provides the `argoWorkflow` trigg
group: argoproj.io
version: v1alpha1
resource: workflows
operation: submit # submit, resubmit, resume, retry or suspend
operation: submit # submit, resubmit, resume, retry, suspend or terminate

Complete example is available [here](https://raw.githubusercontent.com/argoproj/argo-events/stable/examples/sensors/special-workflow-trigger.yaml).
11 changes: 6 additions & 5 deletions pkg/apis/sensor/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ type ArgoWorkflowOperation string

// possible values for ArgoWorkflowOperation
const (
Submit ArgoWorkflowOperation = "submit" // submit a workflow
Suspend ArgoWorkflowOperation = "suspend" // suspends a workflow
Resubmit ArgoWorkflowOperation = "resubmit" // resubmit a workflow
Retry ArgoWorkflowOperation = "retry" // retry a workflow
Resume ArgoWorkflowOperation = "resume" // resume a workflow
Submit ArgoWorkflowOperation = "submit" // submit a workflow
Suspend ArgoWorkflowOperation = "suspend" // suspends a workflow
Resubmit ArgoWorkflowOperation = "resubmit" // resubmit a workflow
Retry ArgoWorkflowOperation = "retry" // retry a workflow
Resume ArgoWorkflowOperation = "resume" // resume a workflow
Terminate ArgoWorkflowOperation = "terminate" // terminate a workflow
)

// Comparator refers to the comparator operator for a data filter
Expand Down
2 changes: 2 additions & 0 deletions sensors/triggers/argo-workflow/argo-workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ func (t *ArgoWorkflowTrigger) Execute(ctx context.Context, events map[string]*v1
cmd = exec.Command("argo", "-n", namespace, "retry", name)
case v1alpha1.Suspend:
cmd = exec.Command("argo", "-n", namespace, "suspend", name)
case v1alpha1.Terminate:
cmd = exec.Command("argo", "-n", namespace, "terminate", name)
default:
return nil, errors.Errorf("unknown operation type %s", string(op))
}
Expand Down

0 comments on commit 37d5d0d

Please sign in to comment.