@@ -19,11 +19,14 @@ package parallel
19
19
import (
20
20
"context"
21
21
"fmt"
22
- osFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/os"
23
22
"os"
24
23
"path"
24
+ "path/filepath"
25
25
"strings"
26
26
27
+ osFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/os"
28
+ "gopkg.in/yaml.v3"
29
+
27
30
argov1beta1api "github.com/argoproj-labs/argocd-operator/api/v1beta1"
28
31
. "github.com/onsi/ginkgo/v2"
29
32
. "github.com/onsi/gomega"
@@ -32,7 +35,6 @@ import (
32
35
argocdFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/argocd"
33
36
fixtureUtils "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/utils"
34
37
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
35
- "sigs.k8s.io/yaml"
36
38
37
39
"sigs.k8s.io/controller-runtime/pkg/client"
38
40
)
@@ -165,14 +167,16 @@ func (matcher *validResourceFile) Match(actual any) (success bool, err error) {
165
167
return false , fmt .Errorf ("BeValidResourceFile matcher expects a string (file path)" )
166
168
}
167
169
168
- content , err := os .ReadFile (filePath )
170
+ filePath = filepath .Clean (filePath )
171
+ f , err := os .Open (filePath )
169
172
if err != nil {
170
173
return false , fmt .Errorf ("failed to read file: %v" , err )
171
174
}
172
- println ( string ( content ) )
175
+ defer f . Close ( )
173
176
177
+ decoder := yaml .NewDecoder (f )
174
178
var data map [string ]any
175
- if err := yaml . Unmarshal ( content , & data ); err != nil {
179
+ if err := decoder . Decode ( & data ); err != nil {
176
180
return false , fmt .Errorf ("failed parsing supposed YAML file: %v" , err )
177
181
}
178
182
0 commit comments