Skip to content

Commit fdaad5f

Browse files
committed
fix: handle keys with dot in the name
Argo Events does not support accessing the event data if the key includes the dot because there is no known way to escape that dot and the square bracket notation cannot be used in dataKey or contextKey. This workaround simply copies the value of the ironic_object.data into body.ironic_object. We could theoretically delete the old copy, but I'm keeping it around in case the original value needs to be consumed.
1 parent f544403 commit fdaad5f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

workflows/openstack/sensors/sensor-ironic-oslo-event.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ metadata:
1414
1515
```
1616
argo -n argo-events submit --from workflowtemplate/ironic-oslo-event \
17-
-p event-json "JSON-payload"
17+
-p event-json "JSON-payload" -p device_id=<UUID> -p project_id=<UUID>
1818
```
1919
2020
Defined in `workflows/argo-events/sensors/sensor-ironic-oslo-event.yaml`
@@ -27,7 +27,10 @@ spec:
2727
# the event is a string-ified JSON so we need to decode it
2828
# replace the whole event body
2929
jq: |
30-
.body = (.body["oslo.message"] | fromjson)
30+
(
31+
.body = (.body["oslo.message"] | fromjson) |
32+
.body.ironic_object = .body.payload["ironic_object.data"]
33+
)
3134
filters:
3235
# applies each of the items in data with 'and' but there's only one
3336
dataLogicalOperator: "and"
@@ -52,11 +55,11 @@ spec:
5255
dependencyName: ironic-dep
5356
- dest: spec.arguments.parameters.1.value # device_id
5457
src:
55-
dataKey: body.payload.ironic_object\.data.uuid
58+
dataKey: body.ironic_object.uuid
5659
dependencyName: ironic-dep
5760
- dest: spec.arguments.parameters.2.value # project_id
5861
src:
59-
dataKey: body.payload.ironic_object\.data.lessee
62+
dataKey: body.ironic_object.lessee
6063
dependencyName: ironic-dep
6164
source:
6265
# create a workflow in argo-events prefixed with ironic-prov-

0 commit comments

Comments
 (0)