Move to yaml-based configuration
This commit updates the configuration to be yaml-based and updates the configuration to read in a yaml file.
This commit is contained in:
parent
568c005d15
commit
945329a080
70 changed files with 1150 additions and 350 deletions
32
internal/config/validators/collection.go
Normal file
32
internal/config/validators/collection.go
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
package validators
|
||||
|
||||
import (
|
||||
"github.com/FAU-CDI/wisski-distillery/pkg/environment"
|
||||
"github.com/FAU-CDI/wisski-distillery/pkg/validator"
|
||||
)
|
||||
|
||||
// New creates a new set of standard validators for the configuration
|
||||
func New(env environment.Environment) validator.Collection {
|
||||
coll := make(validator.Collection)
|
||||
|
||||
validator.Add(coll, "nonempty", ValidateNonempty)
|
||||
|
||||
validator.Add(coll, "directory", func(value *string, dflt string) error {
|
||||
return ValidateDirectory(env, value, dflt)
|
||||
})
|
||||
validator.Add(coll, "file", func(value *string, dflt string) error {
|
||||
return ValidateFile(env, value, dflt)
|
||||
})
|
||||
|
||||
validator.Add(coll, "domain", ValidateDomain)
|
||||
validator.AddSlice(coll, "domains", ",", ValidateDomain)
|
||||
validator.Add(coll, "https", ValidateHTTPSURL)
|
||||
validator.Add(coll, "slug", ValidateSlug)
|
||||
validator.Add(coll, "email", ValidateEmail)
|
||||
|
||||
validator.Add(coll, "positive", ValidatePositive)
|
||||
validator.Add(coll, "port", ValidatePort)
|
||||
|
||||
validator.Add(coll, "duration", ValidateDuration)
|
||||
return coll
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue