@@ -280,12 +280,13 @@ func upgradeFBC(ctx context.Context, f *fbcutil.FBCContext, originalDeclCfg *dec
280
280
existingBundles [bundle .Name ] = bundle .Package
281
281
}
282
282
283
+ extraDeclConfig := & declarativeconfig.DeclarativeConfig {}
283
284
// declcfg contains all the bundles we need to insert to form the new FBC
284
285
entries := []declarativeconfig.ChannelEntry {} // Used when generating a new channel
285
286
for i , bundle := range declcfg .Bundles {
286
287
// if it is not present in the bundles array or belongs to a different package, we can add it
287
288
if _ , present := existingBundles [bundle .Name ]; ! present || existingBundles [bundle .Name ] != bundle .Package {
288
- originalDeclCfg .Bundles = append (originalDeclCfg .Bundles , bundle )
289
+ extraDeclConfig .Bundles = append (extraDeclConfig .Bundles , bundle )
289
290
}
290
291
291
292
// constructing a new entry to add
@@ -300,20 +301,21 @@ func upgradeFBC(ctx context.Context, f *fbcutil.FBCContext, originalDeclCfg *dec
300
301
301
302
// either add it to a new channel or an existing channel
302
303
if channelExists {
303
- originalDeclCfg .Channels [channelIndex ].Entries = append ( originalDeclCfg . Channels [ channelIndex ]. Entries , entry )
304
+ extraDeclConfig .Channels [channelIndex ].Entries = []declarativeconfig. ChannelEntry { entry }
304
305
} else {
305
306
entries = append (entries , entry )
306
307
}
307
308
}
308
309
309
310
// create a new channel if it does not exist
310
311
if ! channelExists {
311
- originalDeclCfg . Channels = append ( originalDeclCfg . Channels , declarativeconfig.Channel {
312
+ channel := declarativeconfig.Channel {
312
313
Schema : fbcutil .SchemaChannel ,
313
314
Name : f .ChannelName ,
314
315
Package : f .Package ,
315
316
Entries : entries ,
316
- })
317
+ }
318
+ extraDeclConfig .Channels = []declarativeconfig.Channel {channel }
317
319
}
318
320
319
321
// check if package already exists
@@ -327,14 +329,15 @@ func upgradeFBC(ctx context.Context, f *fbcutil.FBCContext, originalDeclCfg *dec
327
329
328
330
// only add the new package if it does not already exist
329
331
if ! packagePresent {
330
- originalDeclCfg . Packages = append ( originalDeclCfg . Packages , declarativeconfig.Package {
332
+ packageBlob := declarativeconfig.Package {
331
333
Schema : fbcutil .SchemaPackage ,
332
334
Name : f .Package ,
333
335
DefaultChannel : f .ChannelName ,
334
- })
336
+ }
337
+ extraDeclConfig .Packages = []declarativeconfig.Package {packageBlob }
335
338
}
336
339
337
- return originalDeclCfg , nil
340
+ return extraDeclConfig , nil
338
341
}
339
342
340
343
// UpdateCatalog links a new registry pod in catalog source by updating the address and annotations,
0 commit comments