mirror of
https://github.com/yannh/kubeconform.git
synced 2026-04-11 07:24:17 +00:00
better logic mgmt in output plugins, go fmt
This commit is contained in:
parent
224e9ca17d
commit
8eb297d4c4
11 changed files with 93 additions and 79 deletions
|
|
@ -6,14 +6,16 @@ import (
|
|||
"sigs.k8s.io/yaml"
|
||||
)
|
||||
|
||||
type InvalidResourceError struct { err string }
|
||||
func (r InvalidResourceError) Error() string{
|
||||
type InvalidResourceError struct{ err string }
|
||||
|
||||
func (r InvalidResourceError) Error() string {
|
||||
return r.err
|
||||
}
|
||||
|
||||
// ValidFormat is a type for quickly forcing
|
||||
// new formats on the gojsonschema loader
|
||||
type ValidFormat struct{}
|
||||
|
||||
func (f ValidFormat) IsFormat(input interface{}) bool {
|
||||
return true
|
||||
}
|
||||
|
|
@ -40,13 +42,12 @@ func Validate(rawResource []byte, schema *gojsonschema.Schema) error {
|
|||
results, err := schema.Validate(resourceLoader)
|
||||
if err != nil {
|
||||
// This error can only happen if the Object to validate is poorly formed. There's no hope of saving this one
|
||||
return fmt.Errorf("problem validating schema. Check JSON formatting: %s", err)
|
||||
return fmt.Errorf("problem validating schema. Check JSON formatting: %s", err)
|
||||
}
|
||||
|
||||
if !results.Valid() {
|
||||
return InvalidResourceError{err: fmt.Sprintf("resource does not conform to schema: %+v", results) }
|
||||
return InvalidResourceError{err: fmt.Sprintf("resource does not conform to schema: %+v", results)}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue