Skip to content

Commit e09a9c3

Browse files
author
Tihomir Surdilovic
authored
Replacing jsonpath with jq and adding 'expressionLang' top level property (#249)
* replacing jsonpath with jq Signed-off-by: Tihomir Surdilovic <[email protected]> * updates per comments Signed-off-by: Tihomir Surdilovic <[email protected]> * adding expressionlange prop and description Signed-off-by: Tihomir Surdilovic <[email protected]>
1 parent 21d84a8 commit e09a9c3

13 files changed

+388
-332
lines changed

comparisons/comparison-argo.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ states:
9090
- functionRef:
9191
refName: whalesayimage
9292
arguments:
93-
message: "{{ $.message }}"
93+
message: "${ .message }"
9494
end: true
9595
```
9696
@@ -397,23 +397,23 @@ functions:
397397
metadata:
398398
image: alpine:latest
399399
command: sh, -c
400-
source: 'echo result was: {{inputs.parameters.message}}'
400+
source: 'echo result was: ${ .inputs.parameters.message }'
401401
states:
402402
- name: generate
403403
type: operation
404404
start: true
405405
actions:
406406
- functionRef: gen-random-int-bash
407407
actionDataFilter:
408-
dataResultsPath: "{{ $.results }}"
408+
dataResultsPath: "${ .results }"
409409
transition: print-message
410410
- name: print-message
411411
type: operation
412412
actions:
413413
- functionRef:
414414
refName: printmessagefunc
415415
arguments:
416-
message: "{{ $.results }}"
416+
message: "${ .results }"
417417
end: true
418418
```
419419
@@ -486,14 +486,14 @@ states:
486486
transition: printgreetings
487487
- name: printgreetings
488488
type: foreach
489-
inputCollection: "{{ $.greetings }}"
489+
inputCollection: "${ .greetings }"
490490
iterationParam: greeting
491491
actions:
492492
- name: print-message
493493
functionRef:
494494
refName: whalesay
495495
arguments:
496-
message: "{{ $.greeting }}"
496+
message: "${ .greeting }"
497497
end: true
498498
```
499499
@@ -582,14 +582,14 @@ states:
582582
actions:
583583
- functionRef: flip-coin-function
584584
actionDataFilter:
585-
dataResultsPath: "{{ $.flip.result }}"
585+
dataResultsPath: "${ .flip.result }"
586586
transition: show-flip-results
587587
- name: show-flip-results
588588
type: switch
589589
dataConditions:
590-
- condition: "{{ $.flip[?(@.result == 'heads')] }}"
590+
- condition: "${ .flip | .result == \"heads\" }"
591591
transition: show-results-heads
592-
- condition: "{{ $.flip[?(@.result == 'tails')] }}"
592+
- condition: "${ .flip | .result == \"tails\" }"
593593
transition: show-results-tails
594594
- name: show-results-heads
595595
type: operation
@@ -762,14 +762,14 @@ states:
762762
actions:
763763
- functionRef: flip-coin-function
764764
actionDataFilter:
765-
dataResultsPath: "{{ $.steps.flip-coin.outputs.result }}"
765+
dataResultsPath: "${ .steps.flip-coin.outputs.result }"
766766
transition: flip-coin-check
767767
- name: flip-coin-check
768768
type: switch
769769
dataConditions:
770-
- condition: "{{ $.steps.flip-coin.outputs[?(@.result == 'tails')] }}"
770+
- condition: "${ .steps.flip-coin.outputs | .result == \"tails\" }"
771771
transition: flip-coin-state
772-
- condition: "{{ $.steps.flip-coin.outputs[?(@.result == 'heads')] }}"
772+
- condition: "${ .steps.flip-coin.outputs | .result == \"heads\" }"
773773
transition: heads-state
774774
- name: heads-state
775775
type: operation
@@ -791,7 +791,7 @@ states:
791791
[Argo Example](https://github.com/argoproj/argo/tree/master/examples#exit-handlers)
792792
793793
*Note*: With Serverless Workflow specification we can handle Argos "onExit" functionality
794-
in couple of ways. One is the "onErrors" functionality to define errors and transition to the parts
794+
in a couple of ways. One is the "onErrors" functionality to define errors and transition to the parts
795795
of workflow which is capable of handling the errors.
796796
Another is to send an event at the end of workflow execution
797797
which includes the workflow status. This event can then trigger execution other workflows
@@ -885,14 +885,14 @@ states:
885885
- functionRef:
886886
refName: send-email-function
887887
arguments:
888-
args: 'echo send e-mail: $.workflow.name $.exit-code'
888+
args: "echo send e-mail: ${ .workflow.name } ${ .workflow.status }"
889889
transition: emo-state
890890
- name: emo-state
891891
type: switch
892892
dataConditions:
893-
- condition: "{{ $[?(@.exit_code == '1')] }}"
893+
- condition: "${ .workflow| .status == \"Succeeded\" }"
894894
transition: celebrate-state
895-
- condition: "{{ $[?(@.exit_code != '1')] }}"
895+
- condition: "${ .workflow| .status != \"Succeeded\" }"
896896
transition: cry-state
897897
- name: celebrate-state
898898
type: operation

comparisons/comparison-brigade.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ states:
188188
functionRef:
189189
refName: consoleLogFunction
190190
arguments:
191-
log: Caught Exception ${ .exception }
191+
log: "Caught Exception ${ .exception }"
192192
end: true
193193
```
194194
@@ -403,18 +403,18 @@ states:
403403
- eventRefs:
404404
- execEvent
405405
eventDataFilter:
406-
dataOutputPath: "{{ $.event }}"
406+
dataOutputPath: "${ .event }"
407407
actions:
408408
- name: eventInfoAction
409409
functionRef:
410410
refName: consoleFunction
411411
arguments:
412-
log: ">>> event $event.type caused by $.event.data.provider"
412+
log: ">>> event ${ .event.type } caused by ${ .event.data.provider }"
413413
- name: projectInfoAction
414414
functionRef:
415415
refName: consoleFunction
416416
arguments:
417-
log: ">>> project $event.data.project.name clones the repo at by $.event.data.repo.cloneURL"
417+
log: ">>> project ${ .event.data.project.name } clones the repo at by ${ .event.data.repo.cloneURL }"
418418
end: true
419419

420420
```
@@ -484,18 +484,18 @@ states:
484484
- eventRefs:
485485
- execEvent
486486
eventDataFilter:
487-
dataOutputPath: "{{ $.event }}"
487+
dataOutputPath: "${ .event }"
488488
actions:
489489
- name: helloAction
490490
actionDataFilter:
491-
dataResultsPath: "{{ $.helloResult }}"
491+
dataResultsPath: "${ .helloResult }"
492492
functionRef:
493493
refName: greetingFunction
494494
arguments:
495495
message: hello
496496
- name: worldAction
497497
actionDataFilter:
498-
dataResultsPath: "{{ $.worldResults }}"
498+
dataResultsPath: "${ .worldResults }"
499499
functionRef:
500500
refName: greetingAction
501501
arguments:
@@ -504,8 +504,8 @@ states:
504504
functionRef:
505505
refName: storeToFileFunction
506506
arguments:
507-
destination: "{{ $.event.destination }}"
508-
value: "{{ $.helloResult }} {{ $.worldResults }}"
507+
destination: "${ .event.destination }"
508+
value: "${ .helloResult } ${ .worldResults }"
509509
end: true
510510

511511
```
@@ -572,31 +572,31 @@ states:
572572
- execEvent
573573
actions: []
574574
eventDataFilter:
575-
dataOutputPath: "{{ $.execEvent }}"
575+
dataOutputPath: "${ .execEvent }"
576576
transition:
577577
nextState: NextEventState
578578
produceEvents:
579579
- eventRef: nextEvent
580580
data:
581581
type: next
582582
provider: exec-handler
583-
buildID: "{{ $.execEvent.data.buildID }}"
584-
workerID: "{{ $.execEvent.data.workerID }}"
583+
buildID: "${ .execEvent.data.buildID }"
584+
workerID: "${ .execEvent.data.workerID }"
585585
cause:
586-
event: "{{ $.execEvent }}"
586+
event: "${ .execEvent }"
587587
- name: NextEventState
588588
type: event
589589
onEvents:
590590
- eventRefs:
591591
- nextEvent
592592
eventDataFilter:
593-
dataOutputPath: "{{ $.nextEvent }}"
593+
dataOutputPath: "${ .nextEvent }"
594594
actions:
595595
- name: consoleLogAction
596596
functionRef:
597597
refName: consoleLogFunction
598598
arguments:
599-
log: fired $.nextEvent.data.type caused by $.nextEvent.data.cause.event
599+
log: "fired ${ .nextEvent.data.type } caused by ${ .nextEvent.data.cause.event }"
600600
end: true
601601
```
602602

comparisons/comparison-cadence.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,13 @@ states:
199199
- functionRef:
200200
refName: processfilefunction
201201
arguments:
202-
filename: "{{ $file.name }}"
202+
filename: "${ .file.name }"
203203
actionDataFilter:
204-
dataResultsPath: "{{ $.processed }}"
204+
dataResultsPath: "${ .processed }"
205205
- functionRef:
206206
refName: uploadfunction
207207
arguments:
208-
file: "{{ $processed }}"
208+
file: "${ .processed }"
209209
onErrors:
210210
- error: "*"
211211
retryRef: fileprocessingretry

comparisons/comparison-google-cloud-workflows.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ languages.
9292
"type": "inject",
9393
"start": true,
9494
"data": {
95-
"outputVar": "Hello {{ $.firstName }} {{ $.lastName }}"
95+
"outputVar": "Hello ${ .firstname + \" \" + .lastname }"
9696
},
9797
"stateDataFilter": {
98-
"dataOutputPath": "{{ $.outputVar }}"
98+
"dataOutputPath": "${ .outputVar }"
9999
},
100100
"end": true
101101
}
@@ -206,7 +206,7 @@ instance is created. See the Serverless Workflow ["Workflow Data"](../specificat
206206
]
207207
},
208208
"stateDataFilter": {
209-
"dataOutputPath": "{{ concat($.array.[*]) }}"
209+
"dataOutputPath": "${ .array | join(\"\") }"
210210
},
211211
"end": true
212212
}
@@ -228,10 +228,9 @@ The second step, "exit-loop" is then used alongside the "return" keyword to spec
228228
workflow results.
229229
With Serverless Workflow we can inject the array data via the "inject" state again, or
230230
it can simply be passed as workflow data input. There is no need for looping here as
231-
we can just utilize the JsonPath "concat" method as shown in the states data filter.
231+
we can just utilize the [jq "join" function](https://stedolan.github.io/jq/manual/#join(str)) as shown in the states data filter.
232232
We could use the [ForEach state](../specification.md#ForEach-State) for iteration of
233-
array values, however
234-
it just complicates things and is not needed.
233+
array values, however it would just unnecessarily complicate things.
235234

236235
### Connect Compute Engine
237236

@@ -294,9 +293,9 @@ it just complicates things and is not needed.
294293
"functionRef": {
295294
"refName": "StopComputeEngine",
296295
"arguments": {
297-
"project": "{{ $.project }}",
298-
"zone": "{{ $.zone }}",
299-
"vmToStop": "{{ $.vmToStop }}"
296+
"project": "${ .project }",
297+
"zone": "${ .zone }",
298+
"vmToStop": "${ .vmToStop }"
300299
}
301300
}
302301
}
@@ -424,9 +423,9 @@ as service invocations, where as Google Workflow uses the "call" keyword.
424423
"functionRef": {
425424
"refName": "PublishToTopic",
426425
"arguments": {
427-
"project": "{{ $.project }}",
428-
"topic": "{{ $.topic }}",
429-
"message": "{{ $.message }}"
426+
"project": "${ .project }",
427+
"topic": "${ .topic }",
428+
"message": "${ .message }"
430429
}
431430
}
432431
}
@@ -795,12 +794,12 @@ a separate workflow definition with the "id" parameter set to "calledsubflow" in
795794
"dataConditions": [
796795
{
797796
"name": "Less than 10",
798-
"condition": "{{ $.body[?(@.SomeField < 10)] }}",
797+
"condition": "${ .body | .SomeField < 10 }",
799798
"transition": "CallSmall"
800799
},
801800
{
802801
"name": "Less than 100",
803-
"condition": "{{ $.body[?(@.SomeField < 100)] }}",
802+
"condition": "${ .body | .SomeField < 100 }",
804803
"transition": "CallMedium"
805804
}
806805
],

0 commit comments

Comments
 (0)