loader

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoSources = errors.New("no configuration sources specified; use -f to specify files, directories, or URLs")

ErrNoSources is returned when no configuration sources are provided.

Functions

func FetchURL added in v1.3.0

func FetchURL(ctx context.Context, rawURL string) ([]byte, error)

FetchURL retrieves a declarative configuration source from an HTTP(S) URL.

func FetchURLWithOptions added in v1.3.0

func FetchURLWithOptions(ctx context.Context, rawURL string, options URLFetchOptions) ([]byte, error)

FetchURLWithOptions retrieves a declarative configuration source from an HTTP(S) URL using the provided options.

func ResolveReferences added in v0.1.5

func ResolveReferences(ctx context.Context, rs *resources.ResourceSet) error

ResolveReferences resolves all ref placeholders in the ResourceSet

func ValidateYAMLFile

func ValidateYAMLFile(path string) bool

ValidateYAMLFile checks if a file has a valid YAML extension

Types

type FieldResolver added in v0.1.5

type FieldResolver interface {
	// ResolveField extracts a field value from a resource
	ResolveField(resource resources.Resource, field string) (string, error)

	// CanResolve checks if this resolver can handle the given resource type
	CanResolve(resourceType string) bool
}

FieldResolver interface for field resolution

type Loader

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

Loader handles loading declarative configuration from files

func New

func New() *Loader

New creates a new configuration loader

func NewWithBaseDir added in v0.3.6

func NewWithBaseDir(baseDir string) *Loader

NewWithBaseDir creates a new configuration loader with a base directory for !file boundaries

func NewWithPath

func NewWithPath(path string) *Loader

NewWithPath creates a new configuration loader with a root path (deprecated, for backward compatibility)

func (*Loader) Load

func (l *Loader) Load() (*resources.ResourceSet, error)

Load loads configuration from the default current directory (deprecated)

func (*Loader) LoadFile

func (l *Loader) LoadFile(path string) (*resources.ResourceSet, error)

LoadFile loads configuration from a single YAML file (deprecated, for backward compatibility)

func (*Loader) LoadFromSources

func (l *Loader) LoadFromSources(sources []Source, recursive bool) (*resources.ResourceSet, error)

LoadFromSources loads configuration from multiple sources

func (*Loader) LoadFromSourcesWithContext added in v0.1.5

func (l *Loader) LoadFromSourcesWithContext(ctx context.Context, sources []Source,
	recursive bool,
) (*resources.ResourceSet, error)

LoadFromSourcesWithContext loads configuration from multiple sources with context support

func (*Loader) WithURLFetchOptions added in v1.3.0

func (l *Loader) WithURLFetchOptions(options URLFetchOptions) *Loader

WithURLFetchOptions configures remote URL source fetching.

type LocalFieldResolver added in v0.1.5

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

LocalFieldResolver resolves fields from local ResourceSet

func NewLocalFieldResolver added in v0.1.5

func NewLocalFieldResolver(logger *slog.Logger) *LocalFieldResolver

NewLocalFieldResolver creates a new local field resolver

func (*LocalFieldResolver) CanResolve added in v0.1.5

func (r *LocalFieldResolver) CanResolve(_ string) bool

CanResolve checks if this resolver can handle the resource type

func (*LocalFieldResolver) ResolveField added in v0.1.5

func (r *LocalFieldResolver) ResolveField(resource resources.Resource, field string) (string, error)

ResolveField extracts field value using reflection

type Source

type Source struct {
	Path string
	Type SourceType
}

Source represents a configuration source with its type

func ParseSources

func ParseSources(filenames []string) ([]Source, error)

ParseSources parses the filename flag values into individual sources

type SourceType

type SourceType int

SourceType represents the type of configuration source

const (
	// SourceTypeFile represents a single file source
	SourceTypeFile SourceType = iota
	// SourceTypeDirectory represents a directory source
	SourceTypeDirectory
	// SourceTypeSTDIN represents stdin source
	SourceTypeSTDIN
	// SourceTypeURL represents an HTTP(S) URL source
	SourceTypeURL
)

type URLFetchAuthPolicy added in v1.3.0

type URLFetchAuthPolicy string

URLFetchAuthPolicy controls when remote declarative URL fetches may include authentication.

const (
	// URLFetchAuthAuto sends the configured bearer token only to HTTPS URLs whose host is explicitly allowed.
	URLFetchAuthAuto URLFetchAuthPolicy = "auto"
	// URLFetchAuthNone disables authentication for remote declarative URL fetches.
	URLFetchAuthNone URLFetchAuthPolicy = "none"
)

type URLFetchOptions added in v1.3.0

type URLFetchOptions struct {
	AuthPolicy       URLFetchAuthPolicy
	AuthAllowedHosts []string
	TokenSource      URLFetchTokenSource
}

URLFetchOptions controls remote declarative URL fetch behavior that should be selected by the command layer.

func (URLFetchOptions) AllowsAuthenticationForURL added in v1.3.0

func (o URLFetchOptions) AllowsAuthenticationForURL(rawURL string) bool

AllowsAuthenticationForURL reports whether the URL is within the configured authentication boundary.

type URLFetchTokenSource added in v1.3.0

type URLFetchTokenSource interface {
	Token(context.Context) (string, error)
}

URLFetchTokenSource provides bearer tokens for authenticated remote declarative URL fetches.

Jump to

Keyboard shortcuts

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