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

fix(deployment reconciler): Couldn't parse image reference "docker.io/grafana/grafana@9.1.6" #1320

Merged
merged 2 commits into from
Nov 28, 2023
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
6 changes: 3 additions & 3 deletions controllers/reconcilers/grafana/deployment_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,18 @@ func getVolumeMounts(cr *v1beta1.Grafana, scheme *runtime.Scheme) []v1.VolumeMou
return mounts
}

func setGrafanaImage() string {
func getGrafanaImage() string {
grafanaImg := os.Getenv("RELATED_IMAGE_GRAFANA")
if grafanaImg == "" {
grafanaImg = fmt.Sprintf("%s@%s", config2.GrafanaImage, config2.GrafanaVersion)
grafanaImg = fmt.Sprintf("%s:%s", config2.GrafanaImage, config2.GrafanaVersion)
}
return grafanaImg
}

func getContainers(cr *v1beta1.Grafana, scheme *runtime.Scheme, vars *v1beta1.OperatorReconcileVars, openshiftPlatform bool) []v1.Container {
var containers []v1.Container

image := setGrafanaImage()
image := getGrafanaImage()
plugins := model.GetPluginsConfigMap(cr, scheme)

// env var to restart containers if plugins change
Expand Down
23 changes: 23 additions & 0 deletions controllers/reconcilers/grafana/deployment_reconciler_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package grafana

import (
"fmt"
"testing"

config2 "github.com/grafana-operator/grafana-operator/v5/controllers/config"

"github.com/stretchr/testify/assert"
)

func Test_getGrafanaImage(t *testing.T) {
expectedDeploymentImage := fmt.Sprintf("%s:%s", config2.GrafanaImage, config2.GrafanaVersion)

assert.Equal(t, expectedDeploymentImage, getGrafanaImage())
}

func Test_getGrafanaImage_withEnvironmentOverride(t *testing.T) {
expectedDeploymentImage := "I want this grafana image"
t.Setenv("RELATED_IMAGE_GRAFANA", expectedDeploymentImage)

assert.Equal(t, expectedDeploymentImage, getGrafanaImage())
}