config

package
v0.28.1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package config provides a generic configuration loader for the kat application.

It provides a Loader type that can load, validate, and parse configuration files in YAML format for any type implementing github.com/macropower/kat/api/v1beta1.Object.

Configuration types are defined in sub-packages of github.com/macropower/kat/api/v1beta1:

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Loader added in v0.28.0

type Loader[T v1beta1.Object] struct {
	// contains filtered or unexported fields
}

Loader is a generic configuration loader that handles validation, YAML parsing, and error formatting for any config type T.

func NewLoaderFromBytes added in v0.28.0

func NewLoaderFromBytes[T v1beta1.Object](
	data []byte,
	newFunc func() T,
	defaultValidator Validator,
	opts ...LoaderOpt,
) *Loader[T]

NewLoaderFromBytes creates a Loader from byte data. The newFunc parameter is the constructor for type T (e.g., config.New).

func NewLoaderFromFile added in v0.28.0

func NewLoaderFromFile[T v1beta1.Object](
	path string,
	newFunc func() T,
	defaultValidator Validator,
	opts ...LoaderOpt,
) (*Loader[T], error)

NewLoaderFromFile creates a Loader from a file path.

func (*Loader[T]) GetTheme added in v0.28.0

func (l *Loader[T]) GetTheme() *theme.Theme

GetTheme returns the theme for error formatting.

func (*Loader[T]) Load added in v0.28.0

func (l *Loader[T]) Load() (T, error)

Load parses and returns the configuration.

func (*Loader[T]) Validate added in v0.28.0

func (l *Loader[T]) Validate() error

Validate validates the configuration data against the schema.

type LoaderOpt added in v0.28.0

type LoaderOpt func(*loaderOptions)

LoaderOpt configures a Loader.

func WithThemeFromData added in v0.22.0

func WithThemeFromData() LoaderOpt

WithThemeFromData extracts the theme from the config data for error formatting.

func WithValidator added in v0.28.0

func WithValidator(v Validator) LoaderOpt

WithValidator sets a custom validator.

type Validator added in v0.28.0

type Validator interface {
	Validate(data any) error
}

Validator validates configuration data against a schema.

Jump to

Keyboard shortcuts

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