minor nits

This commit is contained in:
Yann Hamon 2020-06-01 12:20:15 +02:00
parent b4547ce367
commit 8fc1df8d8b
5 changed files with 24 additions and 24 deletions

View file

@ -1,5 +1,7 @@
#!/usr/bin/make -f
.PHONY: test-build test build build-static docker-test docker-build-static
test-build: test build
test:

View file

@ -5,10 +5,10 @@ import (
)
const (
VALID = iota
INVALID = iota
ERROR = iota
SKIPPED = iota
VALID = iota
INVALID
ERROR
SKIPPED
)
type Output interface {

View file

@ -56,7 +56,5 @@ func (r LocalSchemas) DownloadSchema(resourceKind, resourceAPIVersion, k8sVersio
return nil, fmt.Errorf("failed to open schema %s", schemaFile)
}
defer f.Close()
content, err := ioutil.ReadAll(f)
return content, err
return ioutil.ReadAll(f)
}

View file

@ -10,8 +10,8 @@ func TestSignatureFromBytes(t *testing.T) {
name string
have []byte
want resource.Signature
err error
} {
err error
}{
{
name: "valid deployment",
have: []byte(`
@ -24,10 +24,10 @@ metadata:
app: myService
spec:
`),
want: resource.Signature {
Kind: "Deployment",
Version: "apps/v1",
Namespace: "default",
want: resource.Signature{
Kind: "Deployment",
Version: "apps/v1",
Namespace: "default",
},
err: nil,
},
@ -45,4 +45,4 @@ spec:
}
}
}
}

View file

@ -45,16 +45,16 @@ func Validate(rawResource []byte, schema *gojsonschema.Schema) error {
return fmt.Errorf("problem validating schema. Check JSON formatting: %s", err)
}
if !results.Valid() {
msg := ""
for _, errMsg := range results.Errors() {
if msg != "" {
msg += " - "
}
msg += errMsg.Description()
}
return InvalidResourceError{err: msg}
if results.Valid() {
return nil
}
return nil
msg := ""
for _, errMsg := range results.Errors() {
if msg != "" {
msg += " - "
}
msg += errMsg.Description()
}
return InvalidResourceError{err: msg}
}