From 25c4ece630ab50717d9d3f9d8d1b8dae4d0c02bf Mon Sep 17 00:00:00 2001 From: Andrei Pavlov Date: Fri, 18 Oct 2024 23:09:36 +0700 Subject: [PATCH] Fix lint Signed-off-by: Andrei Pavlov --- .../controller/managedcluster_controller.go | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/internal/controller/managedcluster_controller.go b/internal/controller/managedcluster_controller.go index aff940e42..f16f353be 100644 --- a/internal/controller/managedcluster_controller.go +++ b/internal/controller/managedcluster_controller.go @@ -23,7 +23,6 @@ import ( texttemplate "text/template" "time" - "github.com/Mirantis/hmc/internal/sveltos" hcv2 "github.com/fluxcd/helm-controller/api/v2" fluxmeta "github.com/fluxcd/pkg/apis/meta" fluxconditions "github.com/fluxcd/pkg/runtime/conditions" @@ -52,6 +51,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/yaml" + "github.com/Mirantis/hmc/internal/sveltos" + hmc "github.com/Mirantis/hmc/api/v1alpha1" "github.com/Mirantis/hmc/internal/helm" "github.com/Mirantis/hmc/internal/telemetry" @@ -373,9 +374,9 @@ func (r *ManagedClusterReconciler) Update(ctx context.Context, managedCluster *h return ctrl.Result{RequeueAfter: DefaultRequeueInterval}, nil } - result, err := r.reconcileCredentialPropagation(ctx, managedCluster) + err = r.reconcileCredentialPropagation(ctx, managedCluster) if err != nil { - return result, err + return ctrl.Result{}, err } return r.updateServices(ctx, managedCluster) @@ -634,14 +635,13 @@ func (r *ManagedClusterReconciler) objectsAvailable(ctx context.Context, namespa return len(itemsList.Items) != 0, nil } -func (r *ManagedClusterReconciler) reconcileCredentialPropagation(ctx context.Context, managedCluster *hmc.ManagedCluster) (ctrl.Result, error) { +func (r *ManagedClusterReconciler) reconcileCredentialPropagation(ctx context.Context, managedCluster *hmc.ManagedCluster) error { l := ctrl.LoggerFrom(ctx) l.Info("Reconciling CCM credentials propagation") providers, err := r.getProviders(ctx, managedCluster.Namespace, managedCluster.Spec.Template) if err != nil { - return ctrl.Result{}, - fmt.Errorf("failed to get cluster providers for cluster %s/%s: %s", managedCluster.Namespace, managedCluster.Name, err) + return fmt.Errorf("failed to get cluster providers for cluster %s/%s: %s", managedCluster.Namespace, managedCluster.Name, err) } kubeconfSecret := &corev1.Secret{} @@ -649,8 +649,7 @@ func (r *ManagedClusterReconciler) reconcileCredentialPropagation(ctx context.Co Name: fmt.Sprintf("%s-kubeconfig", managedCluster.Name), Namespace: managedCluster.Namespace, }, kubeconfSecret); err != nil { - return ctrl.Result{}, - fmt.Errorf("failed to get kubeconfig secret for cluster %s/%s: %s", managedCluster.Namespace, managedCluster.Name, err) + return fmt.Errorf("failed to get kubeconfig secret for cluster %s/%s: %s", managedCluster.Namespace, managedCluster.Name, err) } for _, provider := range providers.InfrastructureProviders { @@ -669,7 +668,7 @@ func (r *ManagedClusterReconciler) reconcileCredentialPropagation(ctx context.Co Reason: hmc.FailedReason, Message: errMsg, }) - return ctrl.Result{}, errors.New(errMsg) + return errors.New(errMsg) } apimeta.SetStatusCondition(managedCluster.GetConditions(), metav1.Condition{ Type: hmc.CredentialsPropagatedCondition, @@ -689,7 +688,7 @@ func (r *ManagedClusterReconciler) reconcileCredentialPropagation(ctx context.Co Reason: hmc.FailedReason, Message: errMsg, }) - return ctrl.Result{}, errors.New(errMsg) + return errors.New(errMsg) } apimeta.SetStatusCondition(managedCluster.GetConditions(), metav1.Condition{ Type: hmc.CredentialsPropagatedCondition, @@ -710,7 +709,7 @@ func (r *ManagedClusterReconciler) reconcileCredentialPropagation(ctx context.Co } } l.Info("CCM credentials reconcile finished") - return ctrl.Result{}, nil + return nil } func (r *ManagedClusterReconciler) propagateAzureSecrets(ctx context.Context, managedCluster *hmc.ManagedCluster, kubeconfSecret *corev1.Secret) error {