@@ -3,6 +3,7 @@ package payload
33import (
44 "bytes"
55 "fmt"
6+ "io/fs"
67 "os"
78 "path/filepath"
89 "strings"
@@ -327,24 +328,21 @@ func Test_cvoManifests(t *testing.T) {
327328 dir : filepath .Join ("../../bootstrap" ),
328329 },
329330 }
331+ const prefix = "include.release.openshift.io/"
330332 for _ , tt := range tests {
331333 t .Run (tt .name , func (t * testing.T ) {
332- files , err := os .ReadDir (tt .dir )
333- if err != nil {
334- t .Fatalf ("failed to read directory: %v" , err )
335- }
336-
337- if len (files ) == 0 {
338- t .Fatalf ("no files found in %s" , tt .dir )
339- }
334+ var count int
335+ err := filepath .WalkDir (tt .dir , func (path string , d fs.DirEntry , err error ) error {
336+ if err != nil {
337+ return err
338+ }
340339
341- var manifestsWithoutIncludeAnnotation []manifest.Manifest
342- const prefix = "include.release.openshift.io/"
343- for _ , manifestFile := range files {
344- if manifestFile .IsDir () {
345- continue
340+ if d .IsDir () {
341+ return nil
346342 }
347- filePath := filepath .Join (tt .dir , manifestFile .Name ())
343+
344+ var manifestsWithoutIncludeAnnotation []manifest.Manifest
345+ filePath := filepath .Join (tt .dir , d .Name ())
348346 data , err := os .ReadFile (filePath )
349347 if err != nil {
350348 t .Fatalf ("failed to read manifest file: %v" , err )
@@ -371,15 +369,26 @@ func Test_cvoManifests(t *testing.T) {
371369 manifestsWithoutIncludeAnnotation = append (manifestsWithoutIncludeAnnotation , m )
372370 }
373371 }
374- }
375372
376- if len (manifestsWithoutIncludeAnnotation ) > 0 {
377- var messages []string
378- for _ , m := range manifestsWithoutIncludeAnnotation {
379- messages = append (messages , fmt .Sprintf ("%s/%s/%s/%s" , m .OriginalFilename , m .GVK , m .Obj .GetName (), m .Obj .GetNamespace ()))
373+ if len (manifestsWithoutIncludeAnnotation ) > 0 {
374+ var messages []string
375+ for _ , m := range manifestsWithoutIncludeAnnotation {
376+ messages = append (messages , fmt .Sprintf ("%s/%s/%s/%s" , m .OriginalFilename , m .GVK , m .Obj .GetName (), m .Obj .GetNamespace ()))
377+ }
378+ t .Errorf ("Those manifests have no annotation with prefix %q and will not be installed by CVO: %s" , prefix , strings .Join (messages , ", " ))
380379 }
381- t .Fatalf ("Those manifests have no annotation with prefix %q and will not beinstalled by CVO: %s" , prefix , strings .Join (messages , "', '" ))
380+ count ++
381+ return nil
382+ })
383+
384+ if err != nil {
385+ t .Fatalf ("failed to walk directory: %v" , err )
382386 }
387+
388+ if count == 0 {
389+ t .Errorf ("no files found in %s" , tt .dir )
390+ }
391+
383392 })
384393 }
385394}
0 commit comments