Repository: FairwindsOps/polaris (go)

Issue:
Polaris fails to parse/ignore Kustomization yaml JSONPatch files
### Installation Process
Docker image

### Polaris Versions
1.2, 2.0, 3.2.1

### Expected Behavior

It should have ignored the json patch format yaml files when it realized they weren't in the expected yaml format, or there should be an option to ignore files that match a given glob or regex.

### Actual Behavior

Polaris errored out and there doesn't appear to be any CLI way to get it to ignore these jsonpatch yaml files which are valid in Kustomize.

### Steps to Reproduce

```
docker run -ti \
  -v "$PWD:/pwd" \
  -v ~/.kube/config:/opt/app/config:ro \
  quay.io/fairwinds/polaris:1.2 polaris audit \
    --kubeconfig /opt/app/config \
    --audit-path /pwd 
ERRO[0000] Invalid YAML: - op: replace
  path: /spec/syncPolicy
  value: {} 
ERRO[0000] Error parsing YAML: (error unmarshaling JSON: while decoding JSON: json: cannot unmarshal array into Go value of type kube.k8sResource) 
ERRO[0000] Error fetching Kubernetes resources error unmarshaling JSON: while decoding JSON: json: cannot unmarshal array into Go value of type kube.k8sResource 

```

Pull request description:
skip incomplete or broken YAML - warn user
This PR:

- changes `visitFile()` (WalkFunc for `filepath.Walk()`) to log parsing failures and continue (eg, patch files; fixes #667)
- removes error logging of failed parsing - upper functions are now responsible for bubbling up the parse error and reporting it
- corrects test for parsing resources to work again :)


Patch:
diff --git a/.circleci/config.yml b/.circleci/config.yml
index f530784b..6f3a67cd 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -32,20 +32,20 @@ references:
         sudo apt-get install -yqq jq git
 
         echo "Installing KIND"
-        curl -sLO https://github.com/kubernetes-sigs/kind/releases/download/v0.8.1/kind-linux-amd64
+        curl -sLO https://github.com/kubernetes-sigs/kind/releases/download/v0.14.0/kind-linux-amd64
         chmod 0755 kind-linux-amd64
         sudo mv kind-linux-amd64 /usr/local/bin/kind
         kind version
 
         echo "Installing Kubectl"
-        curl -sLO https://storage.googleapis.com/kubernetes-release/release/v1.18.6/bin/linux/amd64/kubectl
+        curl -sLO https://storage.googleapis.com/kubernetes-release/release/v1.21.12/bin/linux/amd64/kubectl
         chmod 0755 kubectl
         sudo mv kubectl /usr/local/bin/
         kubectl version --client
 
 
         echo "Creating Kubernetes Cluster with Kind"
-        kind create cluster --wait=90s --image kindest/node:v1.15.11
+        kind create cluster --wait=90s --image kindest/node:v1.21.12
         docker ps -a
 
         kubectl version
diff --git a/pkg/kube/resources.go b/pkg/kube/resources.go
index 51a92224..344b8850 100644
--- a/pkg/kube/resources.go
+++ b/pkg/kube/resources.go
@@ -215,7 +215,11 @@ func CreateResourceProviderFromPath(directory string) (*ResourceProvider, error)
 			logrus.Errorf("Error reading file: %v", path)
 			return err
 		}
-		return resources.addResourcesFromYaml(string(contents))
+		err = resources.addResourcesFromYaml(string(contents))
+		if err != nil {
+			logrus.Warnf("Skipping %s: cannot add resource from YAML: %v", path, err)
+		}
+		return nil
 	}
 
 	err := filepath.Walk(directory, visitFile)
@@ -443,7 +447,6 @@ func (resources *ResourceProvider) addResourceFromString(contents string) error
 	decoder = k8sYaml.NewYAMLOrJSONDecoder(bytes.NewReader(contentBytes), 1000)
 
 	if err != nil {
-		logrus.Errorf("Invalid YAML: %s", string(contents))
 		return err
 	}
 	if resource.Kind == "Namespace" {


Test patch:
diff --git a/pkg/kube/resources_test.go b/pkg/kube/resources_test.go
index d5699bb0..ceac8d32 100644
--- a/pkg/kube/resources_test.go
+++ b/pkg/kube/resources_test.go
@@ -74,7 +74,7 @@ func TestGetMultipleResourceFromSingleFile(t *testing.T) {
 
 func TestGetMultipleResourceFromBadFile(t *testing.T) {
 	_, err := CreateResourceProviderFromPath("./test_files/test_3")
-	assert.NotEqual(t, nil, err, "CreateResource From Path should fail with bad yaml")
+	assert.Equal(t, nil, err, "CreateResource From Path should not fail with bad yaml")
 }
 
 func TestAddResourcesFromReader(t *testing.T) {