mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-21 19:07:00 +00:00
minor nits
This commit is contained in:
parent
b4547ce367
commit
8fc1df8d8b
5 changed files with 24 additions and 24 deletions
2
Makefile
2
Makefile
|
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/make -f
|
#!/usr/bin/make -f
|
||||||
|
|
||||||
|
.PHONY: test-build test build build-static docker-test docker-build-static
|
||||||
|
|
||||||
test-build: test build
|
test-build: test build
|
||||||
|
|
||||||
test:
|
test:
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
VALID = iota
|
VALID = iota
|
||||||
INVALID = iota
|
INVALID
|
||||||
ERROR = iota
|
ERROR
|
||||||
SKIPPED = iota
|
SKIPPED
|
||||||
)
|
)
|
||||||
|
|
||||||
type Output interface {
|
type Output interface {
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,5 @@ func (r LocalSchemas) DownloadSchema(resourceKind, resourceAPIVersion, k8sVersio
|
||||||
return nil, fmt.Errorf("failed to open schema %s", schemaFile)
|
return nil, fmt.Errorf("failed to open schema %s", schemaFile)
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
content, err := ioutil.ReadAll(f)
|
return ioutil.ReadAll(f)
|
||||||
|
|
||||||
return content, err
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ func TestSignatureFromBytes(t *testing.T) {
|
||||||
name string
|
name string
|
||||||
have []byte
|
have []byte
|
||||||
want resource.Signature
|
want resource.Signature
|
||||||
err error
|
err error
|
||||||
} {
|
}{
|
||||||
{
|
{
|
||||||
name: "valid deployment",
|
name: "valid deployment",
|
||||||
have: []byte(`
|
have: []byte(`
|
||||||
|
|
@ -24,10 +24,10 @@ metadata:
|
||||||
app: myService
|
app: myService
|
||||||
spec:
|
spec:
|
||||||
`),
|
`),
|
||||||
want: resource.Signature {
|
want: resource.Signature{
|
||||||
Kind: "Deployment",
|
Kind: "Deployment",
|
||||||
Version: "apps/v1",
|
Version: "apps/v1",
|
||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
},
|
},
|
||||||
err: nil,
|
err: nil,
|
||||||
},
|
},
|
||||||
|
|
@ -45,4 +45,4 @@ spec:
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,16 +45,16 @@ func Validate(rawResource []byte, schema *gojsonschema.Schema) error {
|
||||||
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() {
|
if results.Valid() {
|
||||||
msg := ""
|
return nil
|
||||||
for _, errMsg := range results.Errors() {
|
|
||||||
if msg != "" {
|
|
||||||
msg += " - "
|
|
||||||
}
|
|
||||||
msg += errMsg.Description()
|
|
||||||
}
|
|
||||||
return InvalidResourceError{err: msg}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
msg := ""
|
||||||
|
for _, errMsg := range results.Errors() {
|
||||||
|
if msg != "" {
|
||||||
|
msg += " - "
|
||||||
|
}
|
||||||
|
msg += errMsg.Description()
|
||||||
|
}
|
||||||
|
return InvalidResourceError{err: msg}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue