Repository navigation
Support per-operand image tags #302
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
11 commits
Select commit
Hold shift + click to select a range
e935561
Support per-operand-image versions via operator.imageTags.
mclasmeier 8019a78
Rename overwrite -> override
mclasmeier e36851b
Update function comment
mclasmeier 8621bec
Address coderabbitai feedback: don't forget scanner v2 images, for de…
mclasmeier e9095a9
Addressing coderabbitai feedback: Add TODO for pre-existing issue
mclasmeier 42982f1
gofmt
mclasmeier 666acd8
Propagate modified operator environment also on the OLM deployment path.
mclasmeier 42aa8e5
e2e tests for new operand image overrides.
mclasmeier 6f5f96a
Merge branch 'main' into mc/per-image-tags
mclasmeier 269368a
Explicitly switch off OLM in test for the test to pass again
mclasmeier 6484250
Merge remote-tracking branch 'refs/remotes/origin/mc/per-image-tags' …
mclasmeier 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
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,98 @@ | ||
| package deployer | ||
|
|
||
| import ( | ||
| "fmt" | ||
|
|
||
| "github.com/stackrox/roxie/internal/constants" | ||
| "github.com/stackrox/roxie/internal/imagetag" | ||
| ) | ||
|
|
||
| var relatedImages = map[string]string{ | ||
| "RELATED_IMAGE_MAIN": "main", | ||
| "RELATED_IMAGE_CENTRAL_DB": "central-db", | ||
| "RELATED_IMAGE_COLLECTOR": "collector", | ||
| "RELATED_IMAGE_SCANNER_V4_DB": "scanner-v4-db", | ||
| "RELATED_IMAGE_SCANNER_V4": "scanner-v4", | ||
| "RELATED_IMAGE_FACT": "fact", | ||
|
|
||
| // Old scanner images need to stay for now to be able to deploy older ACS versions. | ||
| "RELATED_IMAGE_SCANNER": "scanner", | ||
| "RELATED_IMAGE_SCANNER_SLIM": "scanner-slim", | ||
| "RELATED_IMAGE_SCANNER_DB": "scanner-db", | ||
| "RELATED_IMAGE_SCANNER_DB_SLIM": "scanner-db-slim", | ||
| } | ||
|
|
||
| // populateOperatorEnvVars adds RELATED_IMAGE_* env vars to the instance | ||
| // when the effective operand image differs from what the operator would | ||
| // use by default (i.e. when OperandTag or OperandTagOverrides are set). | ||
| // In Konflux mode, all entries are added unconditionally. | ||
| // Explicitly-provided env vars (e.g. from --operator-env) take precedence. | ||
| func populateOperatorEnvVars(instance *OperatorInstanceConfig) { | ||
| if instance == nil { | ||
| // Nothing to do. | ||
| return | ||
| } | ||
|
|
||
| envVars := make(map[string]string) | ||
|
|
||
| for envName, imageName := range relatedImages { | ||
| envVars[envName] = constructOperandImageFromInstance(*instance, imageName) | ||
| } | ||
|
|
||
| instanceWithoutOverrides := *instance | ||
| instanceWithoutOverrides.OperandTag = imagetag.MainTag("") | ||
| instanceWithoutOverrides.OperandTagOverrides = nil | ||
|
|
||
| if instance.EnvVars == nil { | ||
| instance.EnvVars = make(map[string]string) | ||
| } | ||
| for envName, imageRef := range envVars { | ||
| if _, exists := instance.EnvVars[envName]; exists { | ||
| // Explicitly set env vars for related images take precedence. | ||
| continue | ||
| } | ||
| if !instance.KonfluxImagesEnabled() { | ||
| // Only add env var if it differs from what the operator would use anyway. | ||
| // For Konflux mode we need to add the overwrites unconditionally, because the operator | ||
| // happily references non-existing downstream operand images. | ||
| defaultImageRef := constructOperandImageFromInstance(instanceWithoutOverrides, relatedImages[envName]) | ||
| if imageRef == defaultImageRef { | ||
| continue | ||
| } | ||
| } | ||
| instance.EnvVars[envName] = imageRef | ||
| } | ||
| } | ||
|
|
||
| func constructOperandImageFromInstance(instance OperatorInstanceConfig, imageName string) string { | ||
| imagePrefix := "" | ||
| useKonflux := instance.KonfluxImagesEnabled() | ||
| if useKonflux { | ||
| imagePrefix = "release-" | ||
| } | ||
| imageRegistry := constants.DefaultRegistry | ||
| if !useKonflux && instance.ImageRegistry != "" { // Konflux images are only supported for default registry. | ||
| imageRegistry = instance.ImageRegistry | ||
| } | ||
|
|
||
| // The top-level version in an OperatorInstanceConfig can be | ||
| // selectively overwritten for specific images. | ||
| effectiveOperandImageVersion := instance.Version | ||
| if instance.OperandTag.IsSet() { | ||
| effectiveOperandImageVersion = instance.OperandTag | ||
| } | ||
| if perImageVersion := instance.OperandTagOverrides[imageName]; perImageVersion.IsSet() { | ||
| // A custom version for this particular image is requested. | ||
| effectiveOperandImageVersion = perImageVersion | ||
| } | ||
|
|
||
| var effectiveVersionString string | ||
| if useKonflux { | ||
| // Konflux built images use the "operator tag". | ||
| effectiveVersionString = effectiveOperandImageVersion.ToOperatorTag().String() | ||
| } else { | ||
| effectiveVersionString = effectiveOperandImageVersion.String() | ||
| } | ||
|
|
||
| return fmt.Sprintf("%s/%s%s:%s", imageRegistry, imagePrefix, imageName, effectiveVersionString) | ||
| } |
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.