-
Notifications
You must be signed in to change notification settings - Fork 1
ROX-35662: Support konflux deployments on non-OCP #232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| package deployer | ||
|
|
||
| import ( | ||
| "fmt" | ||
|
|
||
| "github.com/stackrox/roxie/internal/constants" | ||
| ) | ||
|
|
||
| var konfluxRelatedImages = map[string]string{ | ||
| "RELATED_IMAGE_MAIN": "main", | ||
| "RELATED_IMAGE_CENTRAL_DB": "central-db", | ||
| "RELATED_IMAGE_SCANNER": "scanner", | ||
| "RELATED_IMAGE_SCANNER_SLIM": "scanner-slim", | ||
| "RELATED_IMAGE_SCANNER_DB": "scanner-db", | ||
| "RELATED_IMAGE_SCANNER_DB_SLIM": "scanner-db-slim", | ||
| "RELATED_IMAGE_COLLECTOR": "collector", | ||
| "RELATED_IMAGE_SCANNER_V4_DB": "scanner-v4-db", | ||
| "RELATED_IMAGE_SCANNER_V4": "scanner-v4", | ||
| "RELATED_IMAGE_FACT": "fact", | ||
| } | ||
|
|
||
| // KonfluxOperatorImage returns the Konflux-built operator image reference. | ||
| func KonfluxOperatorImage(config *Config) string { | ||
| return fmt.Sprintf("%s/release-operator:%s", constants.DefaultRegistry, config.Operator.Version) | ||
| } | ||
|
|
||
| // PopulateKonfluxEnvVars populates config.Operator.EnvVars with RELATED_IMAGE_* | ||
| // entries for Konflux image rewriting. Explicitly-provided env vars (e.g. from | ||
| // --operator-env) take precedence and are not overwritten. | ||
| func PopulateKonfluxEnvVars(config *Config) { | ||
| if config.Operator.EnvVars == nil { | ||
| config.Operator.EnvVars = make(map[string]string) | ||
| } | ||
| for envName, imageSuffix := range konfluxRelatedImages { | ||
| if _, exists := config.Operator.EnvVars[envName]; exists { | ||
| continue | ||
| } | ||
| config.Operator.EnvVars[envName] = fmt.Sprintf( | ||
| "%s/release-%s:%s", | ||
| constants.DefaultRegistry, | ||
| imageSuffix, | ||
| config.Operator.Version, // Konflux built images use the "operator tag". | ||
| ) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| package deployer | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "testing" | ||
|
|
||
| "github.com/stackrox/roxie/internal/constants" | ||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestKonfluxOperatorImage(t *testing.T) { | ||
| config := &Config{ | ||
| Operator: OperatorConfig{Version: "4.9.2"}, | ||
| } | ||
| expected := fmt.Sprintf("%s/release-operator:4.9.2", constants.DefaultRegistry) | ||
| assert.Equal(t, expected, KonfluxOperatorImage(config)) | ||
| } | ||
|
|
||
| func TestPopulateKonfluxEnvVars_AllEntries(t *testing.T) { | ||
| config := &Config{ | ||
| Operator: OperatorConfig{Version: "4.9.2"}, | ||
| } | ||
|
|
||
| PopulateKonfluxEnvVars(config) | ||
|
|
||
| require.Len(t, config.Operator.EnvVars, len(konfluxRelatedImages)) | ||
|
|
||
| for envName, imageSuffix := range konfluxRelatedImages { | ||
| expected := fmt.Sprintf("%s/release-%s:%s", constants.DefaultRegistry, imageSuffix, "4.9.2") | ||
| assert.Equal(t, expected, config.Operator.EnvVars[envName], "mismatch for %s", envName) | ||
| } | ||
| } | ||
|
|
||
| func TestPopulateKonfluxEnvVars_UserOverridePreserved(t *testing.T) { | ||
| userValue := "quay.io/custom/my-main:latest" | ||
| config := &Config{ | ||
| Operator: OperatorConfig{ | ||
| Version: "4.9.2", | ||
| EnvVars: map[string]string{ | ||
| "RELATED_IMAGE_MAIN": userValue, | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| PopulateKonfluxEnvVars(config) | ||
|
|
||
| assert.Equal(t, userValue, config.Operator.EnvVars["RELATED_IMAGE_MAIN"], | ||
| "user override should be preserved") | ||
|
|
||
| assert.Len(t, config.Operator.EnvVars, len(konfluxRelatedImages), | ||
| "all other entries should be populated") | ||
|
|
||
| for envName, imageSuffix := range konfluxRelatedImages { | ||
| if envName == "RELATED_IMAGE_MAIN" { | ||
| continue | ||
| } | ||
| expected := fmt.Sprintf("%s/release-%s:%s", constants.DefaultRegistry, imageSuffix, "4.9.2") | ||
| assert.Equal(t, expected, config.Operator.EnvVars[envName], "mismatch for %s", envName) | ||
| } | ||
| } | ||
|
|
||
| func TestPopulateKonfluxEnvVars_NilEnvVarsMap(t *testing.T) { | ||
| config := &Config{ | ||
| Operator: OperatorConfig{Version: "4.9.2"}, | ||
| } | ||
| assert.Nil(t, config.Operator.EnvVars) | ||
|
|
||
| PopulateKonfluxEnvVars(config) | ||
|
|
||
| require.NotNil(t, config.Operator.EnvVars) | ||
| assert.Len(t, config.Operator.EnvVars, len(konfluxRelatedImages)) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.