diff --git a/pkg/api/versions.go b/pkg/api/versions.go index a8271398..da80890a 100644 --- a/pkg/api/versions.go +++ b/pkg/api/versions.go @@ -17,6 +17,7 @@ package api import ( "bytes" "encoding/json" + "errors" "fmt" "io" "os" @@ -140,6 +141,7 @@ func jsonToStub(data []byte) ([]*Stub, error) { func yamlToStub(data []byte) ([]*Stub, error) { decoder := yaml.NewDecoder(bytes.NewReader(data)) var stubs []*Stub + var tError *yaml.TypeError for { stub := &Stub{} err := decoder.Decode(stub) @@ -147,6 +149,10 @@ func yamlToStub(data []byte) ([]*Stub, error) { if err == io.EOF { break } + if errors.As(err, &tError) { + klog.Infof("skipping for invalid yaml in manifest: %s", err) + continue + } return stubs, err } stubs = append(stubs, stub) diff --git a/pkg/api/versions_test.go b/pkg/api/versions_test.go index ff6d54fd..eaa74af7 100644 --- a/pkg/api/versions_test.go +++ b/pkg/api/versions_test.go @@ -108,7 +108,7 @@ func Test_yamlToStub(t *testing.T) { }, { name: "not yaml", - data: []byte("some text\nthat is not yaml"), + data: []byte("*."), want: nil, wantErr: true, }, @@ -148,7 +148,7 @@ func Test_containsStub(t *testing.T) { }, { name: "not yaml", - data: []byte("some text\nthat is not yaml"), + data: []byte("*."), want: nil, wantErr: true, }, diff --git a/pkg/helm/helm.go b/pkg/helm/helm.go index 3757d0e4..a3429447 100644 --- a/pkg/helm/helm.go +++ b/pkg/helm/helm.go @@ -22,6 +22,7 @@ import ( driverv2 "helm.sh/helm/pkg/storage/driver" helmstoragev3 "helm.sh/helm/v3/pkg/storage" driverv3 "helm.sh/helm/v3/pkg/storage/driver" + "k8s.io/klog" "github.com/fairwindsops/pluto/pkg/api" ) @@ -107,7 +108,8 @@ func (h *Helm) getReleasesVersionTwo() error { } deployed, err := helmClient.Deployed(release.Name) if err != nil { - return fmt.Errorf("error determining most recent deployed for '%s'\n %w", release.Name, err) + klog.Infof("cannot determine most recent deployed for %s - %s", release.Name, err) + continue } if release.Version != deployed.Version { continue @@ -138,7 +140,8 @@ func (h *Helm) getReleasesVersionThree() error { for _, release := range list { deployed, err := helmClient.Deployed(release.Name) if err != nil { - return fmt.Errorf("error determining most recent deployed for '%s'\n %w", release.Name, err) + klog.Infof("cannot determine most recent deployed for %s - %s", release.Name, err) + continue } if release.Version != deployed.Version { continue @@ -157,6 +160,7 @@ func (h *Helm) getReleasesVersionThree() error { func (h *Helm) findVersions() error { for _, release := range h.Releases { + klog.V(2).Infof("parsing release %s", release.Name) outList, err := h.checkForAPIVersion([]byte(release.Manifest)) if err != nil { return fmt.Errorf("error parsing release '%s'\n %w", release.Name, err)