1
0
Fork 0
mirror of https://github.com/external-secrets/external-secrets.git synced 2024-12-14 11:57:59 +00:00

Rename sync_calls_total and sync_calls_error variables to adhere coding style

This commit is contained in:
Jonatas Baldin 2021-04-12 17:23:41 +02:00
parent 80f6376d2c
commit d7fced6310
3 changed files with 19 additions and 19 deletions

View file

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

View file

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

View file

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