config

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Environment

func Environment() string

func SetEnvironment

func SetEnvironment(env string)

Types

type Completable

type Completable interface {
	// Complete performs any required transformations on the configuration,
	// e.g. filling a map[string]X field from an []X field with keys.
	// It is expected to modify the configuration in place.
	// The fieldPath parameter can be used to create error messages.
	Complete(fldPath *field.Path) error
}

type Config

type Config struct {
}

func LoadFromBytes

func LoadFromBytes(rawConfigs ...[]byte) (*Config, error)

LoadFromBytes builds the config from multiple raw YAML byte slices. It merges the configs together, with later configs overriding earlier ones.

func LoadFromFiles

func LoadFromFiles(paths ...string) (*Config, error)

LoadFromFiles builds the config from multiple YAML files.

func (*Config) Complete

func (c *Config) Complete() error

Complete completes the config by calling the Complete() method on each field that implements the Completable interface.

func (*Config) Default

func (c *Config) Default() error

Default defaults the config by calling the Default() method on each field that implements the Defaultable interface.

func (*Config) Dump

func (c *Config) Dump(out io.Writer) error

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the config by calling the Validate() method on each field that implements the Validatable interface.

type Defaultable

type Defaultable interface {
	// Default sets default values for the configuration.
	// It is expected to modify the configuration in place.
	// The fieldPath parameter can be used to create error messages.
	Default(fldPath *field.Path) error
}

type Validatable

type Validatable interface {
	// Validate validates the configuration.
	// It should return an error if the configuration is invalid.
	// It is not supposed to modify the configuration in any way.
	// The fieldPath parameter can be used to create error messages.
	Validate(fldPath *field.Path) error
}

Jump to

Keyboard shortcuts

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