mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-21 19:07:00 +00:00
better example
This commit is contained in:
parent
4e96b44a8b
commit
6f2fe33bc0
1 changed files with 5 additions and 2 deletions
|
|
@ -19,8 +19,11 @@ func main() {
|
||||||
v := validator.New(nil, validator.Opts{Strict: true})
|
v := validator.New(nil, validator.Opts{Strict: true})
|
||||||
for i, res := range v.Validate(filepath, f) { // A file might contain multiple resources
|
for i, res := range v.Validate(filepath, f) { // A file might contain multiple resources
|
||||||
// File starts with ---, the parser assumes a first empty resource
|
// File starts with ---, the parser assumes a first empty resource
|
||||||
if res.Status != validator.Valid && res.Status != validator.Empty {
|
if res.Status == validator.Invalid {
|
||||||
log.Fatalf("resource %d in file %s is not valid: %d, %s", i, filepath, res.Status, res.Err)
|
log.Fatalf("resource %d in file %s is not valid: %s", i, filepath, res.Err)
|
||||||
|
}
|
||||||
|
if res.Status == validator.Error {
|
||||||
|
log.Fatalf("error while processing resource %d in file %s: %s", i, filepath, res.Err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue