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 ¶
- type Config
- func (c *Config) Get(path string) any
- func (c *Config) GetBool(path string) bool
- func (c *Config) GetDuration(path string) time.Duration
- func (c *Config) GetInt(path string) int
- func (c *Config) GetMap(path string) map[string]any
- func (c *Config) GetString(path string) string
- func (c *Config) ToYAML() ([]byte, error)
- type SchemaValidator
- func (v *SchemaValidator) GenerateConfig(format string) ([]byte, error)
- func (v *SchemaValidator) GenerateConfigWithOverrides(format string, overrides map[string]any) ([]byte, error)
- func (v *SchemaValidator) GenerateScheduler(format string) ([]byte, error)
- func (v *SchemaValidator) LoadConfig(data []byte, format string) (*Config, error)
- func (v *SchemaValidator) LoadConfigWithEnvInterpolation(path string) (*Config, error)
- func (v *SchemaValidator) ValidateConfig(data []byte, format string) error
- func (v *SchemaValidator) ValidateScheduler(data []byte, format string) error
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) GetDuration ¶
GetDuration returns a time.Duration value at the given path
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