Documentation Index
Fetch the complete documentation index at: https://ryvn.ai/docs/llms.txt
Use this file to discover all available pages before exploring further.
Template functions enable dynamic configuration across all installation types. These generic functions work in both blueprint configurations and installation configs.
kind: ServiceInstallation
metadata:
name: my-app-production
spec:
service: my-app
environment: production
config:
- key: service_name
value: '{{ lower "MY-SERVICE" }}'
- key: replicas
value: '{{ default 3 .ryvn.env.config.replicas }}'
- key: environment
value: '{{ .ryvn.env.name }}'
Template context object
All templates have access to the .ryvn context object. The following properties are available:
.ryvn.env — environment context
| Property | Type | Description |
|---|
.ryvn.env.name | string | Environment name |
.ryvn.env.orgId | string | Organization ID |
.ryvn.env.defaultNamespace | string | Default Kubernetes namespace |
.ryvn.env.releaseChannel | string | Environment’s release channel |
.ryvn.env.provider.type | string | Cloud provider (aws, gcp, azure, k3s) |
.ryvn.env.provider.aws.accountId | string | AWS account ID (AWS only) |
.ryvn.env.provider.gcp.projectId | string | GCP project ID (GCP only) |
.ryvn.env.config | object | Environment config as key-value map (e.g., .ryvn.env.config.region) |
.ryvn.env.state | object | Provisioned infrastructure state (cluster info, VPC, domains, etc.) |
For the full list of .ryvn.env.state properties (VPC IDs, subnet CIDRs, cluster endpoints, domain names, etc.), see the Outputs section of the environment reference for your provider: AWS, GCP, Azure.
.ryvn.installation — installation context
| Property | Type | Description |
|---|
.ryvn.installation.name | string | Installation name |
.ryvn.installation.outputs | object | Installation outputs |
.ryvn.release — release context
| Property | Type | Description |
|---|
.ryvn.release.images.<name>.repo | string | Image repository for a named artifact |
.ryvn.release.images.<name>.tag | string | Image tag for a named artifact |
.ryvn.registrySecrets — registry credentials
| Property | Type | Description |
|---|
.ryvn.registrySecrets | map | Map of registry name to Kubernetes secret name for image pull secrets |
Template helper functions
| Function | Description |
|---|
serviceInstallation "<name>" | Get another service installation’s .outputs and .outputsSecret |
blueprintInstallation "<name>" | Get a blueprint installation’s .outputs and .outputsSecret |
k8sSecretName "<name>" | Get the Kubernetes secret name for a variable group |
k8sSecretValue "<name>" ["<key>"] | Get a secret value from a variable group (optionally by key) |
String functions
lower, upper, title, trim
Transform string values.
config: |
# Convert to lowercase
env_name: {{ lower "PRODUCTION" }}
# Convert to uppercase
region: {{ upper "us-east-1" }}
# Title case
display_name: {{ title "my service" }}
# Remove whitespace
cleaned: {{ trim " value " }}
contains
Check if a string contains a substring. Returns boolean.
config: |
# Check if environment name contains "prod"
is_production: {{ contains "prod" .ryvn.env.name }}
# Check for feature flag
{{ if contains "beta" .ryvn.env.releaseChannel }}
enable_experimental: true
{{ end }}
substring
Extract a substring from a string.
If start is < 0, extracts from beginning to end position.
If end is < 0 or greater than length, extracts from start to end of string.
config: |
# Get first 5 characters
short_name: {{ substring 0 5 .ryvn.env.name }}
# Get from position 3 to end
suffix: {{ substring 3 -1 .ryvn.installation.name }}
default
Provide a default value if the given value is empty or undefined.
config: |
# Use default if config value is not set
replicas: {{ default 3 .ryvn.env.config.replicas }}
# Provide default timeout
timeout: {{ default "30s" .ryvn.env.config.timeout }}
# Default log level
log_level: {{ default "info" .ryvn.env.config.log_level }}
toYaml
Convert data structures to YAML format. Useful for including complex configuration objects.
config: |
# Include environment config as YAML
environment:
{{ toYaml .ryvn.env.config | nindent 4 }}
# Include installation outputs
outputs:
{{ toYaml .ryvn.installation.outputs | indent 2 }}
toJson
Convert data structures to JSON format.
config: |
# Convert to JSON string
metadata: {{ toJson .ryvn.env.config }}
# Include state as JSON
state_json: {{ toJson .ryvn.env.state }}
indent, nindent
Add indentation to multi-line strings.
indent adds spaces to each line. nindent adds a newline before indenting.
config: |
# Using indent (no leading newline)
nested:
{{ indent 4 (toYaml .ryvn.env.config) }}
# Using nindent (adds newline first)
data:{{ nindent 2 (toYaml .ryvn.env.state) }}
join
Join array elements with a separator.
config: |
# Join with comma
{{ if .ryvn.env.config.zones }}
availability_zones: {{ join "," .ryvn.env.config.zones }}
{{ end }}
Control flow
Go templates support control flow statements for conditional logic.
Conditionals
Use if, else if, else, and end:
config: |
{{ if eq .ryvn.env.provider.type "aws" }}
cloud: aws
storage_class: gp3
{{ else if eq .ryvn.env.provider.type "gcp" }}
cloud: gcp
storage_class: pd-ssd
{{ else }}
cloud: unknown
{{ end }}
Comparison operators
eq - equal to
ne - not equal to
lt - less than
le - less than or equal to
gt - greater than
ge - greater than or equal to
config: |
{{ if gt .ryvn.env.config.replicas 5 }}
high_availability: true
{{ end }}
{{ if ne .ryvn.env.releaseChannel "stable" }}
experimental_features: true
{{ end }}
Boolean logic
Use and, or, and not:
config: |
{{ if and (eq .ryvn.env.provider.type "aws") (eq .ryvn.env.name "production") }}
enable_cloudwatch: true
{{ end }}
{{ if or (contains "prod" .ryvn.env.name) (contains "staging" .ryvn.env.name) }}
monitoring: enabled
{{ end }}
{{ if not (eq .ryvn.env.releaseChannel "stable") }}
log_level: debug
{{ end }}
Examples
Provider-specific configuration
Configure differently based on cloud provider:
config: |
service_name: my-app
environment: {{ .ryvn.env.name }}
storage:
{{ if eq .ryvn.env.provider.type "aws" }}
type: ebs
class: gp3
iops: 16000
{{ else if eq .ryvn.env.provider.type "gcp" }}
type: persistent-disk
class: pd-ssd
{{ else if eq .ryvn.env.provider.type "azure" }}
type: azure-disk
class: managed-premium
{{ end }}
size: {{ default "100Gi" .ryvn.env.config.storage_size }}
Using installation outputs
Reference outputs from other installations in the same environment using the installation function:
config: |
# Reference database installation outputs
database:
host: {{ (serviceInstallation "postgres").outputs.host }}
port: {{ (serviceInstallation "postgres").outputs.port }}
name: {{ (serviceInstallation "postgres").outputs.database }}
# Reference cache installation
{{ with (serviceInstallation "redis") }}
cache:
enabled: true
host: {{ .outputs.host }}
{{ else }}
cache:
enabled: false
{{ end }}
Using blueprint outputs
Reference outputs exposed by blueprints installed in the same environment using the blueprint function. Blueprint outputs are declared in the blueprint spec and resolved from underlying installation outputs.
config: |
# Reference outputs from a blueprint called "database-stack"
database:
host: {{ (blueprintInstallation "database-stack").outputs.host }}
port: {{ (blueprintInstallation "database-stack").outputs.port }}
Secret outputs (isSecret: true in the blueprint output definition) are not available via .outputs template syntax. Use valueFromOutput in env vars to consume them (see Server or Job reference). For Helm charts, use .outputsSecret to get the Kubernetes secret name and reference individual keys:
config: |
# .outputsSecret returns the K8s secret name containing the secret outputs
# Use this in Helm values to wire secrets without exposing them in plaintext
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: {{ (blueprintInstallation "database-stack").outputsSecret }}
key: connection_string
- name: API_KEY
valueFrom:
secretKeyRef:
name: {{ (serviceInstallation "auth-service").outputsSecret }}
key: api_key
Combine multiple functions:
config: |
service:
name: {{ lower .ryvn.installation.name }}
environment: {{ upper .ryvn.env.name }}
namespace: {{ .ryvn.env.defaultNamespace }}
# Include all environment config
envConfig:
{{ toYaml .ryvn.env.config | nindent 4 }}
# Provider-specific settings
{{ if eq .ryvn.env.provider.type "aws" }}
aws:
region: {{ default "us-east-1" .ryvn.env.config.region }}
account_id: {{ .ryvn.env.provider.aws.accountId }}
{{ else if eq .ryvn.env.provider.type "gcp" }}
gcp:
project_id: {{ .ryvn.env.provider.gcp.projectId }}
region: {{ default "us-central1" .ryvn.env.config.region }}
{{ end }}
# Feature flags based on release channel
features:
beta_features: {{ contains "beta" .ryvn.env.releaseChannel }}
stable_only: {{ eq .ryvn.env.releaseChannel "stable" }}
Using release images
Reference images from releases:
config: |
containers:
- name: app
image: {{ .ryvn.release.images.app.repo }}:{{ .ryvn.release.images.app.tag }}
{{ if .ryvn.release.images.sidecar }}
- name: sidecar
image: {{ .ryvn.release.images.sidecar.repo }}:{{ .ryvn.release.images.sidecar.tag }}
{{ end }}
Environment-specific scaling
Configure resources based on environment:
config: |
replicas: {{ default 1 .ryvn.env.config.replicas }}
resources:
{{ if contains "prod" .ryvn.env.name }}
limits:
cpu: "2000m"
memory: "4Gi"
{{ else if contains "staging" .ryvn.env.name }}
limits:
cpu: "1000m"
memory: "2Gi"
{{ else }}
limits:
cpu: "500m"
memory: "1Gi"
{{ end }}
# Include custom resource requirements if specified
{{ if .ryvn.env.config.resources }}
customResources:
{{ toYaml .ryvn.env.config.resources | nindent 4 }}
{{ end }}