2021-08-03 09:55:21 +00:00
|
|
|
package configuration
|
|
|
|
|
|
|
|
import (
|
2023-02-19 00:49:08 +00:00
|
|
|
"github.com/knadh/koanf/v2"
|
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
|
|
|
)
|
|
|
|
|
2022-12-21 09:48:14 +00:00
|
|
|
// Source is an abstract representation of a configuration configuration.Source implementation.
|
2021-08-03 09:55:21 +00:00
|
|
|
type Source interface {
|
|
|
|
Name() (name string)
|
|
|
|
Merge(ko *koanf.Koanf, val *schema.StructValidator) (err error)
|
|
|
|
Load(val *schema.StructValidator) (err error)
|
|
|
|
}
|
|
|
|
|
2022-12-22 06:34:20 +00:00
|
|
|
// FileSource is a file configuration.Source.
|
|
|
|
type FileSource struct {
|
2022-12-21 09:48:14 +00:00
|
|
|
koanf *koanf.Koanf
|
|
|
|
path string
|
|
|
|
filters []FileFilter
|
2021-08-03 09:55:21 +00:00
|
|
|
}
|
|
|
|
|
2022-12-22 00:21:29 +00:00
|
|
|
// EnvironmentSource is a configuration configuration.Source which loads values from the environment.
|
2021-08-03 09:55:21 +00:00
|
|
|
type EnvironmentSource struct {
|
|
|
|
koanf *koanf.Koanf
|
|
|
|
prefix string
|
|
|
|
delimiter string
|
|
|
|
}
|
|
|
|
|
2022-12-22 00:21:29 +00:00
|
|
|
// SecretsSource is a configuration.Source which loads environment variables that have a value pointing to a file.
|
2021-08-03 09:55:21 +00:00
|
|
|
type SecretsSource struct {
|
|
|
|
koanf *koanf.Koanf
|
|
|
|
prefix string
|
|
|
|
delimiter string
|
|
|
|
}
|
2021-11-23 09:45:38 +00:00
|
|
|
|
2022-12-22 00:21:29 +00:00
|
|
|
// CommandLineSource is a configuration.Source which loads configuration from the command line flags.
|
2021-11-23 09:45:38 +00:00
|
|
|
type CommandLineSource struct {
|
|
|
|
koanf *koanf.Koanf
|
|
|
|
flags *pflag.FlagSet
|
2022-10-05 05:05:23 +00:00
|
|
|
callback func(flag *pflag.Flag) (string, any)
|
2021-11-23 09:45:38 +00:00
|
|
|
}
|
2022-06-01 23:18:45 +00:00
|
|
|
|
2022-12-22 00:21:29 +00:00
|
|
|
// MapSource is a configuration.Source which loads configuration from the command line flags.
|
2022-06-01 23:18:45 +00:00
|
|
|
type MapSource struct {
|
2022-10-05 05:05:23 +00:00
|
|
|
m map[string]any
|
2022-06-01 23:18:45 +00:00
|
|
|
koanf *koanf.Koanf
|
|
|
|
}
|