Skip to content

Commit 66c1664

Browse files
committed
Comments out of review
1 parent 0a1586b commit 66c1664

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

test/cvo/cvo.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package cvo
22

33
import (
4-
"bytes"
54
"context"
65
"fmt"
76
"os"
@@ -19,6 +18,7 @@ import (
1918
"github.com/openshift/cluster-version-operator/test/util"
2019
"github.com/openshift/library-go/pkg/manifest"
2120
apierrors "k8s.io/apimachinery/pkg/api/errors"
21+
"k8s.io/apimachinery/pkg/util/sets"
2222

2323
"github.com/openshift/cluster-version-operator/pkg/cvo/external/dynamicclient"
2424
)
@@ -118,29 +118,29 @@ var _ = g.Describe(`[Jira:"Cluster Version Operator"] cluster-version-operator`,
118118
files, err := os.ReadDir(manifestDir.To)
119119
o.Expect(err).NotTo(o.HaveOccurred())
120120
g.By(fmt.Sprintf("Checking if getting manifests with %s on the cluster led to not-found error", annotation))
121+
122+
ignore := sets.New[string]("release-metadata")
123+
121124
for _, manifestFile := range files {
122-
filePath := filepath.Join(manifestDir.To, manifestFile.Name())
123-
raw, err := os.ReadFile(filePath)
124-
if err != nil {
125-
o.Expect(err).NotTo(o.HaveOccurred(), "failed to read manifest file")
126-
}
127-
manifests, err := manifest.ParseManifests(bytes.NewReader(raw))
128-
if err != nil {
129-
// files like release-metadata are not manifest file, so skip them
130-
logger.Error(err, "failed to parse manifest file: "+filePath)
125+
if manifestFile.IsDir() || ignore.Has(manifestFile.Name()) {
131126
continue
132127
}
128+
filePath := filepath.Join(manifestDir.To, manifestFile.Name())
129+
o.Expect(err).NotTo(o.HaveOccurred(), "failed to read manifest file")
130+
manifests, err := manifest.ManifestsFromFiles([]string{filePath})
131+
o.Expect(err).NotTo(o.HaveOccurred(), fmt.Sprintf("failed to parse manifest file: %s", filePath))
133132

134133
for _, ms := range manifests {
135134
ann := ms.Obj.GetAnnotations()
136-
if ann == nil || ann[annotation] != "true" {
135+
if ann[annotation] != "true" {
137136
continue
138137
}
139-
manifestFilePath := filepath.Join(manifestDir.To, manifestFile.Name())
140138
client, err := dynamicclient.New(restCfg, ms.GVK, ms.Obj.GetNamespace())
141139
o.Expect(err).NotTo(o.HaveOccurred())
142140
_, err = client.Get(ctx, ms.Obj.GetName(), metav1.GetOptions{})
143-
o.Expect(apierrors.IsNotFound(err)).To(o.BeTrue(), fmt.Sprintf("The deleted manifest should not be installed, but actually installed: %s, manifest: %v, error: %v", manifestFilePath, string(ms.Raw), err))
141+
o.Expect(apierrors.IsNotFound(err)).To(o.BeTrue(),
142+
fmt.Sprintf("The deleted manifest should not be installed, but actually installed: manifest: %s %s in namespace %s from file %q, error: %v",
143+
ms.GVK, ms.Obj.GetName(), ms.Obj.GetNamespace(), ms.OriginalFilename, err))
144144
}
145145
}
146146
})

0 commit comments

Comments
 (0)