Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyEnvOverrides ¶ added in v0.12.0
ApplyEnvOverrides applies environment variable overrides to a config struct. It checks per-instance variables first (PREFIX_NAME_SUFFIX), then global variables (PREFIX_SUFFIX). Global overrides take precedence.
func LoadInstances ¶ added in v0.12.0
func LoadInstances[C any, I any](dir string, spec InstanceSpec[C, I]) ([]I, error)
LoadInstances reads configs from a .humanconfig file, applies env overrides, and builds instances using the provided spec.
func UnmarshalSection ¶
UnmarshalSection reads a .humanconfig YAML file from dir and unmarshals the given key into target. Returns nil when the config file is missing.
Types ¶
type EnvField ¶ added in v0.12.0
EnvField maps a config struct field to its environment variable suffix. For example, {Suffix: "TOKEN", Set: func(c *MyConfig, v string) { c.Token = v }} will check for PROVIDER_TOKEN (global) and PROVIDER_NAME_TOKEN (per-instance).
type InstanceSpec ¶ added in v0.12.0
type InstanceSpec[C any, I any] struct { // Section is the YAML key in .humanconfig (e.g. "githubs", "jiras"). Section string // EnvPrefix is the prefix for environment variables (e.g. "GITHUB_", "JIRA_"). EnvPrefix string // EnvFields maps config struct fields to env var suffixes. EnvFields []EnvField[C] // DefaultURL is set on configs with an empty URL before env overrides. // Leave empty if no default (e.g. Jira requires explicit URL). DefaultURL string // GetName returns the instance name from a config entry. GetName func(C) string // SetURL sets the URL on the config. Nil if the config has no URL field. SetURL func(*C, string) // GetURL returns the URL from a config entry. Nil if the config has no URL field. GetURL func(C) string // Build creates an instance from a config entry. Return (zero, false) to skip // the entry (e.g. missing required credentials). Build func(C) (I, bool) }
InstanceSpec defines how to load and build instances from config entries.