Skip to content

ROX-35662: Support konflux deployments on non-OCP#232

Merged
mclasmeier merged 2 commits into
mainfrom
konflux-operator-image-rewriting
Jul 10, 2026
Merged

ROX-35662: Support konflux deployments on non-OCP#232
mclasmeier merged 2 commits into
mainfrom
konflux-operator-image-rewriting

Conversation

@mclasmeier

@mclasmeier mclasmeier commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Replace ICSP-based Konflux image rewriting with operator RELATED_IMAGE_* env vars

This removes the OpenShift-only ImageContentSourcePolicy mechanism and instead populates RELATED_IMAGE_* environment variables on the operator deployment, enabling --konflux on any cluster type (GKE, Kind, etc.).

@porridge This feature was discussed in the release sync meetings. GKE is just so much quicker. Builds on top of your feature for setting env vars in operator.

…E_* env vars

This removes the OpenShift-only ImageContentSourcePolicy mechanism and
instead populates RELATED_IMAGE_* environment variables on the operator
deployment, enabling --konflux on any cluster type (GKE, Kind, etc.).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mclasmeier mclasmeier requested a review from porridge July 8, 2026 12:03
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds Konflux operator image support, populates RELATED_IMAGE_* environment variables when Konflux images are enabled, rewrites the operator Deployment’s manager container image directly, and removes the previous ImageContentSourcePolicy-based Konflux path.

Changes

Konflux operator image support

Layer / File(s) Summary
Konflux helpers and tests
internal/deployer/konflux.go, internal/deployer/konflux_test.go
Adds the Konflux related-image mapping, operator image formatter, and env var population helper, with tests for image formatting, missing-key population, override preservation, and nil map initialization.
Deploy config Konflux wiring
cmd/deploy.go
Calls PopulateKonfluxEnvVars during deploy configuration when Konflux images are enabled, and removes the Konflux-only OpenShift validation restriction.
Operator Deployment mutation
internal/deployer/operator.go
Removes the ImageContentSourcePolicy-based Konflux setup/removal path, updates manifest parsing and construction to any-typed maps, and rewrites the manager container image and env vars directly on the CSV-derived Deployment.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant deployOperatorNonOLM
  participant createDeploymentFromCSV
  participant managerContainerFromPodSpec
  participant rewriteKonfluxOperatorImage
  participant injectEnvVarsIntoManagerContainer

  deployOperatorNonOLM->>createDeploymentFromCSV: build Deployment from CSV
  createDeploymentFromCSV->>managerContainerFromPodSpec: locate manager container
  createDeploymentFromCSV->>rewriteKonfluxOperatorImage: replace image when Konflux is enabled
  createDeploymentFromCSV->>injectEnvVarsIntoManagerContainer: merge operator env vars
  createDeploymentFromCSV-->>deployOperatorNonOLM: Deployment ready for apply
Loading

Possibly related PRs

  • stackrox/roxie#215: Shares the config.Operator.EnvVars plumbing and operator Deployment env var injection path used alongside the Konflux RELATED_IMAGE_* population in this PR.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title accurately summarizes the main change: enabling Konflux deployments on non-OCP clusters.
Description check ✅ Passed The description clearly matches the change set by describing the move from ICSP rewriting to RELATED_IMAGE_* env vars.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch konflux-operator-image-rewriting

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
internal/deployer/operator.go (1)

490-507: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider extracting a shared findManagerContainer helper.

rewriteKonfluxOperatorImage and injectEnvVarsIntoManagerContainer (lines 455-487) share identical container-finding logic: iterate containers, type-assert to map[string]interface{}, compare container["name"] to managerContainerName, and return the same "not found" error. Extracting a helper would eliminate this duplication.

♻️ Optional refactor: shared container-finding helper
+// findManagerContainer locates the manager container in the provided list.
+func findManagerContainer(containers []interface{}) (map[string]interface{}, error) {
+	for _, c := range containers {
+		container, ok := c.(map[string]interface{})
+		if !ok {
+			continue
+		}
+		if container["name"] == managerContainerName {
+			return container, nil
+		}
+	}
+	return nil, fmt.Errorf("container %q not found in deployment", managerContainerName)
+}
+
 // rewriteKonfluxOperatorImage replaces the manager container's image with the
 // Konflux-built operator image.
 func (d *Deployer) rewriteKonfluxOperatorImage(containers []interface{}) error {
-	for _, c := range containers {
-		container, ok := c.(map[string]interface{})
-		if !ok {
-			continue
-		}
-		if container["name"] != managerContainerName {
-			continue
-		}
+	container, err := findManagerContainer(containers)
+	if err != nil {
+		return err
+	}
 		newImage := KonfluxOperatorImage(&d.config)
 		d.logger.Infof("Rewriting operator image to %s", newImage)
 		container["image"] = newImage
 		return nil
-	}
-	return fmt.Errorf("container %q not found in deployment", managerContainerName)
 }

Similarly, injectEnvVarsIntoManagerContainer could use the same helper.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/deployer/operator.go` around lines 490 - 507, The container lookup
logic in rewriteKonfluxOperatorImage is duplicated with
injectEnvVarsIntoManagerContainer, so extract a shared findManagerContainer
helper that iterates the containers, type-asserts to map[string]interface{},
matches managerContainerName, and returns the container plus the standard
not-found error. Update rewriteKonfluxOperatorImage to use this helper (and
optionally injectEnvVarsIntoManagerContainer as well) so the lookup and error
handling live in one place.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@internal/deployer/operator.go`:
- Around line 490-507: The container lookup logic in rewriteKonfluxOperatorImage
is duplicated with injectEnvVarsIntoManagerContainer, so extract a shared
findManagerContainer helper that iterates the containers, type-asserts to
map[string]interface{}, matches managerContainerName, and returns the container
plus the standard not-found error. Update rewriteKonfluxOperatorImage to use
this helper (and optionally injectEnvVarsIntoManagerContainer as well) so the
lookup and error handling live in one place.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Enterprise

Run ID: f79a95b1-c04e-4fed-9904-663702b3a163

📥 Commits

Reviewing files that changed from the base of the PR and between 9e28369 and 0537659.

📒 Files selected for processing (4)
  • cmd/deploy.go
  • internal/deployer/konflux.go
  • internal/deployer/konflux_test.go
  • internal/deployer/operator.go

@mclasmeier

Copy link
Copy Markdown
Collaborator Author

@coderabbitai, I have addressed your nit comment, please check again.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
gh pr view 232 --repo stackrox/roxie --json comments,reviews -q '.reviews[] | select(.author.login=="coderabbitai") | .body' | head -100
echo "-----review comments-----"
gh api repos/stackrox/roxie/pulls/232/comments --jq '.[] | select(.user.login=="coderabbitai-app[bot]" or .user.login=="coderabbitai") | {id, body, path, line, diff_hunk}'

Length of output: 3865


🏁 Script executed:

#!/bin/bash
ast-grep outline internal/deployer/operator.go --items all --match 'findManagerContainer|rewriteKonfluxOperatorImage|injectEnvVarsIntoManagerContainer'
echo "-----"
rg -n 'findManagerContainer|rewriteKonfluxOperatorImage|injectEnvVarsIntoManagerContainer' internal/deployer/operator.go

Length of output: 1081


🏁 Script executed:

#!/bin/bash
sed -n '380,510p' internal/deployer/operator.go

Length of output: 4405


Confirmed — the nit has been addressed. The container-lookup logic is now consolidated into the single managerContainerFromPodSpec helper, and both rewriteKonfluxOperatorImage and injectEnvVarsIntoManagerContainer receive the already-resolved managerContainer directly instead of duplicating the find/type-assert logic. This is exactly the refactor I suggested.

@mclasmeier Confirmed, thanks for extracting the shared managerContainerFromPodSpec helper — both rewriteKonfluxOperatorImage and injectEnvVarsIntoManagerContainer now operate on the resolved container directly, eliminating the duplicated lookup logic. LGTM! 🐰

@mclasmeier mclasmeier changed the title Support konflux deployments on non-OCP ROX-35662: Support konflux deployments on non-OCP Jul 8, 2026

@porridge porridge left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would also be nice to be a bit more generic than "konflux/non-konflux", i.e. think of stackrox-io or custom image repos, but maybe it's material for another PR.

Comment thread internal/deployer/konflux.go
@mclasmeier mclasmeier merged commit 50137fa into main Jul 10, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants