From 8fc1df8d8b570a31b18930f7a98c46fd69af43c8 Mon Sep 17 00:00:00 2001 From: Yann Hamon Date: Mon, 1 Jun 2020 12:20:15 +0200 Subject: [PATCH] minor nits --- Makefile | 2 ++ pkg/output/main.go | 8 ++++---- pkg/registry/local.go | 4 +--- pkg/resource/main_test.go | 14 +++++++------- pkg/validator/main.go | 20 ++++++++++---------- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 9bed59b..28372fc 100644 --- a/Makefile +++ b/Makefile @@ -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: diff --git a/pkg/output/main.go b/pkg/output/main.go index 517284e..a1a5ac3 100644 --- a/pkg/output/main.go +++ b/pkg/output/main.go @@ -5,10 +5,10 @@ import ( ) const ( - VALID = iota - INVALID = iota - ERROR = iota - SKIPPED = iota + VALID = iota + INVALID + ERROR + SKIPPED ) type Output interface { diff --git a/pkg/registry/local.go b/pkg/registry/local.go index 4ebb576..e600ed6 100644 --- a/pkg/registry/local.go +++ b/pkg/registry/local.go @@ -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) } diff --git a/pkg/resource/main_test.go b/pkg/resource/main_test.go index a0867f4..4279542 100644 --- a/pkg/resource/main_test.go +++ b/pkg/resource/main_test.go @@ -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: } } -} \ No newline at end of file +} diff --git a/pkg/validator/main.go b/pkg/validator/main.go index d68f82d..3c76226 100644 --- a/pkg/validator/main.go +++ b/pkg/validator/main.go @@ -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} }