config

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package config provides configuration management for the kat application.

It wraps other package configuration to provide a single API for loading, validating, and writing configuration files in YAML format.

Additionally, it implements JSON schema generation and validation for the configuration.

Index

Constants

This section is empty.

Variables

View Source
var (
	ValidAPIVersions = []string{
		"kat.jacobcolvin.com/v1beta1",
	}
	ValidKinds = []string{
		"Configuration",
	}

	DefaultValidator = yaml.MustNewValidator("/config.v1beta1.json", schemaJSON)
)

Functions

func GetPath

func GetPath() string

func WriteDefaultConfig

func WriteDefaultConfig(path string, force bool) error

WriteDefaultConfig writes the embedded default config.yaml and jsonschema to the specified path.

Types

type Config

type Config struct {
	Command *command.Config `json:",inline"`
	UI      *ui.Config      `json:",inline"`
	// APIVersion specifies the API version for this configuration.
	APIVersion string `json:"apiVersion" jsonschema:"title=API Version"`
	// Kind defines the type of configuration.
	Kind string `json:"kind" jsonschema:"title=Kind"`
}

func NewConfig

func NewConfig() *Config

func (*Config) EnsureDefaults

func (c *Config) EnsureDefaults()

func (Config) JSONSchemaExtend added in v0.15.0

func (c Config) JSONSchemaExtend(jss *jsonschema.Schema)

func (Config) MarshalYAML

func (c Config) MarshalYAML() ([]byte, error)

func (Config) Write

func (c Config) Write(path string) error

type ConfigLoader added in v0.22.0

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

func NewConfigLoaderFromBytes added in v0.22.0

func NewConfigLoaderFromBytes(data []byte, opts ...ConfigLoaderOpt) *ConfigLoader

func NewConfigLoaderFromFile added in v0.22.0

func NewConfigLoaderFromFile(path string, opts ...ConfigLoaderOpt) (*ConfigLoader, error)

func (*ConfigLoader) GetTheme added in v0.22.0

func (cl *ConfigLoader) GetTheme() *theme.Theme

func (*ConfigLoader) Load added in v0.22.0

func (cl *ConfigLoader) Load() (*Config, error)

func (*ConfigLoader) Validate added in v0.22.0

func (cl *ConfigLoader) Validate() error

Validate validates configuration data with ConfigValidator without loading it into a Config struct.

type ConfigLoaderOpt added in v0.22.0

type ConfigLoaderOpt func(*ConfigLoader)

func WithConfigValidator added in v0.22.0

func WithConfigValidator(cv ConfigValidator) ConfigLoaderOpt

func WithThemeFromData added in v0.22.0

func WithThemeFromData() ConfigLoaderOpt

type ConfigValidator added in v0.22.0

type ConfigValidator interface {
	Validate(data any) error
}

Jump to

Keyboard shortcuts

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