mirror of
https://github.com/yannh/kubeconform.git
synced 2026-04-14 00:14:45 +00:00
add test for missing apiVersion - better error message
This commit is contained in:
parent
031f83cbde
commit
509ad8e997
5 changed files with 57 additions and 8 deletions
|
|
@ -123,10 +123,6 @@ func (val *v) ValidateResource(res resource.Resource) Result {
|
|||
return Result{Resource: res, Err: fmt.Errorf("error while parsing: %s", err), Status: Error}
|
||||
}
|
||||
|
||||
if sig.Kind == "" { // Resource contains key/values but no Kind
|
||||
return Result{Resource: res, Err: fmt.Errorf("resource missing a Kind"), Status: Error}
|
||||
}
|
||||
|
||||
if skip(*sig) {
|
||||
return Result{Resource: res, Err: nil, Status: Skipped}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ func TestValidate(t *testing.T) {
|
|||
"valid resource",
|
||||
[]byte(`
|
||||
kind: name
|
||||
apiVersion: v1
|
||||
firstName: foo
|
||||
lastName: bar
|
||||
`),
|
||||
|
|
@ -49,6 +50,7 @@ lastName: bar
|
|||
"invalid resource",
|
||||
[]byte(`
|
||||
kind: name
|
||||
apiVersion: v1
|
||||
firstName: foo
|
||||
lastName: bar
|
||||
`),
|
||||
|
|
@ -79,6 +81,7 @@ lastName: bar
|
|||
"missing required field",
|
||||
[]byte(`
|
||||
kind: name
|
||||
apiVersion: v1
|
||||
firstName: foo
|
||||
`),
|
||||
[]byte(`{
|
||||
|
|
@ -108,6 +111,7 @@ firstName: foo
|
|||
"resource has invalid yaml",
|
||||
[]byte(`
|
||||
kind: name
|
||||
apiVersion: v1
|
||||
firstName foo
|
||||
lastName: bar
|
||||
`),
|
||||
|
|
@ -118,6 +122,9 @@ lastName: bar
|
|||
"kind": {
|
||||
"type": "string"
|
||||
},
|
||||
"apiVersion": {
|
||||
"type": "string"
|
||||
},
|
||||
"firstName": {
|
||||
"type": "number"
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue