1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/ztp-example-hub-template-functions.adoc
2023-10-30 10:13:25 -04:00

38 lines
1.2 KiB
Plaintext

// Module included in the following assemblies:
//
// * scalability_and_performance/ztp_far_edge/ztp-advanced-policy-config.adoc
:_mod-docs-content-type: REFERENCE
[id="ztp-example-hub-template-functions_{context}"]
= Example hub templates
The following code examples are valid hub templates. Each of these templates return values from the `ConfigMap` CR with the name `test-config` in the `default` namespace.
* Returns the value with the key `common-key`:
+
[source,yaml]
----
{{hub fromConfigMap "default" "test-config" "common-key" hub}}
----
* Returns a string by using the concatenated value of the `.ManagedClusterName` field and the string `-name`:
+
[source,yaml]
----
{{hub fromConfigMap "default" "test-config" (printf "%s-name" .ManagedClusterName) hub}}
----
* Casts and returns a boolean value from the concatenated value of the `.ManagedClusterName` field and the string `-name`:
+
[source,yaml]
----
{{hub fromConfigMap "default" "test-config" (printf "%s-name" .ManagedClusterName) | toBool hub}}
----
* Casts and returns an integer value from the concatenated value of the `.ManagedClusterName` field and the string `-name`:
+
[source,yaml]
----
{{hub (printf "%s-name" .ManagedClusterName) | fromConfigMap "default" "test-config" | toInt hub}}
----