|
| 1 | +--- |
| 2 | +apiVersion: argoproj.io/v1alpha1 |
| 3 | +kind: Sensor |
| 4 | +metadata: |
| 5 | + name: keystone-oslo-event |
| 6 | + annotations: |
| 7 | + workflows.argoproj.io/title: Process oslo_events for keystone project |
| 8 | + workflows.argoproj.io/description: |+ |
| 9 | + Triggers on the following Keystone Events: |
| 10 | +
|
| 11 | + - identity.project.created |
| 12 | + - identity.project.deleted |
| 13 | + - other events are silently ignored now |
| 14 | +
|
| 15 | + Resulting code should be very similar to: |
| 16 | +
|
| 17 | + ``` |
| 18 | + argo -n argo-events submit --from workflowtemplate/openstack-oslo-event \ |
| 19 | + -p event-json "JSON-payload" |
| 20 | + ``` |
| 21 | +
|
| 22 | + Defined in `workflows/argo-events/sensors/keystone-project.yaml` |
| 23 | +spec: |
| 24 | + dependencies: |
| 25 | + - eventName: notifications |
| 26 | + eventSourceName: openstack-keystone |
| 27 | + name: keystone-dep |
| 28 | + transform: |
| 29 | + # the event is a string-ified JSON so we need to decode it |
| 30 | + # replace the whole event body |
| 31 | + jq: | |
| 32 | + .body = (.body["oslo.message"] | fromjson) |
| 33 | + filters: |
| 34 | + # applies each of the items in data with 'and' but there's only one |
| 35 | + dataLogicalOperator: "and" |
| 36 | + data: |
| 37 | + - path: "body.event_type" |
| 38 | + type: "string" |
| 39 | + value: |
| 40 | + - "identity.project.created" |
| 41 | + - "identity.project.deleted" |
| 42 | + template: |
| 43 | + serviceAccountName: sensor-submit-workflow |
| 44 | + triggers: |
| 45 | + - template: |
| 46 | + name: keystone-project |
| 47 | + # uses 'argo' CLI instead of 'kubectl' |
| 48 | + argoWorkflow: |
| 49 | + # sets the operation to 'argo submit' |
| 50 | + operation: submit |
| 51 | + # edits source section |
| 52 | + parameters: |
| 53 | + # first parameter is the parsed oslo.message |
| 54 | + - dest: spec.arguments.parameters.0.value |
| 55 | + src: |
| 56 | + dataKey: body |
| 57 | + dependencyName: keystone-dep |
| 58 | + source: |
| 59 | + # create a workflow in argo-events prefixed with keystone-project- |
| 60 | + resource: |
| 61 | + apiVersion: argoproj.io/v1alpha1 |
| 62 | + kind: Workflow |
| 63 | + metadata: |
| 64 | + generateName: keystone-project- |
| 65 | + namespace: argo-events |
| 66 | + spec: |
| 67 | + # defines the parameters being replaced above |
| 68 | + arguments: |
| 69 | + parameters: |
| 70 | + - name: event-json |
| 71 | + # references the workflow |
| 72 | + workflowTemplateRef: |
| 73 | + name: openstack-oslo-event |
0 commit comments