This document details the configuration options for the development environment of the Timoni project. It assumes that the environment is already set up.
CUE Configuration
The primary configuration language used in Timoni is CUE. It facilitates the definition of application deployments by providing an expressive syntax and powerful data validation. To integrate CUE into your development environment, follow these examples.
Defining Environment Variables
To define environment variables in your CUE configuration, use the #EnvVar
structure. This allows for setting variables that your application can access.
#EnvVar: {
name: "DATABASE_URL"
value: "postgres://user:password@host:5432/dbname"
}
Environment variables can also reference other environment variables, using the $(VAR_NAME)
syntax.
#EnvVar: {
name: "API_KEY"
value: "$(SECRET_API_KEY)"
}
Using Multiple Environment Variables
It is possible to define a list of environment variables using the env
parameter. Each variable must have a unique name.
env: [
#EnvVar {
name: "DATABASE_URL"
value: "postgres://user:password@host:5432/dbname"
}
#EnvVar {
name: "API_KEY"
value: "$(SECRET_API_KEY)"
}
]
Populating Environment Variables from Sources
You can populate environment variables from different sources using the envFrom
parameter. This is useful for managing environment variables through Kubernetes ConfigMaps or Secrets.
envFrom: [
{
configMapRef: {
name: "app-config"
}
},
{
secretRef: {
name: "app-secret"
}
}
]
Example CUE Module
Below is a complete example of a CUE module that includes environment variable definitions:
module: "example.module"
#EnvVar: {
name: string
value?: string
}
#Deployment: {
containers: [...{
name: "app-container"
image: "your-image:tag"
env: [
#EnvVar {
name: "DATABASE_URL"
value: "postgres://user:password@host:5432/dbname"
}
#EnvVar {
name: "API_KEY"
value: "$(SECRET_API_KEY)"
}
]
}]
}
Makefile Configuration
To build your project with the appropriate options, you might configure your Makefile as follows:
.PHONY: build
build:
go build -o timoni github.com/stefanprodan/timoni
This example compiles the Timoni application without using the -mod=vendor
option, which is important for consistent builds in a development environment.
Kubeconfig Management
The location of the Kubernetes configuration file can be managed through environment variables. You can modify your runtime configuration to retrieve the Kubeconfig path:
func getCurrentKubeconfigPath() string {
defaultPath := ""
kubeConfig := os.Getenv("KUBECONFIG")
if kubeConfig == "" {
return defaultPath
}
return filepath.SplitList(kubeConfig)[0]
}
Ensure that the KUBECONFIG
environment variable is set correctly in your development environment to reference the desired Kubernetes configuration.
Summary
This guide has provided a detailed overview of the configuration options for setting up the Timoni development environment. Following these patterns will help ensure a streamlined development process. For more guidance on using these examples within your application, refer to the CUE documentation and Timoni’s official repository.
Source of information: Timothy official documentation and internal files.