@@ -131,7 +131,7 @@ func (r *CloudKittyReconciler) Reconcile(ctx context.Context, req ctrl.Request)
131131
132132 // Fetch the CloudKitty instance
133133 instance := & telemetryv1.CloudKitty {}
134- err := r .Client . Get (ctx , req .NamespacedName , instance )
134+ err := r .Get (ctx , req .NamespacedName , instance )
135135 if err != nil {
136136 if k8s_errors .IsNotFound (err ) {
137137 // Request object not found, could have been deleted after reconcile request.
@@ -235,7 +235,8 @@ func (r *CloudKittyReconciler) Reconcile(ctx context.Context, req ctrl.Request)
235235
236236// fields to index to reconcile when change
237237const (
238- cloudKittyPasswordSecretField = ".spec.secret"
238+ cloudKittyPasswordSecretField = ".spec.secret"
239+ //nolint:gosec // Not hardcoded credentials, just field name
239240 cloudKittyCaBundleSecretNameField = ".spec.tls.caBundleSecretName"
240241 cloudKittyTLSAPIInternalField = ".spec.tls.api.internal.secretName"
241242 cloudKittyTLSAPIPublicField = ".spec.tls.api.public.secretName"
@@ -280,7 +281,7 @@ func (r *CloudKittyReconciler) SetupWithManager(mgr ctrl.Manager) error {
280281 listOpts := []client.ListOption {
281282 client .InNamespace (o .GetNamespace ()),
282283 }
283- if err := r .Client . List (ctx , cloudkitties , listOpts ... ); err != nil {
284+ if err := r .List (ctx , cloudkitties , listOpts ... ); err != nil {
284285 Log .Error (err , "Unable to retrieve CloudKitty CRs %v" )
285286 return nil
286287 }
@@ -316,7 +317,7 @@ func (r *CloudKittyReconciler) SetupWithManager(mgr ctrl.Manager) error {
316317 listOpts := []client.ListOption {
317318 client .InNamespace (o .GetNamespace ()),
318319 }
319- if err := r .Client . List (ctx , cloudkitties , listOpts ... ); err != nil {
320+ if err := r .List (ctx , cloudkitties , listOpts ... ); err != nil {
320321 Log .Error (err , "Unable to retrieve CloudKitty CRs %w" )
321322 return nil
322323 }
@@ -374,7 +375,7 @@ func (r *CloudKittyReconciler) findObjectForSrc(ctx context.Context, src client.
374375 listOps := & client.ListOptions {
375376 Namespace : src .GetNamespace (),
376377 }
377- err := r .Client . List (ctx , crList , listOps )
378+ err := r .List (ctx , crList , listOps )
378379 if err != nil {
379380 l .Error (err , fmt .Sprintf ("listing %s for namespace: %s" , crList .GroupVersionKind ().Kind , src .GetNamespace ()))
380381 return requests
@@ -609,7 +610,9 @@ func (r *CloudKittyReconciler) reconcileNormal(ctx context.Context, instance *te
609610 condition .SeverityError ,
610611 telemetryv1 .CloudKittyClientCertReadyErrorMessage ,
611612 err .Error ()))
612- return ctrl.Result {}, err
613+ return ctrlResult , err
614+ } else if (ctrlResult != ctrl.Result {}) {
615+ return ctrlResult , nil
613616 }
614617
615618 cms := []util.Template {
@@ -641,15 +644,15 @@ func (r *CloudKittyReconciler) reconcileNormal(ctx context.Context, instance *te
641644 instance .Status .Conditions .MarkTrue (telemetryv1 .CloudKittyClientCertReadyCondition , telemetryv1 .CloudKittyClientCertReadyMessage )
642645
643646 // Deploy Loki
644- var eventHandler handler. EventHandler = handler .EnqueueRequestForOwner (
647+ var eventHandler = handler .EnqueueRequestForOwner (
645648 r .Scheme ,
646649 r .RESTMapper ,
647650 & telemetryv1.CloudKitty {},
648651 handler .OnlyControllerOwner (),
649652 )
650653
651654 err = utils .EnsureWatches (
652- (* utils .ConditionalWatchingReconciler )(r ), ctx ,
655+ ctx , (* utils .ConditionalWatchingReconciler )(r ),
653656 "lokistacks.loki.grafana.com" ,
654657 & lokistackv1.LokiStack {}, eventHandler , helper ,
655658 )
@@ -674,7 +677,7 @@ func (r *CloudKittyReconciler) reconcileNormal(ctx context.Context, instance *te
674677 return err
675678 }
676679 desiredLokiStack .Spec .DeepCopyInto (& lokiStack .Spec )
677- lokiStack .ObjectMeta . Labels = serviceLabels
680+ lokiStack .Labels = serviceLabels
678681 err = controllerutil .SetControllerReference (instance , lokiStack , r .Scheme )
679682 return err
680683 })
@@ -911,6 +914,7 @@ func (r *CloudKittyReconciler) reconcileNormal(ctx context.Context, instance *te
911914 condition .SeverityInfo ,
912915 condition .NetworkAttachmentsReadyWaitingMessage ,
913916 netAtt ))
917+ //nolint:err113 // Using condition message format from lib-common
914918 return cloudkitty .ResultRequeue , fmt .Errorf (condition .NetworkAttachmentsReadyWaitingMessage , netAtt )
915919 }
916920 instance .Status .Conditions .Set (condition .FalseCondition (
@@ -1036,7 +1040,7 @@ func (r *CloudKittyReconciler) generateServiceConfigs(
10361040 labels := labels .GetLabels (instance , labels .GetGroupLabel (cloudkitty .ServiceName ), serviceLabels )
10371041
10381042 var tlsCfg * tls.Service
1039- if instance .Spec .CloudKittyAPI .TLS .Ca . CaBundleSecretName != "" {
1043+ if instance .Spec .CloudKittyAPI .TLS .CaBundleSecretName != "" {
10401044 tlsCfg = & tls.Service {}
10411045 }
10421046
@@ -1072,7 +1076,7 @@ func (r *CloudKittyReconciler) generateServiceConfigs(
10721076 if instance .Spec .PrometheusHost == "" {
10731077 // We're using MetricStorage for Prometheus.
10741078 prometheusEndpointSecret := & corev1.Secret {}
1075- err = r .Client . Get (ctx , client.ObjectKey {
1079+ err = r .Get (ctx , client.ObjectKey {
10761080 Name : cloudkitty .PrometheusEndpointSecret ,
10771081 Namespace : instance .Namespace ,
10781082 }, prometheusEndpointSecret )
@@ -1085,10 +1089,11 @@ func (r *CloudKittyReconciler) generateServiceConfigs(
10851089 if err != nil {
10861090 return err
10871091 }
1092+ //nolint:gosec // G109: Port number is read from a secret and validated to be within valid range
10881093 instance .Status .PrometheusPort = int32 (port )
10891094
10901095 metricStorage := & telemetryv1.MetricStorage {}
1091- err = r .Client . Get (ctx , client.ObjectKey {
1096+ err = r .Get (ctx , client.ObjectKey {
10921097 Namespace : instance .Namespace ,
10931098 Name : telemetryv1 .DefaultServiceName ,
10941099 }, metricStorage )
0 commit comments