diff --git a/cmd/kubeconform/main.go b/cmd/kubeconform/main.go index 554d439..8d5c7ad 100644 --- a/cmd/kubeconform/main.go +++ b/cmd/kubeconform/main.go @@ -29,7 +29,7 @@ func processResults(cancel context.CancelFunc, o output.Output, validationResult fmt.Fprint(os.Stderr, "failed writing log\n") } } - if success == false && exitOnError { + if !success && exitOnError { cancel() // early exit - signal to stop searching for resources break } diff --git a/pkg/cache/inmemory.go b/pkg/cache/inmemory.go index 594bace..ff8a829 100644 --- a/pkg/cache/inmemory.go +++ b/pkg/cache/inmemory.go @@ -31,7 +31,7 @@ func (c *inMemory) Get(resourceKind, resourceAPIVersion, k8sVersion string) (int defer c.RUnlock() schema, ok := c.schemas[k] - if ok == false { + if !ok { return nil, fmt.Errorf("schema not found in in-memory cache") } diff --git a/pkg/registry/http_test.go b/pkg/registry/http_test.go index 45a7ee6..3885b70 100644 --- a/pkg/registry/http_test.go +++ b/pkg/registry/http_test.go @@ -93,7 +93,7 @@ func TestDownloadSchema(t *testing.T) { t.Errorf("during test '%s': expected error, got:\n%s\n%s\n", testCase.name, testCase.expectErr, err) } - if bytes.Compare(res, testCase.expect) != 0 { + if !bytes.Equal(res, testCase.expect) { t.Errorf("during test '%s': expected %s, got %s", testCase.name, testCase.expect, res) } } diff --git a/pkg/resource/files.go b/pkg/resource/files.go index 429c8ad..ce4bf01 100644 --- a/pkg/resource/files.go +++ b/pkg/resource/files.go @@ -92,7 +92,7 @@ func findResourcesInReader(p string, f io.Reader, resources chan<- Resource, err scanner.Buffer(buf, len(buf)) scanner.Split(SplitYAMLDocument) nRes := 0 - for res := scanner.Scan(); res != false; res = scanner.Scan() { + for scanner.Scan() { if len(scanner.Text()) > 0 { resources <- Resource{Path: p, Bytes: []byte(scanner.Text())} nRes++ diff --git a/pkg/resource/stream.go b/pkg/resource/stream.go index 4bd5d5b..6ed328b 100644 --- a/pkg/resource/stream.go +++ b/pkg/resource/stream.go @@ -54,7 +54,7 @@ func FromStream(ctx context.Context, path string, r io.Reader) (<-chan Resource, scanner.Split(SplitYAMLDocument) SCAN: - for res := scanner.Scan(); res != false; res = scanner.Scan() { + for scanner.Scan() { select { case <-ctx.Done(): break SCAN diff --git a/pkg/resource/stream_test.go b/pkg/resource/stream_test.go index 9f17842..6c78eb5 100644 --- a/pkg/resource/stream_test.go +++ b/pkg/resource/stream_test.go @@ -151,7 +151,7 @@ kind: Deployment t.Errorf("test %d - expected %d resources, got %d", testi, len(testCase.Want.Resources), len(res)) } for i, v := range res { - if bytes.Compare(v.Bytes, testCase.Want.Resources[i].Bytes) != 0 { + if !bytes.Equal(v.Bytes, testCase.Want.Resources[i].Bytes) { t.Errorf("test %d - for resource %d, got '%s', expected '%s'", testi, i, string(res[i].Bytes), string(testCase.Want.Resources[i].Bytes)) } } diff --git a/pkg/validator/validator.go b/pkg/validator/validator.go index cf5c99d..c502379 100644 --- a/pkg/validator/validator.go +++ b/pkg/validator/validator.go @@ -55,7 +55,7 @@ type Opts struct { func New(schemaLocations []string, opts Opts) (Validator, error) { // Default to our kubernetes-json-schema fork // raw.githubusercontent.com is frontend by Fastly and very fast - if schemaLocations == nil || len(schemaLocations) == 0 { + if len(schemaLocations) == 0 { schemaLocations = []string{"https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/{{ .NormalizedKubernetesVersion }}-standalone{{ .StrictSuffix }}/{{ .ResourceKind }}{{ .KindSuffix }}.json"} }