Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Pavlov <[email protected]>
  • Loading branch information
Kshatrix committed Oct 18, 2024
1 parent 4af3129 commit 25c4ece
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions internal/controller/managedcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -634,23 +635,21 @@ func (r *ManagedClusterReconciler) objectsAvailable(ctx context.Context, namespa
return len(itemsList.Items) != 0, nil
}

Check failure on line 637 in internal/controller/managedcluster_controller.go

View workflow job for this annotation

GitHub Actions / Build and Unit Test

(*ManagedClusterReconciler).reconcileCredentialPropagation - result 0 (sigs.k8s.io/controller-runtime/pkg/reconcile.Result) is always nil (unparam)
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{}
if err := r.Client.Get(ctx, client.ObjectKey{
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 {
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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 {
Expand Down

0 comments on commit 25c4ece

Please sign in to comment.