From 0fd43fd9f6c491b672dc3d1f3328d628dad3de01 Mon Sep 17 00:00:00 2001 From: Paige Calvert Date: Fri, 7 Mar 2025 10:34:03 -0700 Subject: [PATCH 1/5] Add HelmChart examples to Config template func page --- .../template-functions/_config-context.mdx | 3 + .../template-functions/_identity-context.mdx | 1 + .../template-functions/_kurl-context.mdx | 1 + .../template-functions/_license-context.mdx | 1 + .../template-functions/_static-context.mdx | 3 + .../template-functions-config-context.md | 173 ++++++++++++++---- .../template-functions-identity-context.md | 4 + .../template-functions-kurl-context.md | 12 +- .../template-functions-license-context.md | 4 + .../template-functions-static-context.md | 7 +- 10 files changed, 163 insertions(+), 46 deletions(-) create mode 100644 docs/partials/template-functions/_config-context.mdx create mode 100644 docs/partials/template-functions/_identity-context.mdx create mode 100644 docs/partials/template-functions/_kurl-context.mdx create mode 100644 docs/partials/template-functions/_license-context.mdx create mode 100644 docs/partials/template-functions/_static-context.mdx diff --git a/docs/partials/template-functions/_config-context.mdx b/docs/partials/template-functions/_config-context.mdx new file mode 100644 index 0000000000..1cd4ee3b3e --- /dev/null +++ b/docs/partials/template-functions/_config-context.mdx @@ -0,0 +1,3 @@ +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). \ No newline at end of file diff --git a/docs/partials/template-functions/_identity-context.mdx b/docs/partials/template-functions/_identity-context.mdx new file mode 100644 index 0000000000..d4a926ddc3 --- /dev/null +++ b/docs/partials/template-functions/_identity-context.mdx @@ -0,0 +1 @@ +Template functions in the Identity context have access to Replicated identity service information. \ No newline at end of file diff --git a/docs/partials/template-functions/_kurl-context.mdx b/docs/partials/template-functions/_kurl-context.mdx new file mode 100644 index 0000000000..083774a81e --- /dev/null +++ b/docs/partials/template-functions/_kurl-context.mdx @@ -0,0 +1 @@ +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). \ No newline at end of file diff --git a/docs/partials/template-functions/_license-context.mdx b/docs/partials/template-functions/_license-context.mdx new file mode 100644 index 0000000000..6325c4c0d3 --- /dev/null +++ b/docs/partials/template-functions/_license-context.mdx @@ -0,0 +1 @@ +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). \ No newline at end of file diff --git a/docs/partials/template-functions/_static-context.mdx b/docs/partials/template-functions/_static-context.mdx new file mode 100644 index 0000000000..b10d2ea063 --- /dev/null +++ b/docs/partials/template-functions/_static-context.mdx @@ -0,0 +1,3 @@ +The context necessary to render the static template functions is always available. + +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. \ No newline at end of file diff --git a/docs/reference/template-functions-config-context.md b/docs/reference/template-functions-config-context.md index ee877a6ba1..c0ff8527d5 100644 --- a/docs/reference/template-functions-config-context.md +++ b/docs/reference/template-functions-config-context.md @@ -1,38 +1,42 @@ +import ConfigContext from "../partials/template-functions/_config-context.mdx" + # Config Context + + ## ConfigOption ```go func ConfigOption(optionName string) string ``` -Returns the value of the config option as a string. - -For information about the config screen and associated options, see [Config](custom-resource-config) in the _Custom Resources_ section. +Returns the value of the specified option from the KOTS Config custom resource as a string. For the `file` config option type, `ConfigOption` returns the base64 encoded value. ```yaml '{{repl ConfigOption "hostname" }}' ``` -`ConfigOption` returns the base64 **encoded** value of the `file` config option. +#### Example -```yaml -'{{repl ConfigOption "ssl_key"}}' -``` +The following KOTS [HelmChart](/reference/custom-resource-helmchart-v2) custom resource uses the ConfigOption 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. -To use files in a Secret, use `ConfigOption`: ```yaml -apiVersion: v1 -kind: Secret +# KOTS HelmChart custom resource +apiVersion: kots.io/v1beta2 +kind: HelmChart metadata: - name: tls-secret -type: kubernetes.io/tls -data: - tls.crt: '{{repl ConfigOption "tls_certificate_file" }}' - tls.key: '{{repl ConfigOption "tls_private_key_file" }}' + name: samplechart +spec: + chart: + name: samplechart + chartVersion: 3.1.7 + values: + my-app: + data: + tls.crt: '{{repl ConfigOption "tls_certificate_file" }}' + tls.key: '{{repl ConfigOption "tls_private_key_file" }}' ``` - -For more information about using TLS certificates, see [Using TLS Certificates](../vendor/packaging-using-tls-certs). +For more information, see [Setting Helm Values with KOTS](/vendor/helm-optional-value-keys). ## ConfigOptionData @@ -40,25 +44,34 @@ For more information about using TLS certificates, see [Using TLS Certificates]( func ConfigOptionData(optionName string) string ``` -`ConfigOptionData` returns the base64 **decoded** value of a `file` config option. +`ConfigOptionData` returns the base64 decoded value of a `file` config option. ```yaml '{{repl ConfigOptionData "ssl_key"}}' ``` -To use files in a ConfigMap, use `ConfigOptionData`: +#### Example + +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. + ```yaml -apiVersion: v1 -kind: ConfigMap +# KOTS HelmChart custom resource +apiVersion: kots.io/v1beta2 +kind: HelmChart metadata: - name: tls-config -data: - tls.crt: | - repl{{- ConfigOptionData "tls_certificate_file" | nindent 4 }} - - tls.key: | - repl{{- ConfigOptionData "tls_private_key_file" | nindent 4 }} + name: samplechart +spec: + chart: + name: samplechart + chartVersion: 3.1.7 + values: + tls: + enabled: true + genSelfSignedCert: repl{{ ConfigOptionEquals "myapp_ingress_tls_type" "self_signed" }} + cert: repl{{ print `|`}}repl{{ ConfigOptionData `tls_certificate_file` | nindent 12 }} + key: repl{{ print `|`}}repl{{ ConfigOptionData `tls_private_key_file` | nindent 12 }} ``` +For more information, see [Setting Helm Values with KOTS](/vendor/helm-optional-value-keys). ## ConfigOptionFilename @@ -73,7 +86,9 @@ It will return an empty string if used erroneously with other types. '{{repl ConfigOptionFilename "pom_file"}}' ``` -As an example, if you have the following Config Spec defined: +#### Example + +For example, if you have the following KOTS Config defined: ```yaml apiVersion: kots.io/v1beta1 @@ -91,7 +106,8 @@ spec: required: true ``` -You can use `ConfigOptionFilename` in a Pod Spec to mount a file like so: +You can use `ConfigOptionFilename` in a Pod Spec to mount a file, as shown below: + ```yaml apiVersion: v1 kind: Pod @@ -133,9 +149,25 @@ func ConfigOptionEquals(optionName string, expectedValue string) bool Returns true if the configuration option value is equal to the supplied value. +#### Example + +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. + ```yaml -'{{repl ConfigOptionEquals "http_enabled" "1" }}' +# KOTS HelmChart custom resource +apiVersion: kots.io/v1beta2 +kind: HelmChart +metadata: + name: samplechart +spec: + chart: + name: samplechart + chartVersion: 3.1.7 + values: + postgresql: + enabled: repl{{ ConfigOptionEquals `postgres_type` `embedded_postgres`}} ``` +For more information, see [Setting Helm Values with KOTS](/vendor/helm-optional-value-keys). ## ConfigOptionNotEquals @@ -145,10 +177,6 @@ func ConfigOptionNotEquals(optionName string, expectedValue string) bool Returns true if the configuration option value is not equal to the supplied value. -```yaml -'{{repl ConfigOptionNotEquals "http_enabled" "1" }}' -``` - ## LocalRegistryAddress ```go @@ -168,6 +196,29 @@ Returns the host of the local registry that the user configured. Alternatively, Includes the port if one is specified. +#### Example + +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. + +```yaml +# KOTS HelmChart custom resource +apiVersion: kots.io/v1beta2 +kind: HelmChart +metadata: + name: samplechart +spec: + chart: + name: samplechart + chartVersion: 3.1.7 + values: + my-app: + image: + registry: '{{repl HasLocalRegistry | ternary LocalRegistryHost "images.mycompany.com" }}' + repository: '{{repl HasLocalRegistry | ternary LocalRegistryNamespace "proxy/my-app/quay.io/my-org" }}/nginx' + tag: v1.0.1 +``` +For more information, see [Setting Helm Values with KOTS](/vendor/helm-optional-value-keys). + ## LocalRegistryNamespace ```go @@ -176,6 +227,29 @@ func LocalRegistryNamespace() string Returns the namespace of the local registry that the user configured. Alternatively, for air gap installations with Embedded Cluster or kURL, LocalRegistryNamespace returns the namespace of the built-in registry. +#### Example + +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. + +```yaml +# KOTS HelmChart custom resource +apiVersion: kots.io/v1beta2 +kind: HelmChart +metadata: + name: samplechart +spec: + chart: + name: samplechart + chartVersion: 3.1.7 + values: + my-app: + image: + registry: '{{repl HasLocalRegistry | ternary LocalRegistryHost "images.mycompany.com" }}' + repository: '{{repl HasLocalRegistry | ternary LocalRegistryNamespace "proxy/my-app/quay.io/my-org" }}/nginx' + tag: v1.0.1 +``` +For more information, see [Setting Helm Values with KOTS](/vendor/helm-optional-value-keys). + ## LocalImageName ```go @@ -206,6 +280,8 @@ Returns the base64 encoded local registry image pull secret value. This is often needed when an operator is deploying images to a namespace that is not managed by Replicated KOTS. Image pull secrets must be present in the namespace of the pod. +#### Example + ```yaml apiVersion: v1 kind: Secret @@ -239,6 +315,8 @@ Returns the name of the image pull secret that can be added to pod specs that us The secret will be automatically created in all application namespaces. It will contain authentication information for any private registry used with the application. +#### Example + ```yaml apiVersion: apps/v1 kind: Deployment @@ -258,4 +336,27 @@ func HasLocalRegistry() bool ``` Returns true if the environment is configured to rewrite images to a local registry. -HasLocalRegistry is always true for air gap installations. HasLocalRegistry is true in online installations if the user pushed images to a local registry. \ No newline at end of file +HasLocalRegistry is always true for air gap installations. HasLocalRegistry is true in online installations if the user pushed images to a local registry. + +#### Example + +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. + +```yaml +# KOTS HelmChart custom resource +apiVersion: kots.io/v1beta2 +kind: HelmChart +metadata: + name: samplechart +spec: + chart: + name: samplechart + chartVersion: 3.1.7 + values: + my-app: + image: + registry: '{{repl HasLocalRegistry | ternary LocalRegistryHost "images.mycompany.com" }}' + repository: '{{repl HasLocalRegistry | ternary LocalRegistryNamespace "proxy/my-app/quay.io/my-org" }}/nginx' + tag: v1.0.1 +``` +For more information, see [Setting Helm Values with KOTS](/vendor/helm-optional-value-keys). \ No newline at end of file diff --git a/docs/reference/template-functions-identity-context.md b/docs/reference/template-functions-identity-context.md index b56aae4734..e3176ed270 100644 --- a/docs/reference/template-functions-identity-context.md +++ b/docs/reference/template-functions-identity-context.md @@ -1,5 +1,9 @@ +import IdentityContext from "../partials/template-functions/_identity-context.mdx" + # Identity Context + + ## IdentityServiceEnabled ```go diff --git a/docs/reference/template-functions-kurl-context.md b/docs/reference/template-functions-kurl-context.md index 8885a80709..dee77fcc05 100644 --- a/docs/reference/template-functions-kurl-context.md +++ b/docs/reference/template-functions-kurl-context.md @@ -1,13 +1,15 @@ +import KurlContext from "../partials/template-functions/_kurl-context.mdx" + # kURL Context -## kURL Context Functions +## Overview -For applications installed in embedded clusters created with Replicated kURL, you can use template functions to show all options the cluster was installed with. + -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. +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. KurlBool, KurlInt, KurlString, and KurlOption all take a string yamlPath as a param. -This path is the path from the manifest file, and is delineated between addon and subfield by a period ’.’. +This is the path from the manifest file, and is delineated between add-on and subfield by a period ’.’. For example, the kURL Kubernetes version can be accessed as `{{repl KurlString "Kubernetes.Version" }}`. KurlBool, KurlInt, KurlString respectively return a bool, integer, and string value. @@ -15,8 +17,6 @@ If used on a valid field but with the wrong type these will return the falsy val The `KurlOption` function will convert all bool, int, and string fields to string. 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). -The following provides a complete list of the Installer custom resource with annotations: - ## KurlBool ```go diff --git a/docs/reference/template-functions-license-context.md b/docs/reference/template-functions-license-context.md index de301dfb15..8a03358fd6 100644 --- a/docs/reference/template-functions-license-context.md +++ b/docs/reference/template-functions-license-context.md @@ -1,5 +1,9 @@ +import LicenseContext from "../partials/template-functions/_license-context.mdx" + # License Context + + ## LicenseFieldValue ```go func LicenseFieldValue(name string) string diff --git a/docs/reference/template-functions-static-context.md b/docs/reference/template-functions-static-context.md index 58de3cf2a5..511b9b5708 100644 --- a/docs/reference/template-functions-static-context.md +++ b/docs/reference/template-functions-static-context.md @@ -1,9 +1,8 @@ -# Static Context +import StaticContext from "../partials/template-functions/_static-context.mdx" -## About Mastermind Sprig +# Static Context -Many of the utility functions provided come from sprig, a third-party library of Go template functions. -For more information, see [Sprig Function Documentation](https://masterminds.github.io/sprig/) on the sprig website. + ## Certificate Functions From 33303f59300d1ce7ce71f16f6945323f6d3dee19 Mon Sep 17 00:00:00 2001 From: Paige Calvert Date: Fri, 7 Mar 2025 10:44:38 -0700 Subject: [PATCH 2/5] edits to examples --- .../template-functions/_identity-context.mdx | 6 ++- .../template-functions-config-context.md | 37 ++++++++++--------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/docs/partials/template-functions/_identity-context.mdx b/docs/partials/template-functions/_identity-context.mdx index d4a926ddc3..9ff79e3edd 100644 --- a/docs/partials/template-functions/_identity-context.mdx +++ b/docs/partials/template-functions/_identity-context.mdx @@ -1 +1,5 @@ -Template functions in the Identity context have access to Replicated identity service information. \ No newline at end of file +Template functions in the Identity context have access to Replicated KOTS identity service information. + +:::note +The KOTS identity service feature is deprecated and is not available to new users. +::: \ No newline at end of file diff --git a/docs/reference/template-functions-config-context.md b/docs/reference/template-functions-config-context.md index c0ff8527d5..1ce688521c 100644 --- a/docs/reference/template-functions-config-context.md +++ b/docs/reference/template-functions-config-context.md @@ -18,7 +18,7 @@ Returns the value of the specified option from the KOTS Config custom resource a #### Example -The following KOTS [HelmChart](/reference/custom-resource-helmchart-v2) custom resource uses the ConfigOption 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. +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. ```yaml # KOTS HelmChart custom resource @@ -31,10 +31,12 @@ spec: name: samplechart chartVersion: 3.1.7 values: - my-app: - data: - tls.crt: '{{repl ConfigOption "tls_certificate_file" }}' - tls.key: '{{repl ConfigOption "tls_private_key_file" }}' + myapp: + service: + type: LoadBalancer + port: repl{{ ConfigOption "myapp_load_balancer_port"}} + nodePort: repl{{ ConfigOption "myapp_load_balancer_node_port"}} + annotations: repl{{ ConfigOption `myapp_load_balancer_annotations` | nindent 14 }} ``` For more information, see [Setting Helm Values with KOTS](/vendor/helm-optional-value-keys). @@ -65,11 +67,12 @@ spec: name: samplechart chartVersion: 3.1.7 values: - tls: - enabled: true - genSelfSignedCert: repl{{ ConfigOptionEquals "myapp_ingress_tls_type" "self_signed" }} - cert: repl{{ print `|`}}repl{{ ConfigOptionData `tls_certificate_file` | nindent 12 }} - key: repl{{ print `|`}}repl{{ ConfigOptionData `tls_private_key_file` | nindent 12 }} + myapp: + tls: + enabled: true + genSelfSignedCert: repl{{ ConfigOptionEquals "myapp_ingress_tls_type" "self_signed" }} + cert: repl{{ print `|`}}repl{{ ConfigOptionData `tls_certificate_file` | nindent 12 }} + key: repl{{ print `|`}}repl{{ ConfigOptionData `tls_private_key_file` | nindent 12 }} ``` For more information, see [Setting Helm Values with KOTS](/vendor/helm-optional-value-keys). @@ -94,7 +97,7 @@ For example, if you have the following KOTS Config defined: apiVersion: kots.io/v1beta1 kind: Config metadata: - name: my-application + name: myapp spec: groups: - name: java_settings @@ -211,10 +214,10 @@ spec: name: samplechart chartVersion: 3.1.7 values: - my-app: + myapp: image: registry: '{{repl HasLocalRegistry | ternary LocalRegistryHost "images.mycompany.com" }}' - repository: '{{repl HasLocalRegistry | ternary LocalRegistryNamespace "proxy/my-app/quay.io/my-org" }}/nginx' + repository: '{{repl HasLocalRegistry | ternary LocalRegistryNamespace "proxy/myapp/quay.io/my-org" }}/nginx' tag: v1.0.1 ``` For more information, see [Setting Helm Values with KOTS](/vendor/helm-optional-value-keys). @@ -242,10 +245,10 @@ spec: name: samplechart chartVersion: 3.1.7 values: - my-app: + myapp: image: registry: '{{repl HasLocalRegistry | ternary LocalRegistryHost "images.mycompany.com" }}' - repository: '{{repl HasLocalRegistry | ternary LocalRegistryNamespace "proxy/my-app/quay.io/my-org" }}/nginx' + repository: '{{repl HasLocalRegistry | ternary LocalRegistryNamespace "proxy/myapp/quay.io/my-org" }}/nginx' tag: v1.0.1 ``` For more information, see [Setting Helm Values with KOTS](/vendor/helm-optional-value-keys). @@ -353,10 +356,10 @@ spec: name: samplechart chartVersion: 3.1.7 values: - my-app: + myapp: image: registry: '{{repl HasLocalRegistry | ternary LocalRegistryHost "images.mycompany.com" }}' - repository: '{{repl HasLocalRegistry | ternary LocalRegistryNamespace "proxy/my-app/quay.io/my-org" }}/nginx' + repository: '{{repl HasLocalRegistry | ternary LocalRegistryNamespace "proxy/myapp/quay.io/my-org" }}/nginx' tag: v1.0.1 ``` For more information, see [Setting Helm Values with KOTS](/vendor/helm-optional-value-keys). \ No newline at end of file From 2e78eb518da51f81f3da8ee096863fa9ad38dca2 Mon Sep 17 00:00:00 2001 From: Paige Calvert Date: Fri, 7 Mar 2025 10:58:06 -0700 Subject: [PATCH 3/5] edits --- .../template-functions/_config-context.mdx | 4 +-- .../template-functions/_identity-context.mdx | 6 ++-- docs/reference/template-functions-about.mdx | 31 +++++++++++-------- .../template-functions-config-context.md | 4 +-- .../template-functions-kurl-context.md | 3 ++ 5 files changed, 27 insertions(+), 21 deletions(-) diff --git a/docs/partials/template-functions/_config-context.mdx b/docs/partials/template-functions/_config-context.mdx index 1cd4ee3b3e..6cf086df39 100644 --- a/docs/partials/template-functions/_config-context.mdx +++ b/docs/partials/template-functions/_config-context.mdx @@ -1,3 +1 @@ -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). \ No newline at end of file +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). \ No newline at end of file diff --git a/docs/partials/template-functions/_identity-context.mdx b/docs/partials/template-functions/_identity-context.mdx index 9ff79e3edd..dc2f3cf332 100644 --- a/docs/partials/template-functions/_identity-context.mdx +++ b/docs/partials/template-functions/_identity-context.mdx @@ -1,5 +1,5 @@ -Template functions in the Identity context have access to Replicated KOTS identity service information. - :::note The KOTS identity service feature is deprecated and is not available to new users. -::: \ No newline at end of file +::: + +Template functions in the Identity context have access to Replicated KOTS identity service information. \ No newline at end of file diff --git a/docs/reference/template-functions-about.mdx b/docs/reference/template-functions-about.mdx index cd3a65d15d..31656ceb4e 100644 --- a/docs/reference/template-functions-about.mdx +++ b/docs/reference/template-functions-about.mdx @@ -1,4 +1,10 @@ import UseCases from "../partials/template-functions/_use-cases.mdx" +import StaticContext from "../partials/template-functions/_static-context.mdx" +import ConfigContext from "../partials/template-functions/_config-context.mdx" +import LicenseContext from "../partials/template-functions/_license-context.mdx" +import KurlContext from "../partials/template-functions/_kurl-context.mdx" +import IdentityContext from "../partials/template-functions/_identity-context.mdx" +import KurlAvailability from "../partials/kurl/_kurl-availability.mdx" # About Template Functions @@ -126,33 +132,32 @@ KOTS template functions are grouped into different contexts, depending on the ph ### Static Context -The context necessary to render the static template functions is always available. + -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. - -For a list of all KOTS template functions available in the static context, see [Static context](template-functions-static-context). +For a list of all KOTS template functions available in the static context, see [Static Context](template-functions-static-context). ### Config Context -Template functions in the config context are available when rendering an application that includes a Config custom resource. -At execution time, template functions in the config context also can use the static context functions. + -For a list of all KOTS template functions available in the config context, see [Config context](template-functions-config-context). +For a list of all KOTS template functions available in the config context, see [Config Context](template-functions-config-context). ### License Context -Template functions in the license context have access to customer license and version data. + -For a list of all KOTS template functions available in the license context, see [License context](template-functions-license-context). +For a list of all KOTS template functions available in the license context, see [License Context](template-functions-license-context). ### kURL Context -Template functions in the kURL context have access to information about applications installed in embedded clusters created by Replicated kURL. + + + -For a list of all KOTS template functions available in the kURL context, see [kURL context](template-functions-kurl-context). +For a list of all KOTS template functions available in the kURL context, see [kURL Context](template-functions-kurl-context). ### Identity Context -Template functions in the Identity context have access to Replicated identity service information. + -For a list of all KOTS template functions available in the identity context, see [Identity context](template-functions-identity-context). +For a list of all KOTS template functions available in the identity context, see [Identity Context](template-functions-identity-context). diff --git a/docs/reference/template-functions-config-context.md b/docs/reference/template-functions-config-context.md index 1ce688521c..631ae16834 100644 --- a/docs/reference/template-functions-config-context.md +++ b/docs/reference/template-functions-config-context.md @@ -97,7 +97,7 @@ For example, if you have the following KOTS Config defined: apiVersion: kots.io/v1beta1 kind: Config metadata: - name: myapp + name: my-application spec: groups: - name: java_settings @@ -109,7 +109,7 @@ spec: required: true ``` -You can use `ConfigOptionFilename` in a Pod Spec to mount a file, as shown below: +The following example shows how to use `ConfigOptionFilename` in a Pod Spec to mount a file: ```yaml apiVersion: v1 diff --git a/docs/reference/template-functions-kurl-context.md b/docs/reference/template-functions-kurl-context.md index dee77fcc05..05de1e0180 100644 --- a/docs/reference/template-functions-kurl-context.md +++ b/docs/reference/template-functions-kurl-context.md @@ -1,7 +1,10 @@ import KurlContext from "../partials/template-functions/_kurl-context.mdx" +import KurlAvailability from "../partials/kurl/_kurl-availability.mdx" # kURL Context + + ## Overview From d4b7877f57f6f64926d41eeccd04150dc9410024 Mon Sep 17 00:00:00 2001 From: Paige Calvert Date: Fri, 7 Mar 2025 11:04:30 -0700 Subject: [PATCH 4/5] revert a couple changes --- docs/reference/template-functions-config-context.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/reference/template-functions-config-context.md b/docs/reference/template-functions-config-context.md index 631ae16834..9cea5b5711 100644 --- a/docs/reference/template-functions-config-context.md +++ b/docs/reference/template-functions-config-context.md @@ -152,6 +152,10 @@ func ConfigOptionEquals(optionName string, expectedValue string) bool Returns true if the configuration option value is equal to the supplied value. +```yaml +'{{repl ConfigOptionEquals "http_enabled" "1" }}' +``` + #### Example 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. @@ -180,6 +184,10 @@ func ConfigOptionNotEquals(optionName string, expectedValue string) bool Returns true if the configuration option value is not equal to the supplied value. +```yaml +'{{repl ConfigOptionNotEquals "http_enabled" "1" }}' +``` + ## LocalRegistryAddress ```go From e89cb4232d049d655d98d98441fa90b549a876d3 Mon Sep 17 00:00:00 2001 From: Paige Calvert Date: Tue, 11 Mar 2025 10:23:15 -0600 Subject: [PATCH 5/5] clarify purpose of configoptiondata --- docs/reference/template-functions-config-context.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/reference/template-functions-config-context.md b/docs/reference/template-functions-config-context.md index 9cea5b5711..4482c807a0 100644 --- a/docs/reference/template-functions-config-context.md +++ b/docs/reference/template-functions-config-context.md @@ -10,7 +10,9 @@ import ConfigContext from "../partials/template-functions/_config-context.mdx" func ConfigOption(optionName string) string ``` -Returns the value of the specified option from the KOTS Config custom resource as a string. For the `file` config option type, `ConfigOption` returns the base64 encoded value. +Returns the value of the specified option from the KOTS Config custom resource as a string. + +For the `file` config option type, `ConfigOption` returns the base64 encoded file. To return the decoded contents of a file, use [ConfigOptionData](#configoptiondata) instead. ```yaml '{{repl ConfigOption "hostname" }}' @@ -46,7 +48,7 @@ For more information, see [Setting Helm Values with KOTS](/vendor/helm-optional- func ConfigOptionData(optionName string) string ``` -`ConfigOptionData` returns the base64 decoded value of a `file` config option. +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. ```yaml '{{repl ConfigOptionData "ssl_key"}}'