Browse Source

Rename sync_calls_total and sync_calls_error variables to adhere coding style

Jonatas Baldin 5 years ago
parent
commit
d7fced6310

+ 6 - 6
pkg/controllers/externalsecret/externalsecret_controller.go

@@ -65,7 +65,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
 	err := r.Get(ctx, req.NamespacedName, &externalSecret)
 	if err != nil {
 		log.Error(err, "could not get ExternalSecret")
-		sync_calls_error.With(syncCallsMetricLabels).Inc()
+		syncCallsError.With(syncCallsMetricLabels).Inc()
 		return ctrl.Result{}, client.IgnoreNotFound(err)
 	}
 
@@ -82,7 +82,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
 		conditionSynced := NewExternalSecretCondition(esv1alpha1.ExternalSecretReady, corev1.ConditionFalse, esv1alpha1.ConditionReasonSecretSyncedError, err.Error())
 		SetExternalSecretCondition(&externalSecret.Status, *conditionSynced)
 		err = r.Status().Update(ctx, &externalSecret)
-		sync_calls_error.With(syncCallsMetricLabels).Inc()
+		syncCallsError.With(syncCallsMetricLabels).Inc()
 		return ctrl.Result{RequeueAfter: requeueAfter}, nil
 	}
 
@@ -97,7 +97,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
 	storeProvider, err := schema.GetProvider(store)
 	if err != nil {
 		log.Error(err, "could not get store provider")
-		sync_calls_error.With(syncCallsMetricLabels).Inc()
+		syncCallsError.With(syncCallsMetricLabels).Inc()
 		return ctrl.Result{RequeueAfter: requeueAfter}, nil
 	}
 
@@ -107,7 +107,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
 		conditionSynced := NewExternalSecretCondition(esv1alpha1.ExternalSecretReady, corev1.ConditionFalse, esv1alpha1.ConditionReasonSecretSyncedError, err.Error())
 		SetExternalSecretCondition(&externalSecret.Status, *conditionSynced)
 		err = r.Status().Update(ctx, &externalSecret)
-		sync_calls_error.With(syncCallsMetricLabels).Inc()
+		syncCallsError.With(syncCallsMetricLabels).Inc()
 		return ctrl.Result{RequeueAfter: requeueAfter}, nil
 	}
 
@@ -136,7 +136,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
 		if err != nil {
 			log.Error(err, "unable to update status")
 		}
-		sync_calls_error.With(syncCallsMetricLabels).Inc()
+		syncCallsError.With(syncCallsMetricLabels).Inc()
 		return ctrl.Result{RequeueAfter: requeueAfter}, nil
 	}
 
@@ -153,7 +153,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
 		log.Error(err, "unable to update status")
 	}
 
-	sync_calls_total.With(syncCallsMetricLabels).Inc()
+	syncCallsTotal.With(syncCallsMetricLabels).Inc()
 
 	return ctrl.Result{
 		RequeueAfter: dur,

+ 10 - 10
pkg/controllers/externalsecret/externalsecret_controller_test.go

@@ -69,8 +69,8 @@ var _ = Describe("ExternalSecret controller", func() {
 		})).To(Succeed())
 
 		metric.Reset()
-		sync_calls_total.Reset()
-		sync_calls_error.Reset()
+		syncCallsTotal.Reset()
+		syncCallsError.Reset()
 	})
 
 	AfterEach(func() {
@@ -120,7 +120,7 @@ var _ = Describe("ExternalSecret controller", func() {
 			}, timeout, interval).Should(BeTrue())
 		})
 
-		It("should increment the sync_calls_total metric", func() {
+		It("should increment the syncCallsTotal metric", func() {
 			ctx := context.Background()
 			es := &esv1alpha1.ExternalSecret{
 				ObjectMeta: metav1.ObjectMeta{
@@ -144,14 +144,14 @@ var _ = Describe("ExternalSecret controller", func() {
 			expectedValue := 2.0
 
 			Eventually(func() float64 {
-				Expect(sync_calls_total.WithLabelValues(ExternalSecretName, ExternalSecretNamespace).Write(&metric)).To(Succeed())
+				Expect(syncCallsTotal.WithLabelValues(ExternalSecretName, ExternalSecretNamespace).Write(&metric)).To(Succeed())
 				return metric.GetCounter().GetValue()
 			}, timeout, interval).Should(Equal(expectedValue))
 		})
 	})
 
 	Context("When updating an ExternalSecret", func() {
-		It("should increment the sync_calls_total metric", func() {
+		It("should increment the syncCallsTotal metric", func() {
 			ctx := context.Background()
 			es := &esv1alpha1.ExternalSecret{
 				ObjectMeta: metav1.ObjectMeta{
@@ -171,7 +171,7 @@ var _ = Describe("ExternalSecret controller", func() {
 			Expect(k8sClient.Create(ctx, es)).Should(Succeed())
 
 			Eventually(func() float64 {
-				Expect(sync_calls_total.WithLabelValues(ExternalSecretName, ExternalSecretNamespace).Write(&metric)).To(Succeed())
+				Expect(syncCallsTotal.WithLabelValues(ExternalSecretName, ExternalSecretNamespace).Write(&metric)).To(Succeed())
 				return metric.GetCounter().GetValue()
 			}, timeout, interval).Should(Equal(2.0))
 
@@ -199,7 +199,7 @@ var _ = Describe("ExternalSecret controller", func() {
 			expectedValue := 3.0
 
 			Eventually(func() float64 {
-				Expect(sync_calls_total.WithLabelValues(ExternalSecretName, ExternalSecretNamespace).Write(&metric)).To(Succeed())
+				Expect(syncCallsTotal.WithLabelValues(ExternalSecretName, ExternalSecretNamespace).Write(&metric)).To(Succeed())
 				return metric.GetCounter().GetValue()
 			}, timeout, interval).Should(Equal(expectedValue))
 		})
@@ -406,7 +406,7 @@ var _ = Describe("ExternalSecret controller", func() {
 			}, timeout, interval).Should(BeTrue())
 
 			Eventually(func() float64 {
-				Expect(sync_calls_error.WithLabelValues(ExternalSecretName, ExternalSecretNamespace).Write(&metric)).To(Succeed())
+				Expect(syncCallsError.WithLabelValues(ExternalSecretName, ExternalSecretNamespace).Write(&metric)).To(Succeed())
 				return metric.GetCounter().GetValue()
 			}, timeout, interval).Should(Equal(1.0))
 		})
@@ -457,7 +457,7 @@ var _ = Describe("ExternalSecret controller", func() {
 			}, timeout, interval).Should(BeTrue())
 
 			Eventually(func() float64 {
-				Expect(sync_calls_error.WithLabelValues(ExternalSecretName, ExternalSecretNamespace).Write(&metric)).To(Succeed())
+				Expect(syncCallsError.WithLabelValues(ExternalSecretName, ExternalSecretNamespace).Write(&metric)).To(Succeed())
 				return metric.GetCounter().GetValue()
 			}, timeout, interval).Should(Equal(1.0))
 		})
@@ -512,7 +512,7 @@ var _ = Describe("ExternalSecret controller", func() {
 			}, timeout, interval).Should(BeTrue())
 
 			Eventually(func() float64 {
-				Expect(sync_calls_error.WithLabelValues(ExternalSecretName, ExternalSecretNamespace).Write(&metric)).To(Succeed())
+				Expect(syncCallsError.WithLabelValues(ExternalSecretName, ExternalSecretNamespace).Write(&metric)).To(Succeed())
 				return metric.GetCounter().GetValue()
 			}, timeout, interval).Should(Equal(1.0))
 		})

+ 3 - 3
pkg/controllers/externalsecret/metrics.go

@@ -26,13 +26,13 @@ const (
 )
 
 var (
-	sync_calls_total = prometheus.NewCounterVec(prometheus.CounterOpts{
+	syncCallsTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
 		Subsystem: ExternalSecretSubsystem,
 		Name:      SyncCallsKey,
 		Help:      "Total number of the External Secret sync calls",
 	}, []string{"name", "namespace"})
 
-	sync_calls_error = prometheus.NewCounterVec(prometheus.CounterOpts{
+	syncCallsError = prometheus.NewCounterVec(prometheus.CounterOpts{
 		Subsystem: ExternalSecretSubsystem,
 		Name:      SyncCallsErrorKey,
 		Help:      "Total number of the External Secret sync errors",
@@ -40,5 +40,5 @@ var (
 )
 
 func init() {
-	metrics.Registry.MustRegister(sync_calls_total, sync_calls_error)
+	metrics.Registry.MustRegister(syncCallsTotal, syncCallsError)
 }