cueconfig

package
v0.5.12 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cueconfig provides CUE schema-based configuration validation, generation, and loading. The CUE schemas in cmd/schema/ are the single source of truth for configuration structure and default values. This package provides methods to work with configuration data without requiring explicit Go type definitions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config represents the application configuration loaded from CUE. It wraps a map[string]any and provides typed accessor methods.

func (*Config) Get

func (c *Config) Get(path string) any

Get returns a value at the given path (dot-separated)

func (*Config) GetBool

func (c *Config) GetBool(path string) bool

GetBool returns a bool value at the given path

func (*Config) GetDuration

func (c *Config) GetDuration(path string) time.Duration

GetDuration returns a time.Duration value at the given path

func (*Config) GetInt

func (c *Config) GetInt(path string) int

GetInt returns an int value at the given path

func (*Config) GetMap

func (c *Config) GetMap(path string) map[string]any

GetMap returns a map value at the given path

func (*Config) GetString

func (c *Config) GetString(path string) string

GetString returns a string value at the given path

func (*Config) ToYAML

func (c *Config) ToYAML() ([]byte, error)

ToYAML serializes the config to YAML

type SchemaValidator

type SchemaValidator struct {
	// contains filtered or unexported fields
}

SchemaValidator provides CUE schema validation and config loading

func NewValidator

func NewValidator() *SchemaValidator

NewValidator creates a new schema validator

func (*SchemaValidator) GenerateConfig

func (v *SchemaValidator) GenerateConfig(format string) ([]byte, error)

GenerateConfig generates a default configuration from the schema

func (*SchemaValidator) GenerateConfigWithOverrides

func (v *SchemaValidator) GenerateConfigWithOverrides(format string, overrides map[string]any) ([]byte, error)

GenerateConfigWithOverrides generates configuration with optional overrides

func (*SchemaValidator) GenerateScheduler

func (v *SchemaValidator) GenerateScheduler(format string) ([]byte, error)

GenerateScheduler generates a default scheduler configuration

func (*SchemaValidator) LoadConfig

func (v *SchemaValidator) LoadConfig(data []byte, format string) (*Config, error)

LoadConfig loads configuration from YAML/JSON data, validates it against the schema, and returns a Config with defaults filled in from the CUE schema.

func (*SchemaValidator) LoadConfigWithEnvInterpolation

func (v *SchemaValidator) LoadConfigWithEnvInterpolation(path string) (*Config, error)

LoadConfigWithEnvInterpolation loads config from file, expanding ${VAR}/$VAR environment-variable placeholders inside its string values.

Interpolation happens AFTER parsing, on the parsed map's string values only -- not textually on the raw bytes, which is what an earlier os.ExpandEnv-based version did. Post-parse expansion closes two textual footguns at once: an unset variable now yields an empty STRING (the raw expansion left an empty unquoted YAML token, which parses as null and then fails schema validation with a confusing type error -- quoted or unquoted, the placeholder's spot stays a string now), and a variable's VALUE can never be re-parsed as YAML/JSON syntax, since the document's structure is fixed before any value is substituted.

func (*SchemaValidator) ValidateConfig

func (v *SchemaValidator) ValidateConfig(data []byte, format string) error

ValidateConfig validates configuration data against the schema without loading

func (*SchemaValidator) ValidateScheduler

func (v *SchemaValidator) ValidateScheduler(data []byte, format string) error

ValidateScheduler validates scheduler configuration data

Jump to

Keyboard shortcuts

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