Skip to content

Commit

Permalink
config: Update validation error message
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 a1f4cac commit 55fe937
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/config/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,27 @@ func Parse(data []byte) (Config, error) {
}

if cfg.Generator != nil && len(cfg.Pipeline) != 0 {
return Config{}, errors.New("cannot set both 'pipeline' and 'generator' options")
return Config{}, errors.New("validation error: cannot set both 'pipeline' and 'generator' options")
}

if cfg.Generator != nil {
err := validateGenerators(*cfg.Generator)
if err != nil {
return Config{}, fmt.Errorf("error parsing: %w", err)
return Config{}, fmt.Errorf("validation error: %w", err)
}
}

generatorPositions := make(map[string]int)
for pos, gen := range cfg.Pipeline {
if gen.Name == "" {
return Config{}, fmt.Errorf("error parsing: pipeline[%d], generator is missing a name", pos)
return Config{}, fmt.Errorf("validation error: pipeline[%d], generator is missing a name", pos)
}
if existingPos, exists := generatorPositions[gen.Name]; exists {
return Config{}, fmt.Errorf("error parsing: pipeline[%d], generator %q already exists at pipeline[%d]", pos, gen.Name, existingPos)
return Config{}, fmt.Errorf("validation error: pipeline[%d], generator %q already exists at pipeline[%d]", pos, gen.Name, existingPos)
}
err := validateGenerators(gen)
if err != nil {
return Config{}, fmt.Errorf("error parsing: pipeline[%d] %s: %w", pos, gen.Name, err)
return Config{}, fmt.Errorf("validation error: pipeline[%d] %s: %w", pos, gen.Name, err)
}
generatorPositions[gen.Name] = pos
}
Expand Down

0 comments on commit 55fe937

Please sign in to comment.