From bda0e290f1446089fcd9753a2a13ea3d8102ccbe Mon Sep 17 00:00:00 2001 From: Dejan Zele Pejchev Date: Mon, 4 Dec 2023 12:43:55 +0100 Subject: [PATCH] fix: mutating hook for binoculars panicking on nil pointer dereference (#294) * fix mutating hook for binoculars panicking on nil pointer dereference * lint fixes for binoculars webhook --- api/install/v1alpha1/binoculars_webhook.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/api/install/v1alpha1/binoculars_webhook.go b/api/install/v1alpha1/binoculars_webhook.go index 1d922b10..90658f41 100644 --- a/api/install/v1alpha1/binoculars_webhook.go +++ b/api/install/v1alpha1/binoculars_webhook.go @@ -68,7 +68,10 @@ func (r *Binoculars) Default() { } // prometheus - if r.Spec.Prometheus.ScrapeInterval == nil { - r.Spec.Prometheus.ScrapeInterval = &metav1.Duration{Duration: time.Second * 10} + if r.Spec.Prometheus != nil && r.Spec.Prometheus.Enabled { + if r.Spec.Prometheus.ScrapeInterval == nil { + r.Spec.Prometheus.ScrapeInterval = &metav1.Duration{Duration: time.Second * 10} + } } + }