Skip to content

Commit

Permalink
fix: merge existing and extra fbc while rendering the index image
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
iamniting committed Jul 25, 2023
1 parent 888ea7f commit d1cd90b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
10 changes: 10 additions & 0 deletions changelog/fragments/03-run-bundle-cmd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# entries is a list of entries to include in
# release notes and/or the migration guide
entries:
- description: >
Fix a bug where `run bundle` command does not copy all FBC manifests into the new catalog image if custom index-image is passed.
kind: "bugfix"
# Is this a breaking change?
breaking: false
12 changes: 6 additions & 6 deletions internal/olm/operator/bundle/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func generateFBCContent(ctx context.Context, f *fbcutil.FBCContext, bundleImage,
if indexImage != fbcutil.DefaultIndexImage { // non-default index image was specified.
// since an index image is specified, the bundle image will be added to the index image.
// generateExtraFBC will ensure that the bundle is not already present in the index image and error out if it does.
declcfg, err = generateExtraFBC(ctx, indexImage, bundleDeclcfg, f.SkipTLSVerify, f.UseHTTP)
declcfg, err = generateFBC(ctx, indexImage, bundleDeclcfg, f.SkipTLSVerify, f.UseHTTP)
if err != nil {
return "", fmt.Errorf("error adding bundle image %q to index image %q: %v", bundleImage, indexImage, err)
}
Expand All @@ -181,9 +181,9 @@ func generateFBCContent(ctx context.Context, f *fbcutil.FBCContext, bundleImage,
return content, nil
}

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

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

extraDeclConfig := &declarativeconfig.DeclarativeConfig{
Bundles: []declarativeconfig.Bundle{bundleDeclConfig.Bundle},
Channels: []declarativeconfig.Channel{bundleDeclConfig.Channel},
Bundles: append(imageDeclConfig.Bundles, bundleDeclConfig.Bundle),
Channels: append(imageDeclConfig.Channels, bundleDeclConfig.Channel),
}

if !isPackagePresent {
extraDeclConfig.Packages = []declarativeconfig.Package{bundleDeclConfig.Package}
extraDeclConfig.Packages = append(imageDeclConfig.Packages, bundleDeclConfig.Package)
}

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

0 comments on commit d1cd90b

Please sign in to comment.