@@ -182,7 +182,7 @@ func (p *pkgManToBundleCmd) run() (err error) {
182
182
for _ , dir := range directories {
183
183
if dir .IsDir () {
184
184
// this is required to extract project layout and SDK version information.
185
- otherLabels , channels , err := getSDKStampsAndChannels (filepath .Join (p .pkgmanifestDir , dir .Name ()), channelsByCSV )
185
+ otherLabels , channels , err := getSDKStampsAndChannels (filepath .Join (p .pkgmanifestDir , dir .Name ()), defaultChannel , channelsByCSV )
186
186
if err != nil {
187
187
return fmt .Errorf ("error getting CSV from provided packagemanifest %v" , err )
188
188
}
@@ -268,7 +268,7 @@ func getScorecardConfigPath(inputDir string) (string, error) {
268
268
return scorecardConfigPath , nil
269
269
}
270
270
271
- func getSDKStampsAndChannels (path string , channelsByCSV map [string ][]string ) (map [string ]string , string , error ) {
271
+ func getSDKStampsAndChannels (path , defaultChannel string , channelsByCSV map [string ][]string ) (map [string ]string , string , error ) {
272
272
bundle , err := apimanifests .GetBundleFromDir (path )
273
273
if err != nil {
274
274
return nil , "" , err
@@ -280,7 +280,7 @@ func getSDKStampsAndChannels(path string, channelsByCSV map[string][]string) (ma
280
280
}
281
281
282
282
// Find channels matching the CSV names
283
- channels := getChannelsByCSV (bundle , channelsByCSV )
283
+ channels := getChannelsByCSV (bundle , channelsByCSV , defaultChannel )
284
284
285
285
return sdkLabels , channels , nil
286
286
}
@@ -308,8 +308,9 @@ func getSDKStamps(bundle *apimanifests.Bundle) (map[string]string, error) {
308
308
return sdkLabels , nil
309
309
}
310
310
311
- // getChannelsByCSV creates a list for channels for the currentCSV,
312
- func getChannelsByCSV (bundle * apimanifests.Bundle , channelsByCSV map [string ][]string ) (channels string ) {
311
+ // getChannelsByCSV creates a list for channels for the currentCSV. For other versions of manifests which
312
+ // are not present in the manifest, the defaultChannel is added.
313
+ func getChannelsByCSV (bundle * apimanifests.Bundle , channelsByCSV map [string ][]string , defaultChannel string ) (channels string ) {
313
314
// Find channels matching the CSV names
314
315
var channelNames []string
315
316
for csv , ch := range channelsByCSV {
@@ -323,8 +324,8 @@ func getChannelsByCSV(bundle *apimanifests.Bundle, channelsByCSV map[string][]st
323
324
// TODO: verify if we have to add this validation since while building bundles if channel is not specified
324
325
// we add the default channel.
325
326
if channels == "" {
326
- channels = "candidate"
327
- log .Infof ("Supported channels cannot be identified from CSV %s, using default channel 'preview' " , bundle .CSV .GetName ())
327
+ channels = defaultChannel
328
+ log .Infof ("Supported channels cannot be identified from CSV %s, using default channel %s " , bundle .CSV .GetName (), defaultChannel )
328
329
}
329
330
330
331
return channels
@@ -339,7 +340,8 @@ func getPackageMetadata(pkg *apimanifests.PackageManifest) (packagename, default
339
340
340
341
defaultChannel = pkg .DefaultChannelName
341
342
if defaultChannel == "" {
342
- defaultChannel = "candidate"
343
+ err = fmt .Errorf ("cannot find the default channel for package %q" , packagename )
344
+ return
343
345
}
344
346
345
347
channelsByCSV = make (map [string ][]string )
0 commit comments