From 8382061273468ebc491268b04f02b0a1e4b62079 Mon Sep 17 00:00:00 2001 From: Igor Beliakov Date: Wed, 20 Jul 2022 18:29:27 +0200 Subject: [PATCH 1/2] fix: return correct message about unsupported protocol Signed-off-by: Igor Beliakov --- controllers/grafana/grafana_controller.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/grafana/grafana_controller.go b/controllers/grafana/grafana_controller.go index be3d21a5b..9917e57eb 100644 --- a/controllers/grafana/grafana_controller.go +++ b/controllers/grafana/grafana_controller.go @@ -275,7 +275,7 @@ func (r *ReconcileGrafana) getGrafanaAdminUrl(cr *grafanav1alpha1.Grafana, state protocol := "http" if cr.Spec.Config.Server != nil { - switch cr.Spec.Config.Server.Protocol { + switch protocol = cr.Spec.Config.Server.Protocol; protocol { case "", "http": protocol = "http" case "https": From 3dd7eb6d96942dd658de3ce0e89a60f091ef52e7 Mon Sep 17 00:00:00 2001 From: Igor Beliakov Date: Wed, 20 Jul 2022 18:55:25 +0200 Subject: [PATCH 2/2] Slightly rewrite the switch Signed-off-by: Igor Beliakov --- controllers/grafana/grafana_controller.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/grafana/grafana_controller.go b/controllers/grafana/grafana_controller.go index 9917e57eb..08cb6d2d4 100644 --- a/controllers/grafana/grafana_controller.go +++ b/controllers/grafana/grafana_controller.go @@ -275,13 +275,13 @@ func (r *ReconcileGrafana) getGrafanaAdminUrl(cr *grafanav1alpha1.Grafana, state protocol := "http" if cr.Spec.Config.Server != nil { - switch protocol = cr.Spec.Config.Server.Protocol; protocol { + switch cr.Spec.Config.Server.Protocol { case "", "http": protocol = "http" case "https": protocol = "https" default: - return "", fmt.Errorf("server protocol %v is not supported, please use either http or https", protocol) + return "", fmt.Errorf("server protocol %v is not supported, please use either http or https", cr.Spec.Config.Server.Protocol) } }