config

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2025 License: Apache-2.0 Imports: 13 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",
	}
)

Functions

func GetPath

func GetPath() string

func ReadConfig

func ReadConfig(path string) ([]byte, error)

func ValidateWithSchema added in v0.15.0

func ValidateWithSchema(data any) error

ValidateWithSchema validates the given YAML data against the embedded JSON schema.

func WriteDefaultConfig

func WriteDefaultConfig(path string) 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 LoadConfig

func LoadConfig(data []byte) (*Config, error)

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

Jump to

Keyboard shortcuts

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