config

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProcessIncludes added in v0.7.0

func ProcessIncludes(configMap map[string]any, basePath string, stack IncludeStack) (map[string]any, error)

ProcessIncludes recursively processes includes in a config map. basePath is the directory containing the current config file. stack is used for loop detection via content hashing.

Merge semantics: maps are recursively merged, lists are concatenated (not replaced), and scalar values are overridden by later includes. The local config (non-included content) takes highest priority.

Types

type IncludeEntry added in v0.7.0

type IncludeEntry struct {
	Path string
	Hash string
}

IncludeEntry tracks both path (for error messages) and content hash (for loop detection)

type IncludeStack added in v0.7.0

type IncludeStack []IncludeEntry

IncludeStack tracks the chain of includes for loop detection

func (IncludeStack) ContainsHash added in v0.7.0

func (s IncludeStack) ContainsHash(hash string) bool

ContainsHash checks if a content hash is already in the stack

func (IncludeStack) CycleString added in v0.7.0

func (s IncludeStack) CycleString(cyclePath string) string

CycleString formats the include chain for error messages

func (IncludeStack) Push added in v0.7.0

func (s IncludeStack) Push(path, hash string) IncludeStack

Push adds a new entry to the stack

type LoadResult added in v0.7.0

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

LoadResult wraps config with validation errors from loading. It is safe for concurrent use; the config reload callback (from fsnotify) writes under a write lock, while GetInstances and friends read under a read lock.

func Load added in v0.3.1

func Load(ctx context.Context, configPaths []string, configName string, strict bool) (*LoadResult, error)

Load loads and validates configuration from the specified paths. If strict is true, validation errors are collected; otherwise invalid instances are skipped with warnings.

func (*LoadResult) EnforceStrict added in v0.7.0

func (r *LoadResult) EnforceStrict(log *slog.Logger) error

EnforceStrict logs all validation errors and returns an error if any exist. Used in strict mode to abort on configuration errors.

func (*LoadResult) GetInstances added in v0.7.0

func (r *LoadResult) GetInstances() []provider.Instance

GetInstances returns a flat slice of all loaded provider instances.

func (*LoadResult) HasErrors added in v0.7.0

func (r *LoadResult) HasErrors() bool

HasErrors returns true if any validation errors were collected.

func (*LoadResult) ValidationErrors added in v0.7.0

func (r *LoadResult) ValidationErrors() []error

ValidationErrors returns a copy of the validation errors.

Jump to

Keyboard shortcuts

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