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

PR #3 - Customize Grafana Plugin image #15

Merged
merged 1 commit into from
Jun 14, 2019
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
3 changes: 3 additions & 0 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
var log = logf.Log.WithName("cmd")
var flagImage string
var flagImageTag string
var flagPluginsInitContainerImage string
var scanAll bool
var openshift bool

Expand All @@ -39,6 +40,7 @@ func init() {
flagset := flag.CommandLine
flagset.StringVar(&flagImage, "grafana-image", "", "Overrides the default Grafana image")
flagset.StringVar(&flagImageTag, "grafana-image-tag", "", "Overrides the default Grafana image tag")
flagset.StringVar(&flagPluginsInitContainerImage, "grafana-plugins-init-container-image", "", "Overrides the default Grafana Plugins Init Container image")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to have another flag for the tag as well, like grafana-plugins-init-container-image-tag?

flagset.BoolVar(&scanAll, "scan-all", false, "Scans all namespaces for dashboards")
flagset.BoolVar(&openshift, "openshift", false, "Use Route instead of Ingress")
flagset.Parse(os.Args[1:])
Expand Down Expand Up @@ -89,6 +91,7 @@ func main() {
controllerConfig := common.GetControllerConfig()
controllerConfig.AddConfigItem(common.ConfigGrafanaImage, flagImage)
controllerConfig.AddConfigItem(common.ConfigGrafanaImageTag, flagImageTag)
controllerConfig.AddConfigItem(common.ConfigPluginsInitContainerImage, flagPluginsInitContainerImage)
controllerConfig.AddConfigItem(common.ConfigOperatorNamespace, namespace)
controllerConfig.AddConfigItem(common.ConfigDashboardLabelSelector, "")
controllerConfig.AddConfigItem(common.ConfigOpenshift, openshift)
Expand Down
2 changes: 2 additions & 0 deletions pkg/controller/common/controller_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
const (
ConfigGrafanaImage = "grafana.image.url"
ConfigGrafanaImageTag = "grafana.image.tag"
ConfigPluginsInitContainerImage = "grafana.plugins.init.container.image.url"
ConfigOperatorNamespace = "grafana.operator.namespace"
ConfigDashboardLabelSelector = "grafana.dashboard.selector"
ConfigGrafanaPluginsUpdated = "grafana.plugins.updated"
Expand All @@ -26,6 +27,7 @@ const (
GrafanaRouteName = "grafana-route"
GrafanaIngressName = "grafana-ingress"
GrafanaServiceName = "grafana-service"
PluginsInitContainerImage = "quay.io/integreatly/grafana_plugins_init"
PluginsInitContainerImageTag = "0.0.2"
PluginsEnvVar = "GRAFANA_PLUGINS"
PluginsUrl = "https://grafana.com/api/plugins/%s/versions/%s"
Expand Down
2 changes: 2 additions & 0 deletions pkg/controller/grafana/templateHelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type GrafanaParamaeters struct {
LogLevel string
GrafanaRouteName string
GrafanaServiceName string
PluginsInitContainerImage string
PluginsInitContainerImageTag string
GrafanaIngressName string
Hostname string
Expand Down Expand Up @@ -91,6 +92,7 @@ func newTemplateHelper(cr *integreatly.Grafana) *TemplateHelper {
LogLevel: getLogLevel(cr.Spec.LogLevel),
GrafanaRouteName: common.GrafanaRouteName,
GrafanaServiceName: common.GrafanaServiceName,
PluginsInitContainerImage: controllerConfig.GetConfigString(common.ConfigPluginsInitContainerImage, common.PluginsInitContainerImage),
PluginsInitContainerImageTag: common.PluginsInitContainerImageTag,
GrafanaIngressName: common.GrafanaIngressName,
Hostname: cr.Spec.Hostname,
Expand Down
2 changes: 1 addition & 1 deletion templates/grafana-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spec:
- env:
- name: GRAFANA_PLUGINS
value: ""
image: 'quay.io/integreatly/grafana_plugins_init:{{ .PluginsInitContainerImageTag }}'
image: '{{ .PluginsInitContainerImage }}:{{ .PluginsInitContainerImageTag }}'
imagePullPolicy: IfNotPresent
name: grafana-plugins-init
resources: {}
Expand Down