configuration

package
v4.38.5 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultEnvDelimiter = "_"

DefaultEnvDelimiter is the default environment delimiter.

View Source
const DefaultEnvPrefix = "AUTHELIA_"

DefaultEnvPrefix is the default environment prefix.

Variables

This section is empty.

Functions

func DecodeTimeDuration added in v4.38.0

func DecodeTimeDuration(f, expectedType reflect.Type, prefixType string, data any) (result time.Duration, err error)

func EnsureConfigurationExists

func EnsureConfigurationExists(path string) (created bool, err error)

EnsureConfigurationExists is an auxiliary function to the main Configuration tools that ensures the Configuration template is created if it doesn't already exist.

func GetMultiKeyMappedDeprecationKeys added in v4.38.3

func GetMultiKeyMappedDeprecationKeys() (keys []string)

func IsSecretKey added in v4.36.8

func IsSecretKey(key string) (isSecretKey bool)

IsSecretKey returns true if the provided key is a secret enabled key.

func Load

func Load(val *schema.StructValidator, sources ...Source) (keys []string, configuration *schema.Configuration, err error)

Load the configuration given the provided options and sources.

func LoadAdvanced added in v4.33.0

func LoadAdvanced(val *schema.StructValidator, path string, result any, sources ...Source) (keys []string, err error)

LoadAdvanced is intended to give more flexibility over loading a particular path to a specific interface.

func StringToAddressHookFunc added in v4.36.0

func StringToAddressHookFunc() mapstructure.DecodeHookFuncType

StringToAddressHookFunc decodes a string into an Address or *Address.

func StringToCryptoPrivateKeyHookFunc added in v4.37.0

func StringToCryptoPrivateKeyHookFunc() mapstructure.DecodeHookFuncType

StringToCryptoPrivateKeyHookFunc decodes strings to schema.CryptographicPrivateKey's.

func StringToCryptographicKeyHookFunc added in v4.38.0

func StringToCryptographicKeyHookFunc() mapstructure.DecodeHookFuncType

StringToCryptographicKeyHookFunc decodes strings to schema.CryptographicKey's.

func StringToMailAddressHookFunc added in v4.34.5

func StringToMailAddressHookFunc() mapstructure.DecodeHookFuncType

StringToMailAddressHookFunc decodes a string into a mail.Address or *mail.Address.

func StringToPasswordDigestHookFunc added in v4.37.0

func StringToPasswordDigestHookFunc() mapstructure.DecodeHookFuncType

StringToPasswordDigestHookFunc decodes a string into a crypt.Digest.

func StringToPrivateKeyHookFunc added in v4.37.0

func StringToPrivateKeyHookFunc() mapstructure.DecodeHookFuncType

StringToPrivateKeyHookFunc decodes strings to rsa.PrivateKey's and ecdsa.PrivateKey's.

func StringToRegexpHookFunc added in v4.36.0

func StringToRegexpHookFunc() mapstructure.DecodeHookFuncType

StringToRegexpHookFunc decodes a string into a *regexp.Regexp or regexp.Regexp.

func StringToTLSVersionHookFunc added in v4.37.0

func StringToTLSVersionHookFunc() mapstructure.DecodeHookFuncType

StringToTLSVersionHookFunc decodes strings to schema.TLSVersion's.

func StringToURLHookFunc added in v4.34.5

func StringToURLHookFunc() mapstructure.DecodeHookFuncType

StringToURLHookFunc converts string types into a url.URL or *url.URL.

func StringToX509CertificateChainHookFunc added in v4.37.0

func StringToX509CertificateChainHookFunc() mapstructure.DecodeHookFuncType

StringToX509CertificateChainHookFunc decodes strings to schema.X509CertificateChain's.

func StringToX509CertificateHookFunc added in v4.37.0

func StringToX509CertificateHookFunc() mapstructure.DecodeHookFuncType

StringToX509CertificateHookFunc decodes strings to x509.Certificate's.

func ToEnvironmentKey added in v4.36.8

func ToEnvironmentKey(key, prefix, delimiter string) string

ToEnvironmentKey converts a key into the environment variable name.

func ToEnvironmentSecretKey added in v4.36.8

func ToEnvironmentSecretKey(key, prefix, delimiter string) string

ToEnvironmentSecretKey converts a key into the environment variable name.

func ToRefreshIntervalDurationHookFunc added in v4.38.0

func ToRefreshIntervalDurationHookFunc() mapstructure.DecodeHookFuncType

ToRefreshIntervalDurationHookFunc converts string and integer types to a schema.RefreshIntervalDuration.

func ToTimeDurationHookFunc added in v4.34.5

func ToTimeDurationHookFunc() mapstructure.DecodeHookFuncType

ToTimeDurationHookFunc converts string and integer types to a time.Duration.

Types

type BytesFilter added in v4.38.0

type BytesFilter interface {
	Name() (name string)
	Filter(in []byte) (out []byte, err error)
}

func NewExpandEnvFileFilter added in v4.38.0

func NewExpandEnvFileFilter() BytesFilter

NewExpandEnvFileFilter returns a new BytesFilter which passes the bytes through os.Expand using special env vars.

func NewFileFilters added in v4.38.0

func NewFileFilters(names []string) (filters []BytesFilter, err error)

NewFileFilters returns a list of BytesFilter provided they are valid.

func NewFileFiltersDefault added in v4.38.0

func NewFileFiltersDefault() []BytesFilter

NewFileFiltersDefault returns the default list of BytesFilter.

func NewTemplateFileFilter added in v4.38.0

func NewTemplateFileFilter() BytesFilter

NewTemplateFileFilter returns a new BytesFilter which passes the bytes through text/template.

type BytesSource added in v4.38.0

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

BytesSource is a raw bytes configuration.Source.

func NewBytesSource added in v4.38.0

func NewBytesSource(data []byte) (source *BytesSource)

NewBytesSource returns a configuration.Source configured to load from a specified bytes.

func (*BytesSource) Load added in v4.38.0

func (b *BytesSource) Load(val *schema.StructValidator) (err error)

Load the Source into the FileSource koanf.Koanf.

func (*BytesSource) Merge added in v4.38.0

func (b *BytesSource) Merge(ko *koanf.Koanf, _ *schema.StructValidator) (err error)

Merge the FileSource koanf.Koanf into the provided one.

func (*BytesSource) Name added in v4.38.0

func (b *BytesSource) Name() (name string)

Name of the Source.

func (*BytesSource) Read added in v4.38.0

func (b *BytesSource) Read() (map[string]any, error)

Read is not supported by the filtered file koanf.Provider.

func (*BytesSource) ReadBytes added in v4.38.0

func (b *BytesSource) ReadBytes() (data []byte, err error)

ReadBytes reads the contents of a file on disk, passes it through any configured filters, and returns the bytes.

type CommandLineSource added in v4.33.0

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

CommandLineSource is a configuration.Source which loads configuration from the command line flags.

func NewCommandLineSourceWithMapping added in v4.33.0

func NewCommandLineSourceWithMapping(flags *pflag.FlagSet, mapping map[string]string, includeValidKeys, includeUnchangedKeys bool) (source *CommandLineSource)

NewCommandLineSourceWithMapping creates a new command line configuration source with a map[string]string which converts flag names into other config key names. If includeValidKeys is true we also allow any flag with a name which matches the list of valid keys into the koanf.Koanf, otherwise everything not in the map is skipped. Unchanged flags are also skipped unless includeUnchangedKeys is set to true.

func (*CommandLineSource) Load added in v4.33.0

func (s *CommandLineSource) Load(_ *schema.StructValidator) (err error)

Load the Source into the FileSource koanf.Koanf.

func (*CommandLineSource) Merge added in v4.33.0

func (s *CommandLineSource) Merge(ko *koanf.Koanf, val *schema.StructValidator) (err error)

Merge the CommandLineSource koanf.Koanf into the provided one.

func (*CommandLineSource) Name added in v4.33.0

func (s *CommandLineSource) Name() (name string)

Name of the Source.

type Deprecation added in v4.36.0

type Deprecation struct {
	Version model.SemanticVersion
	Key     string
	NewKey  string
	AutoMap bool
	Keep    bool
	MapFunc func(value any) any
	ErrFunc func(d Deprecation, keysFinal map[string]any, value any, val *schema.StructValidator)
}

Deprecation represents a deprecated configuration key.

type EnvironmentSource

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

EnvironmentSource is a configuration.Source which loads values from the environment.

func NewEnvironmentSource

func NewEnvironmentSource(prefix, delimiter string) (source *EnvironmentSource)

NewEnvironmentSource returns a Source configured to load from environment variables.

func (*EnvironmentSource) Load

func (s *EnvironmentSource) Load(_ *schema.StructValidator) (err error)

Load the Source into the EnvironmentSource koanf.Koanf.

func (*EnvironmentSource) Merge

func (s *EnvironmentSource) Merge(ko *koanf.Koanf, _ *schema.StructValidator) (err error)

Merge the EnvironmentSource koanf.Koanf into the provided one.

func (*EnvironmentSource) Name

func (s *EnvironmentSource) Name() (name string)

Name of the Source.

type ExpandEnvBytesFilter added in v4.38.3

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

func (*ExpandEnvBytesFilter) Filter added in v4.38.3

func (f *ExpandEnvBytesFilter) Filter(in []byte) (out []byte, err error)

func (*ExpandEnvBytesFilter) Name added in v4.38.3

func (f *ExpandEnvBytesFilter) Name() (name string)

type File added in v4.38.0

type File struct {
	Path string
	Data []byte
}

File represents a file path and data content as bytes.

type FileSource added in v4.38.0

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

FileSource is a file configuration.Source.

func NewFileSource added in v4.38.0

func NewFileSource(path string) (source *FileSource)

NewFileSource returns a configuration.Source configured to load from a specified path. If there is an issue accessing this path it also returns an error.

func NewFileSources added in v4.38.0

func NewFileSources(paths []string) (sources []*FileSource)

NewFileSources returns a slice of configuration.Source configured to load from specified files.

func NewFilteredFileSource added in v4.38.0

func NewFilteredFileSource(path string, filters ...BytesFilter) (source *FileSource)

NewFilteredFileSource returns a configuration.Source configured to load from a specified path. If there is an issue accessing this path it also returns an error.

func NewFilteredFileSources added in v4.38.0

func NewFilteredFileSources(paths []string, filters []BytesFilter) (sources []*FileSource)

NewFilteredFileSources returns a slice of configuration.Source configured to load from specified files.

func (*FileSource) GetBytesFilterNames added in v4.38.3

func (s *FileSource) GetBytesFilterNames() (names []string)

func (*FileSource) Load added in v4.38.0

func (s *FileSource) Load(val *schema.StructValidator) (err error)

Load the Source into the FileSource koanf.Koanf.

func (*FileSource) Merge added in v4.38.0

func (s *FileSource) Merge(ko *koanf.Koanf, _ *schema.StructValidator) (err error)

Merge the FileSource koanf.Koanf into the provided one.

func (*FileSource) Name added in v4.38.0

func (s *FileSource) Name() (name string)

Name of the Source.

func (*FileSource) ReadFiles added in v4.38.0

func (s *FileSource) ReadFiles() (files []*File, err error)

ReadFiles reads all the files associated with this FileSource.

type FilteredFile added in v4.38.0

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

FilteredFile implements a koanf.Provider.

func FilteredFileProvider added in v4.38.0

func FilteredFileProvider(path string, filters ...BytesFilter) *FilteredFile

FilteredFileProvider returns a koanf.Provider which provides filtered file output.

func (*FilteredFile) Read added in v4.38.0

func (f *FilteredFile) Read() (map[string]any, error)

Read is not supported by the filtered file koanf.Provider.

func (*FilteredFile) ReadBytes added in v4.38.0

func (f *FilteredFile) ReadBytes() (data []byte, err error)

ReadBytes reads the contents of a file on disk, passes it through any configured filters, and returns the bytes.

type MapSource added in v4.36.0

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

MapSource is a configuration.Source which loads configuration from the command line flags.

func NewMapSource added in v4.36.0

func NewMapSource(m map[string]any) (source *MapSource)

NewMapSource returns a new map[string]any source.

func (*MapSource) Load added in v4.36.0

func (s *MapSource) Load(_ *schema.StructValidator) (err error)

Load the Source into the FileSource koanf.Koanf.

func (*MapSource) Merge added in v4.36.0

func (s *MapSource) Merge(ko *koanf.Koanf, val *schema.StructValidator) (err error)

Merge the CommandLineSource koanf.Koanf into the provided one.

func (*MapSource) Name added in v4.36.0

func (s *MapSource) Name() (name string)

Name of the Source.

type MultiKeyMappedDeprecation added in v4.38.3

type MultiKeyMappedDeprecation struct {
	Version model.SemanticVersion
	Keys    []string
	NewKey  string
	MapFunc func(d MultiKeyMappedDeprecation, keys map[string]any, val *schema.StructValidator)
}

MultiKeyMappedDeprecation represents a deprecated configuration key.

type SecretsSource

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

SecretsSource is a configuration.Source which loads environment variables that have a value pointing to a file.

func NewSecretsSource

func NewSecretsSource(prefix, delimiter string) (source *SecretsSource)

NewSecretsSource returns a Source configured to load from secrets.

func (*SecretsSource) Load

func (s *SecretsSource) Load(val *schema.StructValidator) (err error)

Load the Source into the SecretsSource koanf.Koanf.

func (*SecretsSource) Merge

func (s *SecretsSource) Merge(ko *koanf.Koanf, val *schema.StructValidator) (err error)

Merge the SecretsSource koanf.Koanf into the provided one.

func (*SecretsSource) Name

func (s *SecretsSource) Name() (name string)

Name of the Source.

type Source

type Source interface {
	Name() (name string)
	Merge(ko *koanf.Koanf, val *schema.StructValidator) (err error)
	Load(val *schema.StructValidator) (err error)
}

Source is an abstract representation of a configuration configuration.Source implementation.

func NewDefaultSources

func NewDefaultSources(paths []string, prefix, delimiter string, additionalSources ...Source) (sources []Source)

NewDefaultSources returns a slice of Source configured to load from specified YAML files.

func NewDefaultSourcesFiltered added in v4.38.0

func NewDefaultSourcesFiltered(paths []string, filters []BytesFilter, prefix, delimiter string, additionalSources ...Source) (sources []Source)

NewDefaultSourcesFiltered returns a slice of Source configured to load from specified YAML files.

func NewDefaultSourcesWithDefaults added in v4.36.0

func NewDefaultSourcesWithDefaults(paths []string, filters []BytesFilter, prefix, delimiter string, defaults Source, additionalSources ...Source) (sources []Source)

NewDefaultSourcesWithDefaults returns a slice of Source configured to load from specified YAML files with additional sources.

type TemplateBytesFilter added in v4.38.3

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

func (*TemplateBytesFilter) Filter added in v4.38.3

func (f *TemplateBytesFilter) Filter(in []byte) (out []byte, err error)

func (*TemplateBytesFilter) Name added in v4.38.3

func (f *TemplateBytesFilter) Name() (name string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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