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
Initially, reclass-rs only implemented features present in [kapicorp-reclass], including extensions introduced by kapicorp-reclass.
4
+
This document covers extensions that are currently unique to reclass-rs.
5
+
6
+
## Non-compatible `compose_node_name` option
7
+
8
+
Reclass-rs supports the `compose_node_name` option.
9
+
By default, in contrast to kapicorp-reclass, reclass-rs preserves literal dots in composed node names.
10
+
For example, given the following inventory, the node's internal path is parsed as `['path', 'to', 'the.node']`:
11
+
12
+
```
13
+
.
14
+
├── classes
15
+
│ ├── cls1.yml
16
+
│ └── cls2.yml
17
+
└── nodes
18
+
└── path
19
+
└── to
20
+
└── the.node.yml
21
+
```
22
+
23
+
However, optionally, reclass-rs can be configured to handle `compose_node_name` the same way that kapicorp-reclass does, by naively splitting node names on each dot.
24
+
To enable this compatibility mode, set `compat_flags: ['ComposeNodeNameLiteralDots']` in your inventory's `reclass-config.yml`.
25
+
In compatibility mode, the node's internal path for the previous inventory is `['path', 'to', 'the', 'node']`.
When verbose warnings are enabled, reclass-rs produces the following informational messages on standard error:
31
+
32
+
* warnings when dropping unrendered values which could potentially contain missing references.
33
+
* informational messages when replacing a missing reference with a default value.
34
+
35
+
## Default values for references
36
+
37
+
> [!IMPORTANT]
38
+
> This feature is currently experimental and may change at any time.
39
+
40
+
Reclass-rs supports specifying default (fallback) values for references.
41
+
The format for specifying a default value is
42
+
43
+
```
44
+
${some:reference:path::the_default_value}
45
+
```
46
+
47
+
We chose `::` as the separator between the reference path and the default value because `::` currently can't appear in references in valid kapicorp-reclass inventories (due to [kapicorp/kapitan#1171](https://github.com/kapicorp/kapitan/issues/1171)).
48
+
49
+
Reclass-rs first resolves nested references in the reference path and default value and then splits the reference contents into the path and default value.
50
+
References with default values can be used everywhere that references are supported, including class includes.
51
+
52
+
> [!NOTE]
53
+
> Currently, default values are only applied once all nested references have been successfully resolved.
54
+
> A missing nested reference without its own default value will result in an error even if the top-level reference specifies a default value.
55
+
56
+
For further processing, the default value is parsed as YAML.
57
+
Incomplete YAML flow values always raise an error (also for existing references that specify an incomplete YAML default value).
58
+
59
+
> [!NOTE]
60
+
> While it's generally possible to specify arbitrarily complex YAML default values inline, we recommend specifying complex default values through a nested reference.
61
+
> When providing complex default values inline, it may be necessary to carefully escape characters of the YAML value in order to ensure the reference parser keeps the YAML value intact.
# Fall back to jsonnet rendering if method isn't configured
109
+
compile: ${_compile:${method::jsonnet}}
110
+
```
111
+
112
+
The rendered parameters for node `test` shown above:
113
+
114
+
```yaml
115
+
parameters:
116
+
_reclass_:
117
+
environment: base
118
+
name:
119
+
full: test
120
+
parts:
121
+
- test
122
+
path: test
123
+
short: test
124
+
_base_directory: /tmp
125
+
_compile:
126
+
helm:
127
+
- helm_values:
128
+
a: a
129
+
b: b
130
+
input_paths:
131
+
- /tmp/charts/foo
132
+
output_path: foo
133
+
type: helm
134
+
jsonnet:
135
+
- input_paths:
136
+
- /tmp/foo.jsonnet
137
+
output_path: foo
138
+
type: jsonnet
139
+
kustomize:
140
+
- input_paths:
141
+
- /tmp/kustomization.jsonnet
142
+
output_path: /tmp/kustomizations/foo
143
+
type: jsonnet
144
+
- input_paths:
145
+
- /tmp/kustomizations/foo/
146
+
output_path: foo
147
+
type: kustomize
148
+
compile:
149
+
- input_paths:
150
+
- /tmp/foo.jsonnet
151
+
output_path: foo
152
+
type: jsonnet
153
+
helm_values:
154
+
a: a
155
+
b: b
156
+
```
157
+
158
+
> [!TIP]
159
+
> This example can also be found as node `n9` and classes `component.defaults` and `component.component` in this repository's `tests/inventory-reference-default-values`.
0 commit comments