Begin to overhaul config to couple initialization logic closer to the structs themselves.
This commit is contained in:
parent
d9babf5dc0
commit
1b374bccc6
15 changed files with 122 additions and 33 deletions
19
internal/configparser/modes.go
Normal file
19
internal/configparser/modes.go
Normal file
|
@ -0,0 +1,19 @@
|
|||
package configparser
|
||||
|
||||
import "slices"
|
||||
|
||||
// validateModes checks the provided modes against a larger subset of modes (usually all defined ones)
|
||||
// and returns false if any of the modes are not defined.
|
||||
func validateModes(modes []string, allModes []string) bool {
|
||||
if len(modes) == 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
for _, mode := range modes {
|
||||
if !slices.Contains(allModes, mode) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue