Documentation
¶
Index ¶
- func GetConfigData(cfgPath string, workDir string, envSpecMap ...EnvSpecMap) (_ []byte, gErr error)
- func GetConfigDir() string
- func GetConfigPath() string
- func Merge[A any, B any | *any](dst *A, src ...B) error
- func MergeR[A any, B any | *any](dst *A, src ...B) (r result.Result[*A])
- func RegisterExpr(name string, fn any) error
- func SetConfigPath(confPath string)
- type Base64File
- type Cfg
- type EnvSpec
- type EnvSpecMap
- type ExprExistsError
- type ListOrMap
- type Manager
- type NamedConfig
- type Node
- type Resources
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetConfigData ¶
func GetConfigData(cfgPath string, workDir string, envSpecMap ...EnvSpecMap) (_ []byte, gErr error)
GetConfigData loads and processes config file content with optional envSpecMap validation. If envSpecMap is provided, env() calls in the config will be validated against defined vars. workDir is the root config directory used for embed() path resolution.
func GetConfigDir ¶
func GetConfigDir() string
func GetConfigPath ¶
func GetConfigPath() string
func RegisterExpr ¶
RegisterExpr registers a custom expression function for use in config templates. Returns error if the name already exists. For backward compatibility, use MustRegisterExpr for panic behavior. Note: Custom functions must have simple signatures: func() T or func(T) R
func SetConfigPath ¶
func SetConfigPath(confPath string)
Types ¶
type Base64File ¶
type Base64File string
func (*Base64File) MarshalYAML ¶
func (b *Base64File) MarshalYAML() (any, error)
func (*Base64File) UnmarshalYAML ¶
func (b *Base64File) UnmarshalYAML(value *yaml.Node) error
type Cfg ¶
type Cfg[T any] struct { T T P *T EnvCfg *EnvSpecMap }
type EnvSpec ¶
type EnvSpec struct {
// Name of the environment variable.
Name string `yaml:"name"`
Desc string `yaml:"desc"`
Default string `yaml:"default"`
Value string `yaml:"value"`
Example string `yaml:"example"`
// Validation using go-playground/validator tags
// Examples: "required", "email", "url", "uuid", "ip", "numeric", "min=3,max=50"
Rule string `yaml:"validate"`
}
type EnvSpecMap ¶
func LoadEnvMap ¶
func LoadEnvMap(cfgPath string) EnvSpecMap
func (EnvSpecMap) ValidateAll ¶
func (m EnvSpecMap) ValidateAll() error
ValidateAll validates all environment specs in the map
type ExprExistsError ¶
type ExprExistsError struct {
Name string
}
ExprExistsError is returned when trying to register a duplicate expression
func (*ExprExistsError) Error ¶
func (e *ExprExistsError) Error() string
type ListOrMap ¶
type ListOrMap[T any] []T
func (*ListOrMap[T]) MarshalYAML ¶
MarshalYAML implements the yaml.Marshaler interface.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager provides thread-safe configuration management
func (*Manager) GetExprFuncs ¶
GetExprFuncs returns a copy of registered expression functions
func (*Manager) RegisterExprFunc ¶
RegisterExprFunc registers a custom expression function in a thread-safe manner
type NamedConfig ¶
type NamedConfig interface {
// ConfigUniqueName unique name
ConfigUniqueName() string
}
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
func (*Node) MarshalJSON ¶
func (*Node) MarshalYAML ¶
type Resources ¶
type Resources struct {
// Resources resource config file or dir must exist
Resources []string `yaml:"resources"`
// PatchResources resource config file or dir not required to exist
PatchResources []string `yaml:"patch_resources"`
// PatchEnvs env config file or dir not required to exist
PatchEnvs []string `yaml:"patch_envs"`
}