From 197d3358f755c32f6d3dce9272957c8ab4444166 Mon Sep 17 00:00:00 2001 From: RainbowMango Date: Wed, 22 May 2024 11:39:45 +0800 Subject: [PATCH] Fixed golint issues and new piecies of wait.Poll Signed-off-by: RainbowMango --- pkg/controllers/certificate/cert_rotation_controller.go | 2 +- pkg/karmadactl/register/register.go | 2 +- pkg/karmadactl/unjoin/unjoin.go | 2 +- pkg/util/serviceaccount.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/controllers/certificate/cert_rotation_controller.go b/pkg/controllers/certificate/cert_rotation_controller.go index 403f6c51e..9fe53a085 100644 --- a/pkg/controllers/certificate/cert_rotation_controller.go +++ b/pkg/controllers/certificate/cert_rotation_controller.go @@ -181,7 +181,7 @@ func (c *CertRotationController) syncCertRotation(secret *corev1.Secret) error { var newCertData []byte klog.V(1).Infof("Waiting for the client certificate to be issued") - err = wait.PollUntilContextTimeout(context.TODO(), 1*time.Second, 5*time.Minute, false, func(ctx context.Context) (done bool, err error) { + err = wait.PollUntilContextTimeout(context.TODO(), 1*time.Second, 5*time.Minute, false, func(context.Context) (done bool, err error) { csr, err := c.KubeClient.CertificatesV1().CertificateSigningRequests().Get(context.TODO(), csr, metav1.GetOptions{}) if err != nil { return false, fmt.Errorf("failed to get the cluster csr %s. err: %v", clusterName, err) diff --git a/pkg/karmadactl/register/register.go b/pkg/karmadactl/register/register.go index d7ece31f0..de270856b 100644 --- a/pkg/karmadactl/register/register.go +++ b/pkg/karmadactl/register/register.go @@ -545,7 +545,7 @@ func (o *CommandRegisterOption) constructKarmadaAgentConfig(bootstrapClient *kub } klog.V(1).Infof("Waiting for the client certificate to be issued") - err = wait.PollUntilContextTimeout(context.TODO(), 1*time.Second, o.Timeout, false, func(ctx context.Context) (done bool, err error) { + err = wait.PollUntilContextTimeout(context.TODO(), 1*time.Second, o.Timeout, false, func(context.Context) (done bool, err error) { csrOK, err := bootstrapClient.CertificatesV1().CertificateSigningRequests().Get(context.TODO(), csrName, metav1.GetOptions{}) if err != nil { return false, fmt.Errorf("failed to get the cluster csr %s. err: %v", o.ClusterName, err) diff --git a/pkg/karmadactl/unjoin/unjoin.go b/pkg/karmadactl/unjoin/unjoin.go index 3c4498298..3ca26807b 100644 --- a/pkg/karmadactl/unjoin/unjoin.go +++ b/pkg/karmadactl/unjoin/unjoin.go @@ -239,7 +239,7 @@ func (j *CommandUnjoinOption) deleteClusterObject(controlPlaneKarmadaClient *kar } // make sure the given cluster object has been deleted - err = wait.PollUntilContextTimeout(context.TODO(), 1*time.Second, j.Wait, false, func(ctx context.Context) (done bool, err error) { + err = wait.PollUntilContextTimeout(context.TODO(), 1*time.Second, j.Wait, false, func(context.Context) (done bool, err error) { _, err = controlPlaneKarmadaClient.ClusterV1alpha1().Clusters().Get(context.TODO(), j.ClusterName, metav1.GetOptions{}) if apierrors.IsNotFound(err) { return true, nil diff --git a/pkg/util/serviceaccount.go b/pkg/util/serviceaccount.go index b24efa151..f5c307a17 100644 --- a/pkg/util/serviceaccount.go +++ b/pkg/util/serviceaccount.go @@ -91,7 +91,7 @@ func EnsureServiceAccountExist(client kubeclient.Interface, serviceAccountObj *c // WaitForServiceAccountSecretCreation wait the ServiceAccount's secret has been created. func WaitForServiceAccountSecretCreation(client kubeclient.Interface, asObj *corev1.ServiceAccount) (*corev1.Secret, error) { var clusterSecret *corev1.Secret - err := wait.PollUntilContextTimeout(context.TODO(), 1*time.Second, 30*time.Second, false, func(ctx context.Context) (done bool, err error) { + err := wait.PollUntilContextTimeout(context.TODO(), 1*time.Second, 30*time.Second, false, func(context.Context) (done bool, err error) { serviceAccount, err := client.CoreV1().ServiceAccounts(asObj.Namespace).Get(context.TODO(), asObj.Name, metav1.GetOptions{}) if err != nil { if apierrors.IsNotFound(err) {