diff --git a/operator/pkg/karmadaresource/apiservice/apiservice.go b/operator/pkg/karmadaresource/apiservice/apiservice.go index 4eadfa731784..d0b9bb1ac808 100644 --- a/operator/pkg/karmadaresource/apiservice/apiservice.go +++ b/operator/pkg/karmadaresource/apiservice/apiservice.go @@ -46,7 +46,7 @@ func init() { } // EnsureAggregatedAPIService creates aggregated APIService and a service -func EnsureAggregatedAPIService(aggregatorClient *aggregator.Clientset, client clientset.Interface, karmadaControlPlaneServiceName, karmadaControlPlaneNamespace, hostClusterServiceName, hostClusterNamespace, caBundle string) error { +func EnsureAggregatedAPIService(aggregatorClient aggregator.Interface, client clientset.Interface, karmadaControlPlaneServiceName, karmadaControlPlaneNamespace, hostClusterServiceName, hostClusterNamespace, caBundle string) error { if err := aggregatedApiserverService(client, karmadaControlPlaneServiceName, karmadaControlPlaneNamespace, hostClusterServiceName, hostClusterNamespace); err != nil { return err } @@ -54,7 +54,7 @@ func EnsureAggregatedAPIService(aggregatorClient *aggregator.Clientset, client c return aggregatedAPIService(aggregatorClient, karmadaControlPlaneServiceName, karmadaControlPlaneNamespace, caBundle) } -func aggregatedAPIService(client *aggregator.Clientset, karmadaControlPlaneServiceName, karmadaControlPlaneNamespace, caBundle string) error { +func aggregatedAPIService(client aggregator.Interface, karmadaControlPlaneServiceName, karmadaControlPlaneNamespace, caBundle string) error { apiServiceBytes, err := util.ParseTemplate(KarmadaAggregatedAPIService, struct { Namespace string ServiceName string @@ -101,7 +101,7 @@ func aggregatedApiserverService(client clientset.Interface, karmadaControlPlaneS } // EnsureMetricsAdapterAPIService creates APIService and a service for karmada-metrics-adapter -func EnsureMetricsAdapterAPIService(aggregatorClient *aggregator.Clientset, client clientset.Interface, karmadaControlPlaneServiceName, karmadaControlPlaneNamespace, hostClusterServiceName, hostClusterNamespace, caBundle string) error { +func EnsureMetricsAdapterAPIService(aggregatorClient aggregator.Interface, client clientset.Interface, karmadaControlPlaneServiceName, karmadaControlPlaneNamespace, hostClusterServiceName, hostClusterNamespace, caBundle string) error { if err := karmadaMetricsAdapterService(client, karmadaControlPlaneServiceName, karmadaControlPlaneNamespace, hostClusterServiceName, hostClusterNamespace); err != nil { return err } @@ -109,7 +109,7 @@ func EnsureMetricsAdapterAPIService(aggregatorClient *aggregator.Clientset, clie return karmadaMetricsAdapterAPIService(aggregatorClient, karmadaControlPlaneServiceName, karmadaControlPlaneNamespace, caBundle) } -func karmadaMetricsAdapterAPIService(client *aggregator.Clientset, karmadaControlPlaneServiceName, karmadaControlPlaneNamespace, caBundle string) error { +func karmadaMetricsAdapterAPIService(client aggregator.Interface, karmadaControlPlaneServiceName, karmadaControlPlaneNamespace, caBundle string) error { for _, gv := range constants.KarmadaMetricsAdapterAPIServices { // The APIService name to metrics adapter is "$version.$group" apiServiceName := fmt.Sprintf("%s.%s", gv.Version, gv.Group) @@ -171,7 +171,7 @@ func karmadaMetricsAdapterService(client clientset.Interface, karmadaControlPlan } // EnsureSearchAPIService creates APIService and a service for karmada-metrics-adapter -func EnsureSearchAPIService(aggregatorClient *aggregator.Clientset, client clientset.Interface, karmadaControlPlaneServiceName, karmadaControlPlaneNamespace, hostClusterServiceName, hostClusterNamespace, caBundle string) error { +func EnsureSearchAPIService(aggregatorClient aggregator.Interface, client clientset.Interface, karmadaControlPlaneServiceName, karmadaControlPlaneNamespace, hostClusterServiceName, hostClusterNamespace, caBundle string) error { if err := karmadaSearchService(client, karmadaControlPlaneServiceName, karmadaControlPlaneNamespace, hostClusterServiceName, hostClusterNamespace); err != nil { return err } @@ -179,7 +179,7 @@ func EnsureSearchAPIService(aggregatorClient *aggregator.Clientset, client clien return karmadaSearchAPIService(aggregatorClient, karmadaControlPlaneServiceName, karmadaControlPlaneNamespace, caBundle) } -func karmadaSearchAPIService(client *aggregator.Clientset, karmadaControlPlaneServiceName, karmadaControlPlaneNamespace, caBundle string) error { +func karmadaSearchAPIService(client aggregator.Interface, karmadaControlPlaneServiceName, karmadaControlPlaneNamespace, caBundle string) error { apiServiceBytes, err := util.ParseTemplate(KarmadaSearchAPIService, struct { ServiceName, Namespace string CABundle string diff --git a/operator/pkg/util/apiclient/idempotency.go b/operator/pkg/util/apiclient/idempotency.go index f95e9a191d35..6da6c689fda5 100644 --- a/operator/pkg/util/apiclient/idempotency.go +++ b/operator/pkg/util/apiclient/idempotency.go @@ -49,7 +49,7 @@ func NewCRDsClient(c *rest.Config) (*crdsclient.Clientset, error) { } // NewAPIRegistrationClient is to create an apiregistration ClientSet -func NewAPIRegistrationClient(c *rest.Config) (*aggregator.Clientset, error) { +func NewAPIRegistrationClient(c *rest.Config) (aggregator.Interface, error) { return aggregator.NewForConfig(c) } @@ -183,7 +183,7 @@ func CreateOrUpdateValidatingWebhookConfiguration(client clientset.Interface, vw } // CreateOrUpdateAPIService creates a APIService if the target resource doesn't exist. If the resource exists already, this function will update the resource instead. -func CreateOrUpdateAPIService(apiRegistrationClient *aggregator.Clientset, apiservice *apiregistrationv1.APIService) error { +func CreateOrUpdateAPIService(apiRegistrationClient aggregator.Interface, apiservice *apiregistrationv1.APIService) error { _, err := apiRegistrationClient.ApiregistrationV1().APIServices().Create(context.TODO(), apiservice, metav1.CreateOptions{}) if err != nil { if !apierrors.IsAlreadyExists(err) { diff --git a/pkg/karmadactl/addons/init/global.go b/pkg/karmadactl/addons/init/global.go index cb9ef6be54ad..7b9cb1c18b77 100644 --- a/pkg/karmadactl/addons/init/global.go +++ b/pkg/karmadactl/addons/init/global.go @@ -47,7 +47,7 @@ type GlobalCommandOptions struct { KarmadaRestConfig *rest.Config - KarmadaAggregatorClientSet *aggregator.Clientset + KarmadaAggregatorClientSet aggregator.Interface } // AddFlags adds flags to the specified FlagSet. diff --git a/pkg/karmadactl/cmdinit/karmada/check.go b/pkg/karmadactl/cmdinit/karmada/check.go index 8d2690c1b866..1d068c3c2a30 100644 --- a/pkg/karmadactl/cmdinit/karmada/check.go +++ b/pkg/karmadactl/cmdinit/karmada/check.go @@ -29,7 +29,7 @@ import ( ) // WaitAPIServiceReady wait the api service condition true -func WaitAPIServiceReady(c *aggregator.Clientset, name string, timeout time.Duration) error { +func WaitAPIServiceReady(c aggregator.Interface, name string, timeout time.Duration) error { if err := wait.PollUntilContextTimeout(context.TODO(), time.Second, timeout, true, func(ctx context.Context) (done bool, err error) { apiService, e := c.ApiregistrationV1().APIServices().Get(ctx, name, metav1.GetOptions{}) if e != nil { diff --git a/pkg/karmadactl/util/apiclient/apiclient.go b/pkg/karmadactl/util/apiclient/apiclient.go index 3dfe9432de29..c29dfed8d7ca 100644 --- a/pkg/karmadactl/util/apiclient/apiclient.go +++ b/pkg/karmadactl/util/apiclient/apiclient.go @@ -103,7 +103,7 @@ func NewCRDsClient(c *rest.Config) (clientset.Interface, error) { } // NewAPIRegistrationClient is to create an apiregistration ClientSet -func NewAPIRegistrationClient(c *rest.Config) (*aggregator.Clientset, error) { +func NewAPIRegistrationClient(c *rest.Config) (aggregator.Interface, error) { return aggregator.NewForConfig(c) } diff --git a/pkg/karmadactl/util/idempotency.go b/pkg/karmadactl/util/idempotency.go index 5a0337b4086d..3762c55ac93e 100644 --- a/pkg/karmadactl/util/idempotency.go +++ b/pkg/karmadactl/util/idempotency.go @@ -96,7 +96,7 @@ func CreateOrUpdateDeployment(client kubernetes.Interface, deploy *appsv1.Deploy // CreateOrUpdateAPIService creates a ApiService if the target resource doesn't exist. // If the resource exists already, this function will update the resource instead. -func CreateOrUpdateAPIService(apiRegistrationClient *aggregator.Clientset, apiservice *apiregistrationv1.APIService) error { +func CreateOrUpdateAPIService(apiRegistrationClient aggregator.Interface, apiservice *apiregistrationv1.APIService) error { if _, err := apiRegistrationClient.ApiregistrationV1().APIServices().Create(context.TODO(), apiservice, metav1.CreateOptions{}); err != nil { if !apierrors.IsAlreadyExists(err) { return fmt.Errorf("unable to create APIService: %v", err) diff --git a/pkg/karmadactl/util/validate.go b/pkg/karmadactl/util/validate.go index e387eebba503..10e026046b33 100644 --- a/pkg/karmadactl/util/validate.go +++ b/pkg/karmadactl/util/validate.go @@ -39,7 +39,7 @@ func VerifyClustersExist(input []string, clusters *clusterv1alpha1.ClusterList) } } if len(nonExistClusters) != 0 { - return fmt.Errorf("clusters don't exist: " + strings.Join(nonExistClusters, ",")) + return fmt.Errorf("clusters don't exist: %s", strings.Join(nonExistClusters, ",")) } return nil