Skip to content

Commit

Permalink
Bundle image references and versions are passed in as a map for creat…
Browse files Browse the repository at this point in the history
…ing FBC

Signed-off-by: jubittajohn <jujohn@redhat.com>
  • Loading branch information
jubittajohn committed Aug 4, 2023
1 parent 301dda3 commit 1c2bef0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
17 changes: 11 additions & 6 deletions test/operator-framework-e2e/create_fbc_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@ const (
)

// Forms the FBC declartive config and creates the FBC by calling functions for forming the package, channel and bundles.
func CreateFBC(operatorName, defaultChannel string, bundleRef, bundleVersions []string) *declcfg.DeclarativeConfig {
func CreateFBC(operatorName, defaultChannel string, bundleRefsVersions map[string]string) *declcfg.DeclarativeConfig {
dPackage := formPackage(operatorName)
bundleVersions := make([]string, 0)
for _, bundleVersion := range bundleRefsVersions {
bundleVersions = append(bundleVersions, bundleVersion)
}
dChannel := formChannel(operatorName, defaultChannel, bundleVersions)
dBundle := formBundle(operatorName, bundleVersions, bundleRef)

dBundle := formBundle(operatorName, bundleRefsVersions)

fbc := declcfg.DeclarativeConfig{
Packages: []declcfg.Package{dPackage},
Expand Down Expand Up @@ -73,9 +78,9 @@ func formChannelEntries(pkgName string, bundleVersions []string) []declcfg.Chann
}

// Forms bundle schema for the FBC
func formBundle(pkgName string, versions, imageRefs []string) []declcfg.Bundle {
bundleFormed := make([]declcfg.Bundle, 0, len(imageRefs))
for i, version := range versions {
func formBundle(pkgName string, imgRefsVersions map[string]string) []declcfg.Bundle {
bundleFormed := make([]declcfg.Bundle, 0, len(imgRefsVersions))
for imgRef, version := range imgRefsVersions {
var properties []property.Property
properties = append(properties, property.Property{
Type: SchemaPackage,
Expand All @@ -90,7 +95,7 @@ func formBundle(pkgName string, versions, imageRefs []string) []declcfg.Bundle {
Schema: SchemaBundle,
Name: pkgName + ".v" + version,
Package: pkgName,
Image: imageRefs[i],
Image: imgRef,
Properties: properties,
})
}
Expand Down
8 changes: 3 additions & 5 deletions test/operator-framework-e2e/operator_framework_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,11 @@ var _ = Describe("Operator Framework E2E for plain bundles", func() {
When("Create the FBC", func() {
It("Create a FBC", func() {
By("Creating FBC for plain bundle using custom routine")
var imageRefs []string
var bundleVersions []string
imageRefsBundleVersions := make(map[string]string)
for _, b := range bundleInfo.bundles {
imageRefs = append(imageRefs, b.imageRef)
bundleVersions = append(bundleVersions, b.bundleVersion)
imageRefsBundleVersions[b.imageRef] = b.bundleVersion
}
fbc := CreateFBC(catalogDInfo.operatorName, catalogDInfo.desiredChannelName, imageRefs, bundleVersions)
fbc := CreateFBC(catalogDInfo.operatorName, catalogDInfo.desiredChannelName, imageRefsBundleVersions)
err = WriteFBC(*fbc, filepath.Join(catalogDInfo.baseFolderPath, catalogDInfo.catalogDir), catalogDInfo.fbcFileName)
Expect(err).ToNot(HaveOccurred())
})
Expand Down

0 comments on commit 1c2bef0

Please sign in to comment.