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
Template functions in the config context are available when rendering an application that includes the KOTS [Config](/reference/custom-resource-config) custom resource, which defines the KOTS Admin Console config screen. At execution time, template functions in the config context also can use the static context functions. For more information about configuring the Admin Console config screen, see [About the Configuration Screen](/vendor/config-screen-about).
Template functions in the kURL context have access to information about applications installed with Replicated kURL. For more information about kURL, see [Introduction to kURL](/vendor/kurl-about).
Template functions in the license context have access to customer license and version data. For more information about managing customer licenses, see [About Customers and Licensing](/vendor/licenses-about).
The context necessary to render the static template functions is always available.
2
+
3
+
The static context also includes the Masterminds Sprig function library. For more information, see [Sprig Function Documentation](http://masterminds.github.io/sprig/) on the sprig website.
@@ -126,33 +132,32 @@ KOTS template functions are grouped into different contexts, depending on the ph
126
132
127
133
### Static Context
128
134
129
-
The context necessary to render the static template functions is always available.
135
+
<StaticContext/>
130
136
131
-
The static context also includes the Masterminds Sprig function library. For more information, see [Sprig Function Documentation](http://masterminds.github.io/sprig/) on the sprig website.
132
-
133
-
For a list of all KOTS template functions available in the static context, see [Static context](template-functions-static-context).
137
+
For a list of all KOTS template functions available in the static context, see [Static Context](template-functions-static-context).
134
138
135
139
### Config Context
136
140
137
-
Template functions in the config context are available when rendering an application that includes a Config custom resource.
138
-
At execution time, template functions in the config context also can use the static context functions.
141
+
<ConfigContext/>
139
142
140
-
For a list of all KOTS template functions available in the config context, see [Config context](template-functions-config-context).
143
+
For a list of all KOTS template functions available in the config context, see [Config Context](template-functions-config-context).
141
144
142
145
### License Context
143
146
144
-
Template functions in the license context have access to customer license and version data.
147
+
<LicenseContext/>
145
148
146
-
For a list of all KOTS template functions available in the license context, see [License context](template-functions-license-context).
149
+
For a list of all KOTS template functions available in the license context, see [License Context](template-functions-license-context).
147
150
148
151
### kURL Context
149
152
150
-
Template functions in the kURL context have access to information about applications installed in embedded clusters created by Replicated kURL.
153
+
<KurlAvailability/>
154
+
155
+
<KurlContext/>
151
156
152
-
For a list of all KOTS template functions available in the kURL context, see [kURL context](template-functions-kurl-context).
157
+
For a list of all KOTS template functions available in the kURL context, see [kURL Context](template-functions-kurl-context).
153
158
154
159
### Identity Context
155
160
156
-
Template functions in the Identity context have access to Replicated identity service information.
161
+
<IdentityContext/>
157
162
158
-
For a list of all KOTS template functions available in the identity context, see [Identity context](template-functions-identity-context).
163
+
For a list of all KOTS template functions available in the identity context, see [Identity Context](template-functions-identity-context).
import ConfigContext from "../partials/template-functions/_config-context.mdx"
2
+
1
3
# Config Context
2
4
5
+
<ConfigContext/>
6
+
3
7
## ConfigOption
4
8
5
9
```go
6
10
funcConfigOption(optionNamestring) string
7
11
```
8
12
9
-
Returns the value of the config option as a string.
13
+
Returns the value of the specified option from the KOTS Config custom resource as a string.
10
14
11
-
For information about the config screen and associated options, see [Config](custom-resource-config) in the _Custom Resources_ section.
15
+
For the `file` config option type, `ConfigOption` returns the base64 encoded file. To return the decoded contents of a file, use [ConfigOptionData](#configoptiondata) instead.
12
16
13
17
```yaml
14
18
'{{repl ConfigOption "hostname" }}'
15
19
```
16
20
17
-
`ConfigOption` returns the base64 **encoded** value of the `file` config option.
21
+
#### Example
18
22
19
-
```yaml
20
-
'{{repl ConfigOption "ssl_key"}}'
21
-
```
23
+
The following KOTS [HelmChart](/reference/custom-resource-helmchart-v2) custom resource uses the ConfigOption template function to set the port, node port, and annotations for a LoadBalancer service using the values supplied by the user on the KOTS Admin Console config screen. These values are then mapped to the `values.yaml` file for the associated Helm chart during deployment.
For more information about using TLS certificates, see [Using TLS Certificates](../vendor/packaging-using-tls-certs).
43
+
For more information, see [Setting Helm Values with KOTS](/vendor/helm-optional-value-keys).
36
44
37
45
## ConfigOptionData
38
46
39
47
```go
40
48
func ConfigOptionData(optionName string) string
41
49
```
42
50
43
-
`ConfigOptionData` returns the base64 **decoded** value of a `file` config option.
51
+
For the `file` config option type, `ConfigOptionData` returns the base64 decoded contents of the file. To return the base64 encoded file, use [ConfigOption](#configoption) instead.
44
52
45
53
```yaml
46
54
'{{repl ConfigOptionData "ssl_key"}}'
47
55
```
48
56
49
-
To use files in a ConfigMap, use `ConfigOptionData`:
57
+
#### Example
58
+
59
+
The following KOTS [HelmChart](/reference/custom-resource-helmchart-v2) custom resource uses the ConfigOptionData template function to set the TLS cert and key using the files supplied by the user on the KOTS Admin Console config screen. These values are then mapped to the `values.yaml` file for the associated Helm chart during deployment.
For more information, see [Setting Helm Values with KOTS](/vendor/helm-optional-value-keys).
62
80
63
81
## ConfigOptionFilename
64
82
@@ -73,7 +91,9 @@ It will return an empty string if used erroneously with other types.
73
91
'{{repl ConfigOptionFilename "pom_file"}}'
74
92
```
75
93
76
-
As an example, if you have the following Config Spec defined:
94
+
#### Example
95
+
96
+
For example, if you have the following KOTS Config defined:
77
97
78
98
```yaml
79
99
apiVersion: kots.io/v1beta1
@@ -91,7 +111,8 @@ spec:
91
111
required: true
92
112
```
93
113
94
-
You can use `ConfigOptionFilename` in a Pod Spec to mount a file like so:
114
+
The following example shows how to use `ConfigOptionFilename` in a Pod Spec to mount a file:
115
+
95
116
```yaml
96
117
apiVersion: v1
97
118
kind: Pod
@@ -137,6 +158,26 @@ Returns true if the configuration option value is equal to the supplied value.
137
158
'{{repl ConfigOptionEquals "http_enabled""1" }}'
138
159
```
139
160
161
+
#### Example
162
+
163
+
The following KOTS [HelmChart](/reference/custom-resource-helmchart-v2) custom resource uses the ConfigOptionEquals template function to set the `postgres.enabled` value depending on if the user selected the `embedded_postgres` option on the KOTS Admin Console config screen. This value is then mapped to the `values.yaml` file for the associated Helm chart during deployment.
For more information, see [Setting Helm Values with KOTS](/vendor/helm-optional-value-keys).
180
+
140
181
## ConfigOptionNotEquals
141
182
142
183
```go
@@ -168,6 +209,29 @@ Returns the host of the local registry that the user configured. Alternatively,
168
209
169
210
Includes the port if one is specified.
170
211
212
+
#### Example
213
+
214
+
The following KOTS [HelmChart](/reference/custom-resource-helmchart-v2) custom resource uses the HasLocalRegistry, LocalRegistryHost, and LocalRegistryNamespace template functions to conditionally rewrite an image registry and repository depending on if a local registry is used. These values are then mapped to the `values.yaml` file for the associated Helm chart during deployment.
Returns the namespace of the local registry that the user configured. Alternatively, for air gap installations with EmbeddedCluster or kURL, LocalRegistryNamespace returns the namespace of the built-in registry.
178
242
243
+
#### Example
244
+
245
+
The following KOTS [HelmChart](/reference/custom-resource-helmchart-v2) custom resource uses the HasLocalRegistry, LocalRegistryHost, and LocalRegistryNamespace template functions to conditionally rewrite an image registry and repository depending on if a local registry is used. These values are then mapped to the `values.yaml` file for the associated Helm chart during deployment.
For more information, see [Setting HelmValues with KOTS](/vendor/helm-optional-value-keys).
265
+
179
266
## LocalImageName
180
267
181
268
```go
@@ -206,6 +293,8 @@ Returns the base64 encoded local registry image pull secret value.
206
293
This is often needed when an operator is deploying images to a namespace that is not managed by Replicated KOTS.
207
294
Image pull secrets must be present in the namespace of the pod.
208
295
296
+
#### Example
297
+
209
298
```yaml
210
299
apiVersion: v1
211
300
kind: Secret
@@ -239,6 +328,8 @@ Returns the name of the image pull secret that can be added to pod specs that us
239
328
The secret will be automatically created in all application namespaces.
240
329
It will contain authentication information for any private registry used with the application.
241
330
331
+
#### Example
332
+
242
333
```yaml
243
334
apiVersion: apps/v1
244
335
kind: Deployment
@@ -258,4 +349,27 @@ func HasLocalRegistry() bool
258
349
```
259
350
260
351
Returns true if the environment is configured to rewrite images to a local registry.
261
-
HasLocalRegistry is always true for air gap installations. HasLocalRegistry is true in online installations if the user pushed images to a local registry.
352
+
HasLocalRegistry is always true for air gap installations. HasLocalRegistry is true in online installations if the user pushed images to a local registry.
353
+
354
+
#### Example
355
+
356
+
The following KOTS [HelmChart](/reference/custom-resource-helmchart-v2) custom resource uses the HasLocalRegistry, LocalRegistryHost, and LocalRegistryNamespace template functions to conditionally rewrite an image registry and repository depending on if a local registry is used. These values are then mapped to the `values.yaml` file for the associated Helm chart during deployment.
Copy file name to clipboardExpand all lines: docs/reference/template-functions-kurl-context.md
+9-6Lines changed: 9 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,22 +1,25 @@
1
+
import KurlContext from "../partials/template-functions/_kurl-context.mdx"
2
+
import KurlAvailability from "../partials/kurl/_kurl-availability.mdx"
3
+
1
4
# kURL Context
2
5
3
-
## kURL Context Functions
6
+
<KurlAvailability/>
7
+
8
+
## Overview
4
9
5
-
For applications installed in embedded clusters created with Replicated kURL, you can use template functions to show all options the cluster was installed with.
10
+
<KurlContext/>
6
11
7
-
The creation of the Installer custom resource will reflect both install script changes made by posting YAML to the kURL API and changes made with -s flags at runtime. These functions are not available on the config page.
12
+
The creation of the kURL Installer custom resource will reflect both install script changes made by posting YAML to the kURL API and changes made with -s flags at runtime. These functions are not available on the KOTS Admin Console config page.
8
13
9
14
KurlBool, KurlInt, KurlString, and KurlOption all take a string yamlPath as a param.
10
-
This path is the path from the manifest file, and is delineated between addon and subfield by a period ’.’.
15
+
This is the path from the manifest file, and is delineated between add-on and subfield by a period ’.’.
11
16
For example, the kURL Kubernetes version can be accessed as `{{repl KurlString "Kubernetes.Version" }}`.
12
17
13
18
KurlBool, KurlInt, KurlString respectively return a bool, integer, and string value.
14
19
If used on a valid field but with the wrong type these will return the falsy value for their type, false, 0, and “string respectively.
15
20
The `KurlOption` function will convert all bool, int, and string fields to string.
16
21
All functions will return falsy values if there is nothing at the yamlPath specified, or if these functions are run in a cluster with no installer custom resource (as in, not a cluster created by kURL).
17
22
18
-
The following provides a complete list of the Installer custom resource with annotations:
0 commit comments