2021-08-03 09:55:21 +00:00
|
|
|
package configuration
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/knadh/koanf"
|
2021-11-23 09:45:38 +00:00
|
|
|
"github.com/spf13/pflag"
|
2021-08-03 09:55:21 +00:00
|
|
|
|
2021-08-11 01:04:35 +00:00
|
|
|
"github.com/authelia/authelia/v4/internal/configuration/schema"
|
2021-08-03 09:55:21 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|
2021-11-23 09:45:38 +00:00
|
|
|
|
|
|
|
// CommandLineSource loads configuration from the command line flags.
|
|
|
|
type CommandLineSource struct {
|
|
|
|
koanf *koanf.Koanf
|
|
|
|
flags *pflag.FlagSet
|
|
|
|
callback func(flag *pflag.Flag) (string, interface{})
|
|
|
|
}
|
2022-06-01 23:18:45 +00:00
|
|
|
|
|
|
|
// MapSource loads configuration from the command line flags.
|
|
|
|
type MapSource struct {
|
|
|
|
m map[string]interface{}
|
|
|
|
koanf *koanf.Koanf
|
|
|
|
}
|