Skip to content
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

feat(KFLUXDP-108): Allow to pass via COMPONENT_IMAGE env images with tag and sha #1492

Merged
merged 1 commit into from
Jan 28, 2025
Merged
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
7 changes: 2 additions & 5 deletions magefiles/rulesengine/repos/build_service.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package repos

import (
"fmt"
"os"

"github.com/konflux-ci/e2e-tests/magefiles/rulesengine"
Expand Down Expand Up @@ -38,10 +37,8 @@ var BuildServiceRepoSetDefaultSettingsRule = rulesengine.Rule{Name: "General Req
return nil
}
rctx.ComponentEnvVarPrefix = "BUILD_SERVICE"
// TODO keep only "KONFLUX_CI" option once we migrate off openshift-ci
if os.Getenv("KONFLUX_CI") == "true" {
rctx.ComponentImageTag = fmt.Sprintf("on-pr-%s", rctx.PrCommitSha)
} else {
// Option to execute the tests in Openshift CI
if os.Getenv("KONFLUX_CI") != "true" {
rctx.ComponentImageTag = "redhat-appstudio-build-service-image"
}
return SetEnvVarsForComponentImageDeployment(rctx)
Expand Down
26 changes: 22 additions & 4 deletions magefiles/rulesengine/repos/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,13 +536,31 @@ func SetupMultiPlatformTests() error {

func SetEnvVarsForComponentImageDeployment(rctx *rulesengine.RuleCtx) error {
componentImage := os.Getenv("COMPONENT_IMAGE")
sp := strings.Split(componentImage, "@")
if len(sp) != 2 {

tag := rctx.ComponentImageTag

imageData := strings.SplitN(componentImage, "@", 2)
if len(imageData) != 2 {
return fmt.Errorf("component image ref expected in format 'quay.io/<org>/<repository>@sha256:<sha256-value>', got %s", componentImage)
}
os.Setenv(fmt.Sprintf("%s_IMAGE_REPO", rctx.ComponentEnvVarPrefix), sp[0])
os.Setenv(fmt.Sprintf("%s_IMAGE_TAG", rctx.ComponentEnvVarPrefix), rctx.ComponentImageTag)
repository := imageData[0]

// From Konflux the e2e tests will receive 2 kind of images:
// 1. quay.io/test/test@sha:1234: This images ussually comes from the Konflux snapshots
// 2. quay.io/test/test:on-pr-1234.sealights@sha:1234 This images ussually comes from a build
// that includes the Sealights instrumented code:
if tag == "" {
if repoParts := strings.SplitN(repository, ":", 2); len(repoParts) == 2 {
psturc marked this conversation as resolved.
Show resolved Hide resolved
repository, tag = repoParts[0], repoParts[1]
} else {
tag = fmt.Sprintf("on-pr-%s", rctx.PrCommitSha)
}
}

os.Setenv(fmt.Sprintf("%s_IMAGE_REPO", rctx.ComponentEnvVarPrefix), repository)
Dismissed Show dismissed Hide dismissed
os.Setenv(fmt.Sprintf("%s_IMAGE_TAG", rctx.ComponentEnvVarPrefix), tag)
Dismissed Show dismissed Hide dismissed
os.Setenv(fmt.Sprintf("%s_PR_OWNER", rctx.ComponentEnvVarPrefix), rctx.PrRemoteName)
os.Setenv(fmt.Sprintf("%s_PR_SHA", rctx.ComponentEnvVarPrefix), rctx.PrCommitSha)

return nil
}
5 changes: 1 addition & 4 deletions magefiles/rulesengine/repos/image_controller.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package repos

import (
"fmt"
"os"

"github.com/konflux-ci/e2e-tests/magefiles/rulesengine"
Expand Down Expand Up @@ -39,9 +38,7 @@ var ImageControllerRepoSetDefaultSettingsRule = rulesengine.Rule{Name: "General
}
rctx.ComponentEnvVarPrefix = "IMAGE_CONTROLLER"
// TODO keep only "KONFLUX_CI" option once we migrate off openshift-ci
if os.Getenv("KONFLUX_CI") == "true" {
rctx.ComponentImageTag = fmt.Sprintf("on-pr-%s", rctx.PrCommitSha)
} else {
if os.Getenv("KONFLUX_CI") != "true" {
rctx.ComponentImageTag = "redhat-appstudio-image-controller-image"
}
return SetEnvVarsForComponentImageDeployment(rctx)
Expand Down
5 changes: 1 addition & 4 deletions magefiles/rulesengine/repos/integration_service.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package repos

import (
"fmt"
"os"

"github.com/konflux-ci/e2e-tests/magefiles/rulesengine"
Expand Down Expand Up @@ -39,9 +38,7 @@ var IntegrationServiceRepoSetDefaultSettingsRule = rulesengine.Rule{Name: "Gener
}
rctx.ComponentEnvVarPrefix = "INTEGRATION_SERVICE"
// TODO keep only "KONFLUX_CI" option once we migrate off openshift-ci
if os.Getenv("KONFLUX_CI") == "true" {
rctx.ComponentImageTag = fmt.Sprintf("on-pr-%s", rctx.PrCommitSha)
} else {
if os.Getenv("KONFLUX_CI") != "true" {
rctx.ComponentImageTag = "redhat-appstudio-integration-service-image"
}
return SetEnvVarsForComponentImageDeployment(rctx)
Expand Down
5 changes: 2 additions & 3 deletions magefiles/rulesengine/repos/release_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ var ReleaseServiceRepoSetDefaultSettingsRule = rulesengine.Rule{Name: "General R
}
rctx.ComponentEnvVarPrefix = "RELEASE_SERVICE"
// TODO keep only "KONFLUX_CI" option once we migrate off openshift-ci
if os.Getenv("KONFLUX_CI") == "true" {
rctx.ComponentImageTag = fmt.Sprintf("on-pr-%s", rctx.PrCommitSha)
} else {

if os.Getenv("KONFLUX_CI") != "true" {
rctx.ComponentImageTag = "redhat-appstudio-release-service-image"
}
//This is env variable is specified for release service
Expand Down
Loading