configfile

package
v0.15.4 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package configfile loads YAML configuration files with strict environment interpolation.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidEnvironmentReference reports unsupported environment syntax in a
	// YAML scalar.
	ErrInvalidEnvironmentReference = errors.New("configfile.invalid_environment_reference")

	// ErrMissingEnvironmentVariables reports YAML references to unset
	// environment variables.
	ErrMissingEnvironmentVariables = errors.New("configfile.missing_environment_variables")

	// ErrMissingPath reports an empty config file path.
	ErrMissingPath = errors.New("configfile.missing_path")

	// ErrNilTarget reports a nil or non-pointer decode target.
	ErrNilTarget = errors.New("configfile.nil_target")

	// ErrParse reports malformed YAML or target decode failures.
	ErrParse = errors.New("configfile.parse")

	// ErrRead reports config file read failures.
	ErrRead = errors.New("configfile.read")
)

Functions

func InterpolateYAML

func InterpolateYAML(configPayload []byte) ([]byte, error)

InterpolateYAML expands environment variables only inside YAML scalar nodes.

func LoadYAML

func LoadYAML(path string, target any) error

LoadYAML reads a YAML config file, expands environment variables only inside YAML scalar nodes, and decodes the result with KnownFields enabled.

func LoadYAMLBytes

func LoadYAMLBytes(configPayload []byte, target any) error

LoadYAMLBytes expands environment variables only inside YAML scalar nodes and decodes the result with KnownFields enabled.

Types

type InvalidEnvironmentReferenceError

type InvalidEnvironmentReferenceError struct {
	Reference string
}

InvalidEnvironmentReferenceError identifies an unsupported interpolation reference.

func (InvalidEnvironmentReferenceError) Error

func (invalidReferenceError InvalidEnvironmentReferenceError) Error() string

Error returns a stable invalid-reference error string.

func (InvalidEnvironmentReferenceError) Is

func (invalidReferenceError InvalidEnvironmentReferenceError) Is(target error) bool

Is reports compatibility with ErrInvalidEnvironmentReference.

type MissingEnvironmentVariablesError

type MissingEnvironmentVariablesError struct {
	Names []string
}

MissingEnvironmentVariablesError identifies every unset environment variable referenced by a YAML document.

func (MissingEnvironmentVariablesError) Error

func (missingVariablesError MissingEnvironmentVariablesError) Error() string

Error returns a stable missing-environment error string.

func (MissingEnvironmentVariablesError) Is

func (missingVariablesError MissingEnvironmentVariablesError) Is(target error) bool

Is reports compatibility with ErrMissingEnvironmentVariables.

Jump to

Keyboard shortcuts

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