From c0b0f1a45a9953771d85574d9006873d37dde01a Mon Sep 17 00:00:00 2001 From: Andy Goldstein Date: Thu, 2 Feb 2023 14:29:30 -0500 Subject: [PATCH] Remove unused field, unify pointer-ness Signed-off-by: Andy Goldstein --- pkg/virtual/syncer/builder/build.go | 3 --- pkg/virtual/syncer/builder/template.go | 9 +++------ .../apireconciler/syncer_apireconciler_controller.go | 6 ------ pkg/virtual/syncer/options/options.go | 7 +------ 4 files changed, 4 insertions(+), 21 deletions(-) diff --git a/pkg/virtual/syncer/builder/build.go b/pkg/virtual/syncer/builder/build.go index 5f8469b96d4..c9778ccc4e4 100644 --- a/pkg/virtual/syncer/builder/build.go +++ b/pkg/virtual/syncer/builder/build.go @@ -26,7 +26,6 @@ import ( "k8s.io/client-go/tools/cache" workloadv1alpha1 "github.com/kcp-dev/kcp/pkg/apis/workload/v1alpha1" - kcpclientset "github.com/kcp-dev/kcp/pkg/client/clientset/versioned/cluster" kcpinformers "github.com/kcp-dev/kcp/pkg/client/informers/externalversions" "github.com/kcp-dev/kcp/pkg/indexers" "github.com/kcp-dev/kcp/pkg/virtual/framework/forwardingregistry" @@ -49,7 +48,6 @@ func BuildVirtualWorkspace( rootPathPrefix string, kubeClusterClient kcpkubernetesclientset.ClusterInterface, dynamicClusterClient kcpdynamic.ClusterInterface, - kcpClusterClient kcpclientset.ClusterInterface, cachedKCPInformers kcpinformers.SharedInformerFactory, ) []rootapiserver.NamedVirtualWorkspace { if !strings.HasSuffix(rootPathPrefix, "/") { @@ -73,7 +71,6 @@ func BuildVirtualWorkspace( provider := templateProvider{ kubeClusterClient: kubeClusterClient, dynamicClusterClient: dynamicClusterClient, - kcpClusterClient: kcpClusterClient, cachedKCPInformers: cachedKCPInformers, rootPathPrefix: rootPathPrefix, } diff --git a/pkg/virtual/syncer/builder/template.go b/pkg/virtual/syncer/builder/template.go index a4a2cb637dc..e293ad1f443 100644 --- a/pkg/virtual/syncer/builder/template.go +++ b/pkg/virtual/syncer/builder/template.go @@ -38,7 +38,6 @@ import ( apisv1alpha1 "github.com/kcp-dev/kcp/pkg/apis/apis/v1alpha1" workloadv1alpha1 "github.com/kcp-dev/kcp/pkg/apis/workload/v1alpha1" "github.com/kcp-dev/kcp/pkg/authorization/delegated" - kcpclientset "github.com/kcp-dev/kcp/pkg/client/clientset/versioned/cluster" kcpinformers "github.com/kcp-dev/kcp/pkg/client/informers/externalversions" "github.com/kcp-dev/kcp/pkg/virtual/framework" virtualworkspacesdynamic "github.com/kcp-dev/kcp/pkg/virtual/framework/dynamic" @@ -54,7 +53,6 @@ import ( type templateProvider struct { kubeClusterClient kcpkubernetesclientset.ClusterInterface dynamicClusterClient kcpdynamic.ClusterInterface - kcpClusterClient kcpclientset.ClusterInterface cachedKCPInformers kcpinformers.SharedInformerFactory rootPathPrefix string } @@ -70,8 +68,8 @@ type templateParameters struct { storageWrapperBuilder func(labels.Requirements) forwardingregistry.StorageWrapper } -func (p *templateProvider) newTemplate(parameters templateParameters) template { - return template{ +func (p *templateProvider) newTemplate(parameters templateParameters) *template { + return &template{ templateProvider: *p, templateParameters: parameters, readyCh: make(chan struct{}), @@ -205,7 +203,6 @@ func (t *template) authorize(ctx context.Context, a authorizer.Attributes) (auth func (t *template) bootstrapManagement(mainConfig genericapiserver.CompletedConfig) (apidefinition.APIDefinitionSetGetter, error) { apiReconciler, err := apireconciler.NewAPIReconciler( t.virtualWorkspaceName, - t.kcpClusterClient, t.cachedKCPInformers.Workload().V1alpha1().SyncTargets(), t.cachedKCPInformers.Apis().V1alpha1().APIResourceSchemas(), t.cachedKCPInformers.Apis().V1alpha1().APIExports(), @@ -263,7 +260,7 @@ func (t *template) bootstrapManagement(mainConfig genericapiserver.CompletedConf return apiReconciler, nil } -func (t template) buildVirtualWorkspace() *virtualworkspacesdynamic.DynamicVirtualWorkspace { +func (t *template) buildVirtualWorkspace() *virtualworkspacesdynamic.DynamicVirtualWorkspace { return &virtualworkspacesdynamic.DynamicVirtualWorkspace{ RootPathResolver: framework.RootPathResolverFunc(t.resolveRootPath), Authorizer: authorizer.AuthorizerFunc(t.authorize), diff --git a/pkg/virtual/syncer/controllers/apireconciler/syncer_apireconciler_controller.go b/pkg/virtual/syncer/controllers/apireconciler/syncer_apireconciler_controller.go index 96d0fa06041..193e350a1a2 100644 --- a/pkg/virtual/syncer/controllers/apireconciler/syncer_apireconciler_controller.go +++ b/pkg/virtual/syncer/controllers/apireconciler/syncer_apireconciler_controller.go @@ -37,7 +37,6 @@ import ( apisv1alpha1 "github.com/kcp-dev/kcp/pkg/apis/apis/v1alpha1" workloadv1alpha1 "github.com/kcp-dev/kcp/pkg/apis/workload/v1alpha1" - kcpclientset "github.com/kcp-dev/kcp/pkg/client/clientset/versioned/cluster" apisv1alpha1informers "github.com/kcp-dev/kcp/pkg/client/informers/externalversions/apis/v1alpha1" workloadv1alpha1informers "github.com/kcp-dev/kcp/pkg/client/informers/externalversions/workload/v1alpha1" apisv1alpha1listers "github.com/kcp-dev/kcp/pkg/client/listers/apis/v1alpha1" @@ -59,7 +58,6 @@ type AllowedAPIfilterFunc func(apiGroupResource schema.GroupResource) bool func NewAPIReconciler( virtualWorkspaceName string, - kcpClusterClient kcpclientset.ClusterInterface, syncTargetInformer workloadv1alpha1informers.SyncTargetClusterInformer, apiResourceSchemaInformer apisv1alpha1informers.APIResourceSchemaClusterInformer, apiExportInformer apisv1alpha1informers.APIExportClusterInformer, @@ -71,8 +69,6 @@ func NewAPIReconciler( c := &APIReconciler{ virtualWorkspaceName: virtualWorkspaceName, - kcpClusterClient: kcpClusterClient, - syncTargetLister: syncTargetInformer.Lister(), syncTargetIndexer: syncTargetInformer.Informer().GetIndexer(), @@ -128,8 +124,6 @@ func NewAPIReconciler( type APIReconciler struct { virtualWorkspaceName string - kcpClusterClient kcpclientset.ClusterInterface - syncTargetLister workloadv1alpha1listers.SyncTargetClusterLister syncTargetIndexer cache.Indexer diff --git a/pkg/virtual/syncer/options/options.go b/pkg/virtual/syncer/options/options.go index 3d9316cdcd5..4927c773217 100644 --- a/pkg/virtual/syncer/options/options.go +++ b/pkg/virtual/syncer/options/options.go @@ -23,7 +23,6 @@ import ( "k8s.io/client-go/rest" - kcpclientset "github.com/kcp-dev/kcp/pkg/client/clientset/versioned/cluster" kcpinformers "github.com/kcp-dev/kcp/pkg/client/informers/externalversions" "github.com/kcp-dev/kcp/pkg/virtual/framework/rootapiserver" "github.com/kcp-dev/kcp/pkg/virtual/syncer/builder" @@ -56,10 +55,6 @@ func (o *Syncer) NewVirtualWorkspaces( cachedKCPInformers kcpinformers.SharedInformerFactory, ) (workspaces []rootapiserver.NamedVirtualWorkspace, err error) { config = rest.AddUserAgent(rest.CopyConfig(config), "syncer-virtual-workspace") - kcpClusterClient, err := kcpclientset.NewForConfig(config) - if err != nil { - return nil, err - } kubeClusterClient, err := kcpkubernetesclientset.NewForConfig(config) if err != nil { return nil, err @@ -69,5 +64,5 @@ func (o *Syncer) NewVirtualWorkspaces( return nil, err } - return builder.BuildVirtualWorkspace(rootPathPrefix, kubeClusterClient, dynamicClusterClient, kcpClusterClient, cachedKCPInformers), nil + return builder.BuildVirtualWorkspace(rootPathPrefix, kubeClusterClient, dynamicClusterClient, cachedKCPInformers), nil }