authelia/internal/configuration/types.go
James Elliott a7e867a699
feat(configuration): replace viper with koanf (#2053)
This commit replaces github.com/spf13/viper with github.com/knadh/koanf. Koanf is very similar library to viper, with less dependencies and several quality of life differences. This also allows most config options to be defined by ENV. Lastly it also enables the use of split configuration files which can be configured by setting the --config flag multiple times.

Co-authored-by: Amir Zarrinkafsh <nightah@me.com>
2021-08-03 19:55:21 +10:00

35 lines
851 B
Go

package configuration
import (
"github.com/knadh/koanf"
"github.com/authelia/authelia/internal/configuration/schema"
)
// Source is an abstract representation of a configuration Source implementation.
type Source interface {
Name() (name string)
Merge(ko *koanf.Koanf, val *schema.StructValidator) (err error)
Load(val *schema.StructValidator) (err error)
}
// YAMLFileSource is a configuration Source with a YAML File.
type YAMLFileSource struct {
koanf *koanf.Koanf
path string
}
// EnvironmentSource is a configuration Source which loads values from the environment.
type EnvironmentSource struct {
koanf *koanf.Koanf
prefix string
delimiter string
}
// SecretsSource loads environment variables that have a value pointing to a file.
type SecretsSource struct {
koanf *koanf.Koanf
prefix string
delimiter string
}