Skip to content

Commit f6ab856

Browse files
committed
All CVO manifests in payload should be included
1 parent 57706c4 commit f6ab856

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

pkg/payload/render_test.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
package payload
22

33
import (
4+
"fmt"
45
"os"
6+
"path/filepath"
57
"strings"
68
"testing"
79

810
"github.com/google/go-cmp/cmp"
11+
12+
"github.com/openshift/library-go/pkg/manifest"
913
)
1014

1115
func TestRenderManifest(t *testing.T) {
@@ -58,3 +62,49 @@ func TestRenderManifest(t *testing.T) {
5862
})
5963
}
6064
}
65+
66+
func Test_cvoManifests(t *testing.T) {
67+
installDir := filepath.Join("../../install")
68+
files, err := os.ReadDir(installDir)
69+
if err != nil {
70+
t.Fatalf("failed to read directory: %v", err)
71+
}
72+
73+
if len(files) == 0 {
74+
t.Fatalf("no files found in %s", installDir)
75+
}
76+
77+
var manifestsWithoutIncludeAnnotation []manifest.Manifest
78+
const prefix = "include.release.openshift.io/"
79+
for _, manifestFile := range files {
80+
if manifestFile.IsDir() {
81+
continue
82+
}
83+
filePath := filepath.Join(installDir, manifestFile.Name())
84+
manifests, err := manifest.ManifestsFromFiles([]string{filePath})
85+
if err != nil {
86+
t.Fatalf("failed to load manifests: %v", err)
87+
}
88+
89+
for _, m := range manifests {
90+
var found bool
91+
for k := range m.Obj.GetAnnotations() {
92+
if strings.HasPrefix(k, prefix) {
93+
found = true
94+
break
95+
}
96+
}
97+
if !found {
98+
manifestsWithoutIncludeAnnotation = append(manifestsWithoutIncludeAnnotation, m)
99+
}
100+
}
101+
}
102+
103+
if len(manifestsWithoutIncludeAnnotation) > 0 {
104+
var messages []string
105+
for _, m := range manifestsWithoutIncludeAnnotation {
106+
messages = append(messages, fmt.Sprintf("%s/%s/%s/%s", m.OriginalFilename, m.GVK, m.Obj.GetName(), m.Obj.GetNamespace()))
107+
}
108+
t.Fatalf("Those manifests have no annotation with prefix %q and will not beinstalled by CVO: %s", prefix, strings.Join(messages, "', '"))
109+
}
110+
}

0 commit comments

Comments
 (0)