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: making operator image configurable #334

Closed
wants to merge 1 commit into from
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
10 changes: 10 additions & 0 deletions pkg/resources/jobs/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package jobs

import (
"fmt"
"os"
"strconv"

"github.com/grafana/k6-operator/pkg/types"
Expand Down Expand Up @@ -145,3 +146,12 @@ func getInitContainers(k6Spec *v1alpha1.TestRunSpec, script *types.Script) []cor

return initContainers
}

func getOperatorImageName() string {
image, ok := os.LookupEnv("OPERATOR_IMAGE_NAME")
if ok {
return image
} else {
return "ghcr.io/grafana/k6-operator"
}
}
2 changes: 1 addition & 1 deletion pkg/resources/jobs/initializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func NewInitializerJob(k6 v1alpha1.TestRunI, argLine string) (*batchv1.Job, erro
}

var (
image = "ghcr.io/grafana/k6-operator:latest-runner"
image = getOperatorImageName() + ":latest-runner"
annotations = make(map[string]string)
labels = newLabels(k6.NamespacedName().Name)
serviceAccountName = "default"
Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/jobs/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func NewRunnerJob(k6 v1alpha1.TestRunI, index int, token string) (*batchv1.Job,
zero32 int32 = 0
)

image := "ghcr.io/grafana/k6-operator:latest-runner"
image := getOperatorImageName() + ":latest-runner"
if k6.GetSpec().Runner.Image != "" {
image = k6.GetSpec().Runner.Image
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/jobs/starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func NewStarterJob(k6 v1alpha1.TestRunI, hostname []string) *batchv1.Job {
starterAnnotations = k6.GetSpec().Starter.Metadata.Annotations
}

starterImage := "ghcr.io/grafana/k6-operator:latest-starter"
starterImage := getOperatorImageName() + ":latest-starter"
if k6.GetSpec().Starter.Image != "" {
starterImage = k6.GetSpec().Starter.Image
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/jobs/stopper.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func NewStopJob(k6 v1alpha1.TestRunI, hostname []string) *batchv1.Job {

job.Name = fmt.Sprintf("%s-stopper", k6.NamespacedName().Name)

image := "ghcr.io/grafana/k6-operator:latest-starter"
image := getOperatorImageName() + ":latest-starter"
if k6.GetSpec().Starter.Image != "" {
image = k6.GetSpec().Starter.Image
}
Expand Down
12 changes: 11 additions & 1 deletion pkg/testrun/plz.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package testrun

import (
"fmt"
"os"

"github.com/grafana/k6-operator/api/v1alpha1"
"github.com/grafana/k6-operator/pkg/cloud"
Expand Down Expand Up @@ -30,7 +31,7 @@ func NewPLZTestRun(plz *v1alpha1.PrivateLoadZone, trData *cloud.TestRunData, ing

initContainer := containers.NewS3InitContainer(
trData.ArchiveURL,
"ghcr.io/grafana/k6-operator:latest-starter",
getOperatorImageName()+":latest-starter",
volumeMount,
)

Expand Down Expand Up @@ -76,3 +77,12 @@ func NewPLZTestRun(plz *v1alpha1.PrivateLoadZone, trData *cloud.TestRunData, ing
},
}
}

func getOperatorImageName() string {
image, ok := os.LookupEnv("OPERATOR_IMAGE_NAME")
if ok {
return image
} else {
return "ghcr.io/grafana/k6-operator"
}
}
Loading