You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The ` merge` command offers the option `--partial`. If this option is
176
-
given spiff handles incomplete expression evaluation. All errors are ignored
177
-
and the unresolvable parts of the yaml document are returned as strings.
178
-
179
178
It is possible to read one file from standard input by using the file
180
179
name `-`. It may be used only once. This allows using spiff as part of a
181
180
pipeline to just process a single stream or to process a stream based on
@@ -188,12 +187,32 @@ The result is the stream of processed documents in the same order.
188
187
For example, this can be used to generate *kubernetes* manifests to be used
189
188
by `kubectl`.
190
189
191
-
With the option `--json` the output will be in JSON format instead of YAML.
192
-
The Option `--path <path>` can be used to output a nested path, instead of the
193
-
the complete processed document.
190
+
The ` merge` command offers several options:
194
191
195
-
If the output is a list, the option `--split` outputs every list element as
196
-
deparate document.
192
+
- The option `--partial`. If this option is
193
+
given spiff handles incomplete expression evaluation. All errors are ignored
194
+
and the unresolvable parts of the yaml document are returned as strings.
195
+
196
+
- With the option `--json` the output will be in JSON format instead of YAML.
197
+
198
+
- The Option `--path <path>` can be used to output a nested path, instead of the
199
+
the complete processed document.
200
+
201
+
- If the output is a list, the option `--split` outputs every list element as
202
+
separate documen. The _yaml_ format uses as usual `---` as separator line.
203
+
The _json_ format outputs a sequence of _json_ documents, one per line.
204
+
205
+
- With `--select <field path>` is is possible to select a dedicated field of the
206
+
processed document for the output
207
+
208
+
- The option `--state <path>` enables the state support of _spiff_. If the
209
+
given file exists it is put on top of the configured stub list for the
210
+
merge processing. Additionally to the output of the processed document
211
+
it is filtered for nodes marked with the [`&state` marker](#-state-).
212
+
This filtered document is then stored under the denoted file, saving the old
213
+
state file with the `.bak` suffix. This can be used together with a manual
214
+
merging as offered by the [state](libraries/state/README.md) utility library.
215
+
197
216
198
217
The folder [libraries](libraries/README.md) offers some useful
199
218
utility libraries. They can also be used as an example for the power
@@ -2876,85 +2895,6 @@ value: (( .mult2(3) ))
2876
2895
2877
2896
If a complete expression is a lambda expression the keyword `lambda` can be omitted.
2878
2897
2879
-
## `(( &temporary ))`
2880
-
2881
-
Maps, lists or simple value nodes can be marked as *temporary*. Temporary nodes are removed from the final output document, but are available during merging and dynaml evaluation.
2882
-
2883
-
e.g.:
2884
-
2885
-
```yaml
2886
-
temp:
2887
-
<<: (( &temporary ))
2888
-
foo: bar
2889
-
2890
-
value: (( temp.foo ))
2891
-
```
2892
-
2893
-
yields:
2894
-
2895
-
```yaml
2896
-
value: bar
2897
-
```
2898
-
Adding `- <<: (( &temporary ))` to a list can be used to mark a list as temporary.
2899
-
2900
-
The temporary marker can be combined with regular dynaml expressions to tag plain fields. Hereby the
2901
-
parenthesised expression is just appended to the marker
2902
-
2903
-
e.g.:
2904
-
2905
-
```yaml
2906
-
data:
2907
-
alice: (( &temporary ( "bar" ) ))
2908
-
foo: (( alice ))
2909
-
```
2910
-
2911
-
yields:
2912
-
2913
-
```yaml
2914
-
data:
2915
-
foo: bar
2916
-
```
2917
-
2918
-
The temporary marker can be combined with the [template marker](#templates) to omit templates from the final output.
2919
-
2920
-
The marker `&local` acts similar to `&temporary` but local nodes are always
2921
-
removed from a stub directly after resolving dynaml expressions. Such nodes
2922
-
are therefore not available for merging.
2923
-
2924
-
## `(( &inject ))`
2925
-
2926
-
This marker requests the marked item to be injected into the next stub level,
2927
-
even is the hosting element (list or map) does not requests a merge.
2928
-
This only works if the next level stub already contains the hosting element.
2929
-
2930
-
e.g.:
2931
-
2932
-
**template.yaml**
2933
-
```yaml
2934
-
alice:
2935
-
foo: 1
2936
-
```
2937
-
2938
-
**stub.yaml**
2939
-
```yaml
2940
-
alice:
2941
-
bar: (( &inject(2) ))
2942
-
nope: not injected
2943
-
bob:
2944
-
<<: (( &inject ))
2945
-
foobar: yep
2946
-
2947
-
```
2948
-
2949
-
is merged to
2950
-
2951
-
```yaml
2952
-
alice:
2953
-
foo: 1
2954
-
bar: 2
2955
-
bob:
2956
-
foobar: yep
2957
-
```
2958
2898
## `(( catch[expr|v,e|->v] ))`
2959
2899
2960
2900
This expression evaluates an expression (`expr`) and then
@@ -3412,6 +3352,130 @@ names:
3412
3352
- peter
3413
3353
```
3414
3354
3355
+
## Markers
3356
+
3357
+
Nodes of the yaml document can be marked to enable dedicated behaviours for this
3358
+
node. Such markers are part of the _dynaml_ syntax and may be prepended to
3359
+
any dynaml expression. They are denoted by the `&` character directly followed
3360
+
by a marker name. If the expression is combination of markers and regular
3361
+
expressions, the expression follows the marker list enclosed in brackets
3362
+
(for example `(( &temporary( a + b ) ))`).
3363
+
3364
+
### `(( &temporary ))`
3365
+
3366
+
Maps, lists or simple value nodes can be marked as *temporary*. Temporary nodes
3367
+
are removed from the final output document, but are available during merging and
3368
+
dynaml evaluation.
3369
+
3370
+
e.g.:
3371
+
3372
+
```yaml
3373
+
temp:
3374
+
<<: (( &temporary ))
3375
+
foo: bar
3376
+
3377
+
value: (( temp.foo ))
3378
+
```
3379
+
3380
+
yields:
3381
+
3382
+
```yaml
3383
+
value: bar
3384
+
```
3385
+
Adding `- <<: (( &temporary ))` to a list can be used to mark a list as temporary.
3386
+
3387
+
The temporary marker can be combined with regular dynaml expressions to tag plain fields. Hereby the
3388
+
parenthesised expression is just appended to the marker
3389
+
3390
+
e.g.:
3391
+
3392
+
```yaml
3393
+
data:
3394
+
alice: (( &temporary ( "bar" ) ))
3395
+
foo: (( alice ))
3396
+
```
3397
+
3398
+
yields:
3399
+
3400
+
```yaml
3401
+
data:
3402
+
foo: bar
3403
+
```
3404
+
3405
+
The temporary marker can be combined with the [template marker](#templates) to omit templates from the final output.
3406
+
3407
+
### `(( &local ))`
3408
+
3409
+
The marker `&local` acts similar to `&temporary` but local nodes are always
3410
+
removed from a stub directly after resolving dynaml expressions. Such nodes
3411
+
are therefore not available for merging and they are not used for further
3412
+
merging of stubs and finally the template.
3413
+
3414
+
3415
+
### `(( &inject ))`
3416
+
3417
+
This marker requests the marked item to be injected into the next stub level,
3418
+
even is the hosting element (list or map) does not requests a merge.
3419
+
This only works if the next level stub already contains the hosting element.
3420
+
3421
+
e.g.:
3422
+
3423
+
**template.yaml**
3424
+
```yaml
3425
+
alice:
3426
+
foo: 1
3427
+
```
3428
+
3429
+
**stub.yaml**
3430
+
```yaml
3431
+
alice:
3432
+
bar: (( &inject(2) ))
3433
+
nope: not injected
3434
+
bob:
3435
+
<<: (( &inject ))
3436
+
foobar: yep
3437
+
3438
+
```
3439
+
3440
+
is merged to
3441
+
3442
+
```yaml
3443
+
alice:
3444
+
foo: 1
3445
+
bar: 2
3446
+
bob:
3447
+
foobar: yep
3448
+
```
3449
+
3450
+
### `(( &state ))`
3451
+
3452
+
Nodes marked as *state* are handled during the merge processing as if the
3453
+
marker would not be present. But there will be a special handling for enabled
3454
+
state processing [(option `--state <path>`)](#usage) at the end of the
3455
+
template processing.
3456
+
Additionally to the regular output a document consisting only of state nodes
3457
+
(plus all nested nodes) will be written to a state file. This file will be used
3458
+
as top-level stub for further merge processings with enabled state support.
3459
+
3460
+
This enables to keep state between two merge processings. For regular
3461
+
merging sich nodes are only processed during the first processing. Later
3462
+
processings will keep the state from the first one, because those nodes
3463
+
will be overiden by the state stub added to the end of the sub list.
3464
+
3465
+
If those nodes additionally disable merging (for example using
3466
+
`(( &state(merge none) ))`) dynaml expressions in sub level nodes may
3467
+
perform explicit merging using the function `stub()` to refer to
3468
+
values provided by already processed stubs (especially the implicitly added
3469
+
state stub). For an example please refer to the
3470
+
[state library](libraries/state/README.md).
3471
+
3472
+
### `(( &template ))`
3473
+
3474
+
Nodes marked as *template* will not be evaluated at the place of their
3475
+
occurrence. Instead, they will result in a template value stored as value for
3476
+
the node. They can later be instantiated inside a _dynaml_ expression
3477
+
(see [below](#templates)).
3478
+
3415
3479
## Templates
3416
3480
3417
3481
A map can be tagged by a dynaml expression to be used as template. Dynaml expressions in a template are not evaluated at its definition location in the document, but can be inserted at other locations using dynaml.
@@ -3441,7 +3505,7 @@ The template marker can be combined with the [temporary marker](#-temporary-) to
3441
3505
3442
3506
### `(( *foo.bar ))`
3443
3507
3444
-
The dynaml expression `*<refernce expression>` can be used to evaluate a template somewhere in the yaml document.
3508
+
The dynaml expression `*<reference expression>` can be used to evaluate a template somewhere in the yaml document.
3445
3509
Dynaml expressions in the template are evaluated in the context of this expression.
0 commit comments