@@ -19,11 +19,14 @@ package parallel
1919import (
2020 "context"
2121 "fmt"
22- osFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/os"
2322 "os"
2423 "path"
24+ "path/filepath"
2525 "strings"
2626
27+ osFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/os"
28+ "gopkg.in/yaml.v3"
29+
2730 argov1beta1api "github.com/argoproj-labs/argocd-operator/api/v1beta1"
2831 . "github.com/onsi/ginkgo/v2"
2932 . "github.com/onsi/gomega"
@@ -32,7 +35,6 @@ import (
3235 argocdFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/argocd"
3336 fixtureUtils "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/utils"
3437 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
35- "sigs.k8s.io/yaml"
3638
3739 "sigs.k8s.io/controller-runtime/pkg/client"
3840)
@@ -165,14 +167,16 @@ func (matcher *validResourceFile) Match(actual any) (success bool, err error) {
165167 return false , fmt .Errorf ("BeValidResourceFile matcher expects a string (file path)" )
166168 }
167169
168- content , err := os .ReadFile (filePath )
170+ filePath = filepath .Clean (filePath )
171+ f , err := os .Open (filePath )
169172 if err != nil {
170173 return false , fmt .Errorf ("failed to read file: %v" , err )
171174 }
172- println ( string ( content ) )
175+ defer f . Close ( )
173176
177+ decoder := yaml .NewDecoder (f )
174178 var data map [string ]any
175- if err := yaml . Unmarshal ( content , & data ); err != nil {
179+ if err := decoder . Decode ( & data ); err != nil {
176180 return false , fmt .Errorf ("failed parsing supposed YAML file: %v" , err )
177181 }
178182
0 commit comments