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
Copy file name to clipboardExpand all lines: modules/cluster-compare-configure-inline-diff.adoc
+11-3Lines changed: 11 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,8 @@ The `cluster-compare` plugin provides two functions for inline validation:
14
14
* `regex`: Validates content in a field using a regular expression.
15
15
* `capturegroups`: Enhances multi-line text comparisons by processing non-capture group text as exact matches, applying regular expression matching only within named capture groups, and ensuring consistency for repeated capture groups.
16
16
17
+
When using the `regex` or `capturegroups` function for inline validation, the `cluster-compare` plugin enforces that identically named capture groups match the same values across multiple fields within a template. This means that if a named capture group, such as `(?<username>[a-z0-9]+)`, appears in multiple fields, the values for that group must remain consistent throughout the template.
18
+
17
19
[id="cluster-compare-configure-regex_{context}"]
18
20
== Configuring inline validation with the regex function
19
21
@@ -49,6 +51,7 @@ kind: ConfigMap
49
51
metadata:
50
52
namespace: dashboard
51
53
data:
54
+
username: "(?<username>[a-z0-9]+)"
52
55
bigTextBlock: |-
53
56
This is a big text block with some static content, like this line.
54
57
It also has a place where (?<username>[a-z0-9]+) would put in their own name. (?<username>[a-z0-9]+) would put in their own name.
== Configuring inline validation with the capturegroups function
59
62
60
-
Use the `capturegroups` inline function for more precise validation of fields featuring multi-line strings.
63
+
Use the `capturegroups` inline function for more precise validation of fields featuring multi-line strings. This function also ensures that identically named capture groups match the same values across multiple fields.
61
64
62
65
.Procedure
63
66
@@ -74,11 +77,15 @@ parts:
74
77
- path: example.yaml
75
78
config:
76
79
perField:
77
-
- pathToKey: spec.bigTextBlock <1>
78
-
inlineDiffFunc: capturegroups <2>
80
+
- pathToKey: data.username <1>
81
+
inlineDiffFunc: regex <2>
82
+
- pathToKey: spec.bigTextBlock <3>
83
+
inlineDiffFunc: capturegroups <4>
79
84
----
80
85
<1> Specifies the field for inline validation.
81
86
<2> Enables inline validation using capture groups.
87
+
<3> Specifies the multi-line field for capture group validation.
88
+
<4> Enables inline validation using capture groups.
82
89
83
90
. Use a regular expression to validate the field in the associated template:
84
91
+
@@ -89,6 +96,7 @@ kind: ConfigMap
89
96
metadata:
90
97
namespace: dashboard
91
98
data:
99
+
username: "(?<username>[a-z0-9]+)"
92
100
bigTextBlock: |-
93
101
This static content outside of a capture group should match exactly.
94
102
Here is a username capture group: (?<username>[a-z0-9]+).
Copy file name to clipboardExpand all lines: modules/cluster-compare-reference-args.adoc
+4-1Lines changed: 4 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,6 +29,9 @@ The following content describes the options for the `cluster-compare` plugin.
29
29
| `--generate-override-for`
30
30
| Specify the path for templates that requires a patch.
31
31
32
+
| `--show-template-functions`
33
+
| Displays the available template functions.
34
+
32
35
[NOTE]
33
36
====
34
37
You must use a file path for the target template that is relative to the `metadata.yaml` file. For example, if the file path for the `metadata.yaml` file is `./compare/metadata.yaml`, a relative file path for the template might be `optional/my-template.yaml`.
@@ -41,7 +44,7 @@ You must use a file path for the target template that is relative to the `metada
41
44
| Specify a path to process the `kustomization` directory. This flag cannot be used together with `-f` or `-R`.
42
45
43
46
| `-o`, `--output`
44
-
| Specify the output format. Options include `json`, `yaml`, or `generate-patches`.
47
+
| Specify the output format. Options include `json`, `yaml`, `junit`, or `generate-patches`.
The `cluster-compare` plugin supports all `sprig` library functions, except for the `env` and `expandenv` functions.
11
+
See _Additional resources_ for the full list of `sprig` library functions.
12
+
13
+
The following content describes the additional template functions for the `cluster-compare` plugin.
14
+
15
+
.Additional cluster-compare template functions
16
+
[options="header"]
17
+
[cols="2a,3a"]
18
+
|====
19
+
| Function | Description
20
+
21
+
|`fromJson`
22
+
|Parses the incoming string as a structured JSON object.
23
+
24
+
|`fromJsonArray`
25
+
|Parses the incoming string as a structured JSON array.
26
+
27
+
|`fromYaml`
28
+
|Parses the incoming string as a structured YAML object.
29
+
30
+
|`fromYamlArray`
31
+
|Parses the incoming string as a structured YAML array.
32
+
33
+
|`toJson`
34
+
|Renders incoming data as JSON while preserving object types.
35
+
36
+
|`toToml`
37
+
|Renders the incoming string as structured TOML data.
38
+
39
+
|`toYaml`
40
+
|Renders incoming data as YAML while preserving object types.
41
+
42
+
|`doNotMatch`
43
+
|Prevents a template from matching a cluster resource, even if it would normally match. You can use this function inside a template to conditionally exclude certain resources from correlation. The specified reason is logged when running with the `--verbose` flag. Templates skipped solely due to `doNotMatch` are not considered comparison failures.
0 commit comments