Skip to content

Commit

Permalink
Merge pull request #493 from hazelops/IZE-487-show-possible-propertie…
Browse files Browse the repository at this point in the history
…s-when-ize-toml-has-invalid-syntax

IZE-487 added display of possible properties when ize.toml has invalid syntax
  • Loading branch information
psihachina authored Oct 13, 2022
2 parents fdfe644 + cb78525 commit 73b6f12
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion internal/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,18 @@ func Validate(config map[string]interface{}) error {
} else {
i = strings.ReplaceAll(i[2:], "/", ".")
}
return fmt.Errorf("%s in %s of config file (or environment variables)", m, i)
errMsg := fmt.Sprintf("%s in %s of config file (or environment variables)", m, i)
if strings.Contains(errMsg, "additionalProperties") {
errMsg += ". The following options are available:\n"
properties := GetSchema()
if i != "root" {
properties = properties[strings.Split(i, ".")[0]].Items
}
for k := range properties {
errMsg += fmt.Sprintf("- %s\n", k)
}
}
return fmt.Errorf(errMsg)
}

return nil
Expand Down

0 comments on commit 73b6f12

Please sign in to comment.