Documentation
¶
Overview ¶
Package config provides project configuration file loading and parsing.
The config package is responsible for reading .awf/config.yaml files and providing pre-populated input values for workflow execution.
Configuration Loading:
The primary entry point is YAMLConfigLoader which reads configuration from the project's .awf/config.yaml file:
loader := config.NewYAMLConfigLoader(configPath)
cfg, err := loader.Load()
if err != nil {
// Handle config error
}
// Use cfg.Inputs for workflow input defaults
Merge Priority:
Config file values have the lowest priority and are overridden by CLI --input flags. This allows config to provide defaults while still allowing runtime customization.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigError ¶
type ConfigError struct {
Path string // config file path (may be empty)
Op string // operation: "load", "parse", "validate"
Message string // human-readable error message
Cause error // underlying error (optional)
}
ConfigError represents an error during config file operations.
func (*ConfigError) Error ¶
func (e *ConfigError) Error() string
Error implements the error interface.
func (*ConfigError) Unwrap ¶
func (e *ConfigError) Unwrap() error
Unwrap returns the underlying error for errors.Is/As support.
type ProjectConfig ¶
type ProjectConfig struct {
// Inputs contains pre-populated workflow input values.
// These are merged with CLI --input flags, with CLI taking precedence.
Inputs map[string]any `yaml:"inputs"`
// Notify holds notification backend configuration.
// Loaded from .awf/config.yaml under "notify:" key.
// Type is defined in internal/infrastructure/notify/types.go
Notify struct {
DefaultBackend string `yaml:"default_backend"`
} `yaml:"notify"`
}
ProjectConfig holds the project-level configuration loaded from .awf/config.yaml. It provides default values that can be overridden by CLI flags.
type WarningFunc ¶
WarningFunc is a callback for reporting non-fatal warnings during config loading. The loader calls this for each unknown key found in the config file.
type YAMLConfigLoader ¶
type YAMLConfigLoader struct {
// contains filtered or unexported fields
}
YAMLConfigLoader loads project configuration from a YAML file. The primary config path is .awf/config.yaml relative to project root.
func NewYAMLConfigLoader ¶
func NewYAMLConfigLoader(path string) *YAMLConfigLoader
NewYAMLConfigLoader creates a new config loader for the given path.
func (*YAMLConfigLoader) Load ¶
func (l *YAMLConfigLoader) Load() (*ProjectConfig, error)
Load reads and parses the config file.
Behavior:
- Returns empty config if file does not exist (not an error)
- Returns ConfigError for invalid YAML syntax
- Returns ConfigError for file read errors (permissions, etc.)
- Unknown keys in config trigger warnings via WarningFunc (if set)
- Unknown keys do NOT cause Load to fail
func (*YAMLConfigLoader) Path ¶
func (l *YAMLConfigLoader) Path() string
Path returns the config file path this loader reads from.
func (*YAMLConfigLoader) WithWarningFunc ¶
func (l *YAMLConfigLoader) WithWarningFunc(fn WarningFunc) *YAMLConfigLoader
WithWarningFunc sets a callback for reporting unknown key warnings. If not set, unknown keys are silently ignored.