Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions internal/deployer/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ func (d *Deployer) deployOperatorNonOLM(ctx context.Context) error {
return fmt.Errorf("failed to remove Konflux ImageContentSourcePolicy: %v", err)
}
}
bundleImage := d.getOperatorBundleImage()
bundleImage := getOperatorBundleImage(d.operatorTag, d.useKonflux)
d.logger.Infof("Using operator bundle image %s", bundleImage)

bundleDir, err := d.downloadAndExtractOperatorBundle(ctx, bundleImage)
if err != nil {
Expand Down Expand Up @@ -170,7 +171,8 @@ func (d *Deployer) ensureCRDsInstalled(ctx context.Context) error {
}

if len(missing) > 0 {
bundleImage := d.getOperatorBundleImage()
bundleImage := getOperatorBundleImage(d.operatorTag, d.useKonflux)
d.logger.Infof("Using operator bundle image %s", bundleImage)
d.logger.Warningf("Missing CRDs detected (%s)", strings.Join(missing, ", "))
d.logger.Warningf("Fetching bundle %s", bundleImage)

Expand All @@ -191,12 +193,17 @@ func (d *Deployer) ensureCRDsInstalled(ctx context.Context) error {
return nil
}

func (d *Deployer) getOperatorBundleImage() string {
if d.useKonflux {
d.logger.Infof("Using Konflux-built operator bundle image")
return fmt.Sprintf(operatorBundleImageReleaseRepo+":v%s", d.operatorTag)
func getOperatorBundleImage(operatorTag string, konflux bool) string {
repo := operatorBundleImageRepo
tag := operatorTag
if konflux {
repo = operatorBundleImageReleaseRepo
if !strings.HasSuffix(tag, "-fast") {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work for release-* branch builds or PRs targeting release branches.

Unless something changed and I'm not aware, and the wiki was not updated?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you elaborate? I don't follow.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Konflux builds in the release branches don't have the -fast suffix

tag = tag + "-fast"
}
}
return fmt.Sprintf(operatorBundleImageRepo+":v%s", d.operatorTag)

return fmt.Sprintf("%s:v%s", repo, tag)
}

// ensureKonfluxImageRewriting configures image rewriting for Konflux images
Expand Down
42 changes: 42 additions & 0 deletions internal/deployer/operator_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package deployer

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestGetOperatorBundleImage(t *testing.T) {
tests := []struct {
name string
tag string
konflux bool
wantImage string
}{
{
name: "non-konflux",
tag: "4.6.0",
konflux: false,
wantImage: "quay.io/rhacs-eng/stackrox-operator-bundle:v4.6.0",
},
{
name: "konflux appends -fast",
tag: "4.6.0",
konflux: true,
wantImage: "quay.io/rhacs-eng/release-operator-bundle:v4.6.0-fast",
},
{
name: "konflux with existing -fast suffix",
tag: "4.6.0-fast",
konflux: true,
wantImage: "quay.io/rhacs-eng/release-operator-bundle:v4.6.0-fast",
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := getOperatorBundleImage(tt.tag, tt.konflux)
assert.Equal(t, tt.wantImage, got, "operator image mismatch")
})
}
}
Loading