DNSSEC-Provisioning / DNSSEC-Provisioning/music
Only validate config for enabled signers
- Dominant language
- Go
- Stars
- 6
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
As we gain support for additional signers, that may or may not be enabled, it obviously doesn't work to validate the config for something that isn't configured. So validation must be configurable, preferably on the "signers.{name}.enabled" key. I suggest something like this:
```
func ValidateBySection(config *Config, cfgfile string) error {
var configsections = make(map[string]interface{}, 5)
validate := validator.New()
log.Printf(`
*** Config validation: Note that sections that do not have an 'enabled=true' key
*** are not validated, but may still be used.`)
configsections["signers.desec"] = config.Signers.DeSEC
configsections["signers.foobar"] = config.Signers.Foobar
for k, data := range configsections {
if viper.GetBool(fmt.Sprintf("%s.enabled", k)) {
log.Printf("Validating config for %s section", k)
if err := validate.Struct(data); err != nil {
log.Fatalf("Config %s, section %s: missing required attributes:\n%v\n", cfgfile, k, err)
}
} else {
log.Printf("Config %s, section %s: not enabled (requires %s.enabled=true), not validating its config.",
cfgfile, k, k)
}
}
e=return nil
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.