config

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Build

type Build struct {
	Context    string            `yaml:"context"`              // Build context path
	Dockerfile string            `yaml:"dockerfile,omitempty"` // Dockerfile path (default: Dockerfile)
	Args       map[string]string `yaml:"args,omitempty"`       // Build arguments
}

Build represents build configuration for building from source

type Config

type Config struct {
	Version  string             `yaml:"version"`  // e.g., "1.0"
	Project  string             `yaml:"project"`  // Project name
	Services map[string]Service `yaml:"services"` // Map of service name -> Service
}

Config represents the entire ork.yml file structure

func Load

func Load() (*Config, error)

Load reads and parses the ork.yml configuration file It looks for ork.yml in the current directory, falling back to .ork.yml

func (*Config) Validate

func (c *Config) Validate() error

Validate checks if the config is valid and returns helpful error messages

type EnvVars

type EnvVars map[string]string

EnvVars represents a collection of environment variables

func InterpolateEnvVars

func InterpolateEnvVars(envVars EnvVars) (EnvVars, error)

InterpolateEnvVars interpolates variable references in environment values Supports:

  • ${VAR_NAME} - standard form
  • $VAR_NAME - short form (word characters only)
  • ${VAR_NAME:-default} - with default value

Variables are resolved from:

  1. The provided EnvVars map (for self-referencing)
  2. System environment variables (os.Getenv)

Returns an error if circular references are detected

func LoadAllEnvForService

func LoadAllEnvForService(serviceName string, configEnv map[string]string) (EnvVars, error)

LoadAllEnvForService loads and merges all environment variables for a service Priority (lowest to highest):

  1. Project .env file
  2. Service-specific .env.<service> file
  3. Environment variables from the york.yml config

After merging, all variable references (${VAR} or $VAR) are interpolated

func LoadEnvFile

func LoadEnvFile(filePath string) (EnvVars, error)

LoadEnvFile loads environment variables from a .env file Returns an empty map if the file doesn't exist (not an error)

func LoadProjectEnv

func LoadProjectEnv() (EnvVars, error)

LoadProjectEnv loads the project-level .env file from the current directory Looks for .env in the directory where ork.yml is located

func LoadServiceEnv

func LoadServiceEnv(serviceName string) (EnvVars, error)

LoadServiceEnv loads service-specific .env file Looks for .env.<service-name> in the current directory

func MergeEnvVars

func MergeEnvVars(envMaps ...EnvVars) EnvVars

MergeEnvVars merges multiple EnvVars maps with priority Later maps override earlier ones Example: MergeEnvVars(projectEnv, serviceEnv, configEnv) configEnv has highest priority, projectEnv has lowest

type HealthCheck

type HealthCheck struct {
	Endpoint string `yaml:"endpoint"` // HTTP endpoint to check (e.g., /health)
	Interval string `yaml:"interval"` // Check interval (e.g., 5s)
	Timeout  string `yaml:"timeout"`  // Request timeout (e.g., 3s)
	Retries  int    `yaml:"retries"`  // Number of retries before unhealthy
}

HealthCheck represents health check configuration

type Service

type Service struct {
	// Source configuration (mutually exclusive)
	Git   string `yaml:"git,omitempty"`   // Git repo URL (e.g., github.com/org/repo)
	Image string `yaml:"image,omitempty"` // Docker image (e.g., nginx:alpine)
	Build *Build `yaml:"build,omitempty"` // Build from a local source

	// Runtime configuration
	Ports      []string          `yaml:"ports,omitempty"`      // Port mappings (e.g., "3000:3000")
	Env        map[string]string `yaml:"env,omitempty"`        // Environment variables
	DependsOn  []string          `yaml:"depends_on,omitempty"` // Service dependencies
	Health     *HealthCheck      `yaml:"health,omitempty"`     // Health check config
	Command    []string          `yaml:"command,omitempty"`    // Override container command
	Entrypoint []string          `yaml:"entrypoint,omitempty"` // Override entrypoint
}

Service represents a single service definition

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL