Skip to content

Commit

Permalink
config: Fix parsing validation
Browse files Browse the repository at this point in the history
Signed-off-by: Chance Zibolski <[email protected]>
  • Loading branch information
chancez committed Sep 6, 2024
1 parent 8510394 commit a1f4cac
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions pkg/config/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,44 +57,43 @@ func Parse(data []byte) (Config, error) {

func validateGenerators(generatorCfg Generator) error {
count := 0
switch {
case generatorCfg.File != nil:
if generatorCfg.File != nil {
count++
fallthrough
case generatorCfg.Exec != nil:
}
if generatorCfg.Exec != nil {
count++
fallthrough
case generatorCfg.Helm != nil:
}
if generatorCfg.Helm != nil {
count++
fallthrough
case generatorCfg.Kustomize != nil:
}
if generatorCfg.Kustomize != nil {
count++
fallthrough
case generatorCfg.Merge != nil:
}
if generatorCfg.Merge != nil {
count++
fallthrough
case generatorCfg.GoTemplate != nil:
}
if generatorCfg.GoTemplate != nil {
count++
fallthrough
case generatorCfg.Import != nil:
}
if generatorCfg.Import != nil {
count++
fallthrough
case generatorCfg.JQ != nil:
}
if generatorCfg.JQ != nil {
count++
fallthrough
case generatorCfg.CELFilter != nil:
}
if generatorCfg.CELFilter != nil {
count++
fallthrough
case generatorCfg.YAML != nil:
}
if generatorCfg.YAML != nil {
count++
fallthrough
case generatorCfg.JSON != nil:
}
if generatorCfg.JSON != nil {
count++
}
if count == 0 {
return fmt.Errorf("generator not configured")
}
if count > 0 {
if count > 1 {
return fmt.Errorf("invalid configuration, cannot specify multiple generators in the same generator config")
}
return nil
Expand Down

0 comments on commit a1f4cac

Please sign in to comment.