blueprints: Added conditional entry application (#4167)
* blueprints: Added !AsBool tag * Renamed AsBool tag to Condition * Added conditions attributed to BlueprintEntry * Added docs for the conditions attribute of a blueprint entry * Website linting fix * add new tag to vscode settings Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> Co-authored-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
@ -25,6 +25,18 @@ entries:
|
||||
# the object is created (and create it with the values given here), and "absent" will
|
||||
# delete the object
|
||||
state: present
|
||||
# An optional list of boolean-like conditions. If all conditions match (or
|
||||
# no condiitons are provided) the entry will be evaluated and acted upon
|
||||
# as normal. Otherwise, the entry is skipped as if not defined at all.
|
||||
# Each condition will be evaluated in Python to its boolean representation
|
||||
# bool(<condition>). Furthermore, complex conditions can be built using
|
||||
# a special !Condition tag. See the documentattion for custom tags for more
|
||||
# information.
|
||||
conditions:
|
||||
- true
|
||||
- text
|
||||
- 2
|
||||
- !Condition [AND, ...] # See custom tags section
|
||||
# Key:value filters to uniquely identify this object (required)
|
||||
identifiers:
|
||||
slug: initial-setup
|
||||
|
@ -38,3 +38,28 @@ Find values from the context. Can optionally be called with a default like `!Con
|
||||
Example: `name: !Format [my-policy-%s, !Context instance_name]`
|
||||
|
||||
Format a string using python's % formatting. First argument is the format string, any remaining arguments are used for formatting.
|
||||
|
||||
#### `!Condition`
|
||||
|
||||
Minimal example:
|
||||
|
||||
`required: !Condition [OR, true]`
|
||||
|
||||
Full example:
|
||||
|
||||
```
|
||||
required: !Condition [
|
||||
AND, # Valid modes are: AND, NAND, OR, NOR, XOR, XNOR
|
||||
!Context instance_name,
|
||||
!Find [authentik_flows.flow, [slug, default-password-change],
|
||||
"My string",
|
||||
123
|
||||
]
|
||||
```
|
||||
|
||||
Converts one or more arguments to their boolean representations, then merges all representations together.
|
||||
Requires at least one argument after the mode selection.
|
||||
|
||||
If only a single argument is provided, its boolean representation will be returned for all normal modes and its negated boolean representation will be returned for all negated modes.
|
||||
|
||||
Normally, it should be used to define complex conditions for the `conditions` attribute of a blueprint entry (see [the blueprint file structure](./structure.md)). However, this is essentially just a boolean evaluator so it can be used everywhere a boolean representation is required.
|
||||
|
Reference in New Issue
Block a user