Variables Support
Manage configuration values and secrets across integration workflows
Variables Support
Overview
Variables allow you to store and manage configuration values and secrets that can be used across your integration workflows. The feature leverages Apache Camel’s built-in system properties variable support for seamless integration.
Configuration Format
Variables are configured using YAML files following our standard configuration pattern:
apiVersion: weik.io/v1alpha1
kind: Variable
metadata:
name: database-password
description: PostgreSQL database password for production environment
spec:
value: "your-secure-password-here"
isSecret: true # Optional, defaults to false
Applying Configuration
Use the Weikio CLI to apply variable configurations:
weikio config apply filename.yaml
API Endpoints
GET /variables- Returns all variables
- Secret values are hidden
GET /variables/{name}- Returns a specific variable by name
- Secret values are hidden
Usage in Integration Flows
Integration flows can reference variables using Apache Camel’s system properties property placeholder syntax {{sys:VARIABLE}} in application.properties files.
Example integration flow using variables:
apiVersion: weik.io/v1alpha1
kind: IntegrationFlow
metadata:
name: database-sync
spec:
source:
uri: "postgresql:{{DATABASE_CONNECTION}}"
parameters:
apiKey: "{{EXTERNAL_API_KEY}}"
enableFeatures: "{{ENABLE_BETA_FEATURES}}"
Example application.properties:
# Database configuration
database.url={{sys:DATABASE_CONNECTION}}
database.username={{sys:DB_USERNAME}}
database.password={{sys:DB_PASSWORD}}
# API configuration
api.key={{sys:EXTERNAL_API_KEY}}
api.endpoint={{sys:API_ENDPOINT}}
# Feature flags
features.beta={{sys:ENABLE_BETA_FEATURES}}
System Variables
System variables are automatically provided by the platform and available to all integration flows. These variables provide runtime context and configuration without requiring manual setup.
Available System Variables
| Variable Name | Description |
|---|---|
weikio.agent.id | The unique identifier of the agent running the integration flow |
weikio.nats.url | The URL of the NATS server (defaults to localhost if not configured) |
weikio.nats.username | The username for NATS authentication |
weikio.nats.password | The password for NATS authentication |
weikio.nats.credentialsfilepath | The file path to NATS credentials file |
Using System Variables
System variables use the same syntax as user-defined variables in Apache Camel: {{sys:variable-name}}. They can be referenced in integration flow configurations and application.properties files.
Example application.properties using system variables:
# NATS connection configuration
nats.url={{sys:weikio.nats.url}}
nats.username={{sys:weikio.nats.username}}
nats.password={{sys:weikio.nats.password}}
# Agent identification
agent.id={{sys:weikio.agent.id}}
# Using NATS credentials file
nats.credentials.path={{sys:weikio.nats.credentialsfilepath}}
Example integration flow using system variables:
apiVersion: weik.io/v1alpha1
kind: IntegrationFlow
metadata:
name: nats-publisher
spec:
source:
uri: "timer:publish?period=5000"
steps:
- uri: "nats:events?servers={{sys:weikio.nats.url}}"
Usage in APIM Configurations
APIM configurations (ApiVersions and ApiSubscriptions) can use variables with the {{sys:VARIABLE}} syntax or static values. Variables are defined separately in the variables section of the configuration, making it easier to manage and maintain variable definitions.
Example ApiVersion using variables:
apiVersion: weik.io/v1alpha1
kind: ApiVersion
metadata:
name: v1
spec:
authentication:
type: "oidc"
parameters:
clientId: "{{clientId}}"
clientSecret: "{{clientSecret}}"
tokenEndpoint: "https://auth.example.com/token"
variables:
- clientSecret: "{{sys:OidcClients--ifstest--ClientSecret}}"
- clientId: myClientId
Example ApiSubscription using variables:
apiVersion: weik.io/v1alpha1
kind: ApiSubscription
metadata:
name: api-subscription
spec:
apis:
- myapi
parameters:
apiKey: "{{myApiKey}}"
clientId: "{{clientId}}"
variables:
- myApiKey: "{{sys:ApiSubscriptions--myapi--Key}}"
- clientId: static-client-id-123
Usage in Database Change Tracking
Database change tracking configurations can use variables to manage database connection details and other sensitive information. Variables can be defined directly in the configuration and will be resolved at runtime.
Example DatabaseChangeTracking using variables:
apiVersion: weik.io/v1alpha1
kind: DatabaseChangeTracking
metadata:
name: postgres-test
description: Track database changes on PostgreSQL example database
spec:
type: postgres
parameters:
databasePassword: Q0rZOxIAnnPGgkAN8UPxNk9o5kc3y4V1v8wi6P8L2USup..
databaseHostname: {{dbHost}}
databaseDbname: sampledb
databaseUser: {{user}}
variables:
- user: {{sys:postgress-username}}
- dbHost: {{sys:production-db}}
This allows for:
- Managing sensitive database credentials through variables
- Environment-specific database configurations
- Consistent variable resolution across all database change tracking instances
The variable resolution happens at runtime through the following process:
- Integration runner detects environment variable references in routes and properties
- Variables are fetched from the Variables system
- Values are set as environment variables when starting the integration
- Apache Camel automatically resolves the variables during runtime
This allows for:
- Secure handling of sensitive information
- Environment-specific configurations
- Centralized management of shared values
- Native integration with Apache Camel’s variable resolution
- Consistent syntax across all configuration files
Usage Examples
Database Connection
apiVersion: weik.io/v1alpha1
kind: Variable
metadata:
name: DATABASE_CONNECTION
description: PostgreSQL connection string for production database
spec:
value: "Server=prod-db.example.com;Port=5432;Database=myapp;User Id=app_user;Password=secret;"
isSecret: true
Feature Flag
apiVersion: weik.io/v1alpha1
kind: Variable
metadata:
name: ENABLE_BETA_FEATURES
description: Toggle for beta features in production
spec:
value: "true"
isSecret: false
API Key
apiVersion: weik.io/v1alpha1
kind: Variable
metadata:
name: EXTERNAL_API_KEY
description: Authentication key for external service
spec:
value: "ak_live_12345abcdef"
isSecret: true
Future Enhancements
- Variable scopes (global, project, environment)
- Variable groups for organizing related variables
- Variable history and versioning support
- Variable references in other configurations
- Variable export/import functionality
- Integration with external secret management systems
- Support for complex variable transformations