Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lint #531

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions internal/controller/managedcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
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 @@ -54,6 +53,7 @@

hmc "github.com/Mirantis/hmc/api/v1alpha1"
"github.com/Mirantis/hmc/internal/helm"
"github.com/Mirantis/hmc/internal/sveltos"
"github.com/Mirantis/hmc/internal/telemetry"
)

Expand Down Expand Up @@ -373,9 +373,9 @@
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 +634,21 @@
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 {

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)
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 +667,7 @@
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 +687,7 @@
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 +708,7 @@
}
}
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
Loading