@@ -117,9 +117,7 @@ func (t *semverTemplate) Render(ctx context.Context, reader io.Reader) (*declcfg
117117 out .Channels = channels
118118 out .Packages [0 ].DefaultChannel = sv .defaultChannel
119119
120- if err := sv .populatePackageMetadata (& out ); err != nil {
121- return nil , fmt .Errorf ("render: unable to populate package metadata: %v" , err )
122- }
120+ sv .populatePackageMetadata (& out )
123121
124122 return & out , nil
125123}
@@ -434,19 +432,20 @@ func (sv *SemverTemplateData) generateChannels(semverChannels *bundleVersions) [
434432 return outChannels
435433}
436434
437- // populatePackageMetadata extracts icon and description from the head bundle of the default channel
435+ // populatePackageMetadata extracts icon and description from the head bundle of the default channel -- if present --
438436// and sets them on the package object
439- func (sv * SemverTemplateData ) populatePackageMetadata (cfg * declcfg.DeclarativeConfig ) error {
437+ // this assumes that all schema have been validated as part of the declarative config aggregation
438+ func (sv * SemverTemplateData ) populatePackageMetadata (cfg * declcfg.DeclarativeConfig ) {
440439 if len (cfg .Packages ) == 0 {
441- return nil
440+ return
442441 }
443442
444443 // Find the default channel
445444 channelIdx := slices .IndexFunc (cfg .Channels , func (ch declcfg.Channel ) bool {
446445 return ch .Name == sv .defaultChannel
447446 })
448447 if channelIdx == - 1 || len (cfg .Channels [channelIdx ].Entries ) == 0 {
449- return nil
448+ return
450449 }
451450
452451 // Find the head bundle (the bundle with the highest version, which is the last entry in the channel)
@@ -457,13 +456,13 @@ func (sv *SemverTemplateData) populatePackageMetadata(cfg *declcfg.DeclarativeCo
457456 return b .Name == headBundleName
458457 })
459458 if bundleIdx == - 1 || cfg .Bundles [bundleIdx ].CsvJSON == "" {
460- return nil
459+ return
461460 }
462461
463462 // Parse CSV JSON to extract metadata
464463 var csv registry.ClusterServiceVersion
465464 if err := json .Unmarshal ([]byte (cfg .Bundles [bundleIdx ].CsvJSON ), & csv ); err != nil {
466- return fmt . Errorf ( "unmarshal CSV JSON for bundle %q: %v" , cfg . Bundles [ bundleIdx ]. Name , err )
465+ return
467466 }
468467
469468 // Extract and set description
@@ -478,8 +477,6 @@ func (sv *SemverTemplateData) populatePackageMetadata(cfg *declcfg.DeclarativeCo
478477 MediaType : icons [0 ].MediaType ,
479478 }
480479 }
481-
482- return nil
483480}
484481
485482func (sv * SemverTemplateData ) linkChannels (unlinkedChannels map [string ]* declcfg.Channel , entries []entryTuple ) []declcfg.Channel {
0 commit comments