Skip to content

Commit bd0ccd2

Browse files
authored
fix: merge existing and extra fbc while rendering the index image (#6512)
copy the FBC of index-image as well if --index-image is passed to the operator-sdk run bundle command Fixes #6505 Signed-off-by: Nitin Goyal <[email protected]>
1 parent bcda275 commit bd0ccd2

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# entries is a list of entries to include in
2+
# release notes and/or the migration guide
3+
entries:
4+
- description: >
5+
Fix a bug where `run bundle` command does not copy all FBC manifests into the new catalog image if custom index-image is passed.
6+
7+
kind: "bugfix"
8+
9+
# Is this a breaking change?
10+
breaking: false

internal/olm/operator/bundle/install.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func generateFBCContent(ctx context.Context, f *fbcutil.FBCContext, bundleImage,
164164
if indexImage != fbcutil.DefaultIndexImage { // non-default index image was specified.
165165
// since an index image is specified, the bundle image will be added to the index image.
166166
// generateExtraFBC will ensure that the bundle is not already present in the index image and error out if it does.
167-
declcfg, err = generateExtraFBC(ctx, indexImage, bundleDeclcfg, f.SkipTLSVerify, f.UseHTTP)
167+
declcfg, err = generateFBC(ctx, indexImage, bundleDeclcfg, f.SkipTLSVerify, f.UseHTTP)
168168
if err != nil {
169169
return "", fmt.Errorf("error adding bundle image %q to index image %q: %v", bundleImage, indexImage, err)
170170
}
@@ -181,9 +181,9 @@ func generateFBCContent(ctx context.Context, f *fbcutil.FBCContext, bundleImage,
181181
return content, nil
182182
}
183183

184-
// generateExtraFBC verifies that a bundle is not already present on the index and if not, it renders the bundle contents into a
184+
// generateFBC verifies that a bundle is not already present on the index and if not, it renders the bundle contents into a
185185
// declarative config type.
186-
func generateExtraFBC(ctx context.Context, indexImage string, bundleDeclConfig fbcutil.BundleDeclcfg, skipTLSVerify bool, useHTTP bool) (*declarativeconfig.DeclarativeConfig, error) {
186+
func generateFBC(ctx context.Context, indexImage string, bundleDeclConfig fbcutil.BundleDeclcfg, skipTLSVerify bool, useHTTP bool) (*declarativeconfig.DeclarativeConfig, error) {
187187
log.Infof("Rendering a File-Based Catalog of the Index Image %q to verify if bundle %q is present", indexImage, bundleDeclConfig.Bundle.Name)
188188

189189
imageDeclConfig, err := fbcutil.RenderRefs(ctx, []string{indexImage}, skipTLSVerify, useHTTP)
@@ -212,12 +212,12 @@ func generateExtraFBC(ctx context.Context, indexImage string, bundleDeclConfig f
212212
}
213213

214214
extraDeclConfig := &declarativeconfig.DeclarativeConfig{
215-
Bundles: []declarativeconfig.Bundle{bundleDeclConfig.Bundle},
216-
Channels: []declarativeconfig.Channel{bundleDeclConfig.Channel},
215+
Bundles: append(imageDeclConfig.Bundles, bundleDeclConfig.Bundle),
216+
Channels: append(imageDeclConfig.Channels, bundleDeclConfig.Channel),
217217
}
218218

219219
if !isPackagePresent {
220-
extraDeclConfig.Packages = []declarativeconfig.Package{bundleDeclConfig.Package}
220+
extraDeclConfig.Packages = append(imageDeclConfig.Packages, bundleDeclConfig.Package)
221221
}
222222

223223
log.Infof("Generated the extra FBC for the bundle image %q", bundleDeclConfig.Bundle.Name)

0 commit comments

Comments
 (0)