File tree 1 file changed +67
-0
lines changed 1 file changed +67
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Liquid conditions examples
2
+
3
+ You can use Liquid to configure conditions applicable across multiple policies to <insert_purpose>
4
+ of conditions that can be used across multiple policies
5
+
6
+
7
+ ## Headers
8
+
9
+ ### Header is not present
10
+
11
+ Condition passes if the 'Backend' header is sent and it's staging
12
+
13
+ ```
14
+ "condition":{
15
+ "operations":[
16
+ {
17
+ "left":" {% if headers['Backend'] %}{{ headers['Backend'] }}{%else%}Notpresent{%endif%}",
18
+ "left_type":"liquid",
19
+ "op":"==",
20
+ "right":"staging"
21
+ }
22
+ ]
23
+ }
24
+ ```
25
+
26
+ If you want to test when the ` Backend ` header is not present, the condition is as follows:
27
+
28
+ ```
29
+ "condition":{
30
+ "operations":[
31
+ {
32
+ "left":" {% if headers['Backend'] %}IsPresent{%else%}Notpresent{%endif%}",
33
+ "left_type":"liquid",
34
+ "op":"==",
35
+ "right":"Notpresent"
36
+ }
37
+ ]
38
+ }
39
+ ```
40
+
41
+ ## Numeric operations
42
+
43
+ Numeric operations require additional steps. By default, all the values on liquid are strings, so you need
44
+ to get any integer before do any operation. Use ` minus ` or ` plus `
45
+ filters along with ` 0 ` (zero), and apply the following configuration:
46
+
47
+
48
+ ```
49
+ "condition":{
50
+ "operations":[
51
+ {
52
+ "left": "{% assign val = headers['version'] | minus:0 %} {%if val < 20 %}PASS{%else%}DENIED{%endif%}",
53
+ "left_type":"liquid",
54
+ "op":"==",
55
+ "right":"PASS"
56
+ }
57
+ ]
58
+ }
59
+ ```
60
+
61
+ @TODO : something like a int filter should be added.
62
+ @TODO : default filter should be added too.
63
+
64
+
65
+ ## Additional examples:
66
+
67
+ [ How to send different headers according to the Application Plan] ( https://access.redhat.com/solutions/3925031 )
You can’t perform that action at this time.
0 commit comments