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

operator/pkg: depend on aggregator.Interface instead of *aggregator.Clientset #5602

Merged
Merged
Show file tree
Hide file tree
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
12 changes: 6 additions & 6 deletions operator/pkg/karmadaresource/apiservice/apiservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ 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
}

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
Expand Down Expand Up @@ -101,15 +101,15 @@ 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
}

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)
Expand Down Expand Up @@ -171,15 +171,15 @@ 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
}

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
Expand Down
4 changes: 2 additions & 2 deletions operator/pkg/util/apiclient/idempotency.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/karmadactl/addons/init/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type GlobalCommandOptions struct {

KarmadaRestConfig *rest.Config

KarmadaAggregatorClientSet *aggregator.Clientset
KarmadaAggregatorClientSet aggregator.Interface
}

// AddFlags adds flags to the specified FlagSet.
Expand Down
2 changes: 1 addition & 1 deletion pkg/karmadactl/cmdinit/karmada/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/karmadactl/util/apiclient/apiclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func NewCRDsClient(c *rest.Config) (*clientset.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)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/karmadactl/util/idempotency.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/karmadactl/util/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down