config: add support for policies stored in the databroker (#1099)

* wip

* always use databroker config source

* add test

* valid policy, remove debug lines
This commit is contained in:
Caleb Doxsey 2020-07-17 10:35:29 -06:00 committed by GitHub
parent 821f2e9000
commit b79e73b8b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 965 additions and 6 deletions

View file

@ -52,6 +52,24 @@ type Source interface {
OnConfigChange(ChangeListener)
}
// A StaticSource always returns the same config. Useful for testing.
type StaticSource struct {
cfg *Config
}
// NewStaticSource creates a new StaticSource.
func NewStaticSource(cfg *Config) *StaticSource {
return &StaticSource{cfg: cfg}
}
// GetConfig gets the config.
func (src *StaticSource) GetConfig() *Config {
return src.cfg
}
// OnConfigChange is ignored for the StaticSource.
func (src *StaticSource) OnConfigChange(ChangeListener) {}
// A FileOrEnvironmentSource retrieves config options from a file or the environment.
type FileOrEnvironmentSource struct {
configFile string