docs/snippets/kubernetes-operator-templating-helpers.mdx
The Infisical Secrets Operator exposes a wide range of helper functions to make it easier to work with secrets in Kubernetes.
<AccordionGroup> <Accordion title="encodeBase64"> Encodes a string to a base64-encoded string (e.g. `hello world` becomes `aGVsbG8gd29ybGQ=`).Signature
encodeBase64(plainString string) string
Template usage
template:
data:
ENCODED_SECRET: "{{ .MY_SECRET.Value | encodeBase64 }}"
Signature
decodeBase64ToBytes(encodedString string) string
Template usage
template:
data:
DECODED_SECRET: "{{ .MY_BASE64_SECRET.Value | decodeBase64ToBytes }}"
Signature
pkcs12key(input string) string
Template usage
template:
data:
tls.key: "{{ .TLS_CERT_PKCS12.Value | pkcs12key }}"
Signature
pkcs12keyPass(password string, input string) string
Template usage
template:
data:
tls.key: '{{ pkcs12keyPass "my-password" .TLS_CERT_PKCS12.Value }}'
Signature
pkcs12cert(input string) string
Template usage
template:
data:
tls.crt: "{{ .TLS_CERT_PKCS12.Value | pkcs12cert }}"
Signature
pkcs12certPass(password string, input string) string
Template usage
template:
data:
tls.crt: '{{ pkcs12certPass "my-password" .TLS_CERT_PKCS12.Value }}'
Signature
pemToPkcs12(cert string, key string) string
Template usage
template:
data:
keystore.p12: '{{ pemToPkcs12 .TLS_CERT.Value .TLS_KEY.Value }}'
Signature
pemToPkcs12Pass(cert string, key string, password string) string
Template usage
template:
data:
keystore.p12: '{{ pemToPkcs12Pass .TLS_CERT.Value .TLS_KEY.Value "my-password" }}'
Signature
fullPemToPkcs12(cert string, key string) string
Template usage
template:
data:
keystore.p12: '{{ fullPemToPkcs12 .TLS_FULL_CHAIN.Value .TLS_KEY.Value }}'
Signature
fullPemToPkcs12Pass(cert string, key string, password string) string
Template usage
template:
data:
keystore.p12: '{{ fullPemToPkcs12Pass .TLS_FULL_CHAIN.Value .TLS_KEY.Value "my-password" }}'
Signature
filterPEM(pemType string, input string) string
Template usage
template:
data:
ca.crt: '{{ filterPEM "CERTIFICATE" .TLS_BUNDLE.Value }}'
tls.key: '{{ filterPEM "PRIVATE KEY" .TLS_BUNDLE.Value }}'
Signature
filterCertChain(certType string, input string) string
Template usage
template:
data:
tls.crt: '{{ filterCertChain "leaf" .TLS_CHAIN.Value }}'
ca.crt: '{{ filterCertChain "root" .TLS_CHAIN.Value }}'
intermediate.crt: '{{ filterCertChain "intermediate" .TLS_CHAIN.Value }}'
Signature
jwkPublicKeyPem(jwkJson string) string
Template usage
template:
data:
public.pem: "{{ .MY_JWK.Value | jwkPublicKeyPem }}"
Signature
jwkPrivateKeyPem(jwkJson string) string
Template usage
template:
data:
private.pem: "{{ .MY_JWK.Value | jwkPrivateKeyPem }}"
Signature
toYaml(v any) string
Template usage
template:
data:
config.yaml: "{{ .APP_CONFIG.Value | fromYaml | toYaml }}"
Signature
fromYaml(str string) map[string]any
Template usage
template:
data:
DB_HOST: '{{ (fromYaml .DB_CONFIG.Value).host }}'
DB_PORT: '{{ (fromYaml .DB_CONFIG.Value).port }}'
Resolves a secret from a specific folder path within the Infisical project. Takes a path and a secret name as parameters, and returns the secret's value by default. You can optionally use .Value or .SecretPath accessors on the result -- if omitted, .Value is used.
This is especially useful when multiple secrets share the same key, either from recursive fetches across different paths or from multiple sources. In both cases, the merge strategy only keeps the first occurrence (read more here), so secretFrom lets you explicitly select the one you need by its full path.
Signature
secretFrom(path string, secretName string) string
Template usage
template:
data:
# .Value is implicit when no accessor is specified
DB_PASSWORD: '{{ secretFrom "/databases/postgres" "DB_PASSWORD" }}'
# Explicit .Value accessor (same result as above)
STRIPE_API_KEY: '{{ (secretFrom "/services/payments" "API_KEY").Value }}'
# Using .SecretPath to get the folder path instead of the value
DATADOG_API_KEY: '{{ (secretFrom "/services/observability" "API_KEY").Value }}'
DATADOG_API_KEY_PATH: '{{ (secretFrom "/services/observability" "API_KEY").SecretPath }}'
The Infisical Secrets Operator integrates with the Sprig library to provide additional helper functions.
<Note> We've removed `expandEnv` and `env` from the supported functions for security reasons. </Note>