diff --git a/Makefile b/Makefile index 419d67553..6a30b5880 100644 --- a/Makefile +++ b/Makefile @@ -23,14 +23,6 @@ GOBIN_DIR=$(abspath ./bin ) PATH := $(GOBIN_DIR):$(TOOLS_GOBIN_DIR):$(PATH) TMPDIR := $(shell mktemp -d) -CODE_GENERATOR_VER := 572c29375f0e63c13b31c70931914c420a0a9d59 -CODE_GENERATOR_BIN := code-generator -CODE_GENERATOR := $(TOOLS_DIR)/$(CODE_GENERATOR_BIN)-$(CODE_GENERATOR_VER) -export CODE_GENERATOR # so hack scripts can use it - -$(CODE_GENERATOR): - GOBIN=$(TOOLS_GOBIN_DIR) $(GO_INSTALL) github.com/kcp-dev/code-generator/v2 $(CODE_GENERATOR_BIN) $(CODE_GENERATOR_VER) - OPENSHIFT_GOIMPORTS_VER := c70783e636f2213cac683f6865d88c5edace3157 OPENSHIFT_GOIMPORTS_BIN := openshift-goimports OPENSHIFT_GOIMPORTS := $(TOOLS_DIR)/$(OPENSHIFT_GOIMPORTS_BIN)-$(OPENSHIFT_GOIMPORTS_VER) @@ -56,7 +48,7 @@ lint: $(GOLANGCI_LINT) tools: $(CODE_GENERATOR) $(OPENSHIFT_GOIMPORTS) $(GOLANGCI_LINT) .PHONY: tools -codegen: $(CODE_GENERATOR) +codegen: go mod download ./hack/update-codegen.sh $(MAKE) imports @@ -79,4 +71,5 @@ verify: verify-codegen .PHONY: clean-generated clean-generated: - grep --exclude Makefile -l 'Code generated by kcp code-generator. DO NOT EDIT.' -r . | xargs rm + grep --exclude Makefile -l -e 'Code generated by [a-z-]*. DO NOT EDIT.' -r . | xargs rm -f + find . -type d -empty -delete diff --git a/apiextensions/client/clientset.go b/apiextensions/client/clientset.go index b3da8ce9c..9b2398fde 100644 --- a/apiextensions/client/clientset.go +++ b/apiextensions/client/clientset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,21 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package client import ( - "fmt" - "net/http" + fmt "fmt" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" client "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" - "k8s.io/client-go/discovery" - "k8s.io/client-go/rest" - "k8s.io/client-go/util/flowcontrol" + discovery "k8s.io/client-go/discovery" + rest "k8s.io/client-go/rest" + flowcontrol "k8s.io/client-go/util/flowcontrol" apiextensionsv1 "github.com/kcp-dev/client-go/apiextensions/client/typed/apiextensions/v1" apiextensionsv1beta1 "github.com/kcp-dev/client-go/apiextensions/client/typed/apiextensions/v1beta1" @@ -41,7 +41,7 @@ type ClusterInterface interface { ApiextensionsV1beta1() apiextensionsv1beta1.ApiextensionsV1beta1ClusterInterface } -// ClusterClientset contains the clients for groups. +// ClusterClientset contains the cluster clients for groups. type ClusterClientset struct { *discovery.DiscoveryClient clientCache kcpclient.Cache[*client.Clientset] @@ -49,7 +49,7 @@ type ClusterClientset struct { apiextensionsV1beta1 *apiextensionsv1beta1.ApiextensionsV1beta1ClusterClient } -// Discovery retrieves the DiscoveryClient +// Discovery retrieves the DiscoveryClient. func (c *ClusterClientset) Discovery() discovery.DiscoveryInterface { if c == nil { return nil @@ -144,3 +144,13 @@ func NewForConfigOrDie(c *rest.Config) *ClusterClientset { } return cs } + +// New creates a new ClusterClientset for the given RESTClient. +func New(c *rest.Config) *ClusterClientset { + var cs ClusterClientset + cs.apiextensionsV1 = apiextensionsv1.NewForConfigOrDie(c) + cs.apiextensionsV1beta1 = apiextensionsv1beta1.NewForConfigOrDie(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) + return &cs +} diff --git a/apiextensions/client/fake/clientset.go b/apiextensions/client/fake/clientset.go index 990d32b80..090d79f88 100644 --- a/apiextensions/client/fake/clientset.go +++ b/apiextensions/client/fake/clientset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,54 +14,59 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( "github.com/kcp-dev/logicalcluster/v3" - client "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" - clientscheme "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/scheme" + applyconfiguration "k8s.io/apiextensions-apiserver/pkg/client/applyconfiguration" + clientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1" apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/discovery" - kcpclient "github.com/kcp-dev/client-go/apiextensions/client" + kcpclientset "github.com/kcp-dev/client-go/apiextensions/client" + kcpclientscheme "github.com/kcp-dev/client-go/apiextensions/client/scheme" kcpapiextensionsv1 "github.com/kcp-dev/client-go/apiextensions/client/typed/apiextensions/v1" - fakeapiextensionsv1 "github.com/kcp-dev/client-go/apiextensions/client/typed/apiextensions/v1/fake" + kcpfakeapiextensionsv1 "github.com/kcp-dev/client-go/apiextensions/client/typed/apiextensions/v1/fake" kcpapiextensionsv1beta1 "github.com/kcp-dev/client-go/apiextensions/client/typed/apiextensions/v1beta1" - fakeapiextensionsv1beta1 "github.com/kcp-dev/client-go/apiextensions/client/typed/apiextensions/v1beta1/fake" + kcpfakeapiextensionsv1beta1 "github.com/kcp-dev/client-go/apiextensions/client/typed/apiextensions/v1beta1/fake" kcpfakediscovery "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/discovery/fake" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) // NewSimpleClientset returns a clientset that will respond with the provided objects. // It's backed by a very simple object tracker that processes creates, updates and deletions as-is, -// without applying any validations and/or defaults. It shouldn't be considered a replacement +// without applying any field management, validations and/or defaults. It shouldn't be considered a replacement // for a real clientset and is mostly useful in simple unit tests. +// +// DEPRECATED: NewClientset replaces this with support for field management, which significantly improves +// server side apply testing. NewClientset is only available when apply configurations are generated (e.g. +// via --with-applyconfig). func NewSimpleClientset(objects ...runtime.Object) *ClusterClientset { - o := kcptesting.NewObjectTracker(clientscheme.Scheme, clientscheme.Codecs.UniversalDecoder()) + o := kcptesting.NewObjectTracker(kcpclientscheme.Scheme, kcpclientscheme.Codecs.UniversalDecoder()) o.AddAll(objects...) - cs := &ClusterClientset{Fake: &kcptesting.Fake{}, tracker: o} - cs.discovery = &kcpfakediscovery.FakeDiscovery{Fake: cs.Fake, ClusterPath: logicalcluster.Wildcard} + cs := &ClusterClientset{Fake: kcptesting.Fake{}, tracker: o} + cs.discovery = &kcpfakediscovery.FakeDiscovery{Fake: &cs.Fake, ClusterPath: logicalcluster.Wildcard} cs.AddReactor("*", "*", kcptesting.ObjectReaction(o)) cs.AddWatchReactor("*", kcptesting.WatchReaction(o)) return cs } -var _ kcpclient.ClusterInterface = (*ClusterClientset)(nil) - // ClusterClientset contains the clients for groups. type ClusterClientset struct { - *kcptesting.Fake + kcptesting.Fake discovery *kcpfakediscovery.FakeDiscovery tracker kcptesting.ObjectTracker } +var _ kcpclientset.ClusterInterface = (*ClusterClientset)(nil) + // Discovery retrieves the DiscoveryClient func (c *ClusterClientset) Discovery() discovery.DiscoveryInterface { return c.discovery @@ -71,32 +76,32 @@ func (c *ClusterClientset) Tracker() kcptesting.ObjectTracker { return c.tracker } -// ApiextensionsV1 retrieves the ApiextensionsV1ClusterClient. -func (c *ClusterClientset) ApiextensionsV1() kcpapiextensionsv1.ApiextensionsV1ClusterInterface { - return &fakeapiextensionsv1.ApiextensionsV1ClusterClient{Fake: c.Fake} -} - -// ApiextensionsV1beta1 retrieves the ApiextensionsV1beta1ClusterClient. -func (c *ClusterClientset) ApiextensionsV1beta1() kcpapiextensionsv1beta1.ApiextensionsV1beta1ClusterInterface { - return &fakeapiextensionsv1beta1.ApiextensionsV1beta1ClusterClient{Fake: c.Fake} -} - // Cluster scopes this clientset to one cluster. -func (c *ClusterClientset) Cluster(clusterPath logicalcluster.Path) client.Interface { +func (c *ClusterClientset) Cluster(clusterPath logicalcluster.Path) clientset.Interface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } return &Clientset{ - Fake: c.Fake, - discovery: &kcpfakediscovery.FakeDiscovery{Fake: c.Fake, ClusterPath: clusterPath}, + Fake: &c.Fake, + discovery: &kcpfakediscovery.FakeDiscovery{Fake: &c.Fake, ClusterPath: clusterPath}, tracker: c.tracker.Cluster(clusterPath), clusterPath: clusterPath, } } -var _ client.Interface = (*Clientset)(nil) +// ApiextensionsV1 retrieves the ApiextensionsV1ClusterClient +func (c *ClusterClientset) ApiextensionsV1() kcpapiextensionsv1.ApiextensionsV1ClusterInterface { + return &kcpfakeapiextensionsv1.ApiextensionsV1ClusterClient{Fake: &c.Fake} +} + +// ApiextensionsV1beta1 retrieves the ApiextensionsV1beta1ClusterClient +func (c *ClusterClientset) ApiextensionsV1beta1() kcpapiextensionsv1beta1.ApiextensionsV1beta1ClusterInterface { + return &kcpfakeapiextensionsv1beta1.ApiextensionsV1beta1ClusterClient{Fake: &c.Fake} +} -// Clientset contains the clients for groups. +// Clientset implements clientset.Interface. Meant to be embedded into a +// struct to get a default implementation. This makes faking out just the method +// you want to test easier. type Clientset struct { *kcptesting.Fake discovery *kcpfakediscovery.FakeDiscovery @@ -104,7 +109,11 @@ type Clientset struct { clusterPath logicalcluster.Path } -// Discovery retrieves the DiscoveryClient +var ( + _ clientset.Interface = &Clientset{} + _ kcptesting.FakeScopedClient = &Clientset{} +) + func (c *Clientset) Discovery() discovery.DiscoveryInterface { return c.discovery } @@ -113,12 +122,32 @@ func (c *Clientset) Tracker() kcptesting.ScopedObjectTracker { return c.tracker } -// ApiextensionsV1 retrieves the ApiextensionsV1Client. +// NewClientset returns a clientset that will respond with the provided objects. +// It's backed by a very simple object tracker that processes creates, updates and deletions as-is, +// without applying any validations and/or defaults. It shouldn't be considered a replacement +// for a real clientset and is mostly useful in simple unit tests. +func NewClientset(objects ...runtime.Object) *ClusterClientset { + o := kcptesting.NewFieldManagedObjectTracker( + kcpclientscheme.Scheme, + kcpclientscheme.Codecs.UniversalDecoder(), + applyconfiguration.NewTypeConverter(kcpclientscheme.Scheme), + ) + o.AddAll(objects...) + + cs := &ClusterClientset{Fake: kcptesting.Fake{}, tracker: o} + cs.discovery = &kcpfakediscovery.FakeDiscovery{Fake: &cs.Fake, ClusterPath: logicalcluster.Wildcard} + cs.AddReactor("*", "*", kcptesting.ObjectReaction(o)) + cs.AddWatchReactor("*", kcptesting.WatchReaction(o)) + + return cs +} + +// ApiextensionsV1 retrieves the ApiextensionsV1Client func (c *Clientset) ApiextensionsV1() apiextensionsv1.ApiextensionsV1Interface { - return &fakeapiextensionsv1.ApiextensionsV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakeapiextensionsv1.ApiextensionsV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// ApiextensionsV1beta1 retrieves the ApiextensionsV1beta1Client. +// ApiextensionsV1beta1 retrieves the ApiextensionsV1beta1Client func (c *Clientset) ApiextensionsV1beta1() apiextensionsv1beta1.ApiextensionsV1beta1Interface { - return &fakeapiextensionsv1beta1.ApiextensionsV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakeapiextensionsv1beta1.ApiextensionsV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } diff --git a/apiextensions/client/fake/doc.go b/apiextensions/client/fake/doc.go new file mode 100644 index 000000000..05690c918 --- /dev/null +++ b/apiextensions/client/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated fake clientset. +package fake diff --git a/apiextensions/client/fake/register.go b/apiextensions/client/fake/register.go new file mode 100644 index 000000000..a32f519f8 --- /dev/null +++ b/apiextensions/client/fake/register.go @@ -0,0 +1,58 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package fake + +import ( + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" +) + +var scheme = runtime.NewScheme() +var codecs = serializer.NewCodecFactory(scheme) + +var localSchemeBuilder = runtime.SchemeBuilder{ + apiextensionsv1.AddToScheme, + apiextensionsv1beta1.AddToScheme, +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(AddToScheme(scheme)) +} diff --git a/apiextensions/client/scheme/doc.go b/apiextensions/client/scheme/doc.go new file mode 100644 index 000000000..65ba12554 --- /dev/null +++ b/apiextensions/client/scheme/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package contains the scheme of the automatically generated clientset. +package scheme diff --git a/apiextensions/client/scheme/register.go b/apiextensions/client/scheme/register.go index 69dfdb6fd..fec99fff5 100644 --- a/apiextensions/client/scheme/register.go +++ b/apiextensions/client/scheme/register.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,17 +14,17 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package scheme import ( apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/runtime/serializer" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" utilruntime "k8s.io/apimachinery/pkg/util/runtime" ) @@ -53,6 +53,6 @@ var localSchemeBuilder = runtime.SchemeBuilder{ var AddToScheme = localSchemeBuilder.AddToScheme func init() { - metav1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) + v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) utilruntime.Must(AddToScheme(Scheme)) } diff --git a/apiextensions/client/typed/apiextensions/v1/apiextensions_client.go b/apiextensions/client/typed/apiextensions/v1/apiextensions_client.go index 80c142053..9fe35c464 100644 --- a/apiextensions/client/typed/apiextensions/v1/apiextensions_client.go +++ b/apiextensions/client/typed/apiextensions/v1/apiextensions_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apisapiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/apiextensions/client/scheme" ) type ApiextensionsV1ClusterInterface interface { @@ -37,6 +40,7 @@ type ApiextensionsV1ClusterScoper interface { Cluster(logicalcluster.Path) apiextensionsv1.ApiextensionsV1Interface } +// ApiextensionsV1ClusterClient is used to interact with features provided by the apiextensions.k8s.io group. type ApiextensionsV1ClusterClient struct { clientCache kcpclient.Cache[*apiextensionsv1.ApiextensionsV1Client] } @@ -56,11 +60,13 @@ func (c *ApiextensionsV1ClusterClient) CustomResourceDefinitions() CustomResourc // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*ApiextensionsV1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new ApiextensionsV1ClusterClient for the given config and http client. @@ -72,6 +78,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*ApiextensionsV1Clus if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &ApiextensionsV1ClusterClient{clientCache: cache}, nil } @@ -84,3 +91,14 @@ func NewForConfigOrDie(c *rest.Config) *ApiextensionsV1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apisapiextensionsv1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/apiextensions/client/typed/apiextensions/v1/customresourcedefinition.go b/apiextensions/client/typed/apiextensions/v1/customresourcedefinition.go index 27ad6a011..3c9ad688e 100644 --- a/apiextensions/client/typed/apiextensions/v1/customresourcedefinition.go +++ b/apiextensions/client/typed/apiextensions/v1/customresourcedefinition.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" - apiextensionsv1client "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1" + apisapiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" + watch "k8s.io/apimachinery/pkg/watch" ) // CustomResourceDefinitionsClusterGetter has a method to return a CustomResourceDefinitionClusterInterface. @@ -37,19 +37,20 @@ type CustomResourceDefinitionsClusterGetter interface { } // CustomResourceDefinitionClusterInterface can operate on CustomResourceDefinitions across all clusters, -// or scope down to one cluster and return a apiextensionsv1client.CustomResourceDefinitionInterface. +// or scope down to one cluster and return a apiextensionsv1.CustomResourceDefinitionInterface. type CustomResourceDefinitionClusterInterface interface { - Cluster(logicalcluster.Path) apiextensionsv1client.CustomResourceDefinitionInterface - List(ctx context.Context, opts metav1.ListOptions) (*apiextensionsv1.CustomResourceDefinitionList, error) + Cluster(logicalcluster.Path) apiextensionsv1.CustomResourceDefinitionInterface + List(ctx context.Context, opts metav1.ListOptions) (*apisapiextensionsv1.CustomResourceDefinitionList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + CustomResourceDefinitionClusterExpansion } type customResourceDefinitionsClusterInterface struct { - clientCache kcpclient.Cache[*apiextensionsv1client.ApiextensionsV1Client] + clientCache kcpclient.Cache[*apiextensionsv1.ApiextensionsV1Client] } // Cluster scopes the client down to a particular cluster. -func (c *customResourceDefinitionsClusterInterface) Cluster(clusterPath logicalcluster.Path) apiextensionsv1client.CustomResourceDefinitionInterface { +func (c *customResourceDefinitionsClusterInterface) Cluster(clusterPath logicalcluster.Path) apiextensionsv1.CustomResourceDefinitionInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,7 +59,7 @@ func (c *customResourceDefinitionsClusterInterface) Cluster(clusterPath logicalc } // List returns the entire collection of all CustomResourceDefinitions across all clusters. -func (c *customResourceDefinitionsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*apiextensionsv1.CustomResourceDefinitionList, error) { +func (c *customResourceDefinitionsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*apisapiextensionsv1.CustomResourceDefinitionList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).CustomResourceDefinitions().List(ctx, opts) } diff --git a/apiextensions/client/typed/apiextensions/v1/doc.go b/apiextensions/client/typed/apiextensions/v1/doc.go new file mode 100644 index 000000000..d2f3412ab --- /dev/null +++ b/apiextensions/client/typed/apiextensions/v1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1 diff --git a/apiextensions/client/typed/apiextensions/v1/fake/apiextensions_client.go b/apiextensions/client/typed/apiextensions/v1/fake/apiextensions_client.go index c63e9ab94..168465994 100644 --- a/apiextensions/client/typed/apiextensions/v1/fake/apiextensions_client.go +++ b/apiextensions/client/typed/apiextensions/v1/fake/apiextensions_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpapiextensionsv1 "github.com/kcp-dev/client-go/apiextensions/client/typed/apiextensions/v1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -42,21 +42,21 @@ func (c *ApiextensionsV1ClusterClient) Cluster(clusterPath logicalcluster.Path) } func (c *ApiextensionsV1ClusterClient) CustomResourceDefinitions() kcpapiextensionsv1.CustomResourceDefinitionClusterInterface { - return &customResourceDefinitionsClusterClient{Fake: c.Fake} + return newFakeCustomResourceDefinitionClusterClient(c) } -var _ apiextensionsv1.ApiextensionsV1Interface = (*ApiextensionsV1Client)(nil) - type ApiextensionsV1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } +func (c *ApiextensionsV1Client) CustomResourceDefinitions() apiextensionsv1.CustomResourceDefinitionInterface { + return newFakeCustomResourceDefinitionClient(c.Fake, c.ClusterPath) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. func (c *ApiextensionsV1Client) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } - -func (c *ApiextensionsV1Client) CustomResourceDefinitions() apiextensionsv1.CustomResourceDefinitionInterface { - return &customResourceDefinitionsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} -} diff --git a/apiextensions/client/typed/apiextensions/v1/fake/customresourcedefinition.go b/apiextensions/client/typed/apiextensions/v1/fake/customresourcedefinition.go index c4e48f688..868170298 100644 --- a/apiextensions/client/typed/apiextensions/v1/fake/customresourcedefinition.go +++ b/apiextensions/client/typed/apiextensions/v1/fake/customresourcedefinition.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,82 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" - applyconfigurationsapiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/client/applyconfiguration/apiextensions/v1" - apiextensionsv1client "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - "k8s.io/client-go/testing" + v1 "k8s.io/apiextensions-apiserver/pkg/client/applyconfiguration/apiextensions/v1" + typedapiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1" + typedkcpapiextensionsv1 "github.com/kcp-dev/client-go/apiextensions/client/typed/apiextensions/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var customResourceDefinitionsResource = schema.GroupVersionResource{Group: "apiextensions.k8s.io", Version: "v1", Resource: "customresourcedefinitions"} -var customResourceDefinitionsKind = schema.GroupVersionKind{Group: "apiextensions.k8s.io", Version: "v1", Kind: "CustomResourceDefinition"} - -type customResourceDefinitionsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *customResourceDefinitionsClusterClient) Cluster(clusterPath logicalcluster.Path) apiextensionsv1client.CustomResourceDefinitionInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &customResourceDefinitionsClient{Fake: c.Fake, ClusterPath: clusterPath} -} - -// List takes label and field selectors, and returns the list of CustomResourceDefinitions that match those selectors across all clusters. -func (c *customResourceDefinitionsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*apiextensionsv1.CustomResourceDefinitionList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(customResourceDefinitionsResource, customResourceDefinitionsKind, logicalcluster.Wildcard, opts), &apiextensionsv1.CustomResourceDefinitionList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &apiextensionsv1.CustomResourceDefinitionList{ListMeta: obj.(*apiextensionsv1.CustomResourceDefinitionList).ListMeta} - for _, item := range obj.(*apiextensionsv1.CustomResourceDefinitionList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested CustomResourceDefinitions across all clusters. -func (c *customResourceDefinitionsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(customResourceDefinitionsResource, logicalcluster.Wildcard, opts)) -} - -type customResourceDefinitionsClient struct { - *kcptesting.Fake +// customResourceDefinitionClusterClient implements CustomResourceDefinitionClusterInterface +type customResourceDefinitionClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*apiextensionsv1.CustomResourceDefinition, *apiextensionsv1.CustomResourceDefinitionList] + Fake *kcptesting.Fake +} + +func newFakeCustomResourceDefinitionClusterClient(fake *ApiextensionsV1ClusterClient) typedkcpapiextensionsv1.CustomResourceDefinitionClusterInterface { + return &customResourceDefinitionClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*apiextensionsv1.CustomResourceDefinition, *apiextensionsv1.CustomResourceDefinitionList]( + fake.Fake, + apiextensionsv1.SchemeGroupVersion.WithResource("customresourcedefinitions"), + apiextensionsv1.SchemeGroupVersion.WithKind("CustomResourceDefinition"), + func() *apiextensionsv1.CustomResourceDefinition { return &apiextensionsv1.CustomResourceDefinition{} }, + func() *apiextensionsv1.CustomResourceDefinitionList { + return &apiextensionsv1.CustomResourceDefinitionList{} + }, + func(dst, src *apiextensionsv1.CustomResourceDefinitionList) { dst.ListMeta = src.ListMeta }, + func(list *apiextensionsv1.CustomResourceDefinitionList) []*apiextensionsv1.CustomResourceDefinition { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *apiextensionsv1.CustomResourceDefinitionList, items []*apiextensionsv1.CustomResourceDefinition) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, + } +} + +func (c *customResourceDefinitionClusterClient) Cluster(cluster logicalcluster.Path) typedapiextensionsv1.CustomResourceDefinitionInterface { + return newFakeCustomResourceDefinitionClient(c.Fake, cluster) +} + +// customResourceDefinitionScopedClient implements CustomResourceDefinitionInterface +type customResourceDefinitionScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*apiextensionsv1.CustomResourceDefinition, *apiextensionsv1.CustomResourceDefinitionList, *v1.CustomResourceDefinitionApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *customResourceDefinitionsClient) Create(ctx context.Context, customResourceDefinition *apiextensionsv1.CustomResourceDefinition, opts metav1.CreateOptions) (*apiextensionsv1.CustomResourceDefinition, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(customResourceDefinitionsResource, c.ClusterPath, customResourceDefinition), &apiextensionsv1.CustomResourceDefinition{}) - if obj == nil { - return nil, err - } - return obj.(*apiextensionsv1.CustomResourceDefinition), err -} - -func (c *customResourceDefinitionsClient) Update(ctx context.Context, customResourceDefinition *apiextensionsv1.CustomResourceDefinition, opts metav1.UpdateOptions) (*apiextensionsv1.CustomResourceDefinition, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(customResourceDefinitionsResource, c.ClusterPath, customResourceDefinition), &apiextensionsv1.CustomResourceDefinition{}) - if obj == nil { - return nil, err - } - return obj.(*apiextensionsv1.CustomResourceDefinition), err -} - -func (c *customResourceDefinitionsClient) UpdateStatus(ctx context.Context, customResourceDefinition *apiextensionsv1.CustomResourceDefinition, opts metav1.UpdateOptions) (*apiextensionsv1.CustomResourceDefinition, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(customResourceDefinitionsResource, c.ClusterPath, "status", customResourceDefinition), &apiextensionsv1.CustomResourceDefinition{}) - if obj == nil { - return nil, err - } - return obj.(*apiextensionsv1.CustomResourceDefinition), err -} - -func (c *customResourceDefinitionsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(customResourceDefinitionsResource, c.ClusterPath, name, opts), &apiextensionsv1.CustomResourceDefinition{}) - return err -} - -func (c *customResourceDefinitionsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(customResourceDefinitionsResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &apiextensionsv1.CustomResourceDefinitionList{}) - return err -} - -func (c *customResourceDefinitionsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*apiextensionsv1.CustomResourceDefinition, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(customResourceDefinitionsResource, c.ClusterPath, name), &apiextensionsv1.CustomResourceDefinition{}) - if obj == nil { - return nil, err - } - return obj.(*apiextensionsv1.CustomResourceDefinition), err -} - -// List takes label and field selectors, and returns the list of CustomResourceDefinitions that match those selectors. -func (c *customResourceDefinitionsClient) List(ctx context.Context, opts metav1.ListOptions) (*apiextensionsv1.CustomResourceDefinitionList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(customResourceDefinitionsResource, customResourceDefinitionsKind, c.ClusterPath, opts), &apiextensionsv1.CustomResourceDefinitionList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &apiextensionsv1.CustomResourceDefinitionList{ListMeta: obj.(*apiextensionsv1.CustomResourceDefinitionList).ListMeta} - for _, item := range obj.(*apiextensionsv1.CustomResourceDefinitionList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *customResourceDefinitionsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(customResourceDefinitionsResource, c.ClusterPath, opts)) -} - -func (c *customResourceDefinitionsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*apiextensionsv1.CustomResourceDefinition, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(customResourceDefinitionsResource, c.ClusterPath, name, pt, data, subresources...), &apiextensionsv1.CustomResourceDefinition{}) - if obj == nil { - return nil, err - } - return obj.(*apiextensionsv1.CustomResourceDefinition), err -} - -func (c *customResourceDefinitionsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsapiextensionsv1.CustomResourceDefinitionApplyConfiguration, opts metav1.ApplyOptions) (*apiextensionsv1.CustomResourceDefinition, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(customResourceDefinitionsResource, c.ClusterPath, *name, types.ApplyPatchType, data), &apiextensionsv1.CustomResourceDefinition{}) - if obj == nil { - return nil, err - } - return obj.(*apiextensionsv1.CustomResourceDefinition), err -} - -func (c *customResourceDefinitionsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsapiextensionsv1.CustomResourceDefinitionApplyConfiguration, opts metav1.ApplyOptions) (*apiextensionsv1.CustomResourceDefinition, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(customResourceDefinitionsResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &apiextensionsv1.CustomResourceDefinition{}) - if obj == nil { - return nil, err +func newFakeCustomResourceDefinitionClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedapiextensionsv1.CustomResourceDefinitionInterface { + return &customResourceDefinitionScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*apiextensionsv1.CustomResourceDefinition, *apiextensionsv1.CustomResourceDefinitionList, *v1.CustomResourceDefinitionApplyConfiguration]( + fake, + clusterPath, + "", + apiextensionsv1.SchemeGroupVersion.WithResource("customresourcedefinitions"), + apiextensionsv1.SchemeGroupVersion.WithKind("CustomResourceDefinition"), + func() *apiextensionsv1.CustomResourceDefinition { return &apiextensionsv1.CustomResourceDefinition{} }, + func() *apiextensionsv1.CustomResourceDefinitionList { + return &apiextensionsv1.CustomResourceDefinitionList{} + }, + func(dst, src *apiextensionsv1.CustomResourceDefinitionList) { dst.ListMeta = src.ListMeta }, + func(list *apiextensionsv1.CustomResourceDefinitionList) []*apiextensionsv1.CustomResourceDefinition { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *apiextensionsv1.CustomResourceDefinitionList, items []*apiextensionsv1.CustomResourceDefinition) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*apiextensionsv1.CustomResourceDefinition), err } diff --git a/apiextensions/client/typed/apiextensions/v1/fake/doc.go b/apiextensions/client/typed/apiextensions/v1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/apiextensions/client/typed/apiextensions/v1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/apiextensions/client/typed/apiextensions/v1/generated_expansion.go b/apiextensions/client/typed/apiextensions/v1/generated_expansion.go new file mode 100644 index 000000000..102216e14 --- /dev/null +++ b/apiextensions/client/typed/apiextensions/v1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1 + +type CustomResourceDefinitionClusterExpansion interface{} diff --git a/apiextensions/client/typed/apiextensions/v1beta1/apiextensions_client.go b/apiextensions/client/typed/apiextensions/v1beta1/apiextensions_client.go index 01284572b..aad579e50 100644 --- a/apiextensions/client/typed/apiextensions/v1beta1/apiextensions_client.go +++ b/apiextensions/client/typed/apiextensions/v1beta1/apiextensions_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apisapiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/apiextensions/client/scheme" ) type ApiextensionsV1beta1ClusterInterface interface { @@ -37,6 +40,7 @@ type ApiextensionsV1beta1ClusterScoper interface { Cluster(logicalcluster.Path) apiextensionsv1beta1.ApiextensionsV1beta1Interface } +// ApiextensionsV1beta1ClusterClient is used to interact with features provided by the apiextensions.k8s.io group. type ApiextensionsV1beta1ClusterClient struct { clientCache kcpclient.Cache[*apiextensionsv1beta1.ApiextensionsV1beta1Client] } @@ -56,11 +60,13 @@ func (c *ApiextensionsV1beta1ClusterClient) CustomResourceDefinitions() CustomRe // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*ApiextensionsV1beta1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new ApiextensionsV1beta1ClusterClient for the given config and http client. @@ -72,6 +78,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*ApiextensionsV1beta if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &ApiextensionsV1beta1ClusterClient{clientCache: cache}, nil } @@ -84,3 +91,14 @@ func NewForConfigOrDie(c *rest.Config) *ApiextensionsV1beta1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apisapiextensionsv1beta1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/apiextensions/client/typed/apiextensions/v1beta1/customresourcedefinition.go b/apiextensions/client/typed/apiextensions/v1beta1/customresourcedefinition.go index 68a08800a..35c0dddc9 100644 --- a/apiextensions/client/typed/apiextensions/v1beta1/customresourcedefinition.go +++ b/apiextensions/client/typed/apiextensions/v1beta1/customresourcedefinition.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - apiextensionsv1beta1client "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" + apisapiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" + apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" ) // CustomResourceDefinitionsClusterGetter has a method to return a CustomResourceDefinitionClusterInterface. @@ -37,19 +37,20 @@ type CustomResourceDefinitionsClusterGetter interface { } // CustomResourceDefinitionClusterInterface can operate on CustomResourceDefinitions across all clusters, -// or scope down to one cluster and return a apiextensionsv1beta1client.CustomResourceDefinitionInterface. +// or scope down to one cluster and return a apiextensionsv1beta1.CustomResourceDefinitionInterface. type CustomResourceDefinitionClusterInterface interface { - Cluster(logicalcluster.Path) apiextensionsv1beta1client.CustomResourceDefinitionInterface - List(ctx context.Context, opts metav1.ListOptions) (*apiextensionsv1beta1.CustomResourceDefinitionList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) apiextensionsv1beta1.CustomResourceDefinitionInterface + List(ctx context.Context, opts v1.ListOptions) (*apisapiextensionsv1beta1.CustomResourceDefinitionList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + CustomResourceDefinitionClusterExpansion } type customResourceDefinitionsClusterInterface struct { - clientCache kcpclient.Cache[*apiextensionsv1beta1client.ApiextensionsV1beta1Client] + clientCache kcpclient.Cache[*apiextensionsv1beta1.ApiextensionsV1beta1Client] } // Cluster scopes the client down to a particular cluster. -func (c *customResourceDefinitionsClusterInterface) Cluster(clusterPath logicalcluster.Path) apiextensionsv1beta1client.CustomResourceDefinitionInterface { +func (c *customResourceDefinitionsClusterInterface) Cluster(clusterPath logicalcluster.Path) apiextensionsv1beta1.CustomResourceDefinitionInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *customResourceDefinitionsClusterInterface) Cluster(clusterPath logicalc } // List returns the entire collection of all CustomResourceDefinitions across all clusters. -func (c *customResourceDefinitionsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*apiextensionsv1beta1.CustomResourceDefinitionList, error) { +func (c *customResourceDefinitionsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apisapiextensionsv1beta1.CustomResourceDefinitionList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).CustomResourceDefinitions().List(ctx, opts) } // Watch begins to watch all CustomResourceDefinitions across all clusters. -func (c *customResourceDefinitionsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *customResourceDefinitionsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).CustomResourceDefinitions().Watch(ctx, opts) } diff --git a/apiextensions/client/typed/apiextensions/v1beta1/doc.go b/apiextensions/client/typed/apiextensions/v1beta1/doc.go new file mode 100644 index 000000000..541e9d258 --- /dev/null +++ b/apiextensions/client/typed/apiextensions/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1beta1 diff --git a/apiextensions/client/typed/apiextensions/v1beta1/fake/apiextensions_client.go b/apiextensions/client/typed/apiextensions/v1beta1/fake/apiextensions_client.go index d8a9adcfa..587eaed6f 100644 --- a/apiextensions/client/typed/apiextensions/v1beta1/fake/apiextensions_client.go +++ b/apiextensions/client/typed/apiextensions/v1beta1/fake/apiextensions_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpapiextensionsv1beta1 "github.com/kcp-dev/client-go/apiextensions/client/typed/apiextensions/v1beta1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -42,21 +42,21 @@ func (c *ApiextensionsV1beta1ClusterClient) Cluster(clusterPath logicalcluster.P } func (c *ApiextensionsV1beta1ClusterClient) CustomResourceDefinitions() kcpapiextensionsv1beta1.CustomResourceDefinitionClusterInterface { - return &customResourceDefinitionsClusterClient{Fake: c.Fake} + return newFakeCustomResourceDefinitionClusterClient(c) } -var _ apiextensionsv1beta1.ApiextensionsV1beta1Interface = (*ApiextensionsV1beta1Client)(nil) - type ApiextensionsV1beta1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } +func (c *ApiextensionsV1beta1Client) CustomResourceDefinitions() apiextensionsv1beta1.CustomResourceDefinitionInterface { + return newFakeCustomResourceDefinitionClient(c.Fake, c.ClusterPath) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. func (c *ApiextensionsV1beta1Client) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } - -func (c *ApiextensionsV1beta1Client) CustomResourceDefinitions() apiextensionsv1beta1.CustomResourceDefinitionInterface { - return &customResourceDefinitionsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} -} diff --git a/apiextensions/client/typed/apiextensions/v1beta1/fake/customresourcedefinition.go b/apiextensions/client/typed/apiextensions/v1beta1/fake/customresourcedefinition.go index 5d3aaae74..2dde15c0a 100644 --- a/apiextensions/client/typed/apiextensions/v1beta1/fake/customresourcedefinition.go +++ b/apiextensions/client/typed/apiextensions/v1beta1/fake/customresourcedefinition.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,86 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - applyconfigurationsapiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/client/applyconfiguration/apiextensions/v1beta1" - apiextensionsv1beta1client "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/apiextensions-apiserver/pkg/client/applyconfiguration/apiextensions/v1beta1" + typedapiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1" + typedkcpapiextensionsv1beta1 "github.com/kcp-dev/client-go/apiextensions/client/typed/apiextensions/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var customResourceDefinitionsResource = schema.GroupVersionResource{Group: "apiextensions.k8s.io", Version: "v1beta1", Resource: "customresourcedefinitions"} -var customResourceDefinitionsKind = schema.GroupVersionKind{Group: "apiextensions.k8s.io", Version: "v1beta1", Kind: "CustomResourceDefinition"} - -type customResourceDefinitionsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *customResourceDefinitionsClusterClient) Cluster(clusterPath logicalcluster.Path) apiextensionsv1beta1client.CustomResourceDefinitionInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &customResourceDefinitionsClient{Fake: c.Fake, ClusterPath: clusterPath} -} - -// List takes label and field selectors, and returns the list of CustomResourceDefinitions that match those selectors across all clusters. -func (c *customResourceDefinitionsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*apiextensionsv1beta1.CustomResourceDefinitionList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(customResourceDefinitionsResource, customResourceDefinitionsKind, logicalcluster.Wildcard, opts), &apiextensionsv1beta1.CustomResourceDefinitionList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &apiextensionsv1beta1.CustomResourceDefinitionList{ListMeta: obj.(*apiextensionsv1beta1.CustomResourceDefinitionList).ListMeta} - for _, item := range obj.(*apiextensionsv1beta1.CustomResourceDefinitionList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested CustomResourceDefinitions across all clusters. -func (c *customResourceDefinitionsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(customResourceDefinitionsResource, logicalcluster.Wildcard, opts)) -} - -type customResourceDefinitionsClient struct { - *kcptesting.Fake +// customResourceDefinitionClusterClient implements CustomResourceDefinitionClusterInterface +type customResourceDefinitionClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*apiextensionsv1beta1.CustomResourceDefinition, *apiextensionsv1beta1.CustomResourceDefinitionList] + Fake *kcptesting.Fake +} + +func newFakeCustomResourceDefinitionClusterClient(fake *ApiextensionsV1beta1ClusterClient) typedkcpapiextensionsv1beta1.CustomResourceDefinitionClusterInterface { + return &customResourceDefinitionClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*apiextensionsv1beta1.CustomResourceDefinition, *apiextensionsv1beta1.CustomResourceDefinitionList]( + fake.Fake, + apiextensionsv1beta1.SchemeGroupVersion.WithResource("customresourcedefinitions"), + apiextensionsv1beta1.SchemeGroupVersion.WithKind("CustomResourceDefinition"), + func() *apiextensionsv1beta1.CustomResourceDefinition { + return &apiextensionsv1beta1.CustomResourceDefinition{} + }, + func() *apiextensionsv1beta1.CustomResourceDefinitionList { + return &apiextensionsv1beta1.CustomResourceDefinitionList{} + }, + func(dst, src *apiextensionsv1beta1.CustomResourceDefinitionList) { dst.ListMeta = src.ListMeta }, + func(list *apiextensionsv1beta1.CustomResourceDefinitionList) []*apiextensionsv1beta1.CustomResourceDefinition { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *apiextensionsv1beta1.CustomResourceDefinitionList, items []*apiextensionsv1beta1.CustomResourceDefinition) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, + } +} + +func (c *customResourceDefinitionClusterClient) Cluster(cluster logicalcluster.Path) typedapiextensionsv1beta1.CustomResourceDefinitionInterface { + return newFakeCustomResourceDefinitionClient(c.Fake, cluster) +} + +// customResourceDefinitionScopedClient implements CustomResourceDefinitionInterface +type customResourceDefinitionScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*apiextensionsv1beta1.CustomResourceDefinition, *apiextensionsv1beta1.CustomResourceDefinitionList, *v1beta1.CustomResourceDefinitionApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *customResourceDefinitionsClient) Create(ctx context.Context, customResourceDefinition *apiextensionsv1beta1.CustomResourceDefinition, opts metav1.CreateOptions) (*apiextensionsv1beta1.CustomResourceDefinition, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(customResourceDefinitionsResource, c.ClusterPath, customResourceDefinition), &apiextensionsv1beta1.CustomResourceDefinition{}) - if obj == nil { - return nil, err - } - return obj.(*apiextensionsv1beta1.CustomResourceDefinition), err -} - -func (c *customResourceDefinitionsClient) Update(ctx context.Context, customResourceDefinition *apiextensionsv1beta1.CustomResourceDefinition, opts metav1.UpdateOptions) (*apiextensionsv1beta1.CustomResourceDefinition, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(customResourceDefinitionsResource, c.ClusterPath, customResourceDefinition), &apiextensionsv1beta1.CustomResourceDefinition{}) - if obj == nil { - return nil, err - } - return obj.(*apiextensionsv1beta1.CustomResourceDefinition), err -} - -func (c *customResourceDefinitionsClient) UpdateStatus(ctx context.Context, customResourceDefinition *apiextensionsv1beta1.CustomResourceDefinition, opts metav1.UpdateOptions) (*apiextensionsv1beta1.CustomResourceDefinition, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(customResourceDefinitionsResource, c.ClusterPath, "status", customResourceDefinition), &apiextensionsv1beta1.CustomResourceDefinition{}) - if obj == nil { - return nil, err - } - return obj.(*apiextensionsv1beta1.CustomResourceDefinition), err -} - -func (c *customResourceDefinitionsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(customResourceDefinitionsResource, c.ClusterPath, name, opts), &apiextensionsv1beta1.CustomResourceDefinition{}) - return err -} - -func (c *customResourceDefinitionsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(customResourceDefinitionsResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &apiextensionsv1beta1.CustomResourceDefinitionList{}) - return err -} - -func (c *customResourceDefinitionsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*apiextensionsv1beta1.CustomResourceDefinition, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(customResourceDefinitionsResource, c.ClusterPath, name), &apiextensionsv1beta1.CustomResourceDefinition{}) - if obj == nil { - return nil, err - } - return obj.(*apiextensionsv1beta1.CustomResourceDefinition), err -} - -// List takes label and field selectors, and returns the list of CustomResourceDefinitions that match those selectors. -func (c *customResourceDefinitionsClient) List(ctx context.Context, opts metav1.ListOptions) (*apiextensionsv1beta1.CustomResourceDefinitionList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(customResourceDefinitionsResource, customResourceDefinitionsKind, c.ClusterPath, opts), &apiextensionsv1beta1.CustomResourceDefinitionList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &apiextensionsv1beta1.CustomResourceDefinitionList{ListMeta: obj.(*apiextensionsv1beta1.CustomResourceDefinitionList).ListMeta} - for _, item := range obj.(*apiextensionsv1beta1.CustomResourceDefinitionList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *customResourceDefinitionsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(customResourceDefinitionsResource, c.ClusterPath, opts)) -} - -func (c *customResourceDefinitionsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*apiextensionsv1beta1.CustomResourceDefinition, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(customResourceDefinitionsResource, c.ClusterPath, name, pt, data, subresources...), &apiextensionsv1beta1.CustomResourceDefinition{}) - if obj == nil { - return nil, err - } - return obj.(*apiextensionsv1beta1.CustomResourceDefinition), err -} - -func (c *customResourceDefinitionsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsapiextensionsv1beta1.CustomResourceDefinitionApplyConfiguration, opts metav1.ApplyOptions) (*apiextensionsv1beta1.CustomResourceDefinition, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(customResourceDefinitionsResource, c.ClusterPath, *name, types.ApplyPatchType, data), &apiextensionsv1beta1.CustomResourceDefinition{}) - if obj == nil { - return nil, err - } - return obj.(*apiextensionsv1beta1.CustomResourceDefinition), err -} - -func (c *customResourceDefinitionsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsapiextensionsv1beta1.CustomResourceDefinitionApplyConfiguration, opts metav1.ApplyOptions) (*apiextensionsv1beta1.CustomResourceDefinition, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(customResourceDefinitionsResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &apiextensionsv1beta1.CustomResourceDefinition{}) - if obj == nil { - return nil, err +func newFakeCustomResourceDefinitionClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedapiextensionsv1beta1.CustomResourceDefinitionInterface { + return &customResourceDefinitionScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*apiextensionsv1beta1.CustomResourceDefinition, *apiextensionsv1beta1.CustomResourceDefinitionList, *v1beta1.CustomResourceDefinitionApplyConfiguration]( + fake, + clusterPath, + "", + apiextensionsv1beta1.SchemeGroupVersion.WithResource("customresourcedefinitions"), + apiextensionsv1beta1.SchemeGroupVersion.WithKind("CustomResourceDefinition"), + func() *apiextensionsv1beta1.CustomResourceDefinition { + return &apiextensionsv1beta1.CustomResourceDefinition{} + }, + func() *apiextensionsv1beta1.CustomResourceDefinitionList { + return &apiextensionsv1beta1.CustomResourceDefinitionList{} + }, + func(dst, src *apiextensionsv1beta1.CustomResourceDefinitionList) { dst.ListMeta = src.ListMeta }, + func(list *apiextensionsv1beta1.CustomResourceDefinitionList) []*apiextensionsv1beta1.CustomResourceDefinition { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *apiextensionsv1beta1.CustomResourceDefinitionList, items []*apiextensionsv1beta1.CustomResourceDefinition) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*apiextensionsv1beta1.CustomResourceDefinition), err } diff --git a/apiextensions/client/typed/apiextensions/v1beta1/fake/doc.go b/apiextensions/client/typed/apiextensions/v1beta1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/apiextensions/client/typed/apiextensions/v1beta1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/apiextensions/client/typed/apiextensions/v1beta1/generated_expansion.go b/apiextensions/client/typed/apiextensions/v1beta1/generated_expansion.go new file mode 100644 index 000000000..532b20e8b --- /dev/null +++ b/apiextensions/client/typed/apiextensions/v1beta1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1beta1 + +type CustomResourceDefinitionClusterExpansion interface{} diff --git a/apiextensions/informers/apiextensions/interface.go b/apiextensions/informers/apiextensions/interface.go index 51e4154ec..e77008e3a 100644 --- a/apiextensions/informers/apiextensions/interface.go +++ b/apiextensions/informers/apiextensions/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,39 +14,40 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package apiextensions import ( - "github.com/kcp-dev/client-go/apiextensions/informers/apiextensions/v1" - "github.com/kcp-dev/client-go/apiextensions/informers/apiextensions/v1beta1" - "github.com/kcp-dev/client-go/apiextensions/informers/internalinterfaces" + kcpv1 "github.com/kcp-dev/client-go/apiextensions/informers/apiextensions/v1" + kcpv1beta1 "github.com/kcp-dev/client-go/apiextensions/informers/apiextensions/v1beta1" + kcpinternalinterfaces "github.com/kcp-dev/client-go/apiextensions/informers/internalinterfaces" ) +// ClusterInterface provides access to each of this group's versions. type ClusterInterface interface { - // V1 provides access to the shared informers in V1. - V1() v1.ClusterInterface - // V1beta1 provides access to the shared informers in V1beta1. - V1beta1() v1beta1.ClusterInterface + // V1 provides access to shared informers for resources in V1. + V1() kcpv1.ClusterInterface + // V1beta1 provides access to shared informers for resources in V1beta1. + V1beta1() kcpv1beta1.ClusterInterface } type group struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &group{factory: f, tweakListOptions: tweakListOptions} } -// V1 returns a new v1.ClusterInterface. -func (g *group) V1() v1.ClusterInterface { - return v1.New(g.factory, g.tweakListOptions) +// V1 returns a new kcpv1.ClusterInterface. +func (g *group) V1() kcpv1.ClusterInterface { + return kcpv1.New(g.factory, g.tweakListOptions) } -// V1beta1 returns a new v1beta1.ClusterInterface. -func (g *group) V1beta1() v1beta1.ClusterInterface { - return v1beta1.New(g.factory, g.tweakListOptions) +// V1beta1 returns a new kcpv1beta1.ClusterInterface. +func (g *group) V1beta1() kcpv1beta1.ClusterInterface { + return kcpv1beta1.New(g.factory, g.tweakListOptions) } diff --git a/apiextensions/informers/apiextensions/v1/customresourcedefinition.go b/apiextensions/informers/apiextensions/v1/customresourcedefinition.go index ec4ab4eda..0dab6ce5d 100644 --- a/apiextensions/informers/apiextensions/v1/customresourcedefinition.go +++ b/apiextensions/informers/apiextensions/v1/customresourcedefinition.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" - upstreamapiextensionsv1informers "k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/apiextensions/v1" - upstreamapiextensionsv1listers "k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/v1" + apisapiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/apiextensions/v1" + listersapiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - "k8s.io/client-go/tools/cache" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" - clientset "github.com/kcp-dev/client-go/apiextensions/client" - "github.com/kcp-dev/client-go/apiextensions/informers/internalinterfaces" - apiextensionsv1listers "github.com/kcp-dev/client-go/apiextensions/listers/apiextensions/v1" + kcpclient "github.com/kcp-dev/client-go/apiextensions/client" + kcpinternalinterfaces "github.com/kcp-dev/client-go/apiextensions/informers/internalinterfaces" + kcpv1 "github.com/kcp-dev/client-go/apiextensions/listers/apiextensions/v1" ) // CustomResourceDefinitionClusterInformer provides access to a shared informer and lister for // CustomResourceDefinitions. type CustomResourceDefinitionClusterInformer interface { - Cluster(logicalcluster.Name) upstreamapiextensionsv1informers.CustomResourceDefinitionInformer + Cluster(logicalcluster.Name) apiextensionsv1.CustomResourceDefinitionInformer + ClusterWithContext(context.Context, logicalcluster.Name) apiextensionsv1.CustomResourceDefinitionInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() apiextensionsv1listers.CustomResourceDefinitionClusterLister + Lister() kcpv1.CustomResourceDefinitionClusterLister } type customResourceDefinitionClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewCustomResourceDefinitionClusterInformer constructs a new informer for CustomResourceDefinition type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewCustomResourceDefinitionClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewCustomResourceDefinitionClusterInformer(client kcpclient.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredCustomResourceDefinitionClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredCustomResourceDefinitionClusterInformer constructs a new informer for CustomResourceDefinition type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredCustomResourceDefinitionClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredCustomResourceDefinitionClusterInformer(client kcpclient.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ApiextensionsV1().CustomResourceDefinitions().List(context.TODO(), options) + return client.ApiextensionsV1().CustomResourceDefinitions().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ApiextensionsV1().CustomResourceDefinitions().Watch(context.TODO(), options) + return client.ApiextensionsV1().CustomResourceDefinitions().Watch(context.Background(), options) }, }, - &apiextensionsv1.CustomResourceDefinition{}, + &apisapiextensionsv1.CustomResourceDefinition{}, resyncPeriod, indexers, ) } -func (f *customResourceDefinitionClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *customResourceDefinitionClusterInformer) defaultInformer(client kcpclient.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredCustomResourceDefinitionClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *customResourceDefinitionClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apisapiextensionsv1.CustomResourceDefinition{}, i.defaultInformer) } -func (f *customResourceDefinitionClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&apiextensionsv1.CustomResourceDefinition{}, f.defaultInformer) +func (i *customResourceDefinitionClusterInformer) Lister() kcpv1.CustomResourceDefinitionClusterLister { + return kcpv1.NewCustomResourceDefinitionClusterLister(i.Informer().GetIndexer()) } -func (f *customResourceDefinitionClusterInformer) Lister() apiextensionsv1listers.CustomResourceDefinitionClusterLister { - return apiextensionsv1listers.NewCustomResourceDefinitionClusterLister(f.Informer().GetIndexer()) +func (i *customResourceDefinitionClusterInformer) Cluster(clusterName logicalcluster.Name) apiextensionsv1.CustomResourceDefinitionInformer { + return &customResourceDefinitionInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *customResourceDefinitionClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamapiextensionsv1informers.CustomResourceDefinitionInformer { +func (i *customResourceDefinitionClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) apiextensionsv1.CustomResourceDefinitionInformer { return &customResourceDefinitionInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type customResourceDefinitionInformer struct { informer cache.SharedIndexInformer - lister upstreamapiextensionsv1listers.CustomResourceDefinitionLister + lister listersapiextensionsv1.CustomResourceDefinitionLister } -func (f *customResourceDefinitionInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *customResourceDefinitionInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *customResourceDefinitionInformer) Lister() upstreamapiextensionsv1listers.CustomResourceDefinitionLister { - return f.lister +func (i *customResourceDefinitionInformer) Lister() listersapiextensionsv1.CustomResourceDefinitionLister { + return i.lister } diff --git a/apiextensions/informers/apiextensions/v1/interface.go b/apiextensions/informers/apiextensions/v1/interface.go index 2be6effa2..e6bec9ea0 100644 --- a/apiextensions/informers/apiextensions/v1/interface.go +++ b/apiextensions/informers/apiextensions/v1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,30 +14,30 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "github.com/kcp-dev/client-go/apiextensions/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/apiextensions/informers/internalinterfaces" ) type ClusterInterface interface { - // CustomResourceDefinitions returns a CustomResourceDefinitionClusterInformer + // CustomResourceDefinitions returns a CustomResourceDefinitionClusterInformer. CustomResourceDefinitions() CustomResourceDefinitionClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// CustomResourceDefinitions returns a CustomResourceDefinitionClusterInformer +// CustomResourceDefinitions returns a CustomResourceDefinitionClusterInformer. func (v *version) CustomResourceDefinitions() CustomResourceDefinitionClusterInformer { return &customResourceDefinitionClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/apiextensions/informers/apiextensions/v1beta1/customresourcedefinition.go b/apiextensions/informers/apiextensions/v1beta1/customresourcedefinition.go index bed7c3a4f..b1a836910 100644 --- a/apiextensions/informers/apiextensions/v1beta1/customresourcedefinition.go +++ b/apiextensions/informers/apiextensions/v1beta1/customresourcedefinition.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - upstreamapiextensionsv1beta1informers "k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/apiextensions/v1beta1" - upstreamapiextensionsv1beta1listers "k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - "k8s.io/client-go/tools/cache" - - clientset "github.com/kcp-dev/client-go/apiextensions/client" - "github.com/kcp-dev/client-go/apiextensions/informers/internalinterfaces" - apiextensionsv1beta1listers "github.com/kcp-dev/client-go/apiextensions/listers/apiextensions/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apisapiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" + apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/apiextensions/v1beta1" + listersapiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + + kcpclient "github.com/kcp-dev/client-go/apiextensions/client" + kcpinternalinterfaces "github.com/kcp-dev/client-go/apiextensions/informers/internalinterfaces" + kcpv1beta1 "github.com/kcp-dev/client-go/apiextensions/listers/apiextensions/v1beta1" ) // CustomResourceDefinitionClusterInformer provides access to a shared informer and lister for // CustomResourceDefinitions. type CustomResourceDefinitionClusterInformer interface { - Cluster(logicalcluster.Name) upstreamapiextensionsv1beta1informers.CustomResourceDefinitionInformer + Cluster(logicalcluster.Name) apiextensionsv1beta1.CustomResourceDefinitionInformer + ClusterWithContext(context.Context, logicalcluster.Name) apiextensionsv1beta1.CustomResourceDefinitionInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() apiextensionsv1beta1listers.CustomResourceDefinitionClusterLister + Lister() kcpv1beta1.CustomResourceDefinitionClusterLister } type customResourceDefinitionClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewCustomResourceDefinitionClusterInformer constructs a new informer for CustomResourceDefinition type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewCustomResourceDefinitionClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewCustomResourceDefinitionClusterInformer(client kcpclient.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredCustomResourceDefinitionClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredCustomResourceDefinitionClusterInformer constructs a new informer for CustomResourceDefinition type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredCustomResourceDefinitionClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredCustomResourceDefinitionClusterInformer(client kcpclient.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ApiextensionsV1beta1().CustomResourceDefinitions().List(context.TODO(), options) + return client.ApiextensionsV1beta1().CustomResourceDefinitions().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ApiextensionsV1beta1().CustomResourceDefinitions().Watch(context.TODO(), options) + return client.ApiextensionsV1beta1().CustomResourceDefinitions().Watch(context.Background(), options) }, }, - &apiextensionsv1beta1.CustomResourceDefinition{}, + &apisapiextensionsv1beta1.CustomResourceDefinition{}, resyncPeriod, indexers, ) } -func (f *customResourceDefinitionClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *customResourceDefinitionClusterInformer) defaultInformer(client kcpclient.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredCustomResourceDefinitionClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *customResourceDefinitionClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apisapiextensionsv1beta1.CustomResourceDefinition{}, i.defaultInformer) } -func (f *customResourceDefinitionClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&apiextensionsv1beta1.CustomResourceDefinition{}, f.defaultInformer) +func (i *customResourceDefinitionClusterInformer) Lister() kcpv1beta1.CustomResourceDefinitionClusterLister { + return kcpv1beta1.NewCustomResourceDefinitionClusterLister(i.Informer().GetIndexer()) } -func (f *customResourceDefinitionClusterInformer) Lister() apiextensionsv1beta1listers.CustomResourceDefinitionClusterLister { - return apiextensionsv1beta1listers.NewCustomResourceDefinitionClusterLister(f.Informer().GetIndexer()) +func (i *customResourceDefinitionClusterInformer) Cluster(clusterName logicalcluster.Name) apiextensionsv1beta1.CustomResourceDefinitionInformer { + return &customResourceDefinitionInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *customResourceDefinitionClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamapiextensionsv1beta1informers.CustomResourceDefinitionInformer { +func (i *customResourceDefinitionClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) apiextensionsv1beta1.CustomResourceDefinitionInformer { return &customResourceDefinitionInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type customResourceDefinitionInformer struct { informer cache.SharedIndexInformer - lister upstreamapiextensionsv1beta1listers.CustomResourceDefinitionLister + lister listersapiextensionsv1beta1.CustomResourceDefinitionLister } -func (f *customResourceDefinitionInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *customResourceDefinitionInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *customResourceDefinitionInformer) Lister() upstreamapiextensionsv1beta1listers.CustomResourceDefinitionLister { - return f.lister +func (i *customResourceDefinitionInformer) Lister() listersapiextensionsv1beta1.CustomResourceDefinitionLister { + return i.lister } diff --git a/apiextensions/informers/apiextensions/v1beta1/interface.go b/apiextensions/informers/apiextensions/v1beta1/interface.go index c56fd4597..51f181585 100644 --- a/apiextensions/informers/apiextensions/v1beta1/interface.go +++ b/apiextensions/informers/apiextensions/v1beta1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,30 +14,30 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "github.com/kcp-dev/client-go/apiextensions/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/apiextensions/informers/internalinterfaces" ) type ClusterInterface interface { - // CustomResourceDefinitions returns a CustomResourceDefinitionClusterInformer + // CustomResourceDefinitions returns a CustomResourceDefinitionClusterInformer. CustomResourceDefinitions() CustomResourceDefinitionClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// CustomResourceDefinitions returns a CustomResourceDefinitionClusterInformer +// CustomResourceDefinitions returns a CustomResourceDefinitionClusterInformer. func (v *version) CustomResourceDefinitions() CustomResourceDefinitionClusterInformer { return &customResourceDefinitionClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/apiextensions/informers/factory.go b/apiextensions/informers/factory.go index b1389a49d..2479c10aa 100644 --- a/apiextensions/informers/factory.go +++ b/apiextensions/informers/factory.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,27 +14,27 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package informers import ( - "reflect" - "sync" - "time" + reflect "reflect" + sync "sync" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - upstreaminformers "k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/client-go/tools/cache" + externalversions "k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" - clientset "github.com/kcp-dev/client-go/apiextensions/client" - apiextensionsinformers "github.com/kcp-dev/client-go/apiextensions/informers/apiextensions" - "github.com/kcp-dev/client-go/apiextensions/informers/internalinterfaces" + kcpclient "github.com/kcp-dev/client-go/apiextensions/client" + kcpapiextensions "github.com/kcp-dev/client-go/apiextensions/informers/apiextensions" + kcpinternalinterfaces "github.com/kcp-dev/client-go/apiextensions/informers/internalinterfaces" ) // SharedInformerOption defines the functional option type for SharedInformerFactory. @@ -42,13 +42,14 @@ type SharedInformerOption func(*SharedInformerOptions) *SharedInformerOptions type SharedInformerOptions struct { customResync map[reflect.Type]time.Duration - tweakListOptions internalinterfaces.TweakListOptionsFunc + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc transform cache.TransformFunc + namespace string } type sharedInformerFactory struct { - client clientset.ClusterInterface - tweakListOptions internalinterfaces.TweakListOptionsFunc + client kcpclient.ClusterInterface + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc lock sync.Mutex defaultResync time.Duration customResync map[reflect.Type]time.Duration @@ -66,7 +67,7 @@ type sharedInformerFactory struct { } // WithCustomResyncConfig sets a custom resync period for the specified informer types. -func WithCustomResyncConfig(resyncConfig map[metav1.Object]time.Duration) SharedInformerOption { +func WithCustomResyncConfig(resyncConfig map[v1.Object]time.Duration) SharedInformerOption { return func(opts *SharedInformerOptions) *SharedInformerOptions { for k, v := range resyncConfig { opts.customResync[reflect.TypeOf(k)] = v @@ -76,7 +77,7 @@ func WithCustomResyncConfig(resyncConfig map[metav1.Object]time.Duration) Shared } // WithTweakListOptions sets a custom filter on all listers of the configured SharedInformerFactory. -func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption { +func WithTweakListOptions(tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) SharedInformerOption { return func(opts *SharedInformerOptions) *SharedInformerOptions { opts.tweakListOptions = tweakListOptions return opts @@ -91,13 +92,21 @@ func WithTransform(transform cache.TransformFunc) SharedInformerOption { } } -// NewSharedInformerFactory constructs a new instance of SharedInformerFactory for all namespaces. -func NewSharedInformerFactory(client clientset.ClusterInterface, defaultResync time.Duration) SharedInformerFactory { +// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces. +func NewSharedInformerFactory(client kcpclient.ClusterInterface, defaultResync time.Duration) SharedInformerFactory { return NewSharedInformerFactoryWithOptions(client, defaultResync) } +// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory. +// Listers obtained via this SharedInformerFactory will be subject to the same filters +// as specified here. +// Deprecated: Please use NewSharedInformerFactoryWithOptions instead +func NewFilteredSharedInformerFactory(client kcpclient.ClusterInterface, defaultResync time.Duration, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) SharedInformerFactory { + return NewSharedInformerFactoryWithOptions(client, defaultResync, WithTweakListOptions(tweakListOptions)) +} + // NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options. -func NewSharedInformerFactoryWithOptions(client clientset.ClusterInterface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory { +func NewSharedInformerFactoryWithOptions(client kcpclient.ClusterInterface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory { factory := &sharedInformerFactory{ client: client, defaultResync: defaultResync, @@ -123,7 +132,6 @@ func NewSharedInformerFactoryWithOptions(client clientset.ClusterInterface, defa return factory } -// Start initializes all requested informers. func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) { f.lock.Lock() defer f.lock.Unlock() @@ -157,7 +165,6 @@ func (f *sharedInformerFactory) Shutdown() { f.wg.Wait() } -// WaitForCacheSync waits for all started informers' cache were synced. func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool { informers := func() map[reflect.Type]kcpcache.ScopeableSharedIndexInformer { f.lock.Lock() @@ -176,11 +183,12 @@ func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[ref for informType, informer := range informers { res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced) } + return res } -// InformerFor returns the SharedIndexInformer for obj. -func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) kcpcache.ScopeableSharedIndexInformer { +// InformerFor returns the ScopeableSharedIndexInformer for obj using an internal client. +func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc kcpinternalinterfaces.NewInformerFunc) kcpcache.ScopeableSharedIndexInformer { f.lock.Lock() defer f.lock.Unlock() @@ -196,6 +204,7 @@ func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internal } informer = newFunc(f.client, resyncPeriod) + informer.SetTransform(f.transform) f.informers[informerType] = informer return informer @@ -203,7 +212,7 @@ func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internal type ScopedDynamicSharedInformerFactory interface { // ForResource gives generic access to a shared informer of the matching type. - ForResource(resource schema.GroupVersionResource) (upstreaminformers.GenericInformer, error) + ForResource(resource schema.GroupVersionResource) (externalversions.GenericInformer, error) // Start initializes all requested informers. They are handled in goroutines // which run until the stop channel gets closed. @@ -217,11 +226,11 @@ type ScopedDynamicSharedInformerFactory interface { // // ctx, cancel := context.Background() // defer cancel() -// factory := NewSharedInformerFactoryWithOptions(client, resyncPeriod) -// defer factory.Shutdown() // Returns immediately if nothing was started. +// factory := NewSharedInformerFactory(client, resyncPeriod) +// defer factory.WaitForStop() // Returns immediately if nothing was started. // genericInformer := factory.ForResource(resource) // typedInformer := factory.SomeAPIGroup().V1().SomeType() -// factory.Start(ctx.Done()) // Start processing these informers. +// factory.Start(ctx.Done()) // Start processing these informers. // synced := factory.WaitForCacheSync(ctx.Done()) // for v, ok := range synced { // if !ok { @@ -235,12 +244,13 @@ type ScopedDynamicSharedInformerFactory interface { // anotherGenericInformer := factory.ForResource(resource) // factory.Start(ctx.Done()) type SharedInformerFactory interface { - internalinterfaces.SharedInformerFactory + kcpinternalinterfaces.SharedInformerFactory Cluster(logicalcluster.Name) ScopedDynamicSharedInformerFactory // Start initializes all requested informers. They are handled in goroutines // which run until the stop channel gets closed. + // Warning: Start does not block. When run in a go-routine, it will race with a later WaitForCacheSync. Start(stopCh <-chan struct{}) // Shutdown marks a factory as shutting down. At that point no new @@ -255,21 +265,22 @@ type SharedInformerFactory interface { // block until all goroutines have terminated. Shutdown() - // ForResource gives generic access to a shared informer of the matching type. - ForResource(resource schema.GroupVersionResource) (GenericClusterInformer, error) - // WaitForCacheSync blocks until all started informers' caches were synced // or the stop channel gets closed. WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool - // InformerFor returns the SharedIndexInformer for obj. - InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) kcpcache.ScopeableSharedIndexInformer + // ForResource gives generic access to a shared informer of the matching type. + ForResource(resource schema.GroupVersionResource) (GenericClusterInformer, error) + + // InformerFor returns the SharedIndexInformer for obj using an internal + // client. + InformerFor(obj runtime.Object, newFunc kcpinternalinterfaces.NewInformerFunc) kcpcache.ScopeableSharedIndexInformer - Apiextensions() apiextensionsinformers.ClusterInterface + Apiextensions() kcpapiextensions.ClusterInterface } -func (f *sharedInformerFactory) Apiextensions() apiextensionsinformers.ClusterInterface { - return apiextensionsinformers.New(f, f.tweakListOptions) +func (f *sharedInformerFactory) Apiextensions() kcpapiextensions.ClusterInterface { + return kcpapiextensions.New(f, f.tweakListOptions) } func (f *sharedInformerFactory) Cluster(clusterName logicalcluster.Name) ScopedDynamicSharedInformerFactory { @@ -284,7 +295,7 @@ type scopedDynamicSharedInformerFactory struct { clusterName logicalcluster.Name } -func (f *scopedDynamicSharedInformerFactory) ForResource(resource schema.GroupVersionResource) (upstreaminformers.GenericInformer, error) { +func (f *scopedDynamicSharedInformerFactory) ForResource(resource schema.GroupVersionResource) (externalversions.GenericInformer, error) { clusterInformer, err := f.sharedInformerFactory.ForResource(resource) if err != nil { return nil, err diff --git a/apiextensions/informers/generic.go b/apiextensions/informers/generic.go index 8b61ff1b2..3617f9cc5 100644 --- a/apiextensions/informers/generic.go +++ b/apiextensions/informers/generic.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,25 +14,27 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package informers import ( - "fmt" + context "context" + fmt "fmt" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" - apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - upstreaminformers "k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/client-go/tools/cache" + v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + v1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" + externalversions "k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" ) type GenericClusterInformer interface { - Cluster(logicalcluster.Name) upstreaminformers.GenericInformer + Cluster(logicalcluster.Name) externalversions.GenericInformer + ClusterWithContext(context.Context, logicalcluster.Name) externalversions.GenericInformer Informer() kcpcache.ScopeableSharedIndexInformer Lister() kcpcache.GenericClusterLister } @@ -43,20 +45,29 @@ type genericClusterInformer struct { } // Informer returns the SharedIndexInformer. -func (f *genericClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.informer +func (i *genericClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.informer } -// Lister returns the GenericClusterLister. -func (f *genericClusterInformer) Lister() kcpcache.GenericClusterLister { - return kcpcache.NewGenericClusterLister(f.Informer().GetIndexer(), f.resource) +// Lister returns the GenericLister. +func (i *genericClusterInformer) Lister() kcpcache.GenericClusterLister { + return kcpcache.NewGenericClusterLister(i.Informer().GetIndexer(), i.resource) } // Cluster scopes to a GenericInformer. -func (f *genericClusterInformer) Cluster(clusterName logicalcluster.Name) upstreaminformers.GenericInformer { +func (i *genericClusterInformer) Cluster(clusterName logicalcluster.Name) externalversions.GenericInformer { return &genericInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().ByCluster(clusterName), + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().ByCluster(clusterName), + } +} + +// ClusterWithContext scopes to a GenericInformer and unregisters all +// handles registered through it once the provided context is canceled. +func (i *genericClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) externalversions.GenericInformer { + return &genericInformer{ + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().ByCluster(clusterName), } } @@ -66,25 +77,27 @@ type genericInformer struct { } // Informer returns the SharedIndexInformer. -func (f *genericInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *genericInformer) Informer() cache.SharedIndexInformer { + return i.informer } // Lister returns the GenericLister. -func (f *genericInformer) Lister() cache.GenericLister { - return f.lister +func (i *genericInformer) Lister() cache.GenericLister { + return i.lister } // ForResource gives generic access to a shared informer of the matching type // TODO extend this to unknown resources with a client pool func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericClusterInformer, error) { switch resource { - // Group=apiextensions.k8s.io, Version=V1 - case apiextensionsv1.SchemeGroupVersion.WithResource("customresourcedefinitions"): + // Group=apiextensions.k8s.io, Version=v1 + case v1.SchemeGroupVersion.WithResource("customresourcedefinitions"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Apiextensions().V1().CustomResourceDefinitions().Informer()}, nil - // Group=apiextensions.k8s.io, Version=V1beta1 - case apiextensionsv1beta1.SchemeGroupVersion.WithResource("customresourcedefinitions"): + + // Group=apiextensions.k8s.io, Version=v1beta1 + case v1beta1.SchemeGroupVersion.WithResource("customresourcedefinitions"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Apiextensions().V1beta1().CustomResourceDefinitions().Informer()}, nil + } return nil, fmt.Errorf("no informer found for %v", resource) diff --git a/apiextensions/informers/internalinterfaces/factory_interfaces.go b/apiextensions/informers/internalinterfaces/factory_interfaces.go index e76981cbc..e767f3fb4 100644 --- a/apiextensions/informers/internalinterfaces/factory_interfaces.go +++ b/apiextensions/informers/internalinterfaces/factory_interfaces.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package internalinterfaces @@ -23,20 +23,20 @@ import ( kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" - clientset "github.com/kcp-dev/client-go/apiextensions/client" + kcpclient "github.com/kcp-dev/client-go/apiextensions/client" ) -// NewInformerFunc takes clientset.ClusterInterface and time.Duration to return a ScopeableSharedIndexInformer. -type NewInformerFunc func(clientset.ClusterInterface, time.Duration) kcpcache.ScopeableSharedIndexInformer +// TweakListOptionsFunc is a function that transforms a v1.ListOptions. +type TweakListOptionsFunc func(*v1.ListOptions) -// SharedInformerFactory a small interface to allow for adding an informer without an import cycle +// NewInformerFunc takes kcpclient.ClusterInterface and time.Duration to return a kcpcache.ScopeableSharedIndexInformer. +type NewInformerFunc func(kcpclient.ClusterInterface, time.Duration) kcpcache.ScopeableSharedIndexInformer + +// SharedInformerFactory a small interface to allow for adding an informer without an import cycle. type SharedInformerFactory interface { Start(stopCh <-chan struct{}) InformerFor(obj runtime.Object, newFunc NewInformerFunc) kcpcache.ScopeableSharedIndexInformer } - -// TweakListOptionsFunc is a function that transforms a metav1.ListOptions. -type TweakListOptionsFunc func(*metav1.ListOptions) diff --git a/apiextensions/listers/apiextensions/v1/customresourcedefinition.go b/apiextensions/listers/apiextensions/v1/customresourcedefinition.go index 8317b7b55..cfa3012f2 100644 --- a/apiextensions/listers/apiextensions/v1/customresourcedefinition.go +++ b/apiextensions/listers/apiextensions/v1/customresourcedefinition.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" - apiextensionsv1listers "k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/v1" - "k8s.io/apimachinery/pkg/api/errors" + listersapiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// CustomResourceDefinitionClusterLister can list CustomResourceDefinitions across all workspaces, or scope down to a CustomResourceDefinitionLister for one workspace. +// CustomResourceDefinitionClusterLister helps list CustomResourceDefinitions across all workspaces, +// or scope down to a CustomResourceDefinitionLister for one workspace. // All objects returned here must be treated as read-only. type CustomResourceDefinitionClusterLister interface { // List lists all CustomResourceDefinitions in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*apiextensionsv1.CustomResourceDefinition, err error) // Cluster returns a lister that can list and get CustomResourceDefinitions in one workspace. - Cluster(clusterName logicalcluster.Name) apiextensionsv1listers.CustomResourceDefinitionLister + Cluster(clusterName logicalcluster.Name) listersapiextensionsv1.CustomResourceDefinitionLister CustomResourceDefinitionClusterListerExpansion } +// customResourceDefinitionClusterLister implements the CustomResourceDefinitionClusterLister interface. type customResourceDefinitionClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*apiextensionsv1.CustomResourceDefinition] } +var _ CustomResourceDefinitionClusterLister = new(customResourceDefinitionClusterLister) + // NewCustomResourceDefinitionClusterLister returns a new CustomResourceDefinitionClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewCustomResourceDefinitionClusterLister(indexer cache.Indexer) *customResourceDefinitionClusterLister { - return &customResourceDefinitionClusterLister{indexer: indexer} -} - -// List lists all CustomResourceDefinitions in the indexer across all workspaces. -func (s *customResourceDefinitionClusterLister) List(selector labels.Selector) (ret []*apiextensionsv1.CustomResourceDefinition, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*apiextensionsv1.CustomResourceDefinition)) - }) - return ret, err +func NewCustomResourceDefinitionClusterLister(indexer cache.Indexer) CustomResourceDefinitionClusterLister { + return &customResourceDefinitionClusterLister{ + kcplisters.NewCluster[*apiextensionsv1.CustomResourceDefinition](indexer, apiextensionsv1.Resource("customresourcedefinition")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get CustomResourceDefinitions. -func (s *customResourceDefinitionClusterLister) Cluster(clusterName logicalcluster.Name) apiextensionsv1listers.CustomResourceDefinitionLister { - return &customResourceDefinitionLister{indexer: s.indexer, clusterName: clusterName} +func (l *customResourceDefinitionClusterLister) Cluster(clusterName logicalcluster.Name) listersapiextensionsv1.CustomResourceDefinitionLister { + return &customResourceDefinitionLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// customResourceDefinitionLister implements the apiextensionsv1listers.CustomResourceDefinitionLister interface. +// customResourceDefinitionLister can list all CustomResourceDefinitions inside a workspace +// or scope down to a listersapiextensionsv1.CustomResourceDefinitionNamespaceLister for one namespace. type customResourceDefinitionLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*apiextensionsv1.CustomResourceDefinition] } -// List lists all CustomResourceDefinitions in the indexer for a workspace. -func (s *customResourceDefinitionLister) List(selector labels.Selector) (ret []*apiextensionsv1.CustomResourceDefinition, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*apiextensionsv1.CustomResourceDefinition)) - }) - return ret, err -} +var _ listersapiextensionsv1.CustomResourceDefinitionLister = new(customResourceDefinitionLister) -// Get retrieves the CustomResourceDefinition from the indexer for a given workspace and name. -func (s *customResourceDefinitionLister) Get(name string) (*apiextensionsv1.CustomResourceDefinition, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(apiextensionsv1.Resource("customresourcedefinitions"), name) +// NewCustomResourceDefinitionLister returns a new CustomResourceDefinitionLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewCustomResourceDefinitionLister(indexer cache.Indexer) listersapiextensionsv1.CustomResourceDefinitionLister { + return &customResourceDefinitionLister{ + kcplisters.New[*apiextensionsv1.CustomResourceDefinition](indexer, apiextensionsv1.Resource("customresourcedefinition")), } - return obj.(*apiextensionsv1.CustomResourceDefinition), nil +} + +// customResourceDefinitionScopedLister can list all CustomResourceDefinitions inside a workspace +// or scope down to a listersapiextensionsv1.CustomResourceDefinitionNamespaceLister. +type customResourceDefinitionScopedLister struct { + kcplisters.ResourceIndexer[*apiextensionsv1.CustomResourceDefinition] } diff --git a/apiextensions/listers/apiextensions/v1/customresourcedefinition_expansion.go b/apiextensions/listers/apiextensions/v1/expansion_generated.go similarity index 81% rename from apiextensions/listers/apiextensions/v1/customresourcedefinition_expansion.go rename to apiextensions/listers/apiextensions/v1/expansion_generated.go index 83f3da029..d3093c867 100644 --- a/apiextensions/listers/apiextensions/v1/customresourcedefinition_expansion.go +++ b/apiextensions/listers/apiextensions/v1/expansion_generated.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,9 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 -// CustomResourceDefinitionClusterListerExpansion allows custom methods to be added to CustomResourceDefinitionClusterLister. +// CustomResourceDefinitionClusterListerExpansion allows custom methods to be added to +// CustomResourceDefinitionClusterLister. type CustomResourceDefinitionClusterListerExpansion interface{} diff --git a/apiextensions/listers/apiextensions/v1beta1/customresourcedefinition.go b/apiextensions/listers/apiextensions/v1beta1/customresourcedefinition.go index e1ccff7e9..f0dc0ac0a 100644 --- a/apiextensions/listers/apiextensions/v1beta1/customresourcedefinition.go +++ b/apiextensions/listers/apiextensions/v1beta1/customresourcedefinition.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - apiextensionsv1beta1listers "k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" + listersapiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/v1beta1" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// CustomResourceDefinitionClusterLister can list CustomResourceDefinitions across all workspaces, or scope down to a CustomResourceDefinitionLister for one workspace. +// CustomResourceDefinitionClusterLister helps list CustomResourceDefinitions across all workspaces, +// or scope down to a CustomResourceDefinitionLister for one workspace. // All objects returned here must be treated as read-only. type CustomResourceDefinitionClusterLister interface { // List lists all CustomResourceDefinitions in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*apiextensionsv1beta1.CustomResourceDefinition, err error) // Cluster returns a lister that can list and get CustomResourceDefinitions in one workspace. - Cluster(clusterName logicalcluster.Name) apiextensionsv1beta1listers.CustomResourceDefinitionLister + Cluster(clusterName logicalcluster.Name) listersapiextensionsv1beta1.CustomResourceDefinitionLister CustomResourceDefinitionClusterListerExpansion } +// customResourceDefinitionClusterLister implements the CustomResourceDefinitionClusterLister interface. type customResourceDefinitionClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*apiextensionsv1beta1.CustomResourceDefinition] } +var _ CustomResourceDefinitionClusterLister = new(customResourceDefinitionClusterLister) + // NewCustomResourceDefinitionClusterLister returns a new CustomResourceDefinitionClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewCustomResourceDefinitionClusterLister(indexer cache.Indexer) *customResourceDefinitionClusterLister { - return &customResourceDefinitionClusterLister{indexer: indexer} -} - -// List lists all CustomResourceDefinitions in the indexer across all workspaces. -func (s *customResourceDefinitionClusterLister) List(selector labels.Selector) (ret []*apiextensionsv1beta1.CustomResourceDefinition, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*apiextensionsv1beta1.CustomResourceDefinition)) - }) - return ret, err +func NewCustomResourceDefinitionClusterLister(indexer cache.Indexer) CustomResourceDefinitionClusterLister { + return &customResourceDefinitionClusterLister{ + kcplisters.NewCluster[*apiextensionsv1beta1.CustomResourceDefinition](indexer, apiextensionsv1beta1.Resource("customresourcedefinition")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get CustomResourceDefinitions. -func (s *customResourceDefinitionClusterLister) Cluster(clusterName logicalcluster.Name) apiextensionsv1beta1listers.CustomResourceDefinitionLister { - return &customResourceDefinitionLister{indexer: s.indexer, clusterName: clusterName} +func (l *customResourceDefinitionClusterLister) Cluster(clusterName logicalcluster.Name) listersapiextensionsv1beta1.CustomResourceDefinitionLister { + return &customResourceDefinitionLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// customResourceDefinitionLister implements the apiextensionsv1beta1listers.CustomResourceDefinitionLister interface. +// customResourceDefinitionLister can list all CustomResourceDefinitions inside a workspace +// or scope down to a listersapiextensionsv1beta1.CustomResourceDefinitionNamespaceLister for one namespace. type customResourceDefinitionLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*apiextensionsv1beta1.CustomResourceDefinition] } -// List lists all CustomResourceDefinitions in the indexer for a workspace. -func (s *customResourceDefinitionLister) List(selector labels.Selector) (ret []*apiextensionsv1beta1.CustomResourceDefinition, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*apiextensionsv1beta1.CustomResourceDefinition)) - }) - return ret, err -} +var _ listersapiextensionsv1beta1.CustomResourceDefinitionLister = new(customResourceDefinitionLister) -// Get retrieves the CustomResourceDefinition from the indexer for a given workspace and name. -func (s *customResourceDefinitionLister) Get(name string) (*apiextensionsv1beta1.CustomResourceDefinition, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(apiextensionsv1beta1.Resource("customresourcedefinitions"), name) +// NewCustomResourceDefinitionLister returns a new CustomResourceDefinitionLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewCustomResourceDefinitionLister(indexer cache.Indexer) listersapiextensionsv1beta1.CustomResourceDefinitionLister { + return &customResourceDefinitionLister{ + kcplisters.New[*apiextensionsv1beta1.CustomResourceDefinition](indexer, apiextensionsv1beta1.Resource("customresourcedefinition")), } - return obj.(*apiextensionsv1beta1.CustomResourceDefinition), nil +} + +// customResourceDefinitionScopedLister can list all CustomResourceDefinitions inside a workspace +// or scope down to a listersapiextensionsv1beta1.CustomResourceDefinitionNamespaceLister. +type customResourceDefinitionScopedLister struct { + kcplisters.ResourceIndexer[*apiextensionsv1beta1.CustomResourceDefinition] } diff --git a/apiextensions/listers/apiextensions/v1beta1/customresourcedefinition_expansion.go b/apiextensions/listers/apiextensions/v1beta1/expansion_generated.go similarity index 81% rename from apiextensions/listers/apiextensions/v1beta1/customresourcedefinition_expansion.go rename to apiextensions/listers/apiextensions/v1beta1/expansion_generated.go index 92dccdcb6..757943d6c 100644 --- a/apiextensions/listers/apiextensions/v1beta1/customresourcedefinition_expansion.go +++ b/apiextensions/listers/apiextensions/v1beta1/expansion_generated.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,9 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 -// CustomResourceDefinitionClusterListerExpansion allows custom methods to be added to CustomResourceDefinitionClusterLister. +// CustomResourceDefinitionClusterListerExpansion allows custom methods to be added to +// CustomResourceDefinitionClusterLister. type CustomResourceDefinitionClusterListerExpansion interface{} diff --git a/dependencies.go b/dependencies.go index 4c8cc92cd..e40c184a2 100644 --- a/dependencies.go +++ b/dependencies.go @@ -18,6 +18,7 @@ package main import ( _ "github.com/kcp-dev/apimachinery/v2/pkg/cache" + _ "github.com/kcp-dev/code-generator/v3/cmd/cluster-client-gen/generators" _ "github.com/kcp-dev/logicalcluster/v3" _ "k8s.io/api/core/v1" diff --git a/dynamic/dynamicinformer/informer.go b/dynamic/dynamicinformer/informer.go index c8c746404..396d650a0 100644 --- a/dynamic/dynamicinformer/informer.go +++ b/dynamic/dynamicinformer/informer.go @@ -165,8 +165,12 @@ func (d *dynamicClusterInformer) Lister() kcpcache.GenericClusterLister { } func (d *dynamicClusterInformer) Cluster(clusterName logicalcluster.Name) upstreaminformers.GenericInformer { + return d.ClusterWithContext(context.Background(), clusterName) +} + +func (d *dynamicClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) upstreaminformers.GenericInformer { return &dynamicInformer{ - informer: d.Informer().Cluster(clusterName), + informer: d.Informer().ClusterWithContext(ctx, clusterName), lister: d.Lister().ByCluster(clusterName), } } diff --git a/go.mod b/go.mod index f95f43c5e..17b88d5dd 100644 --- a/go.mod +++ b/go.mod @@ -3,15 +3,18 @@ module github.com/kcp-dev/client-go go 1.23.0 require ( - github.com/evanphx/json-patch v5.6.0+incompatible github.com/google/gnostic-models v0.6.9 - github.com/kcp-dev/apimachinery/v2 v2.0.1-0.20250425065633-635c2a0fbaba + github.com/kcp-dev/apimachinery/v2 v2.0.1-0.20250512171935-ebb573a40077 + github.com/kcp-dev/code-generator/v3 v3.0.0-20250617221607-126a1bcb8dd7 github.com/kcp-dev/logicalcluster/v3 v3.0.5 + gopkg.in/evanphx/json-patch.v4 v4.12.0 k8s.io/api v0.32.3 k8s.io/apiextensions-apiserver v0.32.3 k8s.io/apimachinery v0.32.3 k8s.io/client-go v0.32.3 k8s.io/klog/v2 v2.130.1 + sigs.k8s.io/structured-merge-diff/v4 v4.4.2 + sigs.k8s.io/yaml v1.4.0 ) require ( @@ -69,6 +72,7 @@ require ( go.opentelemetry.io/otel/trace v1.33.0 // indirect go.opentelemetry.io/proto/otlp v1.3.1 // indirect golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 // indirect + golang.org/x/mod v0.24.0 // indirect golang.org/x/net v0.39.0 // indirect golang.org/x/oauth2 v0.29.0 // indirect golang.org/x/sync v0.13.0 // indirect @@ -76,19 +80,19 @@ require ( golang.org/x/term v0.31.0 // indirect golang.org/x/text v0.24.0 // indirect golang.org/x/time v0.11.0 // indirect + golang.org/x/tools v0.32.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 // indirect google.golang.org/grpc v1.69.2 // indirect google.golang.org/protobuf v1.35.1 // indirect - gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/apiserver v0.32.3 // indirect + k8s.io/code-generator v0.32.3 // indirect k8s.io/component-base v0.32.3 // indirect + k8s.io/gengo/v2 v2.0.0-20240911193312-2b36238f13e9 // indirect k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.1 // indirect sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect - sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/go.sum b/go.sum index 323cd622a..61fe33fd3 100644 --- a/go.sum +++ b/go.sum @@ -23,8 +23,6 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/emicklei/go-restful/v3 v3.12.1 h1:PJMDIM/ak7btuL8Ex0iYET9hxM3CI2sjZtzpL63nKAU= github.com/emicklei/go-restful/v3 v3.12.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= -github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= -github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E= @@ -72,8 +70,10 @@ github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8Hm github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kcp-dev/apimachinery/v2 v2.0.1-0.20250425065633-635c2a0fbaba h1:Ar/8wsCQWrZgRiBF2B5xCqCXEA/oiiuDI0yEsUtrxRs= -github.com/kcp-dev/apimachinery/v2 v2.0.1-0.20250425065633-635c2a0fbaba/go.mod h1:pYqnaSG3NlF/pVwfnYCAdGvrA7FpALFmd5S9X4XXf1Q= +github.com/kcp-dev/apimachinery/v2 v2.0.1-0.20250512171935-ebb573a40077 h1:lDi9nZ75ypmRJwDFXUN70Cdu8+HxAjPU1kcnn+l4MvI= +github.com/kcp-dev/apimachinery/v2 v2.0.1-0.20250512171935-ebb573a40077/go.mod h1:jnMZxVnCuKlkIXc4J1Qtmy1Lyo171CDF/RQhNAo0tvA= +github.com/kcp-dev/code-generator/v3 v3.0.0-20250617221607-126a1bcb8dd7 h1:MdpGf4E5hd188dkXXdcod4xJ+9IfsM/O6Zt7r5x3QJ4= +github.com/kcp-dev/code-generator/v3 v3.0.0-20250617221607-126a1bcb8dd7/go.mod h1:1EZhJqiFvXq1N0xKJnJOf8kQ++wuwLkqFGIRVSoVACk= github.com/kcp-dev/logicalcluster/v3 v3.0.5 h1:JbYakokb+5Uinz09oTXomSUJVQsqfxEvU4RyHUYxHOU= github.com/kcp-dev/logicalcluster/v3 v3.0.5/go.mod h1:EWBUBxdr49fUB1cLMO4nOdBWmYifLbP1LfoL20KkXYY= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= @@ -175,6 +175,8 @@ golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 h1:yqrTHse8TCMW1M1ZCP+VAR/l0 golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8/go.mod h1:tujkw807nyEEAamNbDrEGzRav+ilXA7PCRAd6xsmwiU= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU= +golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -205,8 +207,8 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.29.0 h1:Xx0h3TtM9rzQpQuR4dKLrdglAmCEN5Oi+P74JdhdzXE= -golang.org/x/tools v0.29.0/go.mod h1:KMQVMRsVxU6nHCFXrBPhDB8XncLNLM0lIy/F14RP588= +golang.org/x/tools v0.32.0 h1:Q7N1vhpkQv7ybVzLFtTjvQya2ewbwNDZzUgfXGqtMWU= +golang.org/x/tools v0.32.0/go.mod h1:ZxrU41P/wAbZD8EDa6dDCa6XfpkhJ7HFMjHJXfBDu8s= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -239,8 +241,12 @@ k8s.io/apiserver v0.32.3 h1:kOw2KBuHOA+wetX1MkmrxgBr648ksz653j26ESuWNY8= k8s.io/apiserver v0.32.3/go.mod h1:q1x9B8E/WzShF49wh3ADOh6muSfpmFL0I2t+TG0Zdgc= k8s.io/client-go v0.32.3 h1:RKPVltzopkSgHS7aS98QdscAgtgah/+zmpAogooIqVU= k8s.io/client-go v0.32.3/go.mod h1:3v0+3k4IcT9bXTc4V2rt+d2ZPPG700Xy6Oi0Gdl2PaY= +k8s.io/code-generator v0.32.3 h1:31p2TVzC9+hVdSkAFruAk3JY+iSfzrJ83Qij1yZutyw= +k8s.io/code-generator v0.32.3/go.mod h1:+mbiYID5NLsBuqxjQTygKM/DAdKpAjvBzrJd64NU1G8= k8s.io/component-base v0.32.3 h1:98WJvvMs3QZ2LYHBzvltFSeJjEx7t5+8s71P7M74u8k= k8s.io/component-base v0.32.3/go.mod h1:LWi9cR+yPAv7cu2X9rZanTiFKB2kHA+JjmhkKjCZRpI= +k8s.io/gengo/v2 v2.0.0-20240911193312-2b36238f13e9 h1:si3PfKm8dDYxgfbeA6orqrtLkvvIeH8UqffFJDl0bz4= +k8s.io/gengo/v2 v2.0.0-20240911193312-2b36238f13e9/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f h1:GA7//TjRY9yWGy1poLzYYJJ4JRdzg3+O6e8I+e+8T5Y= diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index a41eb80cf..200e1dea8 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -19,21 +19,38 @@ set -o nounset set -o pipefail set -o xtrace -if [[ -z "${MAKELEVEL:-}" ]]; then - echo 'You must invoke this script via make' - exit 1 -fi +CODEGEN_PKG="$(go list -f '{{.Dir}}' -m k8s.io/code-generator)" +source "$CODEGEN_PKG/kube_codegen.sh" -${CODE_GENERATOR} \ - "client:externalOnly=true,standalone=true,outputPackagePath=github.com/kcp-dev/client-go,name=kubernetes,apiPackagePath=k8s.io/api,singleClusterClientPackagePath=k8s.io/client-go/kubernetes,singleClusterApplyConfigurationsPackagePath=k8s.io/client-go/applyconfigurations,headerFile=./hack/boilerplate/boilerplate.go.txt" \ - "lister:apiPackagePath=k8s.io/api,singleClusterListerPackagePath=k8s.io/client-go/listers,headerFile=./hack/boilerplate/boilerplate.go.txt" \ - "informer:clientsetName=kubernetes,externalOnly=true,standalone=true,outputPackagePath=github.com/kcp-dev/client-go,apiPackagePath=k8s.io/api,singleClusterClientPackagePath=k8s.io/client-go/kubernetes, singleClusterListerPackagePath=k8s.io/client-go/listers,singleClusterInformerPackagePath=k8s.io/client-go/informers,headerFile=./hack/boilerplate/boilerplate.go.txt" \ - "paths=$( go list -m -json k8s.io/api | jq --raw-output .Dir )/..." \ - "output:dir=./" +CLUSTER_CODEGEN_PKG="$(go list -f '{{.Dir}}' -m github.com/kcp-dev/code-generator/v3)" +source "$CLUSTER_CODEGEN_PKG/cluster_codegen.sh" -${CODE_GENERATOR} \ - "client:externalOnly=true,standalone=true,outputPackagePath=github.com/kcp-dev/client-go/apiextensions,name=client,apiPackagePath=k8s.io/apiextensions-apiserver/pkg/apis,singleClusterClientPackagePath=k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset,singleClusterApplyConfigurationsPackagePath=k8s.io/apiextensions-apiserver/pkg/client/applyconfiguration,headerFile=./hack/boilerplate/boilerplate.go.txt" \ - "lister:apiPackagePath=k8s.io/apiextensions-apiserver/pkg/apis,singleClusterListerPackagePath=k8s.io/apiextensions-apiserver/pkg/client/listers,headerFile=./hack/boilerplate/boilerplate.go.txt" \ - "informer:clientsetName=client,externalOnly=true,standalone=true,outputPackagePath=github.com/kcp-dev/client-go/apiextensions,apiPackagePath=k8s.io/apiextensions-apiserver/pkg/apis,singleClusterClientPackagePath=k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset, singleClusterListerPackagePath=k8s.io/apiextensions-apiserver/pkg/client/listers,singleClusterInformerPackagePath=k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions,headerFile=./hack/boilerplate/boilerplate.go.txt" \ - "paths=$( go list -m -json k8s.io/apiextensions-apiserver | jq --raw-output .Dir )/pkg/apis/..." \ - "output:dir=./apiextensions" +make clean-generated + +cluster::codegen::gen_client \ + --boilerplate ./hack/boilerplate/boilerplate.go.txt \ + --with-watch \ + --output-dir . \ + --output-pkg github.com/kcp-dev/client-go \ + --versioned-clientset-dir kubernetes \ + --versioned-clientset-pkg github.com/kcp-dev/client-go/kubernetes \ + --single-cluster-versioned-clientset-pkg k8s.io/client-go/kubernetes \ + --single-cluster-applyconfigurations-pkg k8s.io/client-go/applyconfigurations \ + --single-cluster-informers-pkg k8s.io/client-go/informers \ + --single-cluster-listers-pkg k8s.io/client-go/listers \ + --exclude-group-versions "imagepolicy/v1alpha1" \ + --plural-exceptions "Endpoints:Endpoints" \ + "$(go list -m -json k8s.io/api | jq --raw-output .Dir)" + +cluster::codegen::gen_client \ + --boilerplate ./hack/boilerplate/boilerplate.go.txt \ + --output-dir apiextensions \ + --output-pkg github.com/kcp-dev/client-go/apiextensions \ + --with-watch \ + --versioned-clientset-pkg github.com/kcp-dev/client-go/apiextensions/client \ + --versioned-clientset-dir apiextensions/client \ + --single-cluster-versioned-clientset-pkg k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset \ + --single-cluster-applyconfigurations-pkg k8s.io/apiextensions-apiserver/pkg/client/applyconfiguration \ + --single-cluster-informers-pkg k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions \ + --single-cluster-listers-pkg k8s.io/apiextensions-apiserver/pkg/client/listers \ + "$(go list -m -json k8s.io/apiextensions-apiserver | jq --raw-output .Dir)/pkg/apis" diff --git a/informers/admissionregistration/interface.go b/informers/admissionregistration/interface.go index d8a49dcb5..bd62b673e 100644 --- a/informers/admissionregistration/interface.go +++ b/informers/admissionregistration/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,47 +14,48 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package admissionregistration import ( - "github.com/kcp-dev/client-go/informers/admissionregistration/v1" - "github.com/kcp-dev/client-go/informers/admissionregistration/v1alpha1" - "github.com/kcp-dev/client-go/informers/admissionregistration/v1beta1" - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpv1 "github.com/kcp-dev/client-go/informers/admissionregistration/v1" + kcpv1alpha1 "github.com/kcp-dev/client-go/informers/admissionregistration/v1alpha1" + kcpv1beta1 "github.com/kcp-dev/client-go/informers/admissionregistration/v1beta1" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) +// ClusterInterface provides access to each of this group's versions. type ClusterInterface interface { - // V1 provides access to the shared informers in V1. - V1() v1.ClusterInterface - // V1alpha1 provides access to the shared informers in V1alpha1. - V1alpha1() v1alpha1.ClusterInterface - // V1beta1 provides access to the shared informers in V1beta1. - V1beta1() v1beta1.ClusterInterface + // V1 provides access to shared informers for resources in V1. + V1() kcpv1.ClusterInterface + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() kcpv1alpha1.ClusterInterface + // V1beta1 provides access to shared informers for resources in V1beta1. + V1beta1() kcpv1beta1.ClusterInterface } type group struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &group{factory: f, tweakListOptions: tweakListOptions} } -// V1 returns a new v1.ClusterInterface. -func (g *group) V1() v1.ClusterInterface { - return v1.New(g.factory, g.tweakListOptions) +// V1 returns a new kcpv1.ClusterInterface. +func (g *group) V1() kcpv1.ClusterInterface { + return kcpv1.New(g.factory, g.tweakListOptions) } -// V1alpha1 returns a new v1alpha1.ClusterInterface. -func (g *group) V1alpha1() v1alpha1.ClusterInterface { - return v1alpha1.New(g.factory, g.tweakListOptions) +// V1alpha1 returns a new kcpv1alpha1.ClusterInterface. +func (g *group) V1alpha1() kcpv1alpha1.ClusterInterface { + return kcpv1alpha1.New(g.factory, g.tweakListOptions) } -// V1beta1 returns a new v1beta1.ClusterInterface. -func (g *group) V1beta1() v1beta1.ClusterInterface { - return v1beta1.New(g.factory, g.tweakListOptions) +// V1beta1 returns a new kcpv1beta1.ClusterInterface. +func (g *group) V1beta1() kcpv1beta1.ClusterInterface { + return kcpv1beta1.New(g.factory, g.tweakListOptions) } diff --git a/informers/admissionregistration/v1/interface.go b/informers/admissionregistration/v1/interface.go index c9a914cfd..b99bed489 100644 --- a/informers/admissionregistration/v1/interface.go +++ b/informers/admissionregistration/v1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,51 +14,51 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // ValidatingAdmissionPolicies returns a ValidatingAdmissionPolicyClusterInformer + // MutatingWebhookConfigurations returns a MutatingWebhookConfigurationClusterInformer. + MutatingWebhookConfigurations() MutatingWebhookConfigurationClusterInformer + // ValidatingAdmissionPolicies returns a ValidatingAdmissionPolicyClusterInformer. ValidatingAdmissionPolicies() ValidatingAdmissionPolicyClusterInformer - // ValidatingAdmissionPolicyBindings returns a ValidatingAdmissionPolicyBindingClusterInformer + // ValidatingAdmissionPolicyBindings returns a ValidatingAdmissionPolicyBindingClusterInformer. ValidatingAdmissionPolicyBindings() ValidatingAdmissionPolicyBindingClusterInformer - // ValidatingWebhookConfigurations returns a ValidatingWebhookConfigurationClusterInformer + // ValidatingWebhookConfigurations returns a ValidatingWebhookConfigurationClusterInformer. ValidatingWebhookConfigurations() ValidatingWebhookConfigurationClusterInformer - // MutatingWebhookConfigurations returns a MutatingWebhookConfigurationClusterInformer - MutatingWebhookConfigurations() MutatingWebhookConfigurationClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// ValidatingAdmissionPolicies returns a ValidatingAdmissionPolicyClusterInformer +// MutatingWebhookConfigurations returns a MutatingWebhookConfigurationClusterInformer. +func (v *version) MutatingWebhookConfigurations() MutatingWebhookConfigurationClusterInformer { + return &mutatingWebhookConfigurationClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + +// ValidatingAdmissionPolicies returns a ValidatingAdmissionPolicyClusterInformer. func (v *version) ValidatingAdmissionPolicies() ValidatingAdmissionPolicyClusterInformer { return &validatingAdmissionPolicyClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// ValidatingAdmissionPolicyBindings returns a ValidatingAdmissionPolicyBindingClusterInformer +// ValidatingAdmissionPolicyBindings returns a ValidatingAdmissionPolicyBindingClusterInformer. func (v *version) ValidatingAdmissionPolicyBindings() ValidatingAdmissionPolicyBindingClusterInformer { return &validatingAdmissionPolicyBindingClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// ValidatingWebhookConfigurations returns a ValidatingWebhookConfigurationClusterInformer +// ValidatingWebhookConfigurations returns a ValidatingWebhookConfigurationClusterInformer. func (v *version) ValidatingWebhookConfigurations() ValidatingWebhookConfigurationClusterInformer { return &validatingWebhookConfigurationClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } - -// MutatingWebhookConfigurations returns a MutatingWebhookConfigurationClusterInformer -func (v *version) MutatingWebhookConfigurations() MutatingWebhookConfigurationClusterInformer { - return &mutatingWebhookConfigurationClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} diff --git a/informers/admissionregistration/v1/mutatingwebhookconfiguration.go b/informers/admissionregistration/v1/mutatingwebhookconfiguration.go index 7ef9dc139..15e4e4169 100644 --- a/informers/admissionregistration/v1/mutatingwebhookconfiguration.go +++ b/informers/admissionregistration/v1/mutatingwebhookconfiguration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - admissionregistrationv1 "k8s.io/api/admissionregistration/v1" + apiadmissionregistrationv1 "k8s.io/api/admissionregistration/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamadmissionregistrationv1informers "k8s.io/client-go/informers/admissionregistration/v1" - upstreamadmissionregistrationv1listers "k8s.io/client-go/listers/admissionregistration/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - admissionregistrationv1listers "github.com/kcp-dev/client-go/listers/admissionregistration/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + admissionregistrationv1 "k8s.io/client-go/informers/admissionregistration/v1" + listersadmissionregistrationv1 "k8s.io/client-go/listers/admissionregistration/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/admissionregistration/v1" ) // MutatingWebhookConfigurationClusterInformer provides access to a shared informer and lister for // MutatingWebhookConfigurations. type MutatingWebhookConfigurationClusterInformer interface { - Cluster(logicalcluster.Name) upstreamadmissionregistrationv1informers.MutatingWebhookConfigurationInformer + Cluster(logicalcluster.Name) admissionregistrationv1.MutatingWebhookConfigurationInformer + ClusterWithContext(context.Context, logicalcluster.Name) admissionregistrationv1.MutatingWebhookConfigurationInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() admissionregistrationv1listers.MutatingWebhookConfigurationClusterLister + Lister() kcpv1.MutatingWebhookConfigurationClusterLister } type mutatingWebhookConfigurationClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewMutatingWebhookConfigurationClusterInformer constructs a new informer for MutatingWebhookConfiguration type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewMutatingWebhookConfigurationClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewMutatingWebhookConfigurationClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredMutatingWebhookConfigurationClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredMutatingWebhookConfigurationClusterInformer constructs a new informer for MutatingWebhookConfiguration type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredMutatingWebhookConfigurationClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredMutatingWebhookConfigurationClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AdmissionregistrationV1().MutatingWebhookConfigurations().List(context.TODO(), options) + return client.AdmissionregistrationV1().MutatingWebhookConfigurations().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AdmissionregistrationV1().MutatingWebhookConfigurations().Watch(context.TODO(), options) + return client.AdmissionregistrationV1().MutatingWebhookConfigurations().Watch(context.Background(), options) }, }, - &admissionregistrationv1.MutatingWebhookConfiguration{}, + &apiadmissionregistrationv1.MutatingWebhookConfiguration{}, resyncPeriod, indexers, ) } -func (f *mutatingWebhookConfigurationClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *mutatingWebhookConfigurationClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredMutatingWebhookConfigurationClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *mutatingWebhookConfigurationClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiadmissionregistrationv1.MutatingWebhookConfiguration{}, i.defaultInformer) } -func (f *mutatingWebhookConfigurationClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&admissionregistrationv1.MutatingWebhookConfiguration{}, f.defaultInformer) +func (i *mutatingWebhookConfigurationClusterInformer) Lister() kcpv1.MutatingWebhookConfigurationClusterLister { + return kcpv1.NewMutatingWebhookConfigurationClusterLister(i.Informer().GetIndexer()) } -func (f *mutatingWebhookConfigurationClusterInformer) Lister() admissionregistrationv1listers.MutatingWebhookConfigurationClusterLister { - return admissionregistrationv1listers.NewMutatingWebhookConfigurationClusterLister(f.Informer().GetIndexer()) +func (i *mutatingWebhookConfigurationClusterInformer) Cluster(clusterName logicalcluster.Name) admissionregistrationv1.MutatingWebhookConfigurationInformer { + return &mutatingWebhookConfigurationInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *mutatingWebhookConfigurationClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamadmissionregistrationv1informers.MutatingWebhookConfigurationInformer { +func (i *mutatingWebhookConfigurationClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) admissionregistrationv1.MutatingWebhookConfigurationInformer { return &mutatingWebhookConfigurationInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type mutatingWebhookConfigurationInformer struct { informer cache.SharedIndexInformer - lister upstreamadmissionregistrationv1listers.MutatingWebhookConfigurationLister + lister listersadmissionregistrationv1.MutatingWebhookConfigurationLister } -func (f *mutatingWebhookConfigurationInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *mutatingWebhookConfigurationInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *mutatingWebhookConfigurationInformer) Lister() upstreamadmissionregistrationv1listers.MutatingWebhookConfigurationLister { - return f.lister +func (i *mutatingWebhookConfigurationInformer) Lister() listersadmissionregistrationv1.MutatingWebhookConfigurationLister { + return i.lister } diff --git a/informers/admissionregistration/v1/validatingadmissionpolicy.go b/informers/admissionregistration/v1/validatingadmissionpolicy.go index c007908aa..7c96bef7b 100644 --- a/informers/admissionregistration/v1/validatingadmissionpolicy.go +++ b/informers/admissionregistration/v1/validatingadmissionpolicy.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - admissionregistrationv1 "k8s.io/api/admissionregistration/v1" + apiadmissionregistrationv1 "k8s.io/api/admissionregistration/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamadmissionregistrationv1informers "k8s.io/client-go/informers/admissionregistration/v1" - upstreamadmissionregistrationv1listers "k8s.io/client-go/listers/admissionregistration/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - admissionregistrationv1listers "github.com/kcp-dev/client-go/listers/admissionregistration/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + admissionregistrationv1 "k8s.io/client-go/informers/admissionregistration/v1" + listersadmissionregistrationv1 "k8s.io/client-go/listers/admissionregistration/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/admissionregistration/v1" ) // ValidatingAdmissionPolicyClusterInformer provides access to a shared informer and lister for // ValidatingAdmissionPolicies. type ValidatingAdmissionPolicyClusterInformer interface { - Cluster(logicalcluster.Name) upstreamadmissionregistrationv1informers.ValidatingAdmissionPolicyInformer + Cluster(logicalcluster.Name) admissionregistrationv1.ValidatingAdmissionPolicyInformer + ClusterWithContext(context.Context, logicalcluster.Name) admissionregistrationv1.ValidatingAdmissionPolicyInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() admissionregistrationv1listers.ValidatingAdmissionPolicyClusterLister + Lister() kcpv1.ValidatingAdmissionPolicyClusterLister } type validatingAdmissionPolicyClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewValidatingAdmissionPolicyClusterInformer constructs a new informer for ValidatingAdmissionPolicy type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewValidatingAdmissionPolicyClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewValidatingAdmissionPolicyClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredValidatingAdmissionPolicyClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredValidatingAdmissionPolicyClusterInformer constructs a new informer for ValidatingAdmissionPolicy type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredValidatingAdmissionPolicyClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredValidatingAdmissionPolicyClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AdmissionregistrationV1().ValidatingAdmissionPolicies().List(context.TODO(), options) + return client.AdmissionregistrationV1().ValidatingAdmissionPolicies().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AdmissionregistrationV1().ValidatingAdmissionPolicies().Watch(context.TODO(), options) + return client.AdmissionregistrationV1().ValidatingAdmissionPolicies().Watch(context.Background(), options) }, }, - &admissionregistrationv1.ValidatingAdmissionPolicy{}, + &apiadmissionregistrationv1.ValidatingAdmissionPolicy{}, resyncPeriod, indexers, ) } -func (f *validatingAdmissionPolicyClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *validatingAdmissionPolicyClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredValidatingAdmissionPolicyClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *validatingAdmissionPolicyClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiadmissionregistrationv1.ValidatingAdmissionPolicy{}, i.defaultInformer) } -func (f *validatingAdmissionPolicyClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&admissionregistrationv1.ValidatingAdmissionPolicy{}, f.defaultInformer) +func (i *validatingAdmissionPolicyClusterInformer) Lister() kcpv1.ValidatingAdmissionPolicyClusterLister { + return kcpv1.NewValidatingAdmissionPolicyClusterLister(i.Informer().GetIndexer()) } -func (f *validatingAdmissionPolicyClusterInformer) Lister() admissionregistrationv1listers.ValidatingAdmissionPolicyClusterLister { - return admissionregistrationv1listers.NewValidatingAdmissionPolicyClusterLister(f.Informer().GetIndexer()) +func (i *validatingAdmissionPolicyClusterInformer) Cluster(clusterName logicalcluster.Name) admissionregistrationv1.ValidatingAdmissionPolicyInformer { + return &validatingAdmissionPolicyInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *validatingAdmissionPolicyClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamadmissionregistrationv1informers.ValidatingAdmissionPolicyInformer { +func (i *validatingAdmissionPolicyClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) admissionregistrationv1.ValidatingAdmissionPolicyInformer { return &validatingAdmissionPolicyInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type validatingAdmissionPolicyInformer struct { informer cache.SharedIndexInformer - lister upstreamadmissionregistrationv1listers.ValidatingAdmissionPolicyLister + lister listersadmissionregistrationv1.ValidatingAdmissionPolicyLister } -func (f *validatingAdmissionPolicyInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *validatingAdmissionPolicyInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *validatingAdmissionPolicyInformer) Lister() upstreamadmissionregistrationv1listers.ValidatingAdmissionPolicyLister { - return f.lister +func (i *validatingAdmissionPolicyInformer) Lister() listersadmissionregistrationv1.ValidatingAdmissionPolicyLister { + return i.lister } diff --git a/informers/admissionregistration/v1/validatingadmissionpolicybinding.go b/informers/admissionregistration/v1/validatingadmissionpolicybinding.go index 7fb69730c..ceffd8f00 100644 --- a/informers/admissionregistration/v1/validatingadmissionpolicybinding.go +++ b/informers/admissionregistration/v1/validatingadmissionpolicybinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - admissionregistrationv1 "k8s.io/api/admissionregistration/v1" + apiadmissionregistrationv1 "k8s.io/api/admissionregistration/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamadmissionregistrationv1informers "k8s.io/client-go/informers/admissionregistration/v1" - upstreamadmissionregistrationv1listers "k8s.io/client-go/listers/admissionregistration/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - admissionregistrationv1listers "github.com/kcp-dev/client-go/listers/admissionregistration/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + admissionregistrationv1 "k8s.io/client-go/informers/admissionregistration/v1" + listersadmissionregistrationv1 "k8s.io/client-go/listers/admissionregistration/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/admissionregistration/v1" ) // ValidatingAdmissionPolicyBindingClusterInformer provides access to a shared informer and lister for // ValidatingAdmissionPolicyBindings. type ValidatingAdmissionPolicyBindingClusterInformer interface { - Cluster(logicalcluster.Name) upstreamadmissionregistrationv1informers.ValidatingAdmissionPolicyBindingInformer + Cluster(logicalcluster.Name) admissionregistrationv1.ValidatingAdmissionPolicyBindingInformer + ClusterWithContext(context.Context, logicalcluster.Name) admissionregistrationv1.ValidatingAdmissionPolicyBindingInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() admissionregistrationv1listers.ValidatingAdmissionPolicyBindingClusterLister + Lister() kcpv1.ValidatingAdmissionPolicyBindingClusterLister } type validatingAdmissionPolicyBindingClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewValidatingAdmissionPolicyBindingClusterInformer constructs a new informer for ValidatingAdmissionPolicyBinding type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewValidatingAdmissionPolicyBindingClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewValidatingAdmissionPolicyBindingClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredValidatingAdmissionPolicyBindingClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredValidatingAdmissionPolicyBindingClusterInformer constructs a new informer for ValidatingAdmissionPolicyBinding type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredValidatingAdmissionPolicyBindingClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredValidatingAdmissionPolicyBindingClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AdmissionregistrationV1().ValidatingAdmissionPolicyBindings().List(context.TODO(), options) + return client.AdmissionregistrationV1().ValidatingAdmissionPolicyBindings().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AdmissionregistrationV1().ValidatingAdmissionPolicyBindings().Watch(context.TODO(), options) + return client.AdmissionregistrationV1().ValidatingAdmissionPolicyBindings().Watch(context.Background(), options) }, }, - &admissionregistrationv1.ValidatingAdmissionPolicyBinding{}, + &apiadmissionregistrationv1.ValidatingAdmissionPolicyBinding{}, resyncPeriod, indexers, ) } -func (f *validatingAdmissionPolicyBindingClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *validatingAdmissionPolicyBindingClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredValidatingAdmissionPolicyBindingClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *validatingAdmissionPolicyBindingClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiadmissionregistrationv1.ValidatingAdmissionPolicyBinding{}, i.defaultInformer) } -func (f *validatingAdmissionPolicyBindingClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&admissionregistrationv1.ValidatingAdmissionPolicyBinding{}, f.defaultInformer) +func (i *validatingAdmissionPolicyBindingClusterInformer) Lister() kcpv1.ValidatingAdmissionPolicyBindingClusterLister { + return kcpv1.NewValidatingAdmissionPolicyBindingClusterLister(i.Informer().GetIndexer()) } -func (f *validatingAdmissionPolicyBindingClusterInformer) Lister() admissionregistrationv1listers.ValidatingAdmissionPolicyBindingClusterLister { - return admissionregistrationv1listers.NewValidatingAdmissionPolicyBindingClusterLister(f.Informer().GetIndexer()) +func (i *validatingAdmissionPolicyBindingClusterInformer) Cluster(clusterName logicalcluster.Name) admissionregistrationv1.ValidatingAdmissionPolicyBindingInformer { + return &validatingAdmissionPolicyBindingInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *validatingAdmissionPolicyBindingClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamadmissionregistrationv1informers.ValidatingAdmissionPolicyBindingInformer { +func (i *validatingAdmissionPolicyBindingClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) admissionregistrationv1.ValidatingAdmissionPolicyBindingInformer { return &validatingAdmissionPolicyBindingInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type validatingAdmissionPolicyBindingInformer struct { informer cache.SharedIndexInformer - lister upstreamadmissionregistrationv1listers.ValidatingAdmissionPolicyBindingLister + lister listersadmissionregistrationv1.ValidatingAdmissionPolicyBindingLister } -func (f *validatingAdmissionPolicyBindingInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *validatingAdmissionPolicyBindingInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *validatingAdmissionPolicyBindingInformer) Lister() upstreamadmissionregistrationv1listers.ValidatingAdmissionPolicyBindingLister { - return f.lister +func (i *validatingAdmissionPolicyBindingInformer) Lister() listersadmissionregistrationv1.ValidatingAdmissionPolicyBindingLister { + return i.lister } diff --git a/informers/admissionregistration/v1/validatingwebhookconfiguration.go b/informers/admissionregistration/v1/validatingwebhookconfiguration.go index 68e672d66..b51a58c29 100644 --- a/informers/admissionregistration/v1/validatingwebhookconfiguration.go +++ b/informers/admissionregistration/v1/validatingwebhookconfiguration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - admissionregistrationv1 "k8s.io/api/admissionregistration/v1" + apiadmissionregistrationv1 "k8s.io/api/admissionregistration/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamadmissionregistrationv1informers "k8s.io/client-go/informers/admissionregistration/v1" - upstreamadmissionregistrationv1listers "k8s.io/client-go/listers/admissionregistration/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - admissionregistrationv1listers "github.com/kcp-dev/client-go/listers/admissionregistration/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + admissionregistrationv1 "k8s.io/client-go/informers/admissionregistration/v1" + listersadmissionregistrationv1 "k8s.io/client-go/listers/admissionregistration/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/admissionregistration/v1" ) // ValidatingWebhookConfigurationClusterInformer provides access to a shared informer and lister for // ValidatingWebhookConfigurations. type ValidatingWebhookConfigurationClusterInformer interface { - Cluster(logicalcluster.Name) upstreamadmissionregistrationv1informers.ValidatingWebhookConfigurationInformer + Cluster(logicalcluster.Name) admissionregistrationv1.ValidatingWebhookConfigurationInformer + ClusterWithContext(context.Context, logicalcluster.Name) admissionregistrationv1.ValidatingWebhookConfigurationInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() admissionregistrationv1listers.ValidatingWebhookConfigurationClusterLister + Lister() kcpv1.ValidatingWebhookConfigurationClusterLister } type validatingWebhookConfigurationClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewValidatingWebhookConfigurationClusterInformer constructs a new informer for ValidatingWebhookConfiguration type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewValidatingWebhookConfigurationClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewValidatingWebhookConfigurationClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredValidatingWebhookConfigurationClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredValidatingWebhookConfigurationClusterInformer constructs a new informer for ValidatingWebhookConfiguration type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredValidatingWebhookConfigurationClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredValidatingWebhookConfigurationClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AdmissionregistrationV1().ValidatingWebhookConfigurations().List(context.TODO(), options) + return client.AdmissionregistrationV1().ValidatingWebhookConfigurations().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AdmissionregistrationV1().ValidatingWebhookConfigurations().Watch(context.TODO(), options) + return client.AdmissionregistrationV1().ValidatingWebhookConfigurations().Watch(context.Background(), options) }, }, - &admissionregistrationv1.ValidatingWebhookConfiguration{}, + &apiadmissionregistrationv1.ValidatingWebhookConfiguration{}, resyncPeriod, indexers, ) } -func (f *validatingWebhookConfigurationClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *validatingWebhookConfigurationClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredValidatingWebhookConfigurationClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *validatingWebhookConfigurationClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiadmissionregistrationv1.ValidatingWebhookConfiguration{}, i.defaultInformer) } -func (f *validatingWebhookConfigurationClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&admissionregistrationv1.ValidatingWebhookConfiguration{}, f.defaultInformer) +func (i *validatingWebhookConfigurationClusterInformer) Lister() kcpv1.ValidatingWebhookConfigurationClusterLister { + return kcpv1.NewValidatingWebhookConfigurationClusterLister(i.Informer().GetIndexer()) } -func (f *validatingWebhookConfigurationClusterInformer) Lister() admissionregistrationv1listers.ValidatingWebhookConfigurationClusterLister { - return admissionregistrationv1listers.NewValidatingWebhookConfigurationClusterLister(f.Informer().GetIndexer()) +func (i *validatingWebhookConfigurationClusterInformer) Cluster(clusterName logicalcluster.Name) admissionregistrationv1.ValidatingWebhookConfigurationInformer { + return &validatingWebhookConfigurationInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *validatingWebhookConfigurationClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamadmissionregistrationv1informers.ValidatingWebhookConfigurationInformer { +func (i *validatingWebhookConfigurationClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) admissionregistrationv1.ValidatingWebhookConfigurationInformer { return &validatingWebhookConfigurationInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type validatingWebhookConfigurationInformer struct { informer cache.SharedIndexInformer - lister upstreamadmissionregistrationv1listers.ValidatingWebhookConfigurationLister + lister listersadmissionregistrationv1.ValidatingWebhookConfigurationLister } -func (f *validatingWebhookConfigurationInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *validatingWebhookConfigurationInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *validatingWebhookConfigurationInformer) Lister() upstreamadmissionregistrationv1listers.ValidatingWebhookConfigurationLister { - return f.lister +func (i *validatingWebhookConfigurationInformer) Lister() listersadmissionregistrationv1.ValidatingWebhookConfigurationLister { + return i.lister } diff --git a/informers/admissionregistration/v1alpha1/interface.go b/informers/admissionregistration/v1alpha1/interface.go index 310c64724..4ef5057e0 100644 --- a/informers/admissionregistration/v1alpha1/interface.go +++ b/informers/admissionregistration/v1alpha1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,51 +14,51 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // ValidatingAdmissionPolicies returns a ValidatingAdmissionPolicyClusterInformer - ValidatingAdmissionPolicies() ValidatingAdmissionPolicyClusterInformer - // ValidatingAdmissionPolicyBindings returns a ValidatingAdmissionPolicyBindingClusterInformer - ValidatingAdmissionPolicyBindings() ValidatingAdmissionPolicyBindingClusterInformer - // MutatingAdmissionPolicies returns a MutatingAdmissionPolicyClusterInformer + // MutatingAdmissionPolicies returns a MutatingAdmissionPolicyClusterInformer. MutatingAdmissionPolicies() MutatingAdmissionPolicyClusterInformer - // MutatingAdmissionPolicyBindings returns a MutatingAdmissionPolicyBindingClusterInformer + // MutatingAdmissionPolicyBindings returns a MutatingAdmissionPolicyBindingClusterInformer. MutatingAdmissionPolicyBindings() MutatingAdmissionPolicyBindingClusterInformer + // ValidatingAdmissionPolicies returns a ValidatingAdmissionPolicyClusterInformer. + ValidatingAdmissionPolicies() ValidatingAdmissionPolicyClusterInformer + // ValidatingAdmissionPolicyBindings returns a ValidatingAdmissionPolicyBindingClusterInformer. + ValidatingAdmissionPolicyBindings() ValidatingAdmissionPolicyBindingClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// ValidatingAdmissionPolicies returns a ValidatingAdmissionPolicyClusterInformer -func (v *version) ValidatingAdmissionPolicies() ValidatingAdmissionPolicyClusterInformer { - return &validatingAdmissionPolicyClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} - -// ValidatingAdmissionPolicyBindings returns a ValidatingAdmissionPolicyBindingClusterInformer -func (v *version) ValidatingAdmissionPolicyBindings() ValidatingAdmissionPolicyBindingClusterInformer { - return &validatingAdmissionPolicyBindingClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} - -// MutatingAdmissionPolicies returns a MutatingAdmissionPolicyClusterInformer +// MutatingAdmissionPolicies returns a MutatingAdmissionPolicyClusterInformer. func (v *version) MutatingAdmissionPolicies() MutatingAdmissionPolicyClusterInformer { return &mutatingAdmissionPolicyClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// MutatingAdmissionPolicyBindings returns a MutatingAdmissionPolicyBindingClusterInformer +// MutatingAdmissionPolicyBindings returns a MutatingAdmissionPolicyBindingClusterInformer. func (v *version) MutatingAdmissionPolicyBindings() MutatingAdmissionPolicyBindingClusterInformer { return &mutatingAdmissionPolicyBindingClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } + +// ValidatingAdmissionPolicies returns a ValidatingAdmissionPolicyClusterInformer. +func (v *version) ValidatingAdmissionPolicies() ValidatingAdmissionPolicyClusterInformer { + return &validatingAdmissionPolicyClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + +// ValidatingAdmissionPolicyBindings returns a ValidatingAdmissionPolicyBindingClusterInformer. +func (v *version) ValidatingAdmissionPolicyBindings() ValidatingAdmissionPolicyBindingClusterInformer { + return &validatingAdmissionPolicyBindingClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} diff --git a/informers/admissionregistration/v1alpha1/mutatingadmissionpolicy.go b/informers/admissionregistration/v1alpha1/mutatingadmissionpolicy.go index 8a5ad638b..bd3b4c9cd 100644 --- a/informers/admissionregistration/v1alpha1/mutatingadmissionpolicy.go +++ b/informers/admissionregistration/v1alpha1/mutatingadmissionpolicy.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - admissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamadmissionregistrationv1alpha1informers "k8s.io/client-go/informers/admissionregistration/v1alpha1" - upstreamadmissionregistrationv1alpha1listers "k8s.io/client-go/listers/admissionregistration/v1alpha1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - admissionregistrationv1alpha1listers "github.com/kcp-dev/client-go/listers/admissionregistration/v1alpha1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiadmissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + admissionregistrationv1alpha1 "k8s.io/client-go/informers/admissionregistration/v1alpha1" + listersadmissionregistrationv1alpha1 "k8s.io/client-go/listers/admissionregistration/v1alpha1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1alpha1 "github.com/kcp-dev/client-go/listers/admissionregistration/v1alpha1" ) // MutatingAdmissionPolicyClusterInformer provides access to a shared informer and lister for // MutatingAdmissionPolicies. type MutatingAdmissionPolicyClusterInformer interface { - Cluster(logicalcluster.Name) upstreamadmissionregistrationv1alpha1informers.MutatingAdmissionPolicyInformer + Cluster(logicalcluster.Name) admissionregistrationv1alpha1.MutatingAdmissionPolicyInformer + ClusterWithContext(context.Context, logicalcluster.Name) admissionregistrationv1alpha1.MutatingAdmissionPolicyInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() admissionregistrationv1alpha1listers.MutatingAdmissionPolicyClusterLister + Lister() kcpv1alpha1.MutatingAdmissionPolicyClusterLister } type mutatingAdmissionPolicyClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewMutatingAdmissionPolicyClusterInformer constructs a new informer for MutatingAdmissionPolicy type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewMutatingAdmissionPolicyClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewMutatingAdmissionPolicyClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredMutatingAdmissionPolicyClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredMutatingAdmissionPolicyClusterInformer constructs a new informer for MutatingAdmissionPolicy type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredMutatingAdmissionPolicyClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredMutatingAdmissionPolicyClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AdmissionregistrationV1alpha1().MutatingAdmissionPolicies().List(context.TODO(), options) + return client.AdmissionregistrationV1alpha1().MutatingAdmissionPolicies().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AdmissionregistrationV1alpha1().MutatingAdmissionPolicies().Watch(context.TODO(), options) + return client.AdmissionregistrationV1alpha1().MutatingAdmissionPolicies().Watch(context.Background(), options) }, }, - &admissionregistrationv1alpha1.MutatingAdmissionPolicy{}, + &apiadmissionregistrationv1alpha1.MutatingAdmissionPolicy{}, resyncPeriod, indexers, ) } -func (f *mutatingAdmissionPolicyClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *mutatingAdmissionPolicyClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredMutatingAdmissionPolicyClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *mutatingAdmissionPolicyClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiadmissionregistrationv1alpha1.MutatingAdmissionPolicy{}, i.defaultInformer) } -func (f *mutatingAdmissionPolicyClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&admissionregistrationv1alpha1.MutatingAdmissionPolicy{}, f.defaultInformer) +func (i *mutatingAdmissionPolicyClusterInformer) Lister() kcpv1alpha1.MutatingAdmissionPolicyClusterLister { + return kcpv1alpha1.NewMutatingAdmissionPolicyClusterLister(i.Informer().GetIndexer()) } -func (f *mutatingAdmissionPolicyClusterInformer) Lister() admissionregistrationv1alpha1listers.MutatingAdmissionPolicyClusterLister { - return admissionregistrationv1alpha1listers.NewMutatingAdmissionPolicyClusterLister(f.Informer().GetIndexer()) +func (i *mutatingAdmissionPolicyClusterInformer) Cluster(clusterName logicalcluster.Name) admissionregistrationv1alpha1.MutatingAdmissionPolicyInformer { + return &mutatingAdmissionPolicyInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *mutatingAdmissionPolicyClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamadmissionregistrationv1alpha1informers.MutatingAdmissionPolicyInformer { +func (i *mutatingAdmissionPolicyClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) admissionregistrationv1alpha1.MutatingAdmissionPolicyInformer { return &mutatingAdmissionPolicyInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type mutatingAdmissionPolicyInformer struct { informer cache.SharedIndexInformer - lister upstreamadmissionregistrationv1alpha1listers.MutatingAdmissionPolicyLister + lister listersadmissionregistrationv1alpha1.MutatingAdmissionPolicyLister } -func (f *mutatingAdmissionPolicyInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *mutatingAdmissionPolicyInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *mutatingAdmissionPolicyInformer) Lister() upstreamadmissionregistrationv1alpha1listers.MutatingAdmissionPolicyLister { - return f.lister +func (i *mutatingAdmissionPolicyInformer) Lister() listersadmissionregistrationv1alpha1.MutatingAdmissionPolicyLister { + return i.lister } diff --git a/informers/admissionregistration/v1alpha1/mutatingadmissionpolicybinding.go b/informers/admissionregistration/v1alpha1/mutatingadmissionpolicybinding.go index 403921714..286934353 100644 --- a/informers/admissionregistration/v1alpha1/mutatingadmissionpolicybinding.go +++ b/informers/admissionregistration/v1alpha1/mutatingadmissionpolicybinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - admissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamadmissionregistrationv1alpha1informers "k8s.io/client-go/informers/admissionregistration/v1alpha1" - upstreamadmissionregistrationv1alpha1listers "k8s.io/client-go/listers/admissionregistration/v1alpha1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - admissionregistrationv1alpha1listers "github.com/kcp-dev/client-go/listers/admissionregistration/v1alpha1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiadmissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + admissionregistrationv1alpha1 "k8s.io/client-go/informers/admissionregistration/v1alpha1" + listersadmissionregistrationv1alpha1 "k8s.io/client-go/listers/admissionregistration/v1alpha1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1alpha1 "github.com/kcp-dev/client-go/listers/admissionregistration/v1alpha1" ) // MutatingAdmissionPolicyBindingClusterInformer provides access to a shared informer and lister for // MutatingAdmissionPolicyBindings. type MutatingAdmissionPolicyBindingClusterInformer interface { - Cluster(logicalcluster.Name) upstreamadmissionregistrationv1alpha1informers.MutatingAdmissionPolicyBindingInformer + Cluster(logicalcluster.Name) admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingInformer + ClusterWithContext(context.Context, logicalcluster.Name) admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() admissionregistrationv1alpha1listers.MutatingAdmissionPolicyBindingClusterLister + Lister() kcpv1alpha1.MutatingAdmissionPolicyBindingClusterLister } type mutatingAdmissionPolicyBindingClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewMutatingAdmissionPolicyBindingClusterInformer constructs a new informer for MutatingAdmissionPolicyBinding type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewMutatingAdmissionPolicyBindingClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewMutatingAdmissionPolicyBindingClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredMutatingAdmissionPolicyBindingClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredMutatingAdmissionPolicyBindingClusterInformer constructs a new informer for MutatingAdmissionPolicyBinding type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredMutatingAdmissionPolicyBindingClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredMutatingAdmissionPolicyBindingClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AdmissionregistrationV1alpha1().MutatingAdmissionPolicyBindings().List(context.TODO(), options) + return client.AdmissionregistrationV1alpha1().MutatingAdmissionPolicyBindings().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AdmissionregistrationV1alpha1().MutatingAdmissionPolicyBindings().Watch(context.TODO(), options) + return client.AdmissionregistrationV1alpha1().MutatingAdmissionPolicyBindings().Watch(context.Background(), options) }, }, - &admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding{}, + &apiadmissionregistrationv1alpha1.MutatingAdmissionPolicyBinding{}, resyncPeriod, indexers, ) } -func (f *mutatingAdmissionPolicyBindingClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *mutatingAdmissionPolicyBindingClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredMutatingAdmissionPolicyBindingClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *mutatingAdmissionPolicyBindingClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiadmissionregistrationv1alpha1.MutatingAdmissionPolicyBinding{}, i.defaultInformer) } -func (f *mutatingAdmissionPolicyBindingClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding{}, f.defaultInformer) +func (i *mutatingAdmissionPolicyBindingClusterInformer) Lister() kcpv1alpha1.MutatingAdmissionPolicyBindingClusterLister { + return kcpv1alpha1.NewMutatingAdmissionPolicyBindingClusterLister(i.Informer().GetIndexer()) } -func (f *mutatingAdmissionPolicyBindingClusterInformer) Lister() admissionregistrationv1alpha1listers.MutatingAdmissionPolicyBindingClusterLister { - return admissionregistrationv1alpha1listers.NewMutatingAdmissionPolicyBindingClusterLister(f.Informer().GetIndexer()) +func (i *mutatingAdmissionPolicyBindingClusterInformer) Cluster(clusterName logicalcluster.Name) admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingInformer { + return &mutatingAdmissionPolicyBindingInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *mutatingAdmissionPolicyBindingClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamadmissionregistrationv1alpha1informers.MutatingAdmissionPolicyBindingInformer { +func (i *mutatingAdmissionPolicyBindingClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingInformer { return &mutatingAdmissionPolicyBindingInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type mutatingAdmissionPolicyBindingInformer struct { informer cache.SharedIndexInformer - lister upstreamadmissionregistrationv1alpha1listers.MutatingAdmissionPolicyBindingLister + lister listersadmissionregistrationv1alpha1.MutatingAdmissionPolicyBindingLister } -func (f *mutatingAdmissionPolicyBindingInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *mutatingAdmissionPolicyBindingInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *mutatingAdmissionPolicyBindingInformer) Lister() upstreamadmissionregistrationv1alpha1listers.MutatingAdmissionPolicyBindingLister { - return f.lister +func (i *mutatingAdmissionPolicyBindingInformer) Lister() listersadmissionregistrationv1alpha1.MutatingAdmissionPolicyBindingLister { + return i.lister } diff --git a/informers/admissionregistration/v1alpha1/validatingadmissionpolicy.go b/informers/admissionregistration/v1alpha1/validatingadmissionpolicy.go index 9182f9252..5ad1a9fa6 100644 --- a/informers/admissionregistration/v1alpha1/validatingadmissionpolicy.go +++ b/informers/admissionregistration/v1alpha1/validatingadmissionpolicy.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - admissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamadmissionregistrationv1alpha1informers "k8s.io/client-go/informers/admissionregistration/v1alpha1" - upstreamadmissionregistrationv1alpha1listers "k8s.io/client-go/listers/admissionregistration/v1alpha1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - admissionregistrationv1alpha1listers "github.com/kcp-dev/client-go/listers/admissionregistration/v1alpha1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiadmissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + admissionregistrationv1alpha1 "k8s.io/client-go/informers/admissionregistration/v1alpha1" + listersadmissionregistrationv1alpha1 "k8s.io/client-go/listers/admissionregistration/v1alpha1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1alpha1 "github.com/kcp-dev/client-go/listers/admissionregistration/v1alpha1" ) // ValidatingAdmissionPolicyClusterInformer provides access to a shared informer and lister for // ValidatingAdmissionPolicies. type ValidatingAdmissionPolicyClusterInformer interface { - Cluster(logicalcluster.Name) upstreamadmissionregistrationv1alpha1informers.ValidatingAdmissionPolicyInformer + Cluster(logicalcluster.Name) admissionregistrationv1alpha1.ValidatingAdmissionPolicyInformer + ClusterWithContext(context.Context, logicalcluster.Name) admissionregistrationv1alpha1.ValidatingAdmissionPolicyInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() admissionregistrationv1alpha1listers.ValidatingAdmissionPolicyClusterLister + Lister() kcpv1alpha1.ValidatingAdmissionPolicyClusterLister } type validatingAdmissionPolicyClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewValidatingAdmissionPolicyClusterInformer constructs a new informer for ValidatingAdmissionPolicy type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewValidatingAdmissionPolicyClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewValidatingAdmissionPolicyClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredValidatingAdmissionPolicyClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredValidatingAdmissionPolicyClusterInformer constructs a new informer for ValidatingAdmissionPolicy type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredValidatingAdmissionPolicyClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredValidatingAdmissionPolicyClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AdmissionregistrationV1alpha1().ValidatingAdmissionPolicies().List(context.TODO(), options) + return client.AdmissionregistrationV1alpha1().ValidatingAdmissionPolicies().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AdmissionregistrationV1alpha1().ValidatingAdmissionPolicies().Watch(context.TODO(), options) + return client.AdmissionregistrationV1alpha1().ValidatingAdmissionPolicies().Watch(context.Background(), options) }, }, - &admissionregistrationv1alpha1.ValidatingAdmissionPolicy{}, + &apiadmissionregistrationv1alpha1.ValidatingAdmissionPolicy{}, resyncPeriod, indexers, ) } -func (f *validatingAdmissionPolicyClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *validatingAdmissionPolicyClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredValidatingAdmissionPolicyClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *validatingAdmissionPolicyClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiadmissionregistrationv1alpha1.ValidatingAdmissionPolicy{}, i.defaultInformer) } -func (f *validatingAdmissionPolicyClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&admissionregistrationv1alpha1.ValidatingAdmissionPolicy{}, f.defaultInformer) +func (i *validatingAdmissionPolicyClusterInformer) Lister() kcpv1alpha1.ValidatingAdmissionPolicyClusterLister { + return kcpv1alpha1.NewValidatingAdmissionPolicyClusterLister(i.Informer().GetIndexer()) } -func (f *validatingAdmissionPolicyClusterInformer) Lister() admissionregistrationv1alpha1listers.ValidatingAdmissionPolicyClusterLister { - return admissionregistrationv1alpha1listers.NewValidatingAdmissionPolicyClusterLister(f.Informer().GetIndexer()) +func (i *validatingAdmissionPolicyClusterInformer) Cluster(clusterName logicalcluster.Name) admissionregistrationv1alpha1.ValidatingAdmissionPolicyInformer { + return &validatingAdmissionPolicyInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *validatingAdmissionPolicyClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamadmissionregistrationv1alpha1informers.ValidatingAdmissionPolicyInformer { +func (i *validatingAdmissionPolicyClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) admissionregistrationv1alpha1.ValidatingAdmissionPolicyInformer { return &validatingAdmissionPolicyInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type validatingAdmissionPolicyInformer struct { informer cache.SharedIndexInformer - lister upstreamadmissionregistrationv1alpha1listers.ValidatingAdmissionPolicyLister + lister listersadmissionregistrationv1alpha1.ValidatingAdmissionPolicyLister } -func (f *validatingAdmissionPolicyInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *validatingAdmissionPolicyInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *validatingAdmissionPolicyInformer) Lister() upstreamadmissionregistrationv1alpha1listers.ValidatingAdmissionPolicyLister { - return f.lister +func (i *validatingAdmissionPolicyInformer) Lister() listersadmissionregistrationv1alpha1.ValidatingAdmissionPolicyLister { + return i.lister } diff --git a/informers/admissionregistration/v1alpha1/validatingadmissionpolicybinding.go b/informers/admissionregistration/v1alpha1/validatingadmissionpolicybinding.go index e08ca91e6..25a18dc10 100644 --- a/informers/admissionregistration/v1alpha1/validatingadmissionpolicybinding.go +++ b/informers/admissionregistration/v1alpha1/validatingadmissionpolicybinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - admissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamadmissionregistrationv1alpha1informers "k8s.io/client-go/informers/admissionregistration/v1alpha1" - upstreamadmissionregistrationv1alpha1listers "k8s.io/client-go/listers/admissionregistration/v1alpha1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - admissionregistrationv1alpha1listers "github.com/kcp-dev/client-go/listers/admissionregistration/v1alpha1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiadmissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + admissionregistrationv1alpha1 "k8s.io/client-go/informers/admissionregistration/v1alpha1" + listersadmissionregistrationv1alpha1 "k8s.io/client-go/listers/admissionregistration/v1alpha1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1alpha1 "github.com/kcp-dev/client-go/listers/admissionregistration/v1alpha1" ) // ValidatingAdmissionPolicyBindingClusterInformer provides access to a shared informer and lister for // ValidatingAdmissionPolicyBindings. type ValidatingAdmissionPolicyBindingClusterInformer interface { - Cluster(logicalcluster.Name) upstreamadmissionregistrationv1alpha1informers.ValidatingAdmissionPolicyBindingInformer + Cluster(logicalcluster.Name) admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingInformer + ClusterWithContext(context.Context, logicalcluster.Name) admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() admissionregistrationv1alpha1listers.ValidatingAdmissionPolicyBindingClusterLister + Lister() kcpv1alpha1.ValidatingAdmissionPolicyBindingClusterLister } type validatingAdmissionPolicyBindingClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewValidatingAdmissionPolicyBindingClusterInformer constructs a new informer for ValidatingAdmissionPolicyBinding type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewValidatingAdmissionPolicyBindingClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewValidatingAdmissionPolicyBindingClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredValidatingAdmissionPolicyBindingClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredValidatingAdmissionPolicyBindingClusterInformer constructs a new informer for ValidatingAdmissionPolicyBinding type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredValidatingAdmissionPolicyBindingClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredValidatingAdmissionPolicyBindingClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AdmissionregistrationV1alpha1().ValidatingAdmissionPolicyBindings().List(context.TODO(), options) + return client.AdmissionregistrationV1alpha1().ValidatingAdmissionPolicyBindings().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AdmissionregistrationV1alpha1().ValidatingAdmissionPolicyBindings().Watch(context.TODO(), options) + return client.AdmissionregistrationV1alpha1().ValidatingAdmissionPolicyBindings().Watch(context.Background(), options) }, }, - &admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding{}, + &apiadmissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding{}, resyncPeriod, indexers, ) } -func (f *validatingAdmissionPolicyBindingClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *validatingAdmissionPolicyBindingClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredValidatingAdmissionPolicyBindingClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *validatingAdmissionPolicyBindingClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiadmissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding{}, i.defaultInformer) } -func (f *validatingAdmissionPolicyBindingClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding{}, f.defaultInformer) +func (i *validatingAdmissionPolicyBindingClusterInformer) Lister() kcpv1alpha1.ValidatingAdmissionPolicyBindingClusterLister { + return kcpv1alpha1.NewValidatingAdmissionPolicyBindingClusterLister(i.Informer().GetIndexer()) } -func (f *validatingAdmissionPolicyBindingClusterInformer) Lister() admissionregistrationv1alpha1listers.ValidatingAdmissionPolicyBindingClusterLister { - return admissionregistrationv1alpha1listers.NewValidatingAdmissionPolicyBindingClusterLister(f.Informer().GetIndexer()) +func (i *validatingAdmissionPolicyBindingClusterInformer) Cluster(clusterName logicalcluster.Name) admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingInformer { + return &validatingAdmissionPolicyBindingInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *validatingAdmissionPolicyBindingClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamadmissionregistrationv1alpha1informers.ValidatingAdmissionPolicyBindingInformer { +func (i *validatingAdmissionPolicyBindingClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingInformer { return &validatingAdmissionPolicyBindingInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type validatingAdmissionPolicyBindingInformer struct { informer cache.SharedIndexInformer - lister upstreamadmissionregistrationv1alpha1listers.ValidatingAdmissionPolicyBindingLister + lister listersadmissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingLister } -func (f *validatingAdmissionPolicyBindingInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *validatingAdmissionPolicyBindingInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *validatingAdmissionPolicyBindingInformer) Lister() upstreamadmissionregistrationv1alpha1listers.ValidatingAdmissionPolicyBindingLister { - return f.lister +func (i *validatingAdmissionPolicyBindingInformer) Lister() listersadmissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingLister { + return i.lister } diff --git a/informers/admissionregistration/v1beta1/interface.go b/informers/admissionregistration/v1beta1/interface.go index c9eda0d8b..33a637e3e 100644 --- a/informers/admissionregistration/v1beta1/interface.go +++ b/informers/admissionregistration/v1beta1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,51 +14,51 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // ValidatingAdmissionPolicies returns a ValidatingAdmissionPolicyClusterInformer + // MutatingWebhookConfigurations returns a MutatingWebhookConfigurationClusterInformer. + MutatingWebhookConfigurations() MutatingWebhookConfigurationClusterInformer + // ValidatingAdmissionPolicies returns a ValidatingAdmissionPolicyClusterInformer. ValidatingAdmissionPolicies() ValidatingAdmissionPolicyClusterInformer - // ValidatingAdmissionPolicyBindings returns a ValidatingAdmissionPolicyBindingClusterInformer + // ValidatingAdmissionPolicyBindings returns a ValidatingAdmissionPolicyBindingClusterInformer. ValidatingAdmissionPolicyBindings() ValidatingAdmissionPolicyBindingClusterInformer - // ValidatingWebhookConfigurations returns a ValidatingWebhookConfigurationClusterInformer + // ValidatingWebhookConfigurations returns a ValidatingWebhookConfigurationClusterInformer. ValidatingWebhookConfigurations() ValidatingWebhookConfigurationClusterInformer - // MutatingWebhookConfigurations returns a MutatingWebhookConfigurationClusterInformer - MutatingWebhookConfigurations() MutatingWebhookConfigurationClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// ValidatingAdmissionPolicies returns a ValidatingAdmissionPolicyClusterInformer +// MutatingWebhookConfigurations returns a MutatingWebhookConfigurationClusterInformer. +func (v *version) MutatingWebhookConfigurations() MutatingWebhookConfigurationClusterInformer { + return &mutatingWebhookConfigurationClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + +// ValidatingAdmissionPolicies returns a ValidatingAdmissionPolicyClusterInformer. func (v *version) ValidatingAdmissionPolicies() ValidatingAdmissionPolicyClusterInformer { return &validatingAdmissionPolicyClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// ValidatingAdmissionPolicyBindings returns a ValidatingAdmissionPolicyBindingClusterInformer +// ValidatingAdmissionPolicyBindings returns a ValidatingAdmissionPolicyBindingClusterInformer. func (v *version) ValidatingAdmissionPolicyBindings() ValidatingAdmissionPolicyBindingClusterInformer { return &validatingAdmissionPolicyBindingClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// ValidatingWebhookConfigurations returns a ValidatingWebhookConfigurationClusterInformer +// ValidatingWebhookConfigurations returns a ValidatingWebhookConfigurationClusterInformer. func (v *version) ValidatingWebhookConfigurations() ValidatingWebhookConfigurationClusterInformer { return &validatingWebhookConfigurationClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } - -// MutatingWebhookConfigurations returns a MutatingWebhookConfigurationClusterInformer -func (v *version) MutatingWebhookConfigurations() MutatingWebhookConfigurationClusterInformer { - return &mutatingWebhookConfigurationClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} diff --git a/informers/admissionregistration/v1beta1/mutatingwebhookconfiguration.go b/informers/admissionregistration/v1beta1/mutatingwebhookconfiguration.go index e54cc7fdd..e0a04e6ae 100644 --- a/informers/admissionregistration/v1beta1/mutatingwebhookconfiguration.go +++ b/informers/admissionregistration/v1beta1/mutatingwebhookconfiguration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamadmissionregistrationv1beta1informers "k8s.io/client-go/informers/admissionregistration/v1beta1" - upstreamadmissionregistrationv1beta1listers "k8s.io/client-go/listers/admissionregistration/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - admissionregistrationv1beta1listers "github.com/kcp-dev/client-go/listers/admissionregistration/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiadmissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + admissionregistrationv1beta1 "k8s.io/client-go/informers/admissionregistration/v1beta1" + listersadmissionregistrationv1beta1 "k8s.io/client-go/listers/admissionregistration/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/admissionregistration/v1beta1" ) // MutatingWebhookConfigurationClusterInformer provides access to a shared informer and lister for // MutatingWebhookConfigurations. type MutatingWebhookConfigurationClusterInformer interface { - Cluster(logicalcluster.Name) upstreamadmissionregistrationv1beta1informers.MutatingWebhookConfigurationInformer + Cluster(logicalcluster.Name) admissionregistrationv1beta1.MutatingWebhookConfigurationInformer + ClusterWithContext(context.Context, logicalcluster.Name) admissionregistrationv1beta1.MutatingWebhookConfigurationInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() admissionregistrationv1beta1listers.MutatingWebhookConfigurationClusterLister + Lister() kcpv1beta1.MutatingWebhookConfigurationClusterLister } type mutatingWebhookConfigurationClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewMutatingWebhookConfigurationClusterInformer constructs a new informer for MutatingWebhookConfiguration type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewMutatingWebhookConfigurationClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewMutatingWebhookConfigurationClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredMutatingWebhookConfigurationClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredMutatingWebhookConfigurationClusterInformer constructs a new informer for MutatingWebhookConfiguration type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredMutatingWebhookConfigurationClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredMutatingWebhookConfigurationClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AdmissionregistrationV1beta1().MutatingWebhookConfigurations().List(context.TODO(), options) + return client.AdmissionregistrationV1beta1().MutatingWebhookConfigurations().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AdmissionregistrationV1beta1().MutatingWebhookConfigurations().Watch(context.TODO(), options) + return client.AdmissionregistrationV1beta1().MutatingWebhookConfigurations().Watch(context.Background(), options) }, }, - &admissionregistrationv1beta1.MutatingWebhookConfiguration{}, + &apiadmissionregistrationv1beta1.MutatingWebhookConfiguration{}, resyncPeriod, indexers, ) } -func (f *mutatingWebhookConfigurationClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *mutatingWebhookConfigurationClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredMutatingWebhookConfigurationClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *mutatingWebhookConfigurationClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiadmissionregistrationv1beta1.MutatingWebhookConfiguration{}, i.defaultInformer) } -func (f *mutatingWebhookConfigurationClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&admissionregistrationv1beta1.MutatingWebhookConfiguration{}, f.defaultInformer) +func (i *mutatingWebhookConfigurationClusterInformer) Lister() kcpv1beta1.MutatingWebhookConfigurationClusterLister { + return kcpv1beta1.NewMutatingWebhookConfigurationClusterLister(i.Informer().GetIndexer()) } -func (f *mutatingWebhookConfigurationClusterInformer) Lister() admissionregistrationv1beta1listers.MutatingWebhookConfigurationClusterLister { - return admissionregistrationv1beta1listers.NewMutatingWebhookConfigurationClusterLister(f.Informer().GetIndexer()) +func (i *mutatingWebhookConfigurationClusterInformer) Cluster(clusterName logicalcluster.Name) admissionregistrationv1beta1.MutatingWebhookConfigurationInformer { + return &mutatingWebhookConfigurationInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *mutatingWebhookConfigurationClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamadmissionregistrationv1beta1informers.MutatingWebhookConfigurationInformer { +func (i *mutatingWebhookConfigurationClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) admissionregistrationv1beta1.MutatingWebhookConfigurationInformer { return &mutatingWebhookConfigurationInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type mutatingWebhookConfigurationInformer struct { informer cache.SharedIndexInformer - lister upstreamadmissionregistrationv1beta1listers.MutatingWebhookConfigurationLister + lister listersadmissionregistrationv1beta1.MutatingWebhookConfigurationLister } -func (f *mutatingWebhookConfigurationInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *mutatingWebhookConfigurationInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *mutatingWebhookConfigurationInformer) Lister() upstreamadmissionregistrationv1beta1listers.MutatingWebhookConfigurationLister { - return f.lister +func (i *mutatingWebhookConfigurationInformer) Lister() listersadmissionregistrationv1beta1.MutatingWebhookConfigurationLister { + return i.lister } diff --git a/informers/admissionregistration/v1beta1/validatingadmissionpolicy.go b/informers/admissionregistration/v1beta1/validatingadmissionpolicy.go index 1e8fe0083..c754c8aeb 100644 --- a/informers/admissionregistration/v1beta1/validatingadmissionpolicy.go +++ b/informers/admissionregistration/v1beta1/validatingadmissionpolicy.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamadmissionregistrationv1beta1informers "k8s.io/client-go/informers/admissionregistration/v1beta1" - upstreamadmissionregistrationv1beta1listers "k8s.io/client-go/listers/admissionregistration/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - admissionregistrationv1beta1listers "github.com/kcp-dev/client-go/listers/admissionregistration/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiadmissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + admissionregistrationv1beta1 "k8s.io/client-go/informers/admissionregistration/v1beta1" + listersadmissionregistrationv1beta1 "k8s.io/client-go/listers/admissionregistration/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/admissionregistration/v1beta1" ) // ValidatingAdmissionPolicyClusterInformer provides access to a shared informer and lister for // ValidatingAdmissionPolicies. type ValidatingAdmissionPolicyClusterInformer interface { - Cluster(logicalcluster.Name) upstreamadmissionregistrationv1beta1informers.ValidatingAdmissionPolicyInformer + Cluster(logicalcluster.Name) admissionregistrationv1beta1.ValidatingAdmissionPolicyInformer + ClusterWithContext(context.Context, logicalcluster.Name) admissionregistrationv1beta1.ValidatingAdmissionPolicyInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() admissionregistrationv1beta1listers.ValidatingAdmissionPolicyClusterLister + Lister() kcpv1beta1.ValidatingAdmissionPolicyClusterLister } type validatingAdmissionPolicyClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewValidatingAdmissionPolicyClusterInformer constructs a new informer for ValidatingAdmissionPolicy type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewValidatingAdmissionPolicyClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewValidatingAdmissionPolicyClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredValidatingAdmissionPolicyClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredValidatingAdmissionPolicyClusterInformer constructs a new informer for ValidatingAdmissionPolicy type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredValidatingAdmissionPolicyClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredValidatingAdmissionPolicyClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AdmissionregistrationV1beta1().ValidatingAdmissionPolicies().List(context.TODO(), options) + return client.AdmissionregistrationV1beta1().ValidatingAdmissionPolicies().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AdmissionregistrationV1beta1().ValidatingAdmissionPolicies().Watch(context.TODO(), options) + return client.AdmissionregistrationV1beta1().ValidatingAdmissionPolicies().Watch(context.Background(), options) }, }, - &admissionregistrationv1beta1.ValidatingAdmissionPolicy{}, + &apiadmissionregistrationv1beta1.ValidatingAdmissionPolicy{}, resyncPeriod, indexers, ) } -func (f *validatingAdmissionPolicyClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *validatingAdmissionPolicyClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredValidatingAdmissionPolicyClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *validatingAdmissionPolicyClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiadmissionregistrationv1beta1.ValidatingAdmissionPolicy{}, i.defaultInformer) } -func (f *validatingAdmissionPolicyClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&admissionregistrationv1beta1.ValidatingAdmissionPolicy{}, f.defaultInformer) +func (i *validatingAdmissionPolicyClusterInformer) Lister() kcpv1beta1.ValidatingAdmissionPolicyClusterLister { + return kcpv1beta1.NewValidatingAdmissionPolicyClusterLister(i.Informer().GetIndexer()) } -func (f *validatingAdmissionPolicyClusterInformer) Lister() admissionregistrationv1beta1listers.ValidatingAdmissionPolicyClusterLister { - return admissionregistrationv1beta1listers.NewValidatingAdmissionPolicyClusterLister(f.Informer().GetIndexer()) +func (i *validatingAdmissionPolicyClusterInformer) Cluster(clusterName logicalcluster.Name) admissionregistrationv1beta1.ValidatingAdmissionPolicyInformer { + return &validatingAdmissionPolicyInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *validatingAdmissionPolicyClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamadmissionregistrationv1beta1informers.ValidatingAdmissionPolicyInformer { +func (i *validatingAdmissionPolicyClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) admissionregistrationv1beta1.ValidatingAdmissionPolicyInformer { return &validatingAdmissionPolicyInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type validatingAdmissionPolicyInformer struct { informer cache.SharedIndexInformer - lister upstreamadmissionregistrationv1beta1listers.ValidatingAdmissionPolicyLister + lister listersadmissionregistrationv1beta1.ValidatingAdmissionPolicyLister } -func (f *validatingAdmissionPolicyInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *validatingAdmissionPolicyInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *validatingAdmissionPolicyInformer) Lister() upstreamadmissionregistrationv1beta1listers.ValidatingAdmissionPolicyLister { - return f.lister +func (i *validatingAdmissionPolicyInformer) Lister() listersadmissionregistrationv1beta1.ValidatingAdmissionPolicyLister { + return i.lister } diff --git a/informers/admissionregistration/v1beta1/validatingadmissionpolicybinding.go b/informers/admissionregistration/v1beta1/validatingadmissionpolicybinding.go index 5b64efb38..d87a54089 100644 --- a/informers/admissionregistration/v1beta1/validatingadmissionpolicybinding.go +++ b/informers/admissionregistration/v1beta1/validatingadmissionpolicybinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamadmissionregistrationv1beta1informers "k8s.io/client-go/informers/admissionregistration/v1beta1" - upstreamadmissionregistrationv1beta1listers "k8s.io/client-go/listers/admissionregistration/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - admissionregistrationv1beta1listers "github.com/kcp-dev/client-go/listers/admissionregistration/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiadmissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + admissionregistrationv1beta1 "k8s.io/client-go/informers/admissionregistration/v1beta1" + listersadmissionregistrationv1beta1 "k8s.io/client-go/listers/admissionregistration/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/admissionregistration/v1beta1" ) // ValidatingAdmissionPolicyBindingClusterInformer provides access to a shared informer and lister for // ValidatingAdmissionPolicyBindings. type ValidatingAdmissionPolicyBindingClusterInformer interface { - Cluster(logicalcluster.Name) upstreamadmissionregistrationv1beta1informers.ValidatingAdmissionPolicyBindingInformer + Cluster(logicalcluster.Name) admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingInformer + ClusterWithContext(context.Context, logicalcluster.Name) admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() admissionregistrationv1beta1listers.ValidatingAdmissionPolicyBindingClusterLister + Lister() kcpv1beta1.ValidatingAdmissionPolicyBindingClusterLister } type validatingAdmissionPolicyBindingClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewValidatingAdmissionPolicyBindingClusterInformer constructs a new informer for ValidatingAdmissionPolicyBinding type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewValidatingAdmissionPolicyBindingClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewValidatingAdmissionPolicyBindingClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredValidatingAdmissionPolicyBindingClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredValidatingAdmissionPolicyBindingClusterInformer constructs a new informer for ValidatingAdmissionPolicyBinding type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredValidatingAdmissionPolicyBindingClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredValidatingAdmissionPolicyBindingClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AdmissionregistrationV1beta1().ValidatingAdmissionPolicyBindings().List(context.TODO(), options) + return client.AdmissionregistrationV1beta1().ValidatingAdmissionPolicyBindings().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AdmissionregistrationV1beta1().ValidatingAdmissionPolicyBindings().Watch(context.TODO(), options) + return client.AdmissionregistrationV1beta1().ValidatingAdmissionPolicyBindings().Watch(context.Background(), options) }, }, - &admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding{}, + &apiadmissionregistrationv1beta1.ValidatingAdmissionPolicyBinding{}, resyncPeriod, indexers, ) } -func (f *validatingAdmissionPolicyBindingClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *validatingAdmissionPolicyBindingClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredValidatingAdmissionPolicyBindingClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *validatingAdmissionPolicyBindingClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiadmissionregistrationv1beta1.ValidatingAdmissionPolicyBinding{}, i.defaultInformer) } -func (f *validatingAdmissionPolicyBindingClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding{}, f.defaultInformer) +func (i *validatingAdmissionPolicyBindingClusterInformer) Lister() kcpv1beta1.ValidatingAdmissionPolicyBindingClusterLister { + return kcpv1beta1.NewValidatingAdmissionPolicyBindingClusterLister(i.Informer().GetIndexer()) } -func (f *validatingAdmissionPolicyBindingClusterInformer) Lister() admissionregistrationv1beta1listers.ValidatingAdmissionPolicyBindingClusterLister { - return admissionregistrationv1beta1listers.NewValidatingAdmissionPolicyBindingClusterLister(f.Informer().GetIndexer()) +func (i *validatingAdmissionPolicyBindingClusterInformer) Cluster(clusterName logicalcluster.Name) admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingInformer { + return &validatingAdmissionPolicyBindingInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *validatingAdmissionPolicyBindingClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamadmissionregistrationv1beta1informers.ValidatingAdmissionPolicyBindingInformer { +func (i *validatingAdmissionPolicyBindingClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingInformer { return &validatingAdmissionPolicyBindingInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type validatingAdmissionPolicyBindingInformer struct { informer cache.SharedIndexInformer - lister upstreamadmissionregistrationv1beta1listers.ValidatingAdmissionPolicyBindingLister + lister listersadmissionregistrationv1beta1.ValidatingAdmissionPolicyBindingLister } -func (f *validatingAdmissionPolicyBindingInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *validatingAdmissionPolicyBindingInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *validatingAdmissionPolicyBindingInformer) Lister() upstreamadmissionregistrationv1beta1listers.ValidatingAdmissionPolicyBindingLister { - return f.lister +func (i *validatingAdmissionPolicyBindingInformer) Lister() listersadmissionregistrationv1beta1.ValidatingAdmissionPolicyBindingLister { + return i.lister } diff --git a/informers/admissionregistration/v1beta1/validatingwebhookconfiguration.go b/informers/admissionregistration/v1beta1/validatingwebhookconfiguration.go index 1056443ff..285074f45 100644 --- a/informers/admissionregistration/v1beta1/validatingwebhookconfiguration.go +++ b/informers/admissionregistration/v1beta1/validatingwebhookconfiguration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamadmissionregistrationv1beta1informers "k8s.io/client-go/informers/admissionregistration/v1beta1" - upstreamadmissionregistrationv1beta1listers "k8s.io/client-go/listers/admissionregistration/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - admissionregistrationv1beta1listers "github.com/kcp-dev/client-go/listers/admissionregistration/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiadmissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + admissionregistrationv1beta1 "k8s.io/client-go/informers/admissionregistration/v1beta1" + listersadmissionregistrationv1beta1 "k8s.io/client-go/listers/admissionregistration/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/admissionregistration/v1beta1" ) // ValidatingWebhookConfigurationClusterInformer provides access to a shared informer and lister for // ValidatingWebhookConfigurations. type ValidatingWebhookConfigurationClusterInformer interface { - Cluster(logicalcluster.Name) upstreamadmissionregistrationv1beta1informers.ValidatingWebhookConfigurationInformer + Cluster(logicalcluster.Name) admissionregistrationv1beta1.ValidatingWebhookConfigurationInformer + ClusterWithContext(context.Context, logicalcluster.Name) admissionregistrationv1beta1.ValidatingWebhookConfigurationInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() admissionregistrationv1beta1listers.ValidatingWebhookConfigurationClusterLister + Lister() kcpv1beta1.ValidatingWebhookConfigurationClusterLister } type validatingWebhookConfigurationClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewValidatingWebhookConfigurationClusterInformer constructs a new informer for ValidatingWebhookConfiguration type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewValidatingWebhookConfigurationClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewValidatingWebhookConfigurationClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredValidatingWebhookConfigurationClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredValidatingWebhookConfigurationClusterInformer constructs a new informer for ValidatingWebhookConfiguration type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredValidatingWebhookConfigurationClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredValidatingWebhookConfigurationClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AdmissionregistrationV1beta1().ValidatingWebhookConfigurations().List(context.TODO(), options) + return client.AdmissionregistrationV1beta1().ValidatingWebhookConfigurations().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AdmissionregistrationV1beta1().ValidatingWebhookConfigurations().Watch(context.TODO(), options) + return client.AdmissionregistrationV1beta1().ValidatingWebhookConfigurations().Watch(context.Background(), options) }, }, - &admissionregistrationv1beta1.ValidatingWebhookConfiguration{}, + &apiadmissionregistrationv1beta1.ValidatingWebhookConfiguration{}, resyncPeriod, indexers, ) } -func (f *validatingWebhookConfigurationClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *validatingWebhookConfigurationClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredValidatingWebhookConfigurationClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *validatingWebhookConfigurationClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiadmissionregistrationv1beta1.ValidatingWebhookConfiguration{}, i.defaultInformer) } -func (f *validatingWebhookConfigurationClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&admissionregistrationv1beta1.ValidatingWebhookConfiguration{}, f.defaultInformer) +func (i *validatingWebhookConfigurationClusterInformer) Lister() kcpv1beta1.ValidatingWebhookConfigurationClusterLister { + return kcpv1beta1.NewValidatingWebhookConfigurationClusterLister(i.Informer().GetIndexer()) } -func (f *validatingWebhookConfigurationClusterInformer) Lister() admissionregistrationv1beta1listers.ValidatingWebhookConfigurationClusterLister { - return admissionregistrationv1beta1listers.NewValidatingWebhookConfigurationClusterLister(f.Informer().GetIndexer()) +func (i *validatingWebhookConfigurationClusterInformer) Cluster(clusterName logicalcluster.Name) admissionregistrationv1beta1.ValidatingWebhookConfigurationInformer { + return &validatingWebhookConfigurationInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *validatingWebhookConfigurationClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamadmissionregistrationv1beta1informers.ValidatingWebhookConfigurationInformer { +func (i *validatingWebhookConfigurationClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) admissionregistrationv1beta1.ValidatingWebhookConfigurationInformer { return &validatingWebhookConfigurationInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type validatingWebhookConfigurationInformer struct { informer cache.SharedIndexInformer - lister upstreamadmissionregistrationv1beta1listers.ValidatingWebhookConfigurationLister + lister listersadmissionregistrationv1beta1.ValidatingWebhookConfigurationLister } -func (f *validatingWebhookConfigurationInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *validatingWebhookConfigurationInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *validatingWebhookConfigurationInformer) Lister() upstreamadmissionregistrationv1beta1listers.ValidatingWebhookConfigurationLister { - return f.lister +func (i *validatingWebhookConfigurationInformer) Lister() listersadmissionregistrationv1beta1.ValidatingWebhookConfigurationLister { + return i.lister } diff --git a/informers/apiserverinternal/interface.go b/informers/apiserverinternal/interface.go index c5b210b7b..bb9602058 100644 --- a/informers/apiserverinternal/interface.go +++ b/informers/apiserverinternal/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,31 +14,32 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package apiserverinternal import ( - "github.com/kcp-dev/client-go/informers/apiserverinternal/v1alpha1" - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpv1alpha1 "github.com/kcp-dev/client-go/informers/apiserverinternal/v1alpha1" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) +// ClusterInterface provides access to each of this group's versions. type ClusterInterface interface { - // V1alpha1 provides access to the shared informers in V1alpha1. - V1alpha1() v1alpha1.ClusterInterface + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() kcpv1alpha1.ClusterInterface } type group struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &group{factory: f, tweakListOptions: tweakListOptions} } -// V1alpha1 returns a new v1alpha1.ClusterInterface. -func (g *group) V1alpha1() v1alpha1.ClusterInterface { - return v1alpha1.New(g.factory, g.tweakListOptions) +// V1alpha1 returns a new kcpv1alpha1.ClusterInterface. +func (g *group) V1alpha1() kcpv1alpha1.ClusterInterface { + return kcpv1alpha1.New(g.factory, g.tweakListOptions) } diff --git a/informers/apiserverinternal/v1alpha1/interface.go b/informers/apiserverinternal/v1alpha1/interface.go index 4fda7545d..d14e42a82 100644 --- a/informers/apiserverinternal/v1alpha1/interface.go +++ b/informers/apiserverinternal/v1alpha1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,30 +14,30 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // StorageVersions returns a StorageVersionClusterInformer + // StorageVersions returns a StorageVersionClusterInformer. StorageVersions() StorageVersionClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// StorageVersions returns a StorageVersionClusterInformer +// StorageVersions returns a StorageVersionClusterInformer. func (v *version) StorageVersions() StorageVersionClusterInformer { return &storageVersionClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/apiserverinternal/v1alpha1/storageversion.go b/informers/apiserverinternal/v1alpha1/storageversion.go index 378588d16..5446a7c56 100644 --- a/informers/apiserverinternal/v1alpha1/storageversion.go +++ b/informers/apiserverinternal/v1alpha1/storageversion.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - internalv1alpha1 "k8s.io/api/apiserverinternal/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreaminternalv1alpha1informers "k8s.io/client-go/informers/apiserverinternal/v1alpha1" - upstreaminternalv1alpha1listers "k8s.io/client-go/listers/apiserverinternal/v1alpha1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - internalv1alpha1listers "github.com/kcp-dev/client-go/listers/apiserverinternal/v1alpha1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiapiserverinternalv1alpha1 "k8s.io/api/apiserverinternal/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + apiserverinternalv1alpha1 "k8s.io/client-go/informers/apiserverinternal/v1alpha1" + listersapiserverinternalv1alpha1 "k8s.io/client-go/listers/apiserverinternal/v1alpha1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1alpha1 "github.com/kcp-dev/client-go/listers/apiserverinternal/v1alpha1" ) // StorageVersionClusterInformer provides access to a shared informer and lister for // StorageVersions. type StorageVersionClusterInformer interface { - Cluster(logicalcluster.Name) upstreaminternalv1alpha1informers.StorageVersionInformer + Cluster(logicalcluster.Name) apiserverinternalv1alpha1.StorageVersionInformer + ClusterWithContext(context.Context, logicalcluster.Name) apiserverinternalv1alpha1.StorageVersionInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() internalv1alpha1listers.StorageVersionClusterLister + Lister() kcpv1alpha1.StorageVersionClusterLister } type storageVersionClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewStorageVersionClusterInformer constructs a new informer for StorageVersion type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewStorageVersionClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewStorageVersionClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredStorageVersionClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredStorageVersionClusterInformer constructs a new informer for StorageVersion type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredStorageVersionClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredStorageVersionClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.InternalV1alpha1().StorageVersions().List(context.TODO(), options) + return client.InternalV1alpha1().StorageVersions().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.InternalV1alpha1().StorageVersions().Watch(context.TODO(), options) + return client.InternalV1alpha1().StorageVersions().Watch(context.Background(), options) }, }, - &internalv1alpha1.StorageVersion{}, + &apiapiserverinternalv1alpha1.StorageVersion{}, resyncPeriod, indexers, ) } -func (f *storageVersionClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *storageVersionClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredStorageVersionClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *storageVersionClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiapiserverinternalv1alpha1.StorageVersion{}, i.defaultInformer) } -func (f *storageVersionClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&internalv1alpha1.StorageVersion{}, f.defaultInformer) +func (i *storageVersionClusterInformer) Lister() kcpv1alpha1.StorageVersionClusterLister { + return kcpv1alpha1.NewStorageVersionClusterLister(i.Informer().GetIndexer()) } -func (f *storageVersionClusterInformer) Lister() internalv1alpha1listers.StorageVersionClusterLister { - return internalv1alpha1listers.NewStorageVersionClusterLister(f.Informer().GetIndexer()) +func (i *storageVersionClusterInformer) Cluster(clusterName logicalcluster.Name) apiserverinternalv1alpha1.StorageVersionInformer { + return &storageVersionInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *storageVersionClusterInformer) Cluster(clusterName logicalcluster.Name) upstreaminternalv1alpha1informers.StorageVersionInformer { +func (i *storageVersionClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) apiserverinternalv1alpha1.StorageVersionInformer { return &storageVersionInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type storageVersionInformer struct { informer cache.SharedIndexInformer - lister upstreaminternalv1alpha1listers.StorageVersionLister + lister listersapiserverinternalv1alpha1.StorageVersionLister } -func (f *storageVersionInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *storageVersionInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *storageVersionInformer) Lister() upstreaminternalv1alpha1listers.StorageVersionLister { - return f.lister +func (i *storageVersionInformer) Lister() listersapiserverinternalv1alpha1.StorageVersionLister { + return i.lister } diff --git a/informers/apps/interface.go b/informers/apps/interface.go index 8327d7dba..aa7a801f3 100644 --- a/informers/apps/interface.go +++ b/informers/apps/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,47 +14,48 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package apps import ( - "github.com/kcp-dev/client-go/informers/apps/v1" - "github.com/kcp-dev/client-go/informers/apps/v1beta1" - "github.com/kcp-dev/client-go/informers/apps/v1beta2" - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpv1 "github.com/kcp-dev/client-go/informers/apps/v1" + kcpv1beta1 "github.com/kcp-dev/client-go/informers/apps/v1beta1" + kcpv1beta2 "github.com/kcp-dev/client-go/informers/apps/v1beta2" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) +// ClusterInterface provides access to each of this group's versions. type ClusterInterface interface { - // V1 provides access to the shared informers in V1. - V1() v1.ClusterInterface - // V1beta1 provides access to the shared informers in V1beta1. - V1beta1() v1beta1.ClusterInterface - // V1beta2 provides access to the shared informers in V1beta2. - V1beta2() v1beta2.ClusterInterface + // V1 provides access to shared informers for resources in V1. + V1() kcpv1.ClusterInterface + // V1beta1 provides access to shared informers for resources in V1beta1. + V1beta1() kcpv1beta1.ClusterInterface + // V1beta2 provides access to shared informers for resources in V1beta2. + V1beta2() kcpv1beta2.ClusterInterface } type group struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &group{factory: f, tweakListOptions: tweakListOptions} } -// V1 returns a new v1.ClusterInterface. -func (g *group) V1() v1.ClusterInterface { - return v1.New(g.factory, g.tweakListOptions) +// V1 returns a new kcpv1.ClusterInterface. +func (g *group) V1() kcpv1.ClusterInterface { + return kcpv1.New(g.factory, g.tweakListOptions) } -// V1beta1 returns a new v1beta1.ClusterInterface. -func (g *group) V1beta1() v1beta1.ClusterInterface { - return v1beta1.New(g.factory, g.tweakListOptions) +// V1beta1 returns a new kcpv1beta1.ClusterInterface. +func (g *group) V1beta1() kcpv1beta1.ClusterInterface { + return kcpv1beta1.New(g.factory, g.tweakListOptions) } -// V1beta2 returns a new v1beta2.ClusterInterface. -func (g *group) V1beta2() v1beta2.ClusterInterface { - return v1beta2.New(g.factory, g.tweakListOptions) +// V1beta2 returns a new kcpv1beta2.ClusterInterface. +func (g *group) V1beta2() kcpv1beta2.ClusterInterface { + return kcpv1beta2.New(g.factory, g.tweakListOptions) } diff --git a/informers/apps/v1/controllerrevision.go b/informers/apps/v1/controllerrevision.go index 3b9fcde46..29c4ed316 100644 --- a/informers/apps/v1/controllerrevision.go +++ b/informers/apps/v1/controllerrevision.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - appsv1 "k8s.io/api/apps/v1" + apiappsv1 "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamappsv1informers "k8s.io/client-go/informers/apps/v1" - upstreamappsv1listers "k8s.io/client-go/listers/apps/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - appsv1listers "github.com/kcp-dev/client-go/listers/apps/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + appsv1 "k8s.io/client-go/informers/apps/v1" + listersappsv1 "k8s.io/client-go/listers/apps/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/apps/v1" ) // ControllerRevisionClusterInformer provides access to a shared informer and lister for // ControllerRevisions. type ControllerRevisionClusterInformer interface { - Cluster(logicalcluster.Name) upstreamappsv1informers.ControllerRevisionInformer + Cluster(logicalcluster.Name) appsv1.ControllerRevisionInformer + ClusterWithContext(context.Context, logicalcluster.Name) appsv1.ControllerRevisionInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() appsv1listers.ControllerRevisionClusterLister + Lister() kcpv1.ControllerRevisionClusterLister } type controllerRevisionClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewControllerRevisionClusterInformer constructs a new informer for ControllerRevision type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewControllerRevisionClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewControllerRevisionClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredControllerRevisionClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredControllerRevisionClusterInformer constructs a new informer for ControllerRevision type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredControllerRevisionClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredControllerRevisionClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AppsV1().ControllerRevisions().List(context.TODO(), options) + return client.AppsV1().ControllerRevisions().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AppsV1().ControllerRevisions().Watch(context.TODO(), options) + return client.AppsV1().ControllerRevisions().Watch(context.Background(), options) }, }, - &appsv1.ControllerRevision{}, + &apiappsv1.ControllerRevision{}, resyncPeriod, indexers, ) } -func (f *controllerRevisionClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *controllerRevisionClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredControllerRevisionClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *controllerRevisionClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiappsv1.ControllerRevision{}, i.defaultInformer) } -func (f *controllerRevisionClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&appsv1.ControllerRevision{}, f.defaultInformer) +func (i *controllerRevisionClusterInformer) Lister() kcpv1.ControllerRevisionClusterLister { + return kcpv1.NewControllerRevisionClusterLister(i.Informer().GetIndexer()) } -func (f *controllerRevisionClusterInformer) Lister() appsv1listers.ControllerRevisionClusterLister { - return appsv1listers.NewControllerRevisionClusterLister(f.Informer().GetIndexer()) +func (i *controllerRevisionClusterInformer) Cluster(clusterName logicalcluster.Name) appsv1.ControllerRevisionInformer { + return &controllerRevisionInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *controllerRevisionClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamappsv1informers.ControllerRevisionInformer { +func (i *controllerRevisionClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) appsv1.ControllerRevisionInformer { return &controllerRevisionInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type controllerRevisionInformer struct { informer cache.SharedIndexInformer - lister upstreamappsv1listers.ControllerRevisionLister + lister listersappsv1.ControllerRevisionLister } -func (f *controllerRevisionInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *controllerRevisionInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *controllerRevisionInformer) Lister() upstreamappsv1listers.ControllerRevisionLister { - return f.lister +func (i *controllerRevisionInformer) Lister() listersappsv1.ControllerRevisionLister { + return i.lister } diff --git a/informers/apps/v1/daemonset.go b/informers/apps/v1/daemonset.go index f36ef4120..539a0c27d 100644 --- a/informers/apps/v1/daemonset.go +++ b/informers/apps/v1/daemonset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - appsv1 "k8s.io/api/apps/v1" + apiappsv1 "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamappsv1informers "k8s.io/client-go/informers/apps/v1" - upstreamappsv1listers "k8s.io/client-go/listers/apps/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - appsv1listers "github.com/kcp-dev/client-go/listers/apps/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + appsv1 "k8s.io/client-go/informers/apps/v1" + listersappsv1 "k8s.io/client-go/listers/apps/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/apps/v1" ) // DaemonSetClusterInformer provides access to a shared informer and lister for // DaemonSets. type DaemonSetClusterInformer interface { - Cluster(logicalcluster.Name) upstreamappsv1informers.DaemonSetInformer + Cluster(logicalcluster.Name) appsv1.DaemonSetInformer + ClusterWithContext(context.Context, logicalcluster.Name) appsv1.DaemonSetInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() appsv1listers.DaemonSetClusterLister + Lister() kcpv1.DaemonSetClusterLister } type daemonSetClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewDaemonSetClusterInformer constructs a new informer for DaemonSet type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewDaemonSetClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewDaemonSetClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredDaemonSetClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredDaemonSetClusterInformer constructs a new informer for DaemonSet type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredDaemonSetClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredDaemonSetClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AppsV1().DaemonSets().List(context.TODO(), options) + return client.AppsV1().DaemonSets().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AppsV1().DaemonSets().Watch(context.TODO(), options) + return client.AppsV1().DaemonSets().Watch(context.Background(), options) }, }, - &appsv1.DaemonSet{}, + &apiappsv1.DaemonSet{}, resyncPeriod, indexers, ) } -func (f *daemonSetClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *daemonSetClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredDaemonSetClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *daemonSetClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiappsv1.DaemonSet{}, i.defaultInformer) } -func (f *daemonSetClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&appsv1.DaemonSet{}, f.defaultInformer) +func (i *daemonSetClusterInformer) Lister() kcpv1.DaemonSetClusterLister { + return kcpv1.NewDaemonSetClusterLister(i.Informer().GetIndexer()) } -func (f *daemonSetClusterInformer) Lister() appsv1listers.DaemonSetClusterLister { - return appsv1listers.NewDaemonSetClusterLister(f.Informer().GetIndexer()) +func (i *daemonSetClusterInformer) Cluster(clusterName logicalcluster.Name) appsv1.DaemonSetInformer { + return &daemonSetInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *daemonSetClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamappsv1informers.DaemonSetInformer { +func (i *daemonSetClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) appsv1.DaemonSetInformer { return &daemonSetInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type daemonSetInformer struct { informer cache.SharedIndexInformer - lister upstreamappsv1listers.DaemonSetLister + lister listersappsv1.DaemonSetLister } -func (f *daemonSetInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *daemonSetInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *daemonSetInformer) Lister() upstreamappsv1listers.DaemonSetLister { - return f.lister +func (i *daemonSetInformer) Lister() listersappsv1.DaemonSetLister { + return i.lister } diff --git a/informers/apps/v1/deployment.go b/informers/apps/v1/deployment.go index 80d67c24f..71c25a603 100644 --- a/informers/apps/v1/deployment.go +++ b/informers/apps/v1/deployment.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - appsv1 "k8s.io/api/apps/v1" + apiappsv1 "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamappsv1informers "k8s.io/client-go/informers/apps/v1" - upstreamappsv1listers "k8s.io/client-go/listers/apps/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - appsv1listers "github.com/kcp-dev/client-go/listers/apps/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + appsv1 "k8s.io/client-go/informers/apps/v1" + listersappsv1 "k8s.io/client-go/listers/apps/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/apps/v1" ) // DeploymentClusterInformer provides access to a shared informer and lister for // Deployments. type DeploymentClusterInformer interface { - Cluster(logicalcluster.Name) upstreamappsv1informers.DeploymentInformer + Cluster(logicalcluster.Name) appsv1.DeploymentInformer + ClusterWithContext(context.Context, logicalcluster.Name) appsv1.DeploymentInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() appsv1listers.DeploymentClusterLister + Lister() kcpv1.DeploymentClusterLister } type deploymentClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewDeploymentClusterInformer constructs a new informer for Deployment type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewDeploymentClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewDeploymentClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredDeploymentClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredDeploymentClusterInformer constructs a new informer for Deployment type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredDeploymentClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredDeploymentClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AppsV1().Deployments().List(context.TODO(), options) + return client.AppsV1().Deployments().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AppsV1().Deployments().Watch(context.TODO(), options) + return client.AppsV1().Deployments().Watch(context.Background(), options) }, }, - &appsv1.Deployment{}, + &apiappsv1.Deployment{}, resyncPeriod, indexers, ) } -func (f *deploymentClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *deploymentClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredDeploymentClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *deploymentClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiappsv1.Deployment{}, i.defaultInformer) } -func (f *deploymentClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&appsv1.Deployment{}, f.defaultInformer) +func (i *deploymentClusterInformer) Lister() kcpv1.DeploymentClusterLister { + return kcpv1.NewDeploymentClusterLister(i.Informer().GetIndexer()) } -func (f *deploymentClusterInformer) Lister() appsv1listers.DeploymentClusterLister { - return appsv1listers.NewDeploymentClusterLister(f.Informer().GetIndexer()) +func (i *deploymentClusterInformer) Cluster(clusterName logicalcluster.Name) appsv1.DeploymentInformer { + return &deploymentInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *deploymentClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamappsv1informers.DeploymentInformer { +func (i *deploymentClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) appsv1.DeploymentInformer { return &deploymentInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type deploymentInformer struct { informer cache.SharedIndexInformer - lister upstreamappsv1listers.DeploymentLister + lister listersappsv1.DeploymentLister } -func (f *deploymentInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *deploymentInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *deploymentInformer) Lister() upstreamappsv1listers.DeploymentLister { - return f.lister +func (i *deploymentInformer) Lister() listersappsv1.DeploymentLister { + return i.lister } diff --git a/informers/apps/v1/interface.go b/informers/apps/v1/interface.go index 85593b052..bb4873ac5 100644 --- a/informers/apps/v1/interface.go +++ b/informers/apps/v1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,58 +14,58 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // StatefulSets returns a StatefulSetClusterInformer - StatefulSets() StatefulSetClusterInformer - // Deployments returns a DeploymentClusterInformer - Deployments() DeploymentClusterInformer - // DaemonSets returns a DaemonSetClusterInformer + // ControllerRevisions returns a ControllerRevisionClusterInformer. + ControllerRevisions() ControllerRevisionClusterInformer + // DaemonSets returns a DaemonSetClusterInformer. DaemonSets() DaemonSetClusterInformer - // ReplicaSets returns a ReplicaSetClusterInformer + // Deployments returns a DeploymentClusterInformer. + Deployments() DeploymentClusterInformer + // ReplicaSets returns a ReplicaSetClusterInformer. ReplicaSets() ReplicaSetClusterInformer - // ControllerRevisions returns a ControllerRevisionClusterInformer - ControllerRevisions() ControllerRevisionClusterInformer + // StatefulSets returns a StatefulSetClusterInformer. + StatefulSets() StatefulSetClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// StatefulSets returns a StatefulSetClusterInformer -func (v *version) StatefulSets() StatefulSetClusterInformer { - return &statefulSetClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} - -// Deployments returns a DeploymentClusterInformer -func (v *version) Deployments() DeploymentClusterInformer { - return &deploymentClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +// ControllerRevisions returns a ControllerRevisionClusterInformer. +func (v *version) ControllerRevisions() ControllerRevisionClusterInformer { + return &controllerRevisionClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// DaemonSets returns a DaemonSetClusterInformer +// DaemonSets returns a DaemonSetClusterInformer. func (v *version) DaemonSets() DaemonSetClusterInformer { return &daemonSetClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// ReplicaSets returns a ReplicaSetClusterInformer +// Deployments returns a DeploymentClusterInformer. +func (v *version) Deployments() DeploymentClusterInformer { + return &deploymentClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + +// ReplicaSets returns a ReplicaSetClusterInformer. func (v *version) ReplicaSets() ReplicaSetClusterInformer { return &replicaSetClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// ControllerRevisions returns a ControllerRevisionClusterInformer -func (v *version) ControllerRevisions() ControllerRevisionClusterInformer { - return &controllerRevisionClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +// StatefulSets returns a StatefulSetClusterInformer. +func (v *version) StatefulSets() StatefulSetClusterInformer { + return &statefulSetClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/apps/v1/replicaset.go b/informers/apps/v1/replicaset.go index deee7eaa3..08e14daf6 100644 --- a/informers/apps/v1/replicaset.go +++ b/informers/apps/v1/replicaset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - appsv1 "k8s.io/api/apps/v1" + apiappsv1 "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamappsv1informers "k8s.io/client-go/informers/apps/v1" - upstreamappsv1listers "k8s.io/client-go/listers/apps/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - appsv1listers "github.com/kcp-dev/client-go/listers/apps/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + appsv1 "k8s.io/client-go/informers/apps/v1" + listersappsv1 "k8s.io/client-go/listers/apps/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/apps/v1" ) // ReplicaSetClusterInformer provides access to a shared informer and lister for // ReplicaSets. type ReplicaSetClusterInformer interface { - Cluster(logicalcluster.Name) upstreamappsv1informers.ReplicaSetInformer + Cluster(logicalcluster.Name) appsv1.ReplicaSetInformer + ClusterWithContext(context.Context, logicalcluster.Name) appsv1.ReplicaSetInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() appsv1listers.ReplicaSetClusterLister + Lister() kcpv1.ReplicaSetClusterLister } type replicaSetClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewReplicaSetClusterInformer constructs a new informer for ReplicaSet type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewReplicaSetClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewReplicaSetClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredReplicaSetClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredReplicaSetClusterInformer constructs a new informer for ReplicaSet type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredReplicaSetClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredReplicaSetClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AppsV1().ReplicaSets().List(context.TODO(), options) + return client.AppsV1().ReplicaSets().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AppsV1().ReplicaSets().Watch(context.TODO(), options) + return client.AppsV1().ReplicaSets().Watch(context.Background(), options) }, }, - &appsv1.ReplicaSet{}, + &apiappsv1.ReplicaSet{}, resyncPeriod, indexers, ) } -func (f *replicaSetClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *replicaSetClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredReplicaSetClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *replicaSetClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiappsv1.ReplicaSet{}, i.defaultInformer) } -func (f *replicaSetClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&appsv1.ReplicaSet{}, f.defaultInformer) +func (i *replicaSetClusterInformer) Lister() kcpv1.ReplicaSetClusterLister { + return kcpv1.NewReplicaSetClusterLister(i.Informer().GetIndexer()) } -func (f *replicaSetClusterInformer) Lister() appsv1listers.ReplicaSetClusterLister { - return appsv1listers.NewReplicaSetClusterLister(f.Informer().GetIndexer()) +func (i *replicaSetClusterInformer) Cluster(clusterName logicalcluster.Name) appsv1.ReplicaSetInformer { + return &replicaSetInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *replicaSetClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamappsv1informers.ReplicaSetInformer { +func (i *replicaSetClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) appsv1.ReplicaSetInformer { return &replicaSetInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type replicaSetInformer struct { informer cache.SharedIndexInformer - lister upstreamappsv1listers.ReplicaSetLister + lister listersappsv1.ReplicaSetLister } -func (f *replicaSetInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *replicaSetInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *replicaSetInformer) Lister() upstreamappsv1listers.ReplicaSetLister { - return f.lister +func (i *replicaSetInformer) Lister() listersappsv1.ReplicaSetLister { + return i.lister } diff --git a/informers/apps/v1/statefulset.go b/informers/apps/v1/statefulset.go index 26a2e7e2e..97732903a 100644 --- a/informers/apps/v1/statefulset.go +++ b/informers/apps/v1/statefulset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - appsv1 "k8s.io/api/apps/v1" + apiappsv1 "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamappsv1informers "k8s.io/client-go/informers/apps/v1" - upstreamappsv1listers "k8s.io/client-go/listers/apps/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - appsv1listers "github.com/kcp-dev/client-go/listers/apps/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + appsv1 "k8s.io/client-go/informers/apps/v1" + listersappsv1 "k8s.io/client-go/listers/apps/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/apps/v1" ) // StatefulSetClusterInformer provides access to a shared informer and lister for // StatefulSets. type StatefulSetClusterInformer interface { - Cluster(logicalcluster.Name) upstreamappsv1informers.StatefulSetInformer + Cluster(logicalcluster.Name) appsv1.StatefulSetInformer + ClusterWithContext(context.Context, logicalcluster.Name) appsv1.StatefulSetInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() appsv1listers.StatefulSetClusterLister + Lister() kcpv1.StatefulSetClusterLister } type statefulSetClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewStatefulSetClusterInformer constructs a new informer for StatefulSet type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewStatefulSetClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewStatefulSetClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredStatefulSetClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredStatefulSetClusterInformer constructs a new informer for StatefulSet type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredStatefulSetClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredStatefulSetClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AppsV1().StatefulSets().List(context.TODO(), options) + return client.AppsV1().StatefulSets().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AppsV1().StatefulSets().Watch(context.TODO(), options) + return client.AppsV1().StatefulSets().Watch(context.Background(), options) }, }, - &appsv1.StatefulSet{}, + &apiappsv1.StatefulSet{}, resyncPeriod, indexers, ) } -func (f *statefulSetClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *statefulSetClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredStatefulSetClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *statefulSetClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiappsv1.StatefulSet{}, i.defaultInformer) } -func (f *statefulSetClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&appsv1.StatefulSet{}, f.defaultInformer) +func (i *statefulSetClusterInformer) Lister() kcpv1.StatefulSetClusterLister { + return kcpv1.NewStatefulSetClusterLister(i.Informer().GetIndexer()) } -func (f *statefulSetClusterInformer) Lister() appsv1listers.StatefulSetClusterLister { - return appsv1listers.NewStatefulSetClusterLister(f.Informer().GetIndexer()) +func (i *statefulSetClusterInformer) Cluster(clusterName logicalcluster.Name) appsv1.StatefulSetInformer { + return &statefulSetInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *statefulSetClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamappsv1informers.StatefulSetInformer { +func (i *statefulSetClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) appsv1.StatefulSetInformer { return &statefulSetInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type statefulSetInformer struct { informer cache.SharedIndexInformer - lister upstreamappsv1listers.StatefulSetLister + lister listersappsv1.StatefulSetLister } -func (f *statefulSetInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *statefulSetInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *statefulSetInformer) Lister() upstreamappsv1listers.StatefulSetLister { - return f.lister +func (i *statefulSetInformer) Lister() listersappsv1.StatefulSetLister { + return i.lister } diff --git a/informers/apps/v1beta1/controllerrevision.go b/informers/apps/v1beta1/controllerrevision.go index fa32eb61d..814f1b13d 100644 --- a/informers/apps/v1beta1/controllerrevision.go +++ b/informers/apps/v1beta1/controllerrevision.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - appsv1beta1 "k8s.io/api/apps/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamappsv1beta1informers "k8s.io/client-go/informers/apps/v1beta1" - upstreamappsv1beta1listers "k8s.io/client-go/listers/apps/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - appsv1beta1listers "github.com/kcp-dev/client-go/listers/apps/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiappsv1beta1 "k8s.io/api/apps/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + appsv1beta1 "k8s.io/client-go/informers/apps/v1beta1" + listersappsv1beta1 "k8s.io/client-go/listers/apps/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/apps/v1beta1" ) // ControllerRevisionClusterInformer provides access to a shared informer and lister for // ControllerRevisions. type ControllerRevisionClusterInformer interface { - Cluster(logicalcluster.Name) upstreamappsv1beta1informers.ControllerRevisionInformer + Cluster(logicalcluster.Name) appsv1beta1.ControllerRevisionInformer + ClusterWithContext(context.Context, logicalcluster.Name) appsv1beta1.ControllerRevisionInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() appsv1beta1listers.ControllerRevisionClusterLister + Lister() kcpv1beta1.ControllerRevisionClusterLister } type controllerRevisionClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewControllerRevisionClusterInformer constructs a new informer for ControllerRevision type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewControllerRevisionClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewControllerRevisionClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredControllerRevisionClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredControllerRevisionClusterInformer constructs a new informer for ControllerRevision type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredControllerRevisionClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredControllerRevisionClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AppsV1beta1().ControllerRevisions().List(context.TODO(), options) + return client.AppsV1beta1().ControllerRevisions().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AppsV1beta1().ControllerRevisions().Watch(context.TODO(), options) + return client.AppsV1beta1().ControllerRevisions().Watch(context.Background(), options) }, }, - &appsv1beta1.ControllerRevision{}, + &apiappsv1beta1.ControllerRevision{}, resyncPeriod, indexers, ) } -func (f *controllerRevisionClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *controllerRevisionClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredControllerRevisionClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *controllerRevisionClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiappsv1beta1.ControllerRevision{}, i.defaultInformer) } -func (f *controllerRevisionClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&appsv1beta1.ControllerRevision{}, f.defaultInformer) +func (i *controllerRevisionClusterInformer) Lister() kcpv1beta1.ControllerRevisionClusterLister { + return kcpv1beta1.NewControllerRevisionClusterLister(i.Informer().GetIndexer()) } -func (f *controllerRevisionClusterInformer) Lister() appsv1beta1listers.ControllerRevisionClusterLister { - return appsv1beta1listers.NewControllerRevisionClusterLister(f.Informer().GetIndexer()) +func (i *controllerRevisionClusterInformer) Cluster(clusterName logicalcluster.Name) appsv1beta1.ControllerRevisionInformer { + return &controllerRevisionInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *controllerRevisionClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamappsv1beta1informers.ControllerRevisionInformer { +func (i *controllerRevisionClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) appsv1beta1.ControllerRevisionInformer { return &controllerRevisionInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type controllerRevisionInformer struct { informer cache.SharedIndexInformer - lister upstreamappsv1beta1listers.ControllerRevisionLister + lister listersappsv1beta1.ControllerRevisionLister } -func (f *controllerRevisionInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *controllerRevisionInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *controllerRevisionInformer) Lister() upstreamappsv1beta1listers.ControllerRevisionLister { - return f.lister +func (i *controllerRevisionInformer) Lister() listersappsv1beta1.ControllerRevisionLister { + return i.lister } diff --git a/informers/apps/v1beta1/deployment.go b/informers/apps/v1beta1/deployment.go index dd562dcb8..0b8e8d187 100644 --- a/informers/apps/v1beta1/deployment.go +++ b/informers/apps/v1beta1/deployment.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - appsv1beta1 "k8s.io/api/apps/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamappsv1beta1informers "k8s.io/client-go/informers/apps/v1beta1" - upstreamappsv1beta1listers "k8s.io/client-go/listers/apps/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - appsv1beta1listers "github.com/kcp-dev/client-go/listers/apps/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiappsv1beta1 "k8s.io/api/apps/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + appsv1beta1 "k8s.io/client-go/informers/apps/v1beta1" + listersappsv1beta1 "k8s.io/client-go/listers/apps/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/apps/v1beta1" ) // DeploymentClusterInformer provides access to a shared informer and lister for // Deployments. type DeploymentClusterInformer interface { - Cluster(logicalcluster.Name) upstreamappsv1beta1informers.DeploymentInformer + Cluster(logicalcluster.Name) appsv1beta1.DeploymentInformer + ClusterWithContext(context.Context, logicalcluster.Name) appsv1beta1.DeploymentInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() appsv1beta1listers.DeploymentClusterLister + Lister() kcpv1beta1.DeploymentClusterLister } type deploymentClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewDeploymentClusterInformer constructs a new informer for Deployment type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewDeploymentClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewDeploymentClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredDeploymentClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredDeploymentClusterInformer constructs a new informer for Deployment type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredDeploymentClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredDeploymentClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AppsV1beta1().Deployments().List(context.TODO(), options) + return client.AppsV1beta1().Deployments().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AppsV1beta1().Deployments().Watch(context.TODO(), options) + return client.AppsV1beta1().Deployments().Watch(context.Background(), options) }, }, - &appsv1beta1.Deployment{}, + &apiappsv1beta1.Deployment{}, resyncPeriod, indexers, ) } -func (f *deploymentClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *deploymentClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredDeploymentClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *deploymentClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiappsv1beta1.Deployment{}, i.defaultInformer) } -func (f *deploymentClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&appsv1beta1.Deployment{}, f.defaultInformer) +func (i *deploymentClusterInformer) Lister() kcpv1beta1.DeploymentClusterLister { + return kcpv1beta1.NewDeploymentClusterLister(i.Informer().GetIndexer()) } -func (f *deploymentClusterInformer) Lister() appsv1beta1listers.DeploymentClusterLister { - return appsv1beta1listers.NewDeploymentClusterLister(f.Informer().GetIndexer()) +func (i *deploymentClusterInformer) Cluster(clusterName logicalcluster.Name) appsv1beta1.DeploymentInformer { + return &deploymentInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *deploymentClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamappsv1beta1informers.DeploymentInformer { +func (i *deploymentClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) appsv1beta1.DeploymentInformer { return &deploymentInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type deploymentInformer struct { informer cache.SharedIndexInformer - lister upstreamappsv1beta1listers.DeploymentLister + lister listersappsv1beta1.DeploymentLister } -func (f *deploymentInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *deploymentInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *deploymentInformer) Lister() upstreamappsv1beta1listers.DeploymentLister { - return f.lister +func (i *deploymentInformer) Lister() listersappsv1beta1.DeploymentLister { + return i.lister } diff --git a/informers/apps/v1beta1/interface.go b/informers/apps/v1beta1/interface.go index af7a4e19c..d54b4568d 100644 --- a/informers/apps/v1beta1/interface.go +++ b/informers/apps/v1beta1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,44 +14,44 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // StatefulSets returns a StatefulSetClusterInformer - StatefulSets() StatefulSetClusterInformer - // Deployments returns a DeploymentClusterInformer - Deployments() DeploymentClusterInformer - // ControllerRevisions returns a ControllerRevisionClusterInformer + // ControllerRevisions returns a ControllerRevisionClusterInformer. ControllerRevisions() ControllerRevisionClusterInformer + // Deployments returns a DeploymentClusterInformer. + Deployments() DeploymentClusterInformer + // StatefulSets returns a StatefulSetClusterInformer. + StatefulSets() StatefulSetClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// StatefulSets returns a StatefulSetClusterInformer -func (v *version) StatefulSets() StatefulSetClusterInformer { - return &statefulSetClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +// ControllerRevisions returns a ControllerRevisionClusterInformer. +func (v *version) ControllerRevisions() ControllerRevisionClusterInformer { + return &controllerRevisionClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// Deployments returns a DeploymentClusterInformer +// Deployments returns a DeploymentClusterInformer. func (v *version) Deployments() DeploymentClusterInformer { return &deploymentClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// ControllerRevisions returns a ControllerRevisionClusterInformer -func (v *version) ControllerRevisions() ControllerRevisionClusterInformer { - return &controllerRevisionClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +// StatefulSets returns a StatefulSetClusterInformer. +func (v *version) StatefulSets() StatefulSetClusterInformer { + return &statefulSetClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/apps/v1beta1/statefulset.go b/informers/apps/v1beta1/statefulset.go index f679a98ce..7fcf0e0f5 100644 --- a/informers/apps/v1beta1/statefulset.go +++ b/informers/apps/v1beta1/statefulset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - appsv1beta1 "k8s.io/api/apps/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamappsv1beta1informers "k8s.io/client-go/informers/apps/v1beta1" - upstreamappsv1beta1listers "k8s.io/client-go/listers/apps/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - appsv1beta1listers "github.com/kcp-dev/client-go/listers/apps/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiappsv1beta1 "k8s.io/api/apps/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + appsv1beta1 "k8s.io/client-go/informers/apps/v1beta1" + listersappsv1beta1 "k8s.io/client-go/listers/apps/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/apps/v1beta1" ) // StatefulSetClusterInformer provides access to a shared informer and lister for // StatefulSets. type StatefulSetClusterInformer interface { - Cluster(logicalcluster.Name) upstreamappsv1beta1informers.StatefulSetInformer + Cluster(logicalcluster.Name) appsv1beta1.StatefulSetInformer + ClusterWithContext(context.Context, logicalcluster.Name) appsv1beta1.StatefulSetInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() appsv1beta1listers.StatefulSetClusterLister + Lister() kcpv1beta1.StatefulSetClusterLister } type statefulSetClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewStatefulSetClusterInformer constructs a new informer for StatefulSet type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewStatefulSetClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewStatefulSetClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredStatefulSetClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredStatefulSetClusterInformer constructs a new informer for StatefulSet type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredStatefulSetClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredStatefulSetClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AppsV1beta1().StatefulSets().List(context.TODO(), options) + return client.AppsV1beta1().StatefulSets().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AppsV1beta1().StatefulSets().Watch(context.TODO(), options) + return client.AppsV1beta1().StatefulSets().Watch(context.Background(), options) }, }, - &appsv1beta1.StatefulSet{}, + &apiappsv1beta1.StatefulSet{}, resyncPeriod, indexers, ) } -func (f *statefulSetClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *statefulSetClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredStatefulSetClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *statefulSetClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiappsv1beta1.StatefulSet{}, i.defaultInformer) } -func (f *statefulSetClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&appsv1beta1.StatefulSet{}, f.defaultInformer) +func (i *statefulSetClusterInformer) Lister() kcpv1beta1.StatefulSetClusterLister { + return kcpv1beta1.NewStatefulSetClusterLister(i.Informer().GetIndexer()) } -func (f *statefulSetClusterInformer) Lister() appsv1beta1listers.StatefulSetClusterLister { - return appsv1beta1listers.NewStatefulSetClusterLister(f.Informer().GetIndexer()) +func (i *statefulSetClusterInformer) Cluster(clusterName logicalcluster.Name) appsv1beta1.StatefulSetInformer { + return &statefulSetInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *statefulSetClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamappsv1beta1informers.StatefulSetInformer { +func (i *statefulSetClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) appsv1beta1.StatefulSetInformer { return &statefulSetInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type statefulSetInformer struct { informer cache.SharedIndexInformer - lister upstreamappsv1beta1listers.StatefulSetLister + lister listersappsv1beta1.StatefulSetLister } -func (f *statefulSetInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *statefulSetInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *statefulSetInformer) Lister() upstreamappsv1beta1listers.StatefulSetLister { - return f.lister +func (i *statefulSetInformer) Lister() listersappsv1beta1.StatefulSetLister { + return i.lister } diff --git a/informers/apps/v1beta2/controllerrevision.go b/informers/apps/v1beta2/controllerrevision.go index 28c5ea081..c716e5d2b 100644 --- a/informers/apps/v1beta2/controllerrevision.go +++ b/informers/apps/v1beta2/controllerrevision.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta2 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - appsv1beta2 "k8s.io/api/apps/v1beta2" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamappsv1beta2informers "k8s.io/client-go/informers/apps/v1beta2" - upstreamappsv1beta2listers "k8s.io/client-go/listers/apps/v1beta2" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - appsv1beta2listers "github.com/kcp-dev/client-go/listers/apps/v1beta2" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiappsv1beta2 "k8s.io/api/apps/v1beta2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + appsv1beta2 "k8s.io/client-go/informers/apps/v1beta2" + listersappsv1beta2 "k8s.io/client-go/listers/apps/v1beta2" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta2 "github.com/kcp-dev/client-go/listers/apps/v1beta2" ) // ControllerRevisionClusterInformer provides access to a shared informer and lister for // ControllerRevisions. type ControllerRevisionClusterInformer interface { - Cluster(logicalcluster.Name) upstreamappsv1beta2informers.ControllerRevisionInformer + Cluster(logicalcluster.Name) appsv1beta2.ControllerRevisionInformer + ClusterWithContext(context.Context, logicalcluster.Name) appsv1beta2.ControllerRevisionInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() appsv1beta2listers.ControllerRevisionClusterLister + Lister() kcpv1beta2.ControllerRevisionClusterLister } type controllerRevisionClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewControllerRevisionClusterInformer constructs a new informer for ControllerRevision type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewControllerRevisionClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewControllerRevisionClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredControllerRevisionClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredControllerRevisionClusterInformer constructs a new informer for ControllerRevision type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredControllerRevisionClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredControllerRevisionClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AppsV1beta2().ControllerRevisions().List(context.TODO(), options) + return client.AppsV1beta2().ControllerRevisions().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AppsV1beta2().ControllerRevisions().Watch(context.TODO(), options) + return client.AppsV1beta2().ControllerRevisions().Watch(context.Background(), options) }, }, - &appsv1beta2.ControllerRevision{}, + &apiappsv1beta2.ControllerRevision{}, resyncPeriod, indexers, ) } -func (f *controllerRevisionClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *controllerRevisionClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredControllerRevisionClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *controllerRevisionClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiappsv1beta2.ControllerRevision{}, i.defaultInformer) } -func (f *controllerRevisionClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&appsv1beta2.ControllerRevision{}, f.defaultInformer) +func (i *controllerRevisionClusterInformer) Lister() kcpv1beta2.ControllerRevisionClusterLister { + return kcpv1beta2.NewControllerRevisionClusterLister(i.Informer().GetIndexer()) } -func (f *controllerRevisionClusterInformer) Lister() appsv1beta2listers.ControllerRevisionClusterLister { - return appsv1beta2listers.NewControllerRevisionClusterLister(f.Informer().GetIndexer()) +func (i *controllerRevisionClusterInformer) Cluster(clusterName logicalcluster.Name) appsv1beta2.ControllerRevisionInformer { + return &controllerRevisionInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *controllerRevisionClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamappsv1beta2informers.ControllerRevisionInformer { +func (i *controllerRevisionClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) appsv1beta2.ControllerRevisionInformer { return &controllerRevisionInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type controllerRevisionInformer struct { informer cache.SharedIndexInformer - lister upstreamappsv1beta2listers.ControllerRevisionLister + lister listersappsv1beta2.ControllerRevisionLister } -func (f *controllerRevisionInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *controllerRevisionInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *controllerRevisionInformer) Lister() upstreamappsv1beta2listers.ControllerRevisionLister { - return f.lister +func (i *controllerRevisionInformer) Lister() listersappsv1beta2.ControllerRevisionLister { + return i.lister } diff --git a/informers/apps/v1beta2/daemonset.go b/informers/apps/v1beta2/daemonset.go index e9cdd8668..cf2ec6871 100644 --- a/informers/apps/v1beta2/daemonset.go +++ b/informers/apps/v1beta2/daemonset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta2 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - appsv1beta2 "k8s.io/api/apps/v1beta2" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamappsv1beta2informers "k8s.io/client-go/informers/apps/v1beta2" - upstreamappsv1beta2listers "k8s.io/client-go/listers/apps/v1beta2" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - appsv1beta2listers "github.com/kcp-dev/client-go/listers/apps/v1beta2" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiappsv1beta2 "k8s.io/api/apps/v1beta2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + appsv1beta2 "k8s.io/client-go/informers/apps/v1beta2" + listersappsv1beta2 "k8s.io/client-go/listers/apps/v1beta2" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta2 "github.com/kcp-dev/client-go/listers/apps/v1beta2" ) // DaemonSetClusterInformer provides access to a shared informer and lister for // DaemonSets. type DaemonSetClusterInformer interface { - Cluster(logicalcluster.Name) upstreamappsv1beta2informers.DaemonSetInformer + Cluster(logicalcluster.Name) appsv1beta2.DaemonSetInformer + ClusterWithContext(context.Context, logicalcluster.Name) appsv1beta2.DaemonSetInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() appsv1beta2listers.DaemonSetClusterLister + Lister() kcpv1beta2.DaemonSetClusterLister } type daemonSetClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewDaemonSetClusterInformer constructs a new informer for DaemonSet type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewDaemonSetClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewDaemonSetClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredDaemonSetClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredDaemonSetClusterInformer constructs a new informer for DaemonSet type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredDaemonSetClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredDaemonSetClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AppsV1beta2().DaemonSets().List(context.TODO(), options) + return client.AppsV1beta2().DaemonSets().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AppsV1beta2().DaemonSets().Watch(context.TODO(), options) + return client.AppsV1beta2().DaemonSets().Watch(context.Background(), options) }, }, - &appsv1beta2.DaemonSet{}, + &apiappsv1beta2.DaemonSet{}, resyncPeriod, indexers, ) } -func (f *daemonSetClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *daemonSetClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredDaemonSetClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *daemonSetClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiappsv1beta2.DaemonSet{}, i.defaultInformer) } -func (f *daemonSetClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&appsv1beta2.DaemonSet{}, f.defaultInformer) +func (i *daemonSetClusterInformer) Lister() kcpv1beta2.DaemonSetClusterLister { + return kcpv1beta2.NewDaemonSetClusterLister(i.Informer().GetIndexer()) } -func (f *daemonSetClusterInformer) Lister() appsv1beta2listers.DaemonSetClusterLister { - return appsv1beta2listers.NewDaemonSetClusterLister(f.Informer().GetIndexer()) +func (i *daemonSetClusterInformer) Cluster(clusterName logicalcluster.Name) appsv1beta2.DaemonSetInformer { + return &daemonSetInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *daemonSetClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamappsv1beta2informers.DaemonSetInformer { +func (i *daemonSetClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) appsv1beta2.DaemonSetInformer { return &daemonSetInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type daemonSetInformer struct { informer cache.SharedIndexInformer - lister upstreamappsv1beta2listers.DaemonSetLister + lister listersappsv1beta2.DaemonSetLister } -func (f *daemonSetInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *daemonSetInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *daemonSetInformer) Lister() upstreamappsv1beta2listers.DaemonSetLister { - return f.lister +func (i *daemonSetInformer) Lister() listersappsv1beta2.DaemonSetLister { + return i.lister } diff --git a/informers/apps/v1beta2/deployment.go b/informers/apps/v1beta2/deployment.go index c2e885240..04ffc59c9 100644 --- a/informers/apps/v1beta2/deployment.go +++ b/informers/apps/v1beta2/deployment.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta2 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - appsv1beta2 "k8s.io/api/apps/v1beta2" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamappsv1beta2informers "k8s.io/client-go/informers/apps/v1beta2" - upstreamappsv1beta2listers "k8s.io/client-go/listers/apps/v1beta2" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - appsv1beta2listers "github.com/kcp-dev/client-go/listers/apps/v1beta2" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiappsv1beta2 "k8s.io/api/apps/v1beta2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + appsv1beta2 "k8s.io/client-go/informers/apps/v1beta2" + listersappsv1beta2 "k8s.io/client-go/listers/apps/v1beta2" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta2 "github.com/kcp-dev/client-go/listers/apps/v1beta2" ) // DeploymentClusterInformer provides access to a shared informer and lister for // Deployments. type DeploymentClusterInformer interface { - Cluster(logicalcluster.Name) upstreamappsv1beta2informers.DeploymentInformer + Cluster(logicalcluster.Name) appsv1beta2.DeploymentInformer + ClusterWithContext(context.Context, logicalcluster.Name) appsv1beta2.DeploymentInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() appsv1beta2listers.DeploymentClusterLister + Lister() kcpv1beta2.DeploymentClusterLister } type deploymentClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewDeploymentClusterInformer constructs a new informer for Deployment type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewDeploymentClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewDeploymentClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredDeploymentClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredDeploymentClusterInformer constructs a new informer for Deployment type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredDeploymentClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredDeploymentClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AppsV1beta2().Deployments().List(context.TODO(), options) + return client.AppsV1beta2().Deployments().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AppsV1beta2().Deployments().Watch(context.TODO(), options) + return client.AppsV1beta2().Deployments().Watch(context.Background(), options) }, }, - &appsv1beta2.Deployment{}, + &apiappsv1beta2.Deployment{}, resyncPeriod, indexers, ) } -func (f *deploymentClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *deploymentClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredDeploymentClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *deploymentClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiappsv1beta2.Deployment{}, i.defaultInformer) } -func (f *deploymentClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&appsv1beta2.Deployment{}, f.defaultInformer) +func (i *deploymentClusterInformer) Lister() kcpv1beta2.DeploymentClusterLister { + return kcpv1beta2.NewDeploymentClusterLister(i.Informer().GetIndexer()) } -func (f *deploymentClusterInformer) Lister() appsv1beta2listers.DeploymentClusterLister { - return appsv1beta2listers.NewDeploymentClusterLister(f.Informer().GetIndexer()) +func (i *deploymentClusterInformer) Cluster(clusterName logicalcluster.Name) appsv1beta2.DeploymentInformer { + return &deploymentInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *deploymentClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamappsv1beta2informers.DeploymentInformer { +func (i *deploymentClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) appsv1beta2.DeploymentInformer { return &deploymentInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type deploymentInformer struct { informer cache.SharedIndexInformer - lister upstreamappsv1beta2listers.DeploymentLister + lister listersappsv1beta2.DeploymentLister } -func (f *deploymentInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *deploymentInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *deploymentInformer) Lister() upstreamappsv1beta2listers.DeploymentLister { - return f.lister +func (i *deploymentInformer) Lister() listersappsv1beta2.DeploymentLister { + return i.lister } diff --git a/informers/apps/v1beta2/interface.go b/informers/apps/v1beta2/interface.go index f367c4dca..b7fc5f1d2 100644 --- a/informers/apps/v1beta2/interface.go +++ b/informers/apps/v1beta2/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,58 +14,58 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta2 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // StatefulSets returns a StatefulSetClusterInformer - StatefulSets() StatefulSetClusterInformer - // Deployments returns a DeploymentClusterInformer - Deployments() DeploymentClusterInformer - // DaemonSets returns a DaemonSetClusterInformer + // ControllerRevisions returns a ControllerRevisionClusterInformer. + ControllerRevisions() ControllerRevisionClusterInformer + // DaemonSets returns a DaemonSetClusterInformer. DaemonSets() DaemonSetClusterInformer - // ReplicaSets returns a ReplicaSetClusterInformer + // Deployments returns a DeploymentClusterInformer. + Deployments() DeploymentClusterInformer + // ReplicaSets returns a ReplicaSetClusterInformer. ReplicaSets() ReplicaSetClusterInformer - // ControllerRevisions returns a ControllerRevisionClusterInformer - ControllerRevisions() ControllerRevisionClusterInformer + // StatefulSets returns a StatefulSetClusterInformer. + StatefulSets() StatefulSetClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// StatefulSets returns a StatefulSetClusterInformer -func (v *version) StatefulSets() StatefulSetClusterInformer { - return &statefulSetClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} - -// Deployments returns a DeploymentClusterInformer -func (v *version) Deployments() DeploymentClusterInformer { - return &deploymentClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +// ControllerRevisions returns a ControllerRevisionClusterInformer. +func (v *version) ControllerRevisions() ControllerRevisionClusterInformer { + return &controllerRevisionClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// DaemonSets returns a DaemonSetClusterInformer +// DaemonSets returns a DaemonSetClusterInformer. func (v *version) DaemonSets() DaemonSetClusterInformer { return &daemonSetClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// ReplicaSets returns a ReplicaSetClusterInformer +// Deployments returns a DeploymentClusterInformer. +func (v *version) Deployments() DeploymentClusterInformer { + return &deploymentClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + +// ReplicaSets returns a ReplicaSetClusterInformer. func (v *version) ReplicaSets() ReplicaSetClusterInformer { return &replicaSetClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// ControllerRevisions returns a ControllerRevisionClusterInformer -func (v *version) ControllerRevisions() ControllerRevisionClusterInformer { - return &controllerRevisionClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +// StatefulSets returns a StatefulSetClusterInformer. +func (v *version) StatefulSets() StatefulSetClusterInformer { + return &statefulSetClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/apps/v1beta2/replicaset.go b/informers/apps/v1beta2/replicaset.go index 267a1a87a..f3e77fcb6 100644 --- a/informers/apps/v1beta2/replicaset.go +++ b/informers/apps/v1beta2/replicaset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta2 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - appsv1beta2 "k8s.io/api/apps/v1beta2" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamappsv1beta2informers "k8s.io/client-go/informers/apps/v1beta2" - upstreamappsv1beta2listers "k8s.io/client-go/listers/apps/v1beta2" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - appsv1beta2listers "github.com/kcp-dev/client-go/listers/apps/v1beta2" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiappsv1beta2 "k8s.io/api/apps/v1beta2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + appsv1beta2 "k8s.io/client-go/informers/apps/v1beta2" + listersappsv1beta2 "k8s.io/client-go/listers/apps/v1beta2" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta2 "github.com/kcp-dev/client-go/listers/apps/v1beta2" ) // ReplicaSetClusterInformer provides access to a shared informer and lister for // ReplicaSets. type ReplicaSetClusterInformer interface { - Cluster(logicalcluster.Name) upstreamappsv1beta2informers.ReplicaSetInformer + Cluster(logicalcluster.Name) appsv1beta2.ReplicaSetInformer + ClusterWithContext(context.Context, logicalcluster.Name) appsv1beta2.ReplicaSetInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() appsv1beta2listers.ReplicaSetClusterLister + Lister() kcpv1beta2.ReplicaSetClusterLister } type replicaSetClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewReplicaSetClusterInformer constructs a new informer for ReplicaSet type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewReplicaSetClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewReplicaSetClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredReplicaSetClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredReplicaSetClusterInformer constructs a new informer for ReplicaSet type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredReplicaSetClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredReplicaSetClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AppsV1beta2().ReplicaSets().List(context.TODO(), options) + return client.AppsV1beta2().ReplicaSets().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AppsV1beta2().ReplicaSets().Watch(context.TODO(), options) + return client.AppsV1beta2().ReplicaSets().Watch(context.Background(), options) }, }, - &appsv1beta2.ReplicaSet{}, + &apiappsv1beta2.ReplicaSet{}, resyncPeriod, indexers, ) } -func (f *replicaSetClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *replicaSetClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredReplicaSetClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *replicaSetClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiappsv1beta2.ReplicaSet{}, i.defaultInformer) } -func (f *replicaSetClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&appsv1beta2.ReplicaSet{}, f.defaultInformer) +func (i *replicaSetClusterInformer) Lister() kcpv1beta2.ReplicaSetClusterLister { + return kcpv1beta2.NewReplicaSetClusterLister(i.Informer().GetIndexer()) } -func (f *replicaSetClusterInformer) Lister() appsv1beta2listers.ReplicaSetClusterLister { - return appsv1beta2listers.NewReplicaSetClusterLister(f.Informer().GetIndexer()) +func (i *replicaSetClusterInformer) Cluster(clusterName logicalcluster.Name) appsv1beta2.ReplicaSetInformer { + return &replicaSetInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *replicaSetClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamappsv1beta2informers.ReplicaSetInformer { +func (i *replicaSetClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) appsv1beta2.ReplicaSetInformer { return &replicaSetInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type replicaSetInformer struct { informer cache.SharedIndexInformer - lister upstreamappsv1beta2listers.ReplicaSetLister + lister listersappsv1beta2.ReplicaSetLister } -func (f *replicaSetInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *replicaSetInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *replicaSetInformer) Lister() upstreamappsv1beta2listers.ReplicaSetLister { - return f.lister +func (i *replicaSetInformer) Lister() listersappsv1beta2.ReplicaSetLister { + return i.lister } diff --git a/informers/apps/v1beta2/statefulset.go b/informers/apps/v1beta2/statefulset.go index 6236bd44a..3b1caf15d 100644 --- a/informers/apps/v1beta2/statefulset.go +++ b/informers/apps/v1beta2/statefulset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta2 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - appsv1beta2 "k8s.io/api/apps/v1beta2" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamappsv1beta2informers "k8s.io/client-go/informers/apps/v1beta2" - upstreamappsv1beta2listers "k8s.io/client-go/listers/apps/v1beta2" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - appsv1beta2listers "github.com/kcp-dev/client-go/listers/apps/v1beta2" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiappsv1beta2 "k8s.io/api/apps/v1beta2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + appsv1beta2 "k8s.io/client-go/informers/apps/v1beta2" + listersappsv1beta2 "k8s.io/client-go/listers/apps/v1beta2" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta2 "github.com/kcp-dev/client-go/listers/apps/v1beta2" ) // StatefulSetClusterInformer provides access to a shared informer and lister for // StatefulSets. type StatefulSetClusterInformer interface { - Cluster(logicalcluster.Name) upstreamappsv1beta2informers.StatefulSetInformer + Cluster(logicalcluster.Name) appsv1beta2.StatefulSetInformer + ClusterWithContext(context.Context, logicalcluster.Name) appsv1beta2.StatefulSetInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() appsv1beta2listers.StatefulSetClusterLister + Lister() kcpv1beta2.StatefulSetClusterLister } type statefulSetClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewStatefulSetClusterInformer constructs a new informer for StatefulSet type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewStatefulSetClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewStatefulSetClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredStatefulSetClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredStatefulSetClusterInformer constructs a new informer for StatefulSet type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredStatefulSetClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredStatefulSetClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AppsV1beta2().StatefulSets().List(context.TODO(), options) + return client.AppsV1beta2().StatefulSets().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AppsV1beta2().StatefulSets().Watch(context.TODO(), options) + return client.AppsV1beta2().StatefulSets().Watch(context.Background(), options) }, }, - &appsv1beta2.StatefulSet{}, + &apiappsv1beta2.StatefulSet{}, resyncPeriod, indexers, ) } -func (f *statefulSetClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *statefulSetClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredStatefulSetClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *statefulSetClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiappsv1beta2.StatefulSet{}, i.defaultInformer) } -func (f *statefulSetClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&appsv1beta2.StatefulSet{}, f.defaultInformer) +func (i *statefulSetClusterInformer) Lister() kcpv1beta2.StatefulSetClusterLister { + return kcpv1beta2.NewStatefulSetClusterLister(i.Informer().GetIndexer()) } -func (f *statefulSetClusterInformer) Lister() appsv1beta2listers.StatefulSetClusterLister { - return appsv1beta2listers.NewStatefulSetClusterLister(f.Informer().GetIndexer()) +func (i *statefulSetClusterInformer) Cluster(clusterName logicalcluster.Name) appsv1beta2.StatefulSetInformer { + return &statefulSetInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *statefulSetClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamappsv1beta2informers.StatefulSetInformer { +func (i *statefulSetClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) appsv1beta2.StatefulSetInformer { return &statefulSetInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type statefulSetInformer struct { informer cache.SharedIndexInformer - lister upstreamappsv1beta2listers.StatefulSetLister + lister listersappsv1beta2.StatefulSetLister } -func (f *statefulSetInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *statefulSetInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *statefulSetInformer) Lister() upstreamappsv1beta2listers.StatefulSetLister { - return f.lister +func (i *statefulSetInformer) Lister() listersappsv1beta2.StatefulSetLister { + return i.lister } diff --git a/informers/autoscaling/interface.go b/informers/autoscaling/interface.go index 6033b8a81..3956026f8 100644 --- a/informers/autoscaling/interface.go +++ b/informers/autoscaling/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,55 +14,56 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package autoscaling import ( - "github.com/kcp-dev/client-go/informers/autoscaling/v1" - "github.com/kcp-dev/client-go/informers/autoscaling/v2" - "github.com/kcp-dev/client-go/informers/autoscaling/v2beta1" - "github.com/kcp-dev/client-go/informers/autoscaling/v2beta2" - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpv1 "github.com/kcp-dev/client-go/informers/autoscaling/v1" + kcpv2 "github.com/kcp-dev/client-go/informers/autoscaling/v2" + kcpv2beta1 "github.com/kcp-dev/client-go/informers/autoscaling/v2beta1" + kcpv2beta2 "github.com/kcp-dev/client-go/informers/autoscaling/v2beta2" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) +// ClusterInterface provides access to each of this group's versions. type ClusterInterface interface { - // V1 provides access to the shared informers in V1. - V1() v1.ClusterInterface - // V2 provides access to the shared informers in V2. - V2() v2.ClusterInterface - // V2beta1 provides access to the shared informers in V2beta1. - V2beta1() v2beta1.ClusterInterface - // V2beta2 provides access to the shared informers in V2beta2. - V2beta2() v2beta2.ClusterInterface + // V1 provides access to shared informers for resources in V1. + V1() kcpv1.ClusterInterface + // V2 provides access to shared informers for resources in V2. + V2() kcpv2.ClusterInterface + // V2beta1 provides access to shared informers for resources in V2beta1. + V2beta1() kcpv2beta1.ClusterInterface + // V2beta2 provides access to shared informers for resources in V2beta2. + V2beta2() kcpv2beta2.ClusterInterface } type group struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &group{factory: f, tweakListOptions: tweakListOptions} } -// V1 returns a new v1.ClusterInterface. -func (g *group) V1() v1.ClusterInterface { - return v1.New(g.factory, g.tweakListOptions) +// V1 returns a new kcpv1.ClusterInterface. +func (g *group) V1() kcpv1.ClusterInterface { + return kcpv1.New(g.factory, g.tweakListOptions) } -// V2 returns a new v2.ClusterInterface. -func (g *group) V2() v2.ClusterInterface { - return v2.New(g.factory, g.tweakListOptions) +// V2 returns a new kcpv2.ClusterInterface. +func (g *group) V2() kcpv2.ClusterInterface { + return kcpv2.New(g.factory, g.tweakListOptions) } -// V2beta1 returns a new v2beta1.ClusterInterface. -func (g *group) V2beta1() v2beta1.ClusterInterface { - return v2beta1.New(g.factory, g.tweakListOptions) +// V2beta1 returns a new kcpv2beta1.ClusterInterface. +func (g *group) V2beta1() kcpv2beta1.ClusterInterface { + return kcpv2beta1.New(g.factory, g.tweakListOptions) } -// V2beta2 returns a new v2beta2.ClusterInterface. -func (g *group) V2beta2() v2beta2.ClusterInterface { - return v2beta2.New(g.factory, g.tweakListOptions) +// V2beta2 returns a new kcpv2beta2.ClusterInterface. +func (g *group) V2beta2() kcpv2beta2.ClusterInterface { + return kcpv2beta2.New(g.factory, g.tweakListOptions) } diff --git a/informers/autoscaling/v1/horizontalpodautoscaler.go b/informers/autoscaling/v1/horizontalpodautoscaler.go index 56046213d..16b210e17 100644 --- a/informers/autoscaling/v1/horizontalpodautoscaler.go +++ b/informers/autoscaling/v1/horizontalpodautoscaler.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - autoscalingv1 "k8s.io/api/autoscaling/v1" + apiautoscalingv1 "k8s.io/api/autoscaling/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamautoscalingv1informers "k8s.io/client-go/informers/autoscaling/v1" - upstreamautoscalingv1listers "k8s.io/client-go/listers/autoscaling/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - autoscalingv1listers "github.com/kcp-dev/client-go/listers/autoscaling/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + autoscalingv1 "k8s.io/client-go/informers/autoscaling/v1" + listersautoscalingv1 "k8s.io/client-go/listers/autoscaling/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/autoscaling/v1" ) // HorizontalPodAutoscalerClusterInformer provides access to a shared informer and lister for // HorizontalPodAutoscalers. type HorizontalPodAutoscalerClusterInformer interface { - Cluster(logicalcluster.Name) upstreamautoscalingv1informers.HorizontalPodAutoscalerInformer + Cluster(logicalcluster.Name) autoscalingv1.HorizontalPodAutoscalerInformer + ClusterWithContext(context.Context, logicalcluster.Name) autoscalingv1.HorizontalPodAutoscalerInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() autoscalingv1listers.HorizontalPodAutoscalerClusterLister + Lister() kcpv1.HorizontalPodAutoscalerClusterLister } type horizontalPodAutoscalerClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewHorizontalPodAutoscalerClusterInformer constructs a new informer for HorizontalPodAutoscaler type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewHorizontalPodAutoscalerClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewHorizontalPodAutoscalerClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredHorizontalPodAutoscalerClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredHorizontalPodAutoscalerClusterInformer constructs a new informer for HorizontalPodAutoscaler type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredHorizontalPodAutoscalerClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredHorizontalPodAutoscalerClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AutoscalingV1().HorizontalPodAutoscalers().List(context.TODO(), options) + return client.AutoscalingV1().HorizontalPodAutoscalers().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AutoscalingV1().HorizontalPodAutoscalers().Watch(context.TODO(), options) + return client.AutoscalingV1().HorizontalPodAutoscalers().Watch(context.Background(), options) }, }, - &autoscalingv1.HorizontalPodAutoscaler{}, + &apiautoscalingv1.HorizontalPodAutoscaler{}, resyncPeriod, indexers, ) } -func (f *horizontalPodAutoscalerClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *horizontalPodAutoscalerClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredHorizontalPodAutoscalerClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *horizontalPodAutoscalerClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiautoscalingv1.HorizontalPodAutoscaler{}, i.defaultInformer) } -func (f *horizontalPodAutoscalerClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&autoscalingv1.HorizontalPodAutoscaler{}, f.defaultInformer) +func (i *horizontalPodAutoscalerClusterInformer) Lister() kcpv1.HorizontalPodAutoscalerClusterLister { + return kcpv1.NewHorizontalPodAutoscalerClusterLister(i.Informer().GetIndexer()) } -func (f *horizontalPodAutoscalerClusterInformer) Lister() autoscalingv1listers.HorizontalPodAutoscalerClusterLister { - return autoscalingv1listers.NewHorizontalPodAutoscalerClusterLister(f.Informer().GetIndexer()) +func (i *horizontalPodAutoscalerClusterInformer) Cluster(clusterName logicalcluster.Name) autoscalingv1.HorizontalPodAutoscalerInformer { + return &horizontalPodAutoscalerInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *horizontalPodAutoscalerClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamautoscalingv1informers.HorizontalPodAutoscalerInformer { +func (i *horizontalPodAutoscalerClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) autoscalingv1.HorizontalPodAutoscalerInformer { return &horizontalPodAutoscalerInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type horizontalPodAutoscalerInformer struct { informer cache.SharedIndexInformer - lister upstreamautoscalingv1listers.HorizontalPodAutoscalerLister + lister listersautoscalingv1.HorizontalPodAutoscalerLister } -func (f *horizontalPodAutoscalerInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *horizontalPodAutoscalerInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *horizontalPodAutoscalerInformer) Lister() upstreamautoscalingv1listers.HorizontalPodAutoscalerLister { - return f.lister +func (i *horizontalPodAutoscalerInformer) Lister() listersautoscalingv1.HorizontalPodAutoscalerLister { + return i.lister } diff --git a/informers/autoscaling/v1/interface.go b/informers/autoscaling/v1/interface.go index e3e2a6f1f..342976b1a 100644 --- a/informers/autoscaling/v1/interface.go +++ b/informers/autoscaling/v1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,30 +14,30 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // HorizontalPodAutoscalers returns a HorizontalPodAutoscalerClusterInformer + // HorizontalPodAutoscalers returns a HorizontalPodAutoscalerClusterInformer. HorizontalPodAutoscalers() HorizontalPodAutoscalerClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// HorizontalPodAutoscalers returns a HorizontalPodAutoscalerClusterInformer +// HorizontalPodAutoscalers returns a HorizontalPodAutoscalerClusterInformer. func (v *version) HorizontalPodAutoscalers() HorizontalPodAutoscalerClusterInformer { return &horizontalPodAutoscalerClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/autoscaling/v2/horizontalpodautoscaler.go b/informers/autoscaling/v2/horizontalpodautoscaler.go index 446032baa..d9d5fd2e8 100644 --- a/informers/autoscaling/v2/horizontalpodautoscaler.go +++ b/informers/autoscaling/v2/horizontalpodautoscaler.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v2 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - autoscalingv2 "k8s.io/api/autoscaling/v2" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamautoscalingv2informers "k8s.io/client-go/informers/autoscaling/v2" - upstreamautoscalingv2listers "k8s.io/client-go/listers/autoscaling/v2" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - autoscalingv2listers "github.com/kcp-dev/client-go/listers/autoscaling/v2" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiautoscalingv2 "k8s.io/api/autoscaling/v2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + autoscalingv2 "k8s.io/client-go/informers/autoscaling/v2" + listersautoscalingv2 "k8s.io/client-go/listers/autoscaling/v2" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv2 "github.com/kcp-dev/client-go/listers/autoscaling/v2" ) // HorizontalPodAutoscalerClusterInformer provides access to a shared informer and lister for // HorizontalPodAutoscalers. type HorizontalPodAutoscalerClusterInformer interface { - Cluster(logicalcluster.Name) upstreamautoscalingv2informers.HorizontalPodAutoscalerInformer + Cluster(logicalcluster.Name) autoscalingv2.HorizontalPodAutoscalerInformer + ClusterWithContext(context.Context, logicalcluster.Name) autoscalingv2.HorizontalPodAutoscalerInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() autoscalingv2listers.HorizontalPodAutoscalerClusterLister + Lister() kcpv2.HorizontalPodAutoscalerClusterLister } type horizontalPodAutoscalerClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewHorizontalPodAutoscalerClusterInformer constructs a new informer for HorizontalPodAutoscaler type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewHorizontalPodAutoscalerClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewHorizontalPodAutoscalerClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredHorizontalPodAutoscalerClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredHorizontalPodAutoscalerClusterInformer constructs a new informer for HorizontalPodAutoscaler type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredHorizontalPodAutoscalerClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredHorizontalPodAutoscalerClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AutoscalingV2().HorizontalPodAutoscalers().List(context.TODO(), options) + return client.AutoscalingV2().HorizontalPodAutoscalers().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AutoscalingV2().HorizontalPodAutoscalers().Watch(context.TODO(), options) + return client.AutoscalingV2().HorizontalPodAutoscalers().Watch(context.Background(), options) }, }, - &autoscalingv2.HorizontalPodAutoscaler{}, + &apiautoscalingv2.HorizontalPodAutoscaler{}, resyncPeriod, indexers, ) } -func (f *horizontalPodAutoscalerClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *horizontalPodAutoscalerClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredHorizontalPodAutoscalerClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *horizontalPodAutoscalerClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiautoscalingv2.HorizontalPodAutoscaler{}, i.defaultInformer) } -func (f *horizontalPodAutoscalerClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&autoscalingv2.HorizontalPodAutoscaler{}, f.defaultInformer) +func (i *horizontalPodAutoscalerClusterInformer) Lister() kcpv2.HorizontalPodAutoscalerClusterLister { + return kcpv2.NewHorizontalPodAutoscalerClusterLister(i.Informer().GetIndexer()) } -func (f *horizontalPodAutoscalerClusterInformer) Lister() autoscalingv2listers.HorizontalPodAutoscalerClusterLister { - return autoscalingv2listers.NewHorizontalPodAutoscalerClusterLister(f.Informer().GetIndexer()) +func (i *horizontalPodAutoscalerClusterInformer) Cluster(clusterName logicalcluster.Name) autoscalingv2.HorizontalPodAutoscalerInformer { + return &horizontalPodAutoscalerInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *horizontalPodAutoscalerClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamautoscalingv2informers.HorizontalPodAutoscalerInformer { +func (i *horizontalPodAutoscalerClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) autoscalingv2.HorizontalPodAutoscalerInformer { return &horizontalPodAutoscalerInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type horizontalPodAutoscalerInformer struct { informer cache.SharedIndexInformer - lister upstreamautoscalingv2listers.HorizontalPodAutoscalerLister + lister listersautoscalingv2.HorizontalPodAutoscalerLister } -func (f *horizontalPodAutoscalerInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *horizontalPodAutoscalerInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *horizontalPodAutoscalerInformer) Lister() upstreamautoscalingv2listers.HorizontalPodAutoscalerLister { - return f.lister +func (i *horizontalPodAutoscalerInformer) Lister() listersautoscalingv2.HorizontalPodAutoscalerLister { + return i.lister } diff --git a/informers/autoscaling/v2/interface.go b/informers/autoscaling/v2/interface.go index add4f946b..44dad46c5 100644 --- a/informers/autoscaling/v2/interface.go +++ b/informers/autoscaling/v2/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,30 +14,30 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v2 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // HorizontalPodAutoscalers returns a HorizontalPodAutoscalerClusterInformer + // HorizontalPodAutoscalers returns a HorizontalPodAutoscalerClusterInformer. HorizontalPodAutoscalers() HorizontalPodAutoscalerClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// HorizontalPodAutoscalers returns a HorizontalPodAutoscalerClusterInformer +// HorizontalPodAutoscalers returns a HorizontalPodAutoscalerClusterInformer. func (v *version) HorizontalPodAutoscalers() HorizontalPodAutoscalerClusterInformer { return &horizontalPodAutoscalerClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/autoscaling/v2beta1/horizontalpodautoscaler.go b/informers/autoscaling/v2beta1/horizontalpodautoscaler.go index eae8ab179..329a13fdc 100644 --- a/informers/autoscaling/v2beta1/horizontalpodautoscaler.go +++ b/informers/autoscaling/v2beta1/horizontalpodautoscaler.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v2beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - autoscalingv2beta1 "k8s.io/api/autoscaling/v2beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamautoscalingv2beta1informers "k8s.io/client-go/informers/autoscaling/v2beta1" - upstreamautoscalingv2beta1listers "k8s.io/client-go/listers/autoscaling/v2beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - autoscalingv2beta1listers "github.com/kcp-dev/client-go/listers/autoscaling/v2beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiautoscalingv2beta1 "k8s.io/api/autoscaling/v2beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + autoscalingv2beta1 "k8s.io/client-go/informers/autoscaling/v2beta1" + listersautoscalingv2beta1 "k8s.io/client-go/listers/autoscaling/v2beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv2beta1 "github.com/kcp-dev/client-go/listers/autoscaling/v2beta1" ) // HorizontalPodAutoscalerClusterInformer provides access to a shared informer and lister for // HorizontalPodAutoscalers. type HorizontalPodAutoscalerClusterInformer interface { - Cluster(logicalcluster.Name) upstreamautoscalingv2beta1informers.HorizontalPodAutoscalerInformer + Cluster(logicalcluster.Name) autoscalingv2beta1.HorizontalPodAutoscalerInformer + ClusterWithContext(context.Context, logicalcluster.Name) autoscalingv2beta1.HorizontalPodAutoscalerInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() autoscalingv2beta1listers.HorizontalPodAutoscalerClusterLister + Lister() kcpv2beta1.HorizontalPodAutoscalerClusterLister } type horizontalPodAutoscalerClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewHorizontalPodAutoscalerClusterInformer constructs a new informer for HorizontalPodAutoscaler type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewHorizontalPodAutoscalerClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewHorizontalPodAutoscalerClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredHorizontalPodAutoscalerClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredHorizontalPodAutoscalerClusterInformer constructs a new informer for HorizontalPodAutoscaler type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredHorizontalPodAutoscalerClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredHorizontalPodAutoscalerClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AutoscalingV2beta1().HorizontalPodAutoscalers().List(context.TODO(), options) + return client.AutoscalingV2beta1().HorizontalPodAutoscalers().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AutoscalingV2beta1().HorizontalPodAutoscalers().Watch(context.TODO(), options) + return client.AutoscalingV2beta1().HorizontalPodAutoscalers().Watch(context.Background(), options) }, }, - &autoscalingv2beta1.HorizontalPodAutoscaler{}, + &apiautoscalingv2beta1.HorizontalPodAutoscaler{}, resyncPeriod, indexers, ) } -func (f *horizontalPodAutoscalerClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *horizontalPodAutoscalerClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredHorizontalPodAutoscalerClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *horizontalPodAutoscalerClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiautoscalingv2beta1.HorizontalPodAutoscaler{}, i.defaultInformer) } -func (f *horizontalPodAutoscalerClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&autoscalingv2beta1.HorizontalPodAutoscaler{}, f.defaultInformer) +func (i *horizontalPodAutoscalerClusterInformer) Lister() kcpv2beta1.HorizontalPodAutoscalerClusterLister { + return kcpv2beta1.NewHorizontalPodAutoscalerClusterLister(i.Informer().GetIndexer()) } -func (f *horizontalPodAutoscalerClusterInformer) Lister() autoscalingv2beta1listers.HorizontalPodAutoscalerClusterLister { - return autoscalingv2beta1listers.NewHorizontalPodAutoscalerClusterLister(f.Informer().GetIndexer()) +func (i *horizontalPodAutoscalerClusterInformer) Cluster(clusterName logicalcluster.Name) autoscalingv2beta1.HorizontalPodAutoscalerInformer { + return &horizontalPodAutoscalerInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *horizontalPodAutoscalerClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamautoscalingv2beta1informers.HorizontalPodAutoscalerInformer { +func (i *horizontalPodAutoscalerClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) autoscalingv2beta1.HorizontalPodAutoscalerInformer { return &horizontalPodAutoscalerInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type horizontalPodAutoscalerInformer struct { informer cache.SharedIndexInformer - lister upstreamautoscalingv2beta1listers.HorizontalPodAutoscalerLister + lister listersautoscalingv2beta1.HorizontalPodAutoscalerLister } -func (f *horizontalPodAutoscalerInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *horizontalPodAutoscalerInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *horizontalPodAutoscalerInformer) Lister() upstreamautoscalingv2beta1listers.HorizontalPodAutoscalerLister { - return f.lister +func (i *horizontalPodAutoscalerInformer) Lister() listersautoscalingv2beta1.HorizontalPodAutoscalerLister { + return i.lister } diff --git a/informers/autoscaling/v2beta1/interface.go b/informers/autoscaling/v2beta1/interface.go index cb292bc70..7c0775ad8 100644 --- a/informers/autoscaling/v2beta1/interface.go +++ b/informers/autoscaling/v2beta1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,30 +14,30 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v2beta1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // HorizontalPodAutoscalers returns a HorizontalPodAutoscalerClusterInformer + // HorizontalPodAutoscalers returns a HorizontalPodAutoscalerClusterInformer. HorizontalPodAutoscalers() HorizontalPodAutoscalerClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// HorizontalPodAutoscalers returns a HorizontalPodAutoscalerClusterInformer +// HorizontalPodAutoscalers returns a HorizontalPodAutoscalerClusterInformer. func (v *version) HorizontalPodAutoscalers() HorizontalPodAutoscalerClusterInformer { return &horizontalPodAutoscalerClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/autoscaling/v2beta2/horizontalpodautoscaler.go b/informers/autoscaling/v2beta2/horizontalpodautoscaler.go index 6c9e4b96f..f1c114d1a 100644 --- a/informers/autoscaling/v2beta2/horizontalpodautoscaler.go +++ b/informers/autoscaling/v2beta2/horizontalpodautoscaler.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v2beta2 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - autoscalingv2beta2 "k8s.io/api/autoscaling/v2beta2" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamautoscalingv2beta2informers "k8s.io/client-go/informers/autoscaling/v2beta2" - upstreamautoscalingv2beta2listers "k8s.io/client-go/listers/autoscaling/v2beta2" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - autoscalingv2beta2listers "github.com/kcp-dev/client-go/listers/autoscaling/v2beta2" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiautoscalingv2beta2 "k8s.io/api/autoscaling/v2beta2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + autoscalingv2beta2 "k8s.io/client-go/informers/autoscaling/v2beta2" + listersautoscalingv2beta2 "k8s.io/client-go/listers/autoscaling/v2beta2" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv2beta2 "github.com/kcp-dev/client-go/listers/autoscaling/v2beta2" ) // HorizontalPodAutoscalerClusterInformer provides access to a shared informer and lister for // HorizontalPodAutoscalers. type HorizontalPodAutoscalerClusterInformer interface { - Cluster(logicalcluster.Name) upstreamautoscalingv2beta2informers.HorizontalPodAutoscalerInformer + Cluster(logicalcluster.Name) autoscalingv2beta2.HorizontalPodAutoscalerInformer + ClusterWithContext(context.Context, logicalcluster.Name) autoscalingv2beta2.HorizontalPodAutoscalerInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() autoscalingv2beta2listers.HorizontalPodAutoscalerClusterLister + Lister() kcpv2beta2.HorizontalPodAutoscalerClusterLister } type horizontalPodAutoscalerClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewHorizontalPodAutoscalerClusterInformer constructs a new informer for HorizontalPodAutoscaler type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewHorizontalPodAutoscalerClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewHorizontalPodAutoscalerClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredHorizontalPodAutoscalerClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredHorizontalPodAutoscalerClusterInformer constructs a new informer for HorizontalPodAutoscaler type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredHorizontalPodAutoscalerClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredHorizontalPodAutoscalerClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AutoscalingV2beta2().HorizontalPodAutoscalers().List(context.TODO(), options) + return client.AutoscalingV2beta2().HorizontalPodAutoscalers().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AutoscalingV2beta2().HorizontalPodAutoscalers().Watch(context.TODO(), options) + return client.AutoscalingV2beta2().HorizontalPodAutoscalers().Watch(context.Background(), options) }, }, - &autoscalingv2beta2.HorizontalPodAutoscaler{}, + &apiautoscalingv2beta2.HorizontalPodAutoscaler{}, resyncPeriod, indexers, ) } -func (f *horizontalPodAutoscalerClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *horizontalPodAutoscalerClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredHorizontalPodAutoscalerClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *horizontalPodAutoscalerClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiautoscalingv2beta2.HorizontalPodAutoscaler{}, i.defaultInformer) } -func (f *horizontalPodAutoscalerClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&autoscalingv2beta2.HorizontalPodAutoscaler{}, f.defaultInformer) +func (i *horizontalPodAutoscalerClusterInformer) Lister() kcpv2beta2.HorizontalPodAutoscalerClusterLister { + return kcpv2beta2.NewHorizontalPodAutoscalerClusterLister(i.Informer().GetIndexer()) } -func (f *horizontalPodAutoscalerClusterInformer) Lister() autoscalingv2beta2listers.HorizontalPodAutoscalerClusterLister { - return autoscalingv2beta2listers.NewHorizontalPodAutoscalerClusterLister(f.Informer().GetIndexer()) +func (i *horizontalPodAutoscalerClusterInformer) Cluster(clusterName logicalcluster.Name) autoscalingv2beta2.HorizontalPodAutoscalerInformer { + return &horizontalPodAutoscalerInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *horizontalPodAutoscalerClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamautoscalingv2beta2informers.HorizontalPodAutoscalerInformer { +func (i *horizontalPodAutoscalerClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) autoscalingv2beta2.HorizontalPodAutoscalerInformer { return &horizontalPodAutoscalerInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type horizontalPodAutoscalerInformer struct { informer cache.SharedIndexInformer - lister upstreamautoscalingv2beta2listers.HorizontalPodAutoscalerLister + lister listersautoscalingv2beta2.HorizontalPodAutoscalerLister } -func (f *horizontalPodAutoscalerInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *horizontalPodAutoscalerInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *horizontalPodAutoscalerInformer) Lister() upstreamautoscalingv2beta2listers.HorizontalPodAutoscalerLister { - return f.lister +func (i *horizontalPodAutoscalerInformer) Lister() listersautoscalingv2beta2.HorizontalPodAutoscalerLister { + return i.lister } diff --git a/informers/autoscaling/v2beta2/interface.go b/informers/autoscaling/v2beta2/interface.go index f32c863bf..a3f9b3e7b 100644 --- a/informers/autoscaling/v2beta2/interface.go +++ b/informers/autoscaling/v2beta2/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,30 +14,30 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v2beta2 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // HorizontalPodAutoscalers returns a HorizontalPodAutoscalerClusterInformer + // HorizontalPodAutoscalers returns a HorizontalPodAutoscalerClusterInformer. HorizontalPodAutoscalers() HorizontalPodAutoscalerClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// HorizontalPodAutoscalers returns a HorizontalPodAutoscalerClusterInformer +// HorizontalPodAutoscalers returns a HorizontalPodAutoscalerClusterInformer. func (v *version) HorizontalPodAutoscalers() HorizontalPodAutoscalerClusterInformer { return &horizontalPodAutoscalerClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/batch/interface.go b/informers/batch/interface.go index 30f1f05fb..609b3e545 100644 --- a/informers/batch/interface.go +++ b/informers/batch/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,39 +14,40 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package batch import ( - "github.com/kcp-dev/client-go/informers/batch/v1" - "github.com/kcp-dev/client-go/informers/batch/v1beta1" - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpv1 "github.com/kcp-dev/client-go/informers/batch/v1" + kcpv1beta1 "github.com/kcp-dev/client-go/informers/batch/v1beta1" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) +// ClusterInterface provides access to each of this group's versions. type ClusterInterface interface { - // V1 provides access to the shared informers in V1. - V1() v1.ClusterInterface - // V1beta1 provides access to the shared informers in V1beta1. - V1beta1() v1beta1.ClusterInterface + // V1 provides access to shared informers for resources in V1. + V1() kcpv1.ClusterInterface + // V1beta1 provides access to shared informers for resources in V1beta1. + V1beta1() kcpv1beta1.ClusterInterface } type group struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &group{factory: f, tweakListOptions: tweakListOptions} } -// V1 returns a new v1.ClusterInterface. -func (g *group) V1() v1.ClusterInterface { - return v1.New(g.factory, g.tweakListOptions) +// V1 returns a new kcpv1.ClusterInterface. +func (g *group) V1() kcpv1.ClusterInterface { + return kcpv1.New(g.factory, g.tweakListOptions) } -// V1beta1 returns a new v1beta1.ClusterInterface. -func (g *group) V1beta1() v1beta1.ClusterInterface { - return v1beta1.New(g.factory, g.tweakListOptions) +// V1beta1 returns a new kcpv1beta1.ClusterInterface. +func (g *group) V1beta1() kcpv1beta1.ClusterInterface { + return kcpv1beta1.New(g.factory, g.tweakListOptions) } diff --git a/informers/batch/v1/cronjob.go b/informers/batch/v1/cronjob.go index 97d8a9077..5e4cbe1e4 100644 --- a/informers/batch/v1/cronjob.go +++ b/informers/batch/v1/cronjob.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - batchv1 "k8s.io/api/batch/v1" + apibatchv1 "k8s.io/api/batch/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreambatchv1informers "k8s.io/client-go/informers/batch/v1" - upstreambatchv1listers "k8s.io/client-go/listers/batch/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - batchv1listers "github.com/kcp-dev/client-go/listers/batch/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + batchv1 "k8s.io/client-go/informers/batch/v1" + listersbatchv1 "k8s.io/client-go/listers/batch/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/batch/v1" ) // CronJobClusterInformer provides access to a shared informer and lister for // CronJobs. type CronJobClusterInformer interface { - Cluster(logicalcluster.Name) upstreambatchv1informers.CronJobInformer + Cluster(logicalcluster.Name) batchv1.CronJobInformer + ClusterWithContext(context.Context, logicalcluster.Name) batchv1.CronJobInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() batchv1listers.CronJobClusterLister + Lister() kcpv1.CronJobClusterLister } type cronJobClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewCronJobClusterInformer constructs a new informer for CronJob type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewCronJobClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewCronJobClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredCronJobClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredCronJobClusterInformer constructs a new informer for CronJob type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredCronJobClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredCronJobClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.BatchV1().CronJobs().List(context.TODO(), options) + return client.BatchV1().CronJobs().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.BatchV1().CronJobs().Watch(context.TODO(), options) + return client.BatchV1().CronJobs().Watch(context.Background(), options) }, }, - &batchv1.CronJob{}, + &apibatchv1.CronJob{}, resyncPeriod, indexers, ) } -func (f *cronJobClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *cronJobClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredCronJobClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *cronJobClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apibatchv1.CronJob{}, i.defaultInformer) } -func (f *cronJobClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&batchv1.CronJob{}, f.defaultInformer) +func (i *cronJobClusterInformer) Lister() kcpv1.CronJobClusterLister { + return kcpv1.NewCronJobClusterLister(i.Informer().GetIndexer()) } -func (f *cronJobClusterInformer) Lister() batchv1listers.CronJobClusterLister { - return batchv1listers.NewCronJobClusterLister(f.Informer().GetIndexer()) +func (i *cronJobClusterInformer) Cluster(clusterName logicalcluster.Name) batchv1.CronJobInformer { + return &cronJobInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *cronJobClusterInformer) Cluster(clusterName logicalcluster.Name) upstreambatchv1informers.CronJobInformer { +func (i *cronJobClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) batchv1.CronJobInformer { return &cronJobInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type cronJobInformer struct { informer cache.SharedIndexInformer - lister upstreambatchv1listers.CronJobLister + lister listersbatchv1.CronJobLister } -func (f *cronJobInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *cronJobInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *cronJobInformer) Lister() upstreambatchv1listers.CronJobLister { - return f.lister +func (i *cronJobInformer) Lister() listersbatchv1.CronJobLister { + return i.lister } diff --git a/informers/batch/v1/interface.go b/informers/batch/v1/interface.go index 06500c9e3..85f2fdab8 100644 --- a/informers/batch/v1/interface.go +++ b/informers/batch/v1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,37 +14,37 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // Jobs returns a JobClusterInformer - Jobs() JobClusterInformer - // CronJobs returns a CronJobClusterInformer + // CronJobs returns a CronJobClusterInformer. CronJobs() CronJobClusterInformer + // Jobs returns a JobClusterInformer. + Jobs() JobClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// Jobs returns a JobClusterInformer -func (v *version) Jobs() JobClusterInformer { - return &jobClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} - -// CronJobs returns a CronJobClusterInformer +// CronJobs returns a CronJobClusterInformer. func (v *version) CronJobs() CronJobClusterInformer { return &cronJobClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } + +// Jobs returns a JobClusterInformer. +func (v *version) Jobs() JobClusterInformer { + return &jobClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} diff --git a/informers/batch/v1/job.go b/informers/batch/v1/job.go index a3d3d26c0..54a7d2327 100644 --- a/informers/batch/v1/job.go +++ b/informers/batch/v1/job.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - batchv1 "k8s.io/api/batch/v1" + apibatchv1 "k8s.io/api/batch/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreambatchv1informers "k8s.io/client-go/informers/batch/v1" - upstreambatchv1listers "k8s.io/client-go/listers/batch/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - batchv1listers "github.com/kcp-dev/client-go/listers/batch/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + batchv1 "k8s.io/client-go/informers/batch/v1" + listersbatchv1 "k8s.io/client-go/listers/batch/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/batch/v1" ) // JobClusterInformer provides access to a shared informer and lister for // Jobs. type JobClusterInformer interface { - Cluster(logicalcluster.Name) upstreambatchv1informers.JobInformer + Cluster(logicalcluster.Name) batchv1.JobInformer + ClusterWithContext(context.Context, logicalcluster.Name) batchv1.JobInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() batchv1listers.JobClusterLister + Lister() kcpv1.JobClusterLister } type jobClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewJobClusterInformer constructs a new informer for Job type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewJobClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewJobClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredJobClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredJobClusterInformer constructs a new informer for Job type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredJobClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredJobClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.BatchV1().Jobs().List(context.TODO(), options) + return client.BatchV1().Jobs().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.BatchV1().Jobs().Watch(context.TODO(), options) + return client.BatchV1().Jobs().Watch(context.Background(), options) }, }, - &batchv1.Job{}, + &apibatchv1.Job{}, resyncPeriod, indexers, ) } -func (f *jobClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *jobClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredJobClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *jobClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apibatchv1.Job{}, i.defaultInformer) } -func (f *jobClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&batchv1.Job{}, f.defaultInformer) +func (i *jobClusterInformer) Lister() kcpv1.JobClusterLister { + return kcpv1.NewJobClusterLister(i.Informer().GetIndexer()) } -func (f *jobClusterInformer) Lister() batchv1listers.JobClusterLister { - return batchv1listers.NewJobClusterLister(f.Informer().GetIndexer()) +func (i *jobClusterInformer) Cluster(clusterName logicalcluster.Name) batchv1.JobInformer { + return &jobInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *jobClusterInformer) Cluster(clusterName logicalcluster.Name) upstreambatchv1informers.JobInformer { +func (i *jobClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) batchv1.JobInformer { return &jobInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type jobInformer struct { informer cache.SharedIndexInformer - lister upstreambatchv1listers.JobLister + lister listersbatchv1.JobLister } -func (f *jobInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *jobInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *jobInformer) Lister() upstreambatchv1listers.JobLister { - return f.lister +func (i *jobInformer) Lister() listersbatchv1.JobLister { + return i.lister } diff --git a/informers/batch/v1beta1/cronjob.go b/informers/batch/v1beta1/cronjob.go index ec45b1351..3093d9dec 100644 --- a/informers/batch/v1beta1/cronjob.go +++ b/informers/batch/v1beta1/cronjob.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - batchv1beta1 "k8s.io/api/batch/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreambatchv1beta1informers "k8s.io/client-go/informers/batch/v1beta1" - upstreambatchv1beta1listers "k8s.io/client-go/listers/batch/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - batchv1beta1listers "github.com/kcp-dev/client-go/listers/batch/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apibatchv1beta1 "k8s.io/api/batch/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + batchv1beta1 "k8s.io/client-go/informers/batch/v1beta1" + listersbatchv1beta1 "k8s.io/client-go/listers/batch/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/batch/v1beta1" ) // CronJobClusterInformer provides access to a shared informer and lister for // CronJobs. type CronJobClusterInformer interface { - Cluster(logicalcluster.Name) upstreambatchv1beta1informers.CronJobInformer + Cluster(logicalcluster.Name) batchv1beta1.CronJobInformer + ClusterWithContext(context.Context, logicalcluster.Name) batchv1beta1.CronJobInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() batchv1beta1listers.CronJobClusterLister + Lister() kcpv1beta1.CronJobClusterLister } type cronJobClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewCronJobClusterInformer constructs a new informer for CronJob type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewCronJobClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewCronJobClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredCronJobClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredCronJobClusterInformer constructs a new informer for CronJob type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredCronJobClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredCronJobClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.BatchV1beta1().CronJobs().List(context.TODO(), options) + return client.BatchV1beta1().CronJobs().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.BatchV1beta1().CronJobs().Watch(context.TODO(), options) + return client.BatchV1beta1().CronJobs().Watch(context.Background(), options) }, }, - &batchv1beta1.CronJob{}, + &apibatchv1beta1.CronJob{}, resyncPeriod, indexers, ) } -func (f *cronJobClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *cronJobClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredCronJobClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *cronJobClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apibatchv1beta1.CronJob{}, i.defaultInformer) } -func (f *cronJobClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&batchv1beta1.CronJob{}, f.defaultInformer) +func (i *cronJobClusterInformer) Lister() kcpv1beta1.CronJobClusterLister { + return kcpv1beta1.NewCronJobClusterLister(i.Informer().GetIndexer()) } -func (f *cronJobClusterInformer) Lister() batchv1beta1listers.CronJobClusterLister { - return batchv1beta1listers.NewCronJobClusterLister(f.Informer().GetIndexer()) +func (i *cronJobClusterInformer) Cluster(clusterName logicalcluster.Name) batchv1beta1.CronJobInformer { + return &cronJobInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *cronJobClusterInformer) Cluster(clusterName logicalcluster.Name) upstreambatchv1beta1informers.CronJobInformer { +func (i *cronJobClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) batchv1beta1.CronJobInformer { return &cronJobInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type cronJobInformer struct { informer cache.SharedIndexInformer - lister upstreambatchv1beta1listers.CronJobLister + lister listersbatchv1beta1.CronJobLister } -func (f *cronJobInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *cronJobInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *cronJobInformer) Lister() upstreambatchv1beta1listers.CronJobLister { - return f.lister +func (i *cronJobInformer) Lister() listersbatchv1beta1.CronJobLister { + return i.lister } diff --git a/informers/batch/v1beta1/interface.go b/informers/batch/v1beta1/interface.go index a0d60bcb3..146dda567 100644 --- a/informers/batch/v1beta1/interface.go +++ b/informers/batch/v1beta1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,30 +14,30 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // CronJobs returns a CronJobClusterInformer + // CronJobs returns a CronJobClusterInformer. CronJobs() CronJobClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// CronJobs returns a CronJobClusterInformer +// CronJobs returns a CronJobClusterInformer. func (v *version) CronJobs() CronJobClusterInformer { return &cronJobClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/certificates/interface.go b/informers/certificates/interface.go index b88b53676..de21bb4a0 100644 --- a/informers/certificates/interface.go +++ b/informers/certificates/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,47 +14,48 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package certificates import ( - "github.com/kcp-dev/client-go/informers/certificates/v1" - "github.com/kcp-dev/client-go/informers/certificates/v1alpha1" - "github.com/kcp-dev/client-go/informers/certificates/v1beta1" - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpv1 "github.com/kcp-dev/client-go/informers/certificates/v1" + kcpv1alpha1 "github.com/kcp-dev/client-go/informers/certificates/v1alpha1" + kcpv1beta1 "github.com/kcp-dev/client-go/informers/certificates/v1beta1" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) +// ClusterInterface provides access to each of this group's versions. type ClusterInterface interface { - // V1 provides access to the shared informers in V1. - V1() v1.ClusterInterface - // V1alpha1 provides access to the shared informers in V1alpha1. - V1alpha1() v1alpha1.ClusterInterface - // V1beta1 provides access to the shared informers in V1beta1. - V1beta1() v1beta1.ClusterInterface + // V1 provides access to shared informers for resources in V1. + V1() kcpv1.ClusterInterface + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() kcpv1alpha1.ClusterInterface + // V1beta1 provides access to shared informers for resources in V1beta1. + V1beta1() kcpv1beta1.ClusterInterface } type group struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &group{factory: f, tweakListOptions: tweakListOptions} } -// V1 returns a new v1.ClusterInterface. -func (g *group) V1() v1.ClusterInterface { - return v1.New(g.factory, g.tweakListOptions) +// V1 returns a new kcpv1.ClusterInterface. +func (g *group) V1() kcpv1.ClusterInterface { + return kcpv1.New(g.factory, g.tweakListOptions) } -// V1alpha1 returns a new v1alpha1.ClusterInterface. -func (g *group) V1alpha1() v1alpha1.ClusterInterface { - return v1alpha1.New(g.factory, g.tweakListOptions) +// V1alpha1 returns a new kcpv1alpha1.ClusterInterface. +func (g *group) V1alpha1() kcpv1alpha1.ClusterInterface { + return kcpv1alpha1.New(g.factory, g.tweakListOptions) } -// V1beta1 returns a new v1beta1.ClusterInterface. -func (g *group) V1beta1() v1beta1.ClusterInterface { - return v1beta1.New(g.factory, g.tweakListOptions) +// V1beta1 returns a new kcpv1beta1.ClusterInterface. +func (g *group) V1beta1() kcpv1beta1.ClusterInterface { + return kcpv1beta1.New(g.factory, g.tweakListOptions) } diff --git a/informers/certificates/v1/certificatesigningrequest.go b/informers/certificates/v1/certificatesigningrequest.go index baf61f313..73183671c 100644 --- a/informers/certificates/v1/certificatesigningrequest.go +++ b/informers/certificates/v1/certificatesigningrequest.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - certificatesv1 "k8s.io/api/certificates/v1" + apicertificatesv1 "k8s.io/api/certificates/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamcertificatesv1informers "k8s.io/client-go/informers/certificates/v1" - upstreamcertificatesv1listers "k8s.io/client-go/listers/certificates/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - certificatesv1listers "github.com/kcp-dev/client-go/listers/certificates/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + certificatesv1 "k8s.io/client-go/informers/certificates/v1" + listerscertificatesv1 "k8s.io/client-go/listers/certificates/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/certificates/v1" ) // CertificateSigningRequestClusterInformer provides access to a shared informer and lister for // CertificateSigningRequests. type CertificateSigningRequestClusterInformer interface { - Cluster(logicalcluster.Name) upstreamcertificatesv1informers.CertificateSigningRequestInformer + Cluster(logicalcluster.Name) certificatesv1.CertificateSigningRequestInformer + ClusterWithContext(context.Context, logicalcluster.Name) certificatesv1.CertificateSigningRequestInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() certificatesv1listers.CertificateSigningRequestClusterLister + Lister() kcpv1.CertificateSigningRequestClusterLister } type certificateSigningRequestClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewCertificateSigningRequestClusterInformer constructs a new informer for CertificateSigningRequest type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewCertificateSigningRequestClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewCertificateSigningRequestClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredCertificateSigningRequestClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredCertificateSigningRequestClusterInformer constructs a new informer for CertificateSigningRequest type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredCertificateSigningRequestClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredCertificateSigningRequestClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CertificatesV1().CertificateSigningRequests().List(context.TODO(), options) + return client.CertificatesV1().CertificateSigningRequests().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CertificatesV1().CertificateSigningRequests().Watch(context.TODO(), options) + return client.CertificatesV1().CertificateSigningRequests().Watch(context.Background(), options) }, }, - &certificatesv1.CertificateSigningRequest{}, + &apicertificatesv1.CertificateSigningRequest{}, resyncPeriod, indexers, ) } -func (f *certificateSigningRequestClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *certificateSigningRequestClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredCertificateSigningRequestClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *certificateSigningRequestClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apicertificatesv1.CertificateSigningRequest{}, i.defaultInformer) } -func (f *certificateSigningRequestClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&certificatesv1.CertificateSigningRequest{}, f.defaultInformer) +func (i *certificateSigningRequestClusterInformer) Lister() kcpv1.CertificateSigningRequestClusterLister { + return kcpv1.NewCertificateSigningRequestClusterLister(i.Informer().GetIndexer()) } -func (f *certificateSigningRequestClusterInformer) Lister() certificatesv1listers.CertificateSigningRequestClusterLister { - return certificatesv1listers.NewCertificateSigningRequestClusterLister(f.Informer().GetIndexer()) +func (i *certificateSigningRequestClusterInformer) Cluster(clusterName logicalcluster.Name) certificatesv1.CertificateSigningRequestInformer { + return &certificateSigningRequestInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *certificateSigningRequestClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamcertificatesv1informers.CertificateSigningRequestInformer { +func (i *certificateSigningRequestClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) certificatesv1.CertificateSigningRequestInformer { return &certificateSigningRequestInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type certificateSigningRequestInformer struct { informer cache.SharedIndexInformer - lister upstreamcertificatesv1listers.CertificateSigningRequestLister + lister listerscertificatesv1.CertificateSigningRequestLister } -func (f *certificateSigningRequestInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *certificateSigningRequestInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *certificateSigningRequestInformer) Lister() upstreamcertificatesv1listers.CertificateSigningRequestLister { - return f.lister +func (i *certificateSigningRequestInformer) Lister() listerscertificatesv1.CertificateSigningRequestLister { + return i.lister } diff --git a/informers/certificates/v1/interface.go b/informers/certificates/v1/interface.go index 5622f4d0a..970795524 100644 --- a/informers/certificates/v1/interface.go +++ b/informers/certificates/v1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,30 +14,30 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // CertificateSigningRequests returns a CertificateSigningRequestClusterInformer + // CertificateSigningRequests returns a CertificateSigningRequestClusterInformer. CertificateSigningRequests() CertificateSigningRequestClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// CertificateSigningRequests returns a CertificateSigningRequestClusterInformer +// CertificateSigningRequests returns a CertificateSigningRequestClusterInformer. func (v *version) CertificateSigningRequests() CertificateSigningRequestClusterInformer { return &certificateSigningRequestClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/certificates/v1alpha1/clustertrustbundle.go b/informers/certificates/v1alpha1/clustertrustbundle.go index 1e80131a9..0a33056bc 100644 --- a/informers/certificates/v1alpha1/clustertrustbundle.go +++ b/informers/certificates/v1alpha1/clustertrustbundle.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - certificatesv1alpha1 "k8s.io/api/certificates/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamcertificatesv1alpha1informers "k8s.io/client-go/informers/certificates/v1alpha1" - upstreamcertificatesv1alpha1listers "k8s.io/client-go/listers/certificates/v1alpha1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - certificatesv1alpha1listers "github.com/kcp-dev/client-go/listers/certificates/v1alpha1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apicertificatesv1alpha1 "k8s.io/api/certificates/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + certificatesv1alpha1 "k8s.io/client-go/informers/certificates/v1alpha1" + listerscertificatesv1alpha1 "k8s.io/client-go/listers/certificates/v1alpha1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1alpha1 "github.com/kcp-dev/client-go/listers/certificates/v1alpha1" ) // ClusterTrustBundleClusterInformer provides access to a shared informer and lister for // ClusterTrustBundles. type ClusterTrustBundleClusterInformer interface { - Cluster(logicalcluster.Name) upstreamcertificatesv1alpha1informers.ClusterTrustBundleInformer + Cluster(logicalcluster.Name) certificatesv1alpha1.ClusterTrustBundleInformer + ClusterWithContext(context.Context, logicalcluster.Name) certificatesv1alpha1.ClusterTrustBundleInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() certificatesv1alpha1listers.ClusterTrustBundleClusterLister + Lister() kcpv1alpha1.ClusterTrustBundleClusterLister } type clusterTrustBundleClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewClusterTrustBundleClusterInformer constructs a new informer for ClusterTrustBundle type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewClusterTrustBundleClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewClusterTrustBundleClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredClusterTrustBundleClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredClusterTrustBundleClusterInformer constructs a new informer for ClusterTrustBundle type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredClusterTrustBundleClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredClusterTrustBundleClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CertificatesV1alpha1().ClusterTrustBundles().List(context.TODO(), options) + return client.CertificatesV1alpha1().ClusterTrustBundles().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CertificatesV1alpha1().ClusterTrustBundles().Watch(context.TODO(), options) + return client.CertificatesV1alpha1().ClusterTrustBundles().Watch(context.Background(), options) }, }, - &certificatesv1alpha1.ClusterTrustBundle{}, + &apicertificatesv1alpha1.ClusterTrustBundle{}, resyncPeriod, indexers, ) } -func (f *clusterTrustBundleClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *clusterTrustBundleClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredClusterTrustBundleClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *clusterTrustBundleClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apicertificatesv1alpha1.ClusterTrustBundle{}, i.defaultInformer) } -func (f *clusterTrustBundleClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&certificatesv1alpha1.ClusterTrustBundle{}, f.defaultInformer) +func (i *clusterTrustBundleClusterInformer) Lister() kcpv1alpha1.ClusterTrustBundleClusterLister { + return kcpv1alpha1.NewClusterTrustBundleClusterLister(i.Informer().GetIndexer()) } -func (f *clusterTrustBundleClusterInformer) Lister() certificatesv1alpha1listers.ClusterTrustBundleClusterLister { - return certificatesv1alpha1listers.NewClusterTrustBundleClusterLister(f.Informer().GetIndexer()) +func (i *clusterTrustBundleClusterInformer) Cluster(clusterName logicalcluster.Name) certificatesv1alpha1.ClusterTrustBundleInformer { + return &clusterTrustBundleInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *clusterTrustBundleClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamcertificatesv1alpha1informers.ClusterTrustBundleInformer { +func (i *clusterTrustBundleClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) certificatesv1alpha1.ClusterTrustBundleInformer { return &clusterTrustBundleInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type clusterTrustBundleInformer struct { informer cache.SharedIndexInformer - lister upstreamcertificatesv1alpha1listers.ClusterTrustBundleLister + lister listerscertificatesv1alpha1.ClusterTrustBundleLister } -func (f *clusterTrustBundleInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *clusterTrustBundleInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *clusterTrustBundleInformer) Lister() upstreamcertificatesv1alpha1listers.ClusterTrustBundleLister { - return f.lister +func (i *clusterTrustBundleInformer) Lister() listerscertificatesv1alpha1.ClusterTrustBundleLister { + return i.lister } diff --git a/informers/certificates/v1alpha1/interface.go b/informers/certificates/v1alpha1/interface.go index 7b11a2f8b..4928d9099 100644 --- a/informers/certificates/v1alpha1/interface.go +++ b/informers/certificates/v1alpha1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,30 +14,30 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // ClusterTrustBundles returns a ClusterTrustBundleClusterInformer + // ClusterTrustBundles returns a ClusterTrustBundleClusterInformer. ClusterTrustBundles() ClusterTrustBundleClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// ClusterTrustBundles returns a ClusterTrustBundleClusterInformer +// ClusterTrustBundles returns a ClusterTrustBundleClusterInformer. func (v *version) ClusterTrustBundles() ClusterTrustBundleClusterInformer { return &clusterTrustBundleClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/certificates/v1beta1/certificatesigningrequest.go b/informers/certificates/v1beta1/certificatesigningrequest.go index 5ca7078d8..1b29067ae 100644 --- a/informers/certificates/v1beta1/certificatesigningrequest.go +++ b/informers/certificates/v1beta1/certificatesigningrequest.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - certificatesv1beta1 "k8s.io/api/certificates/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamcertificatesv1beta1informers "k8s.io/client-go/informers/certificates/v1beta1" - upstreamcertificatesv1beta1listers "k8s.io/client-go/listers/certificates/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - certificatesv1beta1listers "github.com/kcp-dev/client-go/listers/certificates/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apicertificatesv1beta1 "k8s.io/api/certificates/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + certificatesv1beta1 "k8s.io/client-go/informers/certificates/v1beta1" + listerscertificatesv1beta1 "k8s.io/client-go/listers/certificates/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/certificates/v1beta1" ) // CertificateSigningRequestClusterInformer provides access to a shared informer and lister for // CertificateSigningRequests. type CertificateSigningRequestClusterInformer interface { - Cluster(logicalcluster.Name) upstreamcertificatesv1beta1informers.CertificateSigningRequestInformer + Cluster(logicalcluster.Name) certificatesv1beta1.CertificateSigningRequestInformer + ClusterWithContext(context.Context, logicalcluster.Name) certificatesv1beta1.CertificateSigningRequestInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() certificatesv1beta1listers.CertificateSigningRequestClusterLister + Lister() kcpv1beta1.CertificateSigningRequestClusterLister } type certificateSigningRequestClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewCertificateSigningRequestClusterInformer constructs a new informer for CertificateSigningRequest type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewCertificateSigningRequestClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewCertificateSigningRequestClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredCertificateSigningRequestClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredCertificateSigningRequestClusterInformer constructs a new informer for CertificateSigningRequest type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredCertificateSigningRequestClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredCertificateSigningRequestClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CertificatesV1beta1().CertificateSigningRequests().List(context.TODO(), options) + return client.CertificatesV1beta1().CertificateSigningRequests().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CertificatesV1beta1().CertificateSigningRequests().Watch(context.TODO(), options) + return client.CertificatesV1beta1().CertificateSigningRequests().Watch(context.Background(), options) }, }, - &certificatesv1beta1.CertificateSigningRequest{}, + &apicertificatesv1beta1.CertificateSigningRequest{}, resyncPeriod, indexers, ) } -func (f *certificateSigningRequestClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *certificateSigningRequestClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredCertificateSigningRequestClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *certificateSigningRequestClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apicertificatesv1beta1.CertificateSigningRequest{}, i.defaultInformer) } -func (f *certificateSigningRequestClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&certificatesv1beta1.CertificateSigningRequest{}, f.defaultInformer) +func (i *certificateSigningRequestClusterInformer) Lister() kcpv1beta1.CertificateSigningRequestClusterLister { + return kcpv1beta1.NewCertificateSigningRequestClusterLister(i.Informer().GetIndexer()) } -func (f *certificateSigningRequestClusterInformer) Lister() certificatesv1beta1listers.CertificateSigningRequestClusterLister { - return certificatesv1beta1listers.NewCertificateSigningRequestClusterLister(f.Informer().GetIndexer()) +func (i *certificateSigningRequestClusterInformer) Cluster(clusterName logicalcluster.Name) certificatesv1beta1.CertificateSigningRequestInformer { + return &certificateSigningRequestInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *certificateSigningRequestClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamcertificatesv1beta1informers.CertificateSigningRequestInformer { +func (i *certificateSigningRequestClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) certificatesv1beta1.CertificateSigningRequestInformer { return &certificateSigningRequestInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type certificateSigningRequestInformer struct { informer cache.SharedIndexInformer - lister upstreamcertificatesv1beta1listers.CertificateSigningRequestLister + lister listerscertificatesv1beta1.CertificateSigningRequestLister } -func (f *certificateSigningRequestInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *certificateSigningRequestInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *certificateSigningRequestInformer) Lister() upstreamcertificatesv1beta1listers.CertificateSigningRequestLister { - return f.lister +func (i *certificateSigningRequestInformer) Lister() listerscertificatesv1beta1.CertificateSigningRequestLister { + return i.lister } diff --git a/informers/certificates/v1beta1/interface.go b/informers/certificates/v1beta1/interface.go index 7eaa69b6e..4ac17deb1 100644 --- a/informers/certificates/v1beta1/interface.go +++ b/informers/certificates/v1beta1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,30 +14,30 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // CertificateSigningRequests returns a CertificateSigningRequestClusterInformer + // CertificateSigningRequests returns a CertificateSigningRequestClusterInformer. CertificateSigningRequests() CertificateSigningRequestClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// CertificateSigningRequests returns a CertificateSigningRequestClusterInformer +// CertificateSigningRequests returns a CertificateSigningRequestClusterInformer. func (v *version) CertificateSigningRequests() CertificateSigningRequestClusterInformer { return &certificateSigningRequestClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/coordination/interface.go b/informers/coordination/interface.go index dabeca5f7..bfb8cb118 100644 --- a/informers/coordination/interface.go +++ b/informers/coordination/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,47 +14,48 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package coordination import ( - "github.com/kcp-dev/client-go/informers/coordination/v1" - "github.com/kcp-dev/client-go/informers/coordination/v1alpha2" - "github.com/kcp-dev/client-go/informers/coordination/v1beta1" - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpv1 "github.com/kcp-dev/client-go/informers/coordination/v1" + kcpv1alpha2 "github.com/kcp-dev/client-go/informers/coordination/v1alpha2" + kcpv1beta1 "github.com/kcp-dev/client-go/informers/coordination/v1beta1" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) +// ClusterInterface provides access to each of this group's versions. type ClusterInterface interface { - // V1 provides access to the shared informers in V1. - V1() v1.ClusterInterface - // V1alpha2 provides access to the shared informers in V1alpha2. - V1alpha2() v1alpha2.ClusterInterface - // V1beta1 provides access to the shared informers in V1beta1. - V1beta1() v1beta1.ClusterInterface + // V1 provides access to shared informers for resources in V1. + V1() kcpv1.ClusterInterface + // V1alpha2 provides access to shared informers for resources in V1alpha2. + V1alpha2() kcpv1alpha2.ClusterInterface + // V1beta1 provides access to shared informers for resources in V1beta1. + V1beta1() kcpv1beta1.ClusterInterface } type group struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &group{factory: f, tweakListOptions: tweakListOptions} } -// V1 returns a new v1.ClusterInterface. -func (g *group) V1() v1.ClusterInterface { - return v1.New(g.factory, g.tweakListOptions) +// V1 returns a new kcpv1.ClusterInterface. +func (g *group) V1() kcpv1.ClusterInterface { + return kcpv1.New(g.factory, g.tweakListOptions) } -// V1alpha2 returns a new v1alpha2.ClusterInterface. -func (g *group) V1alpha2() v1alpha2.ClusterInterface { - return v1alpha2.New(g.factory, g.tweakListOptions) +// V1alpha2 returns a new kcpv1alpha2.ClusterInterface. +func (g *group) V1alpha2() kcpv1alpha2.ClusterInterface { + return kcpv1alpha2.New(g.factory, g.tweakListOptions) } -// V1beta1 returns a new v1beta1.ClusterInterface. -func (g *group) V1beta1() v1beta1.ClusterInterface { - return v1beta1.New(g.factory, g.tweakListOptions) +// V1beta1 returns a new kcpv1beta1.ClusterInterface. +func (g *group) V1beta1() kcpv1beta1.ClusterInterface { + return kcpv1beta1.New(g.factory, g.tweakListOptions) } diff --git a/informers/coordination/v1/interface.go b/informers/coordination/v1/interface.go index 0f815d71e..a9916ed7e 100644 --- a/informers/coordination/v1/interface.go +++ b/informers/coordination/v1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,30 +14,30 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // Leases returns a LeaseClusterInformer + // Leases returns a LeaseClusterInformer. Leases() LeaseClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// Leases returns a LeaseClusterInformer +// Leases returns a LeaseClusterInformer. func (v *version) Leases() LeaseClusterInformer { return &leaseClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/coordination/v1/lease.go b/informers/coordination/v1/lease.go index 98687d328..fe55e39a8 100644 --- a/informers/coordination/v1/lease.go +++ b/informers/coordination/v1/lease.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - coordinationv1 "k8s.io/api/coordination/v1" + apicoordinationv1 "k8s.io/api/coordination/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamcoordinationv1informers "k8s.io/client-go/informers/coordination/v1" - upstreamcoordinationv1listers "k8s.io/client-go/listers/coordination/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - coordinationv1listers "github.com/kcp-dev/client-go/listers/coordination/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + coordinationv1 "k8s.io/client-go/informers/coordination/v1" + listerscoordinationv1 "k8s.io/client-go/listers/coordination/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/coordination/v1" ) // LeaseClusterInformer provides access to a shared informer and lister for // Leases. type LeaseClusterInformer interface { - Cluster(logicalcluster.Name) upstreamcoordinationv1informers.LeaseInformer + Cluster(logicalcluster.Name) coordinationv1.LeaseInformer + ClusterWithContext(context.Context, logicalcluster.Name) coordinationv1.LeaseInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() coordinationv1listers.LeaseClusterLister + Lister() kcpv1.LeaseClusterLister } type leaseClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewLeaseClusterInformer constructs a new informer for Lease type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewLeaseClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewLeaseClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredLeaseClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredLeaseClusterInformer constructs a new informer for Lease type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredLeaseClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredLeaseClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoordinationV1().Leases().List(context.TODO(), options) + return client.CoordinationV1().Leases().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoordinationV1().Leases().Watch(context.TODO(), options) + return client.CoordinationV1().Leases().Watch(context.Background(), options) }, }, - &coordinationv1.Lease{}, + &apicoordinationv1.Lease{}, resyncPeriod, indexers, ) } -func (f *leaseClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *leaseClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredLeaseClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *leaseClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apicoordinationv1.Lease{}, i.defaultInformer) } -func (f *leaseClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&coordinationv1.Lease{}, f.defaultInformer) +func (i *leaseClusterInformer) Lister() kcpv1.LeaseClusterLister { + return kcpv1.NewLeaseClusterLister(i.Informer().GetIndexer()) } -func (f *leaseClusterInformer) Lister() coordinationv1listers.LeaseClusterLister { - return coordinationv1listers.NewLeaseClusterLister(f.Informer().GetIndexer()) +func (i *leaseClusterInformer) Cluster(clusterName logicalcluster.Name) coordinationv1.LeaseInformer { + return &leaseInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *leaseClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamcoordinationv1informers.LeaseInformer { +func (i *leaseClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) coordinationv1.LeaseInformer { return &leaseInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type leaseInformer struct { informer cache.SharedIndexInformer - lister upstreamcoordinationv1listers.LeaseLister + lister listerscoordinationv1.LeaseLister } -func (f *leaseInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *leaseInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *leaseInformer) Lister() upstreamcoordinationv1listers.LeaseLister { - return f.lister +func (i *leaseInformer) Lister() listerscoordinationv1.LeaseLister { + return i.lister } diff --git a/informers/coordination/v1alpha2/interface.go b/informers/coordination/v1alpha2/interface.go index ad5f0ecd4..dc7e402ff 100644 --- a/informers/coordination/v1alpha2/interface.go +++ b/informers/coordination/v1alpha2/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,30 +14,30 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha2 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // LeaseCandidates returns a LeaseCandidateClusterInformer + // LeaseCandidates returns a LeaseCandidateClusterInformer. LeaseCandidates() LeaseCandidateClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// LeaseCandidates returns a LeaseCandidateClusterInformer +// LeaseCandidates returns a LeaseCandidateClusterInformer. func (v *version) LeaseCandidates() LeaseCandidateClusterInformer { return &leaseCandidateClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/coordination/v1alpha2/leasecandidate.go b/informers/coordination/v1alpha2/leasecandidate.go index 551b59aa7..e2b393e74 100644 --- a/informers/coordination/v1alpha2/leasecandidate.go +++ b/informers/coordination/v1alpha2/leasecandidate.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha2 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - coordinationv1alpha2 "k8s.io/api/coordination/v1alpha2" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamcoordinationv1alpha2informers "k8s.io/client-go/informers/coordination/v1alpha2" - upstreamcoordinationv1alpha2listers "k8s.io/client-go/listers/coordination/v1alpha2" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - coordinationv1alpha2listers "github.com/kcp-dev/client-go/listers/coordination/v1alpha2" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apicoordinationv1alpha2 "k8s.io/api/coordination/v1alpha2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + coordinationv1alpha2 "k8s.io/client-go/informers/coordination/v1alpha2" + listerscoordinationv1alpha2 "k8s.io/client-go/listers/coordination/v1alpha2" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1alpha2 "github.com/kcp-dev/client-go/listers/coordination/v1alpha2" ) // LeaseCandidateClusterInformer provides access to a shared informer and lister for // LeaseCandidates. type LeaseCandidateClusterInformer interface { - Cluster(logicalcluster.Name) upstreamcoordinationv1alpha2informers.LeaseCandidateInformer + Cluster(logicalcluster.Name) coordinationv1alpha2.LeaseCandidateInformer + ClusterWithContext(context.Context, logicalcluster.Name) coordinationv1alpha2.LeaseCandidateInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() coordinationv1alpha2listers.LeaseCandidateClusterLister + Lister() kcpv1alpha2.LeaseCandidateClusterLister } type leaseCandidateClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewLeaseCandidateClusterInformer constructs a new informer for LeaseCandidate type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewLeaseCandidateClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewLeaseCandidateClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredLeaseCandidateClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredLeaseCandidateClusterInformer constructs a new informer for LeaseCandidate type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredLeaseCandidateClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredLeaseCandidateClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoordinationV1alpha2().LeaseCandidates().List(context.TODO(), options) + return client.CoordinationV1alpha2().LeaseCandidates().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoordinationV1alpha2().LeaseCandidates().Watch(context.TODO(), options) + return client.CoordinationV1alpha2().LeaseCandidates().Watch(context.Background(), options) }, }, - &coordinationv1alpha2.LeaseCandidate{}, + &apicoordinationv1alpha2.LeaseCandidate{}, resyncPeriod, indexers, ) } -func (f *leaseCandidateClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *leaseCandidateClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredLeaseCandidateClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *leaseCandidateClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apicoordinationv1alpha2.LeaseCandidate{}, i.defaultInformer) } -func (f *leaseCandidateClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&coordinationv1alpha2.LeaseCandidate{}, f.defaultInformer) +func (i *leaseCandidateClusterInformer) Lister() kcpv1alpha2.LeaseCandidateClusterLister { + return kcpv1alpha2.NewLeaseCandidateClusterLister(i.Informer().GetIndexer()) } -func (f *leaseCandidateClusterInformer) Lister() coordinationv1alpha2listers.LeaseCandidateClusterLister { - return coordinationv1alpha2listers.NewLeaseCandidateClusterLister(f.Informer().GetIndexer()) +func (i *leaseCandidateClusterInformer) Cluster(clusterName logicalcluster.Name) coordinationv1alpha2.LeaseCandidateInformer { + return &leaseCandidateInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *leaseCandidateClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamcoordinationv1alpha2informers.LeaseCandidateInformer { +func (i *leaseCandidateClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) coordinationv1alpha2.LeaseCandidateInformer { return &leaseCandidateInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type leaseCandidateInformer struct { informer cache.SharedIndexInformer - lister upstreamcoordinationv1alpha2listers.LeaseCandidateLister + lister listerscoordinationv1alpha2.LeaseCandidateLister } -func (f *leaseCandidateInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *leaseCandidateInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *leaseCandidateInformer) Lister() upstreamcoordinationv1alpha2listers.LeaseCandidateLister { - return f.lister +func (i *leaseCandidateInformer) Lister() listerscoordinationv1alpha2.LeaseCandidateLister { + return i.lister } diff --git a/informers/coordination/v1beta1/interface.go b/informers/coordination/v1beta1/interface.go index 19b03308f..2f0cb1f10 100644 --- a/informers/coordination/v1beta1/interface.go +++ b/informers/coordination/v1beta1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,30 +14,30 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // Leases returns a LeaseClusterInformer + // Leases returns a LeaseClusterInformer. Leases() LeaseClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// Leases returns a LeaseClusterInformer +// Leases returns a LeaseClusterInformer. func (v *version) Leases() LeaseClusterInformer { return &leaseClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/coordination/v1beta1/lease.go b/informers/coordination/v1beta1/lease.go index 7e9bdcef8..7a43d9322 100644 --- a/informers/coordination/v1beta1/lease.go +++ b/informers/coordination/v1beta1/lease.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - coordinationv1beta1 "k8s.io/api/coordination/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamcoordinationv1beta1informers "k8s.io/client-go/informers/coordination/v1beta1" - upstreamcoordinationv1beta1listers "k8s.io/client-go/listers/coordination/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - coordinationv1beta1listers "github.com/kcp-dev/client-go/listers/coordination/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apicoordinationv1beta1 "k8s.io/api/coordination/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + coordinationv1beta1 "k8s.io/client-go/informers/coordination/v1beta1" + listerscoordinationv1beta1 "k8s.io/client-go/listers/coordination/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/coordination/v1beta1" ) // LeaseClusterInformer provides access to a shared informer and lister for // Leases. type LeaseClusterInformer interface { - Cluster(logicalcluster.Name) upstreamcoordinationv1beta1informers.LeaseInformer + Cluster(logicalcluster.Name) coordinationv1beta1.LeaseInformer + ClusterWithContext(context.Context, logicalcluster.Name) coordinationv1beta1.LeaseInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() coordinationv1beta1listers.LeaseClusterLister + Lister() kcpv1beta1.LeaseClusterLister } type leaseClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewLeaseClusterInformer constructs a new informer for Lease type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewLeaseClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewLeaseClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredLeaseClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredLeaseClusterInformer constructs a new informer for Lease type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredLeaseClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredLeaseClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoordinationV1beta1().Leases().List(context.TODO(), options) + return client.CoordinationV1beta1().Leases().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoordinationV1beta1().Leases().Watch(context.TODO(), options) + return client.CoordinationV1beta1().Leases().Watch(context.Background(), options) }, }, - &coordinationv1beta1.Lease{}, + &apicoordinationv1beta1.Lease{}, resyncPeriod, indexers, ) } -func (f *leaseClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *leaseClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredLeaseClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *leaseClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apicoordinationv1beta1.Lease{}, i.defaultInformer) } -func (f *leaseClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&coordinationv1beta1.Lease{}, f.defaultInformer) +func (i *leaseClusterInformer) Lister() kcpv1beta1.LeaseClusterLister { + return kcpv1beta1.NewLeaseClusterLister(i.Informer().GetIndexer()) } -func (f *leaseClusterInformer) Lister() coordinationv1beta1listers.LeaseClusterLister { - return coordinationv1beta1listers.NewLeaseClusterLister(f.Informer().GetIndexer()) +func (i *leaseClusterInformer) Cluster(clusterName logicalcluster.Name) coordinationv1beta1.LeaseInformer { + return &leaseInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *leaseClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamcoordinationv1beta1informers.LeaseInformer { +func (i *leaseClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) coordinationv1beta1.LeaseInformer { return &leaseInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type leaseInformer struct { informer cache.SharedIndexInformer - lister upstreamcoordinationv1beta1listers.LeaseLister + lister listerscoordinationv1beta1.LeaseLister } -func (f *leaseInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *leaseInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *leaseInformer) Lister() upstreamcoordinationv1beta1listers.LeaseLister { - return f.lister +func (i *leaseInformer) Lister() listerscoordinationv1beta1.LeaseLister { + return i.lister } diff --git a/informers/core/interface.go b/informers/core/interface.go index 3cfedf46e..635244f35 100644 --- a/informers/core/interface.go +++ b/informers/core/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,31 +14,32 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package core import ( - "github.com/kcp-dev/client-go/informers/core/v1" - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpv1 "github.com/kcp-dev/client-go/informers/core/v1" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) +// ClusterInterface provides access to each of this group's versions. type ClusterInterface interface { - // V1 provides access to the shared informers in V1. - V1() v1.ClusterInterface + // V1 provides access to shared informers for resources in V1. + V1() kcpv1.ClusterInterface } type group struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &group{factory: f, tweakListOptions: tweakListOptions} } -// V1 returns a new v1.ClusterInterface. -func (g *group) V1() v1.ClusterInterface { - return v1.New(g.factory, g.tweakListOptions) +// V1 returns a new kcpv1.ClusterInterface. +func (g *group) V1() kcpv1.ClusterInterface { + return kcpv1.New(g.factory, g.tweakListOptions) } diff --git a/informers/core/v1/componentstatus.go b/informers/core/v1/componentstatus.go index 012c94ad5..5aaf1f0fb 100644 --- a/informers/core/v1/componentstatus.go +++ b/informers/core/v1/componentstatus.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - corev1 "k8s.io/api/core/v1" + apicorev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamcorev1informers "k8s.io/client-go/informers/core/v1" - upstreamcorev1listers "k8s.io/client-go/listers/core/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - corev1listers "github.com/kcp-dev/client-go/listers/core/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + corev1 "k8s.io/client-go/informers/core/v1" + listerscorev1 "k8s.io/client-go/listers/core/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/core/v1" ) // ComponentStatusClusterInformer provides access to a shared informer and lister for // ComponentStatuses. type ComponentStatusClusterInformer interface { - Cluster(logicalcluster.Name) upstreamcorev1informers.ComponentStatusInformer + Cluster(logicalcluster.Name) corev1.ComponentStatusInformer + ClusterWithContext(context.Context, logicalcluster.Name) corev1.ComponentStatusInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() corev1listers.ComponentStatusClusterLister + Lister() kcpv1.ComponentStatusClusterLister } type componentStatusClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewComponentStatusClusterInformer constructs a new informer for ComponentStatus type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewComponentStatusClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewComponentStatusClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredComponentStatusClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredComponentStatusClusterInformer constructs a new informer for ComponentStatus type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredComponentStatusClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredComponentStatusClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoreV1().ComponentStatuses().List(context.TODO(), options) + return client.CoreV1().ComponentStatuses().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoreV1().ComponentStatuses().Watch(context.TODO(), options) + return client.CoreV1().ComponentStatuses().Watch(context.Background(), options) }, }, - &corev1.ComponentStatus{}, + &apicorev1.ComponentStatus{}, resyncPeriod, indexers, ) } -func (f *componentStatusClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *componentStatusClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredComponentStatusClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *componentStatusClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apicorev1.ComponentStatus{}, i.defaultInformer) } -func (f *componentStatusClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&corev1.ComponentStatus{}, f.defaultInformer) +func (i *componentStatusClusterInformer) Lister() kcpv1.ComponentStatusClusterLister { + return kcpv1.NewComponentStatusClusterLister(i.Informer().GetIndexer()) } -func (f *componentStatusClusterInformer) Lister() corev1listers.ComponentStatusClusterLister { - return corev1listers.NewComponentStatusClusterLister(f.Informer().GetIndexer()) +func (i *componentStatusClusterInformer) Cluster(clusterName logicalcluster.Name) corev1.ComponentStatusInformer { + return &componentStatusInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *componentStatusClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamcorev1informers.ComponentStatusInformer { +func (i *componentStatusClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) corev1.ComponentStatusInformer { return &componentStatusInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type componentStatusInformer struct { informer cache.SharedIndexInformer - lister upstreamcorev1listers.ComponentStatusLister + lister listerscorev1.ComponentStatusLister } -func (f *componentStatusInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *componentStatusInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *componentStatusInformer) Lister() upstreamcorev1listers.ComponentStatusLister { - return f.lister +func (i *componentStatusInformer) Lister() listerscorev1.ComponentStatusLister { + return i.lister } diff --git a/informers/core/v1/configmap.go b/informers/core/v1/configmap.go index 4bb74a663..2e99feabf 100644 --- a/informers/core/v1/configmap.go +++ b/informers/core/v1/configmap.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - corev1 "k8s.io/api/core/v1" + apicorev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamcorev1informers "k8s.io/client-go/informers/core/v1" - upstreamcorev1listers "k8s.io/client-go/listers/core/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - corev1listers "github.com/kcp-dev/client-go/listers/core/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + corev1 "k8s.io/client-go/informers/core/v1" + listerscorev1 "k8s.io/client-go/listers/core/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/core/v1" ) // ConfigMapClusterInformer provides access to a shared informer and lister for // ConfigMaps. type ConfigMapClusterInformer interface { - Cluster(logicalcluster.Name) upstreamcorev1informers.ConfigMapInformer + Cluster(logicalcluster.Name) corev1.ConfigMapInformer + ClusterWithContext(context.Context, logicalcluster.Name) corev1.ConfigMapInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() corev1listers.ConfigMapClusterLister + Lister() kcpv1.ConfigMapClusterLister } type configMapClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewConfigMapClusterInformer constructs a new informer for ConfigMap type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewConfigMapClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewConfigMapClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredConfigMapClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredConfigMapClusterInformer constructs a new informer for ConfigMap type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredConfigMapClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredConfigMapClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoreV1().ConfigMaps().List(context.TODO(), options) + return client.CoreV1().ConfigMaps().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoreV1().ConfigMaps().Watch(context.TODO(), options) + return client.CoreV1().ConfigMaps().Watch(context.Background(), options) }, }, - &corev1.ConfigMap{}, + &apicorev1.ConfigMap{}, resyncPeriod, indexers, ) } -func (f *configMapClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *configMapClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredConfigMapClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *configMapClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apicorev1.ConfigMap{}, i.defaultInformer) } -func (f *configMapClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&corev1.ConfigMap{}, f.defaultInformer) +func (i *configMapClusterInformer) Lister() kcpv1.ConfigMapClusterLister { + return kcpv1.NewConfigMapClusterLister(i.Informer().GetIndexer()) } -func (f *configMapClusterInformer) Lister() corev1listers.ConfigMapClusterLister { - return corev1listers.NewConfigMapClusterLister(f.Informer().GetIndexer()) +func (i *configMapClusterInformer) Cluster(clusterName logicalcluster.Name) corev1.ConfigMapInformer { + return &configMapInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *configMapClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamcorev1informers.ConfigMapInformer { +func (i *configMapClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) corev1.ConfigMapInformer { return &configMapInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type configMapInformer struct { informer cache.SharedIndexInformer - lister upstreamcorev1listers.ConfigMapLister + lister listerscorev1.ConfigMapLister } -func (f *configMapInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *configMapInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *configMapInformer) Lister() upstreamcorev1listers.ConfigMapLister { - return f.lister +func (i *configMapInformer) Lister() listerscorev1.ConfigMapLister { + return i.lister } diff --git a/informers/core/v1/endpoints.go b/informers/core/v1/endpoints.go index cd9d731f0..5360e0a1b 100644 --- a/informers/core/v1/endpoints.go +++ b/informers/core/v1/endpoints.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - corev1 "k8s.io/api/core/v1" + apicorev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamcorev1informers "k8s.io/client-go/informers/core/v1" - upstreamcorev1listers "k8s.io/client-go/listers/core/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - corev1listers "github.com/kcp-dev/client-go/listers/core/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + corev1 "k8s.io/client-go/informers/core/v1" + listerscorev1 "k8s.io/client-go/listers/core/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/core/v1" ) // EndpointsClusterInformer provides access to a shared informer and lister for // Endpoints. type EndpointsClusterInformer interface { - Cluster(logicalcluster.Name) upstreamcorev1informers.EndpointsInformer + Cluster(logicalcluster.Name) corev1.EndpointsInformer + ClusterWithContext(context.Context, logicalcluster.Name) corev1.EndpointsInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() corev1listers.EndpointsClusterLister + Lister() kcpv1.EndpointsClusterLister } type endpointsClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewEndpointsClusterInformer constructs a new informer for Endpoints type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewEndpointsClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewEndpointsClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredEndpointsClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredEndpointsClusterInformer constructs a new informer for Endpoints type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredEndpointsClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredEndpointsClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoreV1().Endpoints().List(context.TODO(), options) + return client.CoreV1().Endpoints().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoreV1().Endpoints().Watch(context.TODO(), options) + return client.CoreV1().Endpoints().Watch(context.Background(), options) }, }, - &corev1.Endpoints{}, + &apicorev1.Endpoints{}, resyncPeriod, indexers, ) } -func (f *endpointsClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *endpointsClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredEndpointsClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *endpointsClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apicorev1.Endpoints{}, i.defaultInformer) } -func (f *endpointsClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&corev1.Endpoints{}, f.defaultInformer) +func (i *endpointsClusterInformer) Lister() kcpv1.EndpointsClusterLister { + return kcpv1.NewEndpointsClusterLister(i.Informer().GetIndexer()) } -func (f *endpointsClusterInformer) Lister() corev1listers.EndpointsClusterLister { - return corev1listers.NewEndpointsClusterLister(f.Informer().GetIndexer()) +func (i *endpointsClusterInformer) Cluster(clusterName logicalcluster.Name) corev1.EndpointsInformer { + return &endpointsInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *endpointsClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamcorev1informers.EndpointsInformer { +func (i *endpointsClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) corev1.EndpointsInformer { return &endpointsInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type endpointsInformer struct { informer cache.SharedIndexInformer - lister upstreamcorev1listers.EndpointsLister + lister listerscorev1.EndpointsLister } -func (f *endpointsInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *endpointsInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *endpointsInformer) Lister() upstreamcorev1listers.EndpointsLister { - return f.lister +func (i *endpointsInformer) Lister() listerscorev1.EndpointsLister { + return i.lister } diff --git a/informers/core/v1/event.go b/informers/core/v1/event.go index 3711faba9..a7dec535f 100644 --- a/informers/core/v1/event.go +++ b/informers/core/v1/event.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - corev1 "k8s.io/api/core/v1" + apicorev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamcorev1informers "k8s.io/client-go/informers/core/v1" - upstreamcorev1listers "k8s.io/client-go/listers/core/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - corev1listers "github.com/kcp-dev/client-go/listers/core/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + corev1 "k8s.io/client-go/informers/core/v1" + listerscorev1 "k8s.io/client-go/listers/core/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/core/v1" ) // EventClusterInformer provides access to a shared informer and lister for // Events. type EventClusterInformer interface { - Cluster(logicalcluster.Name) upstreamcorev1informers.EventInformer + Cluster(logicalcluster.Name) corev1.EventInformer + ClusterWithContext(context.Context, logicalcluster.Name) corev1.EventInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() corev1listers.EventClusterLister + Lister() kcpv1.EventClusterLister } type eventClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewEventClusterInformer constructs a new informer for Event type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewEventClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewEventClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredEventClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredEventClusterInformer constructs a new informer for Event type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredEventClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredEventClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoreV1().Events().List(context.TODO(), options) + return client.CoreV1().Events().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoreV1().Events().Watch(context.TODO(), options) + return client.CoreV1().Events().Watch(context.Background(), options) }, }, - &corev1.Event{}, + &apicorev1.Event{}, resyncPeriod, indexers, ) } -func (f *eventClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *eventClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredEventClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *eventClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apicorev1.Event{}, i.defaultInformer) } -func (f *eventClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&corev1.Event{}, f.defaultInformer) +func (i *eventClusterInformer) Lister() kcpv1.EventClusterLister { + return kcpv1.NewEventClusterLister(i.Informer().GetIndexer()) } -func (f *eventClusterInformer) Lister() corev1listers.EventClusterLister { - return corev1listers.NewEventClusterLister(f.Informer().GetIndexer()) +func (i *eventClusterInformer) Cluster(clusterName logicalcluster.Name) corev1.EventInformer { + return &eventInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *eventClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamcorev1informers.EventInformer { +func (i *eventClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) corev1.EventInformer { return &eventInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type eventInformer struct { informer cache.SharedIndexInformer - lister upstreamcorev1listers.EventLister + lister listerscorev1.EventLister } -func (f *eventInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *eventInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *eventInformer) Lister() upstreamcorev1listers.EventLister { - return f.lister +func (i *eventInformer) Lister() listerscorev1.EventLister { + return i.lister } diff --git a/informers/core/v1/interface.go b/informers/core/v1/interface.go index a5b3c63c2..c65e6ed7c 100644 --- a/informers/core/v1/interface.go +++ b/informers/core/v1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,135 +14,135 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // PersistentVolumes returns a PersistentVolumeClusterInformer + // ComponentStatuses returns a ComponentStatusClusterInformer. + ComponentStatuses() ComponentStatusClusterInformer + // ConfigMaps returns a ConfigMapClusterInformer. + ConfigMaps() ConfigMapClusterInformer + // Endpoints returns a EndpointsClusterInformer. + Endpoints() EndpointsClusterInformer + // Events returns a EventClusterInformer. + Events() EventClusterInformer + // LimitRanges returns a LimitRangeClusterInformer. + LimitRanges() LimitRangeClusterInformer + // Namespaces returns a NamespaceClusterInformer. + Namespaces() NamespaceClusterInformer + // Nodes returns a NodeClusterInformer. + Nodes() NodeClusterInformer + // PersistentVolumes returns a PersistentVolumeClusterInformer. PersistentVolumes() PersistentVolumeClusterInformer - // PersistentVolumeClaims returns a PersistentVolumeClaimClusterInformer + // PersistentVolumeClaims returns a PersistentVolumeClaimClusterInformer. PersistentVolumeClaims() PersistentVolumeClaimClusterInformer - // Pods returns a PodClusterInformer + // Pods returns a PodClusterInformer. Pods() PodClusterInformer - // PodTemplates returns a PodTemplateClusterInformer + // PodTemplates returns a PodTemplateClusterInformer. PodTemplates() PodTemplateClusterInformer - // ReplicationControllers returns a ReplicationControllerClusterInformer + // ReplicationControllers returns a ReplicationControllerClusterInformer. ReplicationControllers() ReplicationControllerClusterInformer - // Services returns a ServiceClusterInformer - Services() ServiceClusterInformer - // ServiceAccounts returns a ServiceAccountClusterInformer - ServiceAccounts() ServiceAccountClusterInformer - // Endpoints returns a EndpointsClusterInformer - Endpoints() EndpointsClusterInformer - // Nodes returns a NodeClusterInformer - Nodes() NodeClusterInformer - // Namespaces returns a NamespaceClusterInformer - Namespaces() NamespaceClusterInformer - // Events returns a EventClusterInformer - Events() EventClusterInformer - // LimitRanges returns a LimitRangeClusterInformer - LimitRanges() LimitRangeClusterInformer - // ResourceQuotas returns a ResourceQuotaClusterInformer + // ResourceQuotas returns a ResourceQuotaClusterInformer. ResourceQuotas() ResourceQuotaClusterInformer - // Secrets returns a SecretClusterInformer + // Secrets returns a SecretClusterInformer. Secrets() SecretClusterInformer - // ConfigMaps returns a ConfigMapClusterInformer - ConfigMaps() ConfigMapClusterInformer - // ComponentStatuses returns a ComponentStatusClusterInformer - ComponentStatuses() ComponentStatusClusterInformer + // Services returns a ServiceClusterInformer. + Services() ServiceClusterInformer + // ServiceAccounts returns a ServiceAccountClusterInformer. + ServiceAccounts() ServiceAccountClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// PersistentVolumes returns a PersistentVolumeClusterInformer -func (v *version) PersistentVolumes() PersistentVolumeClusterInformer { - return &persistentVolumeClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +// ComponentStatuses returns a ComponentStatusClusterInformer. +func (v *version) ComponentStatuses() ComponentStatusClusterInformer { + return &componentStatusClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// PersistentVolumeClaims returns a PersistentVolumeClaimClusterInformer -func (v *version) PersistentVolumeClaims() PersistentVolumeClaimClusterInformer { - return &persistentVolumeClaimClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +// ConfigMaps returns a ConfigMapClusterInformer. +func (v *version) ConfigMaps() ConfigMapClusterInformer { + return &configMapClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// Pods returns a PodClusterInformer -func (v *version) Pods() PodClusterInformer { - return &podClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +// Endpoints returns a EndpointsClusterInformer. +func (v *version) Endpoints() EndpointsClusterInformer { + return &endpointsClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// PodTemplates returns a PodTemplateClusterInformer -func (v *version) PodTemplates() PodTemplateClusterInformer { - return &podTemplateClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +// Events returns a EventClusterInformer. +func (v *version) Events() EventClusterInformer { + return &eventClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// ReplicationControllers returns a ReplicationControllerClusterInformer -func (v *version) ReplicationControllers() ReplicationControllerClusterInformer { - return &replicationControllerClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +// LimitRanges returns a LimitRangeClusterInformer. +func (v *version) LimitRanges() LimitRangeClusterInformer { + return &limitRangeClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// Services returns a ServiceClusterInformer -func (v *version) Services() ServiceClusterInformer { - return &serviceClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +// Namespaces returns a NamespaceClusterInformer. +func (v *version) Namespaces() NamespaceClusterInformer { + return &namespaceClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// ServiceAccounts returns a ServiceAccountClusterInformer -func (v *version) ServiceAccounts() ServiceAccountClusterInformer { - return &serviceAccountClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +// Nodes returns a NodeClusterInformer. +func (v *version) Nodes() NodeClusterInformer { + return &nodeClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// Endpoints returns a EndpointsClusterInformer -func (v *version) Endpoints() EndpointsClusterInformer { - return &endpointsClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +// PersistentVolumes returns a PersistentVolumeClusterInformer. +func (v *version) PersistentVolumes() PersistentVolumeClusterInformer { + return &persistentVolumeClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// Nodes returns a NodeClusterInformer -func (v *version) Nodes() NodeClusterInformer { - return &nodeClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +// PersistentVolumeClaims returns a PersistentVolumeClaimClusterInformer. +func (v *version) PersistentVolumeClaims() PersistentVolumeClaimClusterInformer { + return &persistentVolumeClaimClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// Namespaces returns a NamespaceClusterInformer -func (v *version) Namespaces() NamespaceClusterInformer { - return &namespaceClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +// Pods returns a PodClusterInformer. +func (v *version) Pods() PodClusterInformer { + return &podClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// Events returns a EventClusterInformer -func (v *version) Events() EventClusterInformer { - return &eventClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +// PodTemplates returns a PodTemplateClusterInformer. +func (v *version) PodTemplates() PodTemplateClusterInformer { + return &podTemplateClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// LimitRanges returns a LimitRangeClusterInformer -func (v *version) LimitRanges() LimitRangeClusterInformer { - return &limitRangeClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +// ReplicationControllers returns a ReplicationControllerClusterInformer. +func (v *version) ReplicationControllers() ReplicationControllerClusterInformer { + return &replicationControllerClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// ResourceQuotas returns a ResourceQuotaClusterInformer +// ResourceQuotas returns a ResourceQuotaClusterInformer. func (v *version) ResourceQuotas() ResourceQuotaClusterInformer { return &resourceQuotaClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// Secrets returns a SecretClusterInformer +// Secrets returns a SecretClusterInformer. func (v *version) Secrets() SecretClusterInformer { return &secretClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// ConfigMaps returns a ConfigMapClusterInformer -func (v *version) ConfigMaps() ConfigMapClusterInformer { - return &configMapClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +// Services returns a ServiceClusterInformer. +func (v *version) Services() ServiceClusterInformer { + return &serviceClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// ComponentStatuses returns a ComponentStatusClusterInformer -func (v *version) ComponentStatuses() ComponentStatusClusterInformer { - return &componentStatusClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +// ServiceAccounts returns a ServiceAccountClusterInformer. +func (v *version) ServiceAccounts() ServiceAccountClusterInformer { + return &serviceAccountClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/core/v1/limitrange.go b/informers/core/v1/limitrange.go index 1612e41e5..bc92f0795 100644 --- a/informers/core/v1/limitrange.go +++ b/informers/core/v1/limitrange.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - corev1 "k8s.io/api/core/v1" + apicorev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamcorev1informers "k8s.io/client-go/informers/core/v1" - upstreamcorev1listers "k8s.io/client-go/listers/core/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - corev1listers "github.com/kcp-dev/client-go/listers/core/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + corev1 "k8s.io/client-go/informers/core/v1" + listerscorev1 "k8s.io/client-go/listers/core/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/core/v1" ) // LimitRangeClusterInformer provides access to a shared informer and lister for // LimitRanges. type LimitRangeClusterInformer interface { - Cluster(logicalcluster.Name) upstreamcorev1informers.LimitRangeInformer + Cluster(logicalcluster.Name) corev1.LimitRangeInformer + ClusterWithContext(context.Context, logicalcluster.Name) corev1.LimitRangeInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() corev1listers.LimitRangeClusterLister + Lister() kcpv1.LimitRangeClusterLister } type limitRangeClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewLimitRangeClusterInformer constructs a new informer for LimitRange type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewLimitRangeClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewLimitRangeClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredLimitRangeClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredLimitRangeClusterInformer constructs a new informer for LimitRange type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredLimitRangeClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredLimitRangeClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoreV1().LimitRanges().List(context.TODO(), options) + return client.CoreV1().LimitRanges().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoreV1().LimitRanges().Watch(context.TODO(), options) + return client.CoreV1().LimitRanges().Watch(context.Background(), options) }, }, - &corev1.LimitRange{}, + &apicorev1.LimitRange{}, resyncPeriod, indexers, ) } -func (f *limitRangeClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *limitRangeClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredLimitRangeClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *limitRangeClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apicorev1.LimitRange{}, i.defaultInformer) } -func (f *limitRangeClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&corev1.LimitRange{}, f.defaultInformer) +func (i *limitRangeClusterInformer) Lister() kcpv1.LimitRangeClusterLister { + return kcpv1.NewLimitRangeClusterLister(i.Informer().GetIndexer()) } -func (f *limitRangeClusterInformer) Lister() corev1listers.LimitRangeClusterLister { - return corev1listers.NewLimitRangeClusterLister(f.Informer().GetIndexer()) +func (i *limitRangeClusterInformer) Cluster(clusterName logicalcluster.Name) corev1.LimitRangeInformer { + return &limitRangeInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *limitRangeClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamcorev1informers.LimitRangeInformer { +func (i *limitRangeClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) corev1.LimitRangeInformer { return &limitRangeInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type limitRangeInformer struct { informer cache.SharedIndexInformer - lister upstreamcorev1listers.LimitRangeLister + lister listerscorev1.LimitRangeLister } -func (f *limitRangeInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *limitRangeInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *limitRangeInformer) Lister() upstreamcorev1listers.LimitRangeLister { - return f.lister +func (i *limitRangeInformer) Lister() listerscorev1.LimitRangeLister { + return i.lister } diff --git a/informers/core/v1/namespace.go b/informers/core/v1/namespace.go index 269a74785..bdcce54f1 100644 --- a/informers/core/v1/namespace.go +++ b/informers/core/v1/namespace.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - corev1 "k8s.io/api/core/v1" + apicorev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamcorev1informers "k8s.io/client-go/informers/core/v1" - upstreamcorev1listers "k8s.io/client-go/listers/core/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - corev1listers "github.com/kcp-dev/client-go/listers/core/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + corev1 "k8s.io/client-go/informers/core/v1" + listerscorev1 "k8s.io/client-go/listers/core/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/core/v1" ) // NamespaceClusterInformer provides access to a shared informer and lister for // Namespaces. type NamespaceClusterInformer interface { - Cluster(logicalcluster.Name) upstreamcorev1informers.NamespaceInformer + Cluster(logicalcluster.Name) corev1.NamespaceInformer + ClusterWithContext(context.Context, logicalcluster.Name) corev1.NamespaceInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() corev1listers.NamespaceClusterLister + Lister() kcpv1.NamespaceClusterLister } type namespaceClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewNamespaceClusterInformer constructs a new informer for Namespace type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewNamespaceClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewNamespaceClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredNamespaceClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredNamespaceClusterInformer constructs a new informer for Namespace type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredNamespaceClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredNamespaceClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoreV1().Namespaces().List(context.TODO(), options) + return client.CoreV1().Namespaces().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoreV1().Namespaces().Watch(context.TODO(), options) + return client.CoreV1().Namespaces().Watch(context.Background(), options) }, }, - &corev1.Namespace{}, + &apicorev1.Namespace{}, resyncPeriod, indexers, ) } -func (f *namespaceClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *namespaceClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredNamespaceClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *namespaceClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apicorev1.Namespace{}, i.defaultInformer) } -func (f *namespaceClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&corev1.Namespace{}, f.defaultInformer) +func (i *namespaceClusterInformer) Lister() kcpv1.NamespaceClusterLister { + return kcpv1.NewNamespaceClusterLister(i.Informer().GetIndexer()) } -func (f *namespaceClusterInformer) Lister() corev1listers.NamespaceClusterLister { - return corev1listers.NewNamespaceClusterLister(f.Informer().GetIndexer()) +func (i *namespaceClusterInformer) Cluster(clusterName logicalcluster.Name) corev1.NamespaceInformer { + return &namespaceInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *namespaceClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamcorev1informers.NamespaceInformer { +func (i *namespaceClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) corev1.NamespaceInformer { return &namespaceInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type namespaceInformer struct { informer cache.SharedIndexInformer - lister upstreamcorev1listers.NamespaceLister + lister listerscorev1.NamespaceLister } -func (f *namespaceInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *namespaceInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *namespaceInformer) Lister() upstreamcorev1listers.NamespaceLister { - return f.lister +func (i *namespaceInformer) Lister() listerscorev1.NamespaceLister { + return i.lister } diff --git a/informers/core/v1/node.go b/informers/core/v1/node.go index 95b64b60d..cda1e4616 100644 --- a/informers/core/v1/node.go +++ b/informers/core/v1/node.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - corev1 "k8s.io/api/core/v1" + apicorev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamcorev1informers "k8s.io/client-go/informers/core/v1" - upstreamcorev1listers "k8s.io/client-go/listers/core/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - corev1listers "github.com/kcp-dev/client-go/listers/core/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + corev1 "k8s.io/client-go/informers/core/v1" + listerscorev1 "k8s.io/client-go/listers/core/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/core/v1" ) // NodeClusterInformer provides access to a shared informer and lister for // Nodes. type NodeClusterInformer interface { - Cluster(logicalcluster.Name) upstreamcorev1informers.NodeInformer + Cluster(logicalcluster.Name) corev1.NodeInformer + ClusterWithContext(context.Context, logicalcluster.Name) corev1.NodeInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() corev1listers.NodeClusterLister + Lister() kcpv1.NodeClusterLister } type nodeClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewNodeClusterInformer constructs a new informer for Node type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewNodeClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewNodeClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredNodeClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredNodeClusterInformer constructs a new informer for Node type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredNodeClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredNodeClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoreV1().Nodes().List(context.TODO(), options) + return client.CoreV1().Nodes().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoreV1().Nodes().Watch(context.TODO(), options) + return client.CoreV1().Nodes().Watch(context.Background(), options) }, }, - &corev1.Node{}, + &apicorev1.Node{}, resyncPeriod, indexers, ) } -func (f *nodeClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *nodeClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredNodeClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *nodeClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apicorev1.Node{}, i.defaultInformer) } -func (f *nodeClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&corev1.Node{}, f.defaultInformer) +func (i *nodeClusterInformer) Lister() kcpv1.NodeClusterLister { + return kcpv1.NewNodeClusterLister(i.Informer().GetIndexer()) } -func (f *nodeClusterInformer) Lister() corev1listers.NodeClusterLister { - return corev1listers.NewNodeClusterLister(f.Informer().GetIndexer()) +func (i *nodeClusterInformer) Cluster(clusterName logicalcluster.Name) corev1.NodeInformer { + return &nodeInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *nodeClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamcorev1informers.NodeInformer { +func (i *nodeClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) corev1.NodeInformer { return &nodeInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type nodeInformer struct { informer cache.SharedIndexInformer - lister upstreamcorev1listers.NodeLister + lister listerscorev1.NodeLister } -func (f *nodeInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *nodeInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *nodeInformer) Lister() upstreamcorev1listers.NodeLister { - return f.lister +func (i *nodeInformer) Lister() listerscorev1.NodeLister { + return i.lister } diff --git a/informers/core/v1/persistentvolume.go b/informers/core/v1/persistentvolume.go index 6eb49bb4d..11bb1de69 100644 --- a/informers/core/v1/persistentvolume.go +++ b/informers/core/v1/persistentvolume.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - corev1 "k8s.io/api/core/v1" + apicorev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamcorev1informers "k8s.io/client-go/informers/core/v1" - upstreamcorev1listers "k8s.io/client-go/listers/core/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - corev1listers "github.com/kcp-dev/client-go/listers/core/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + corev1 "k8s.io/client-go/informers/core/v1" + listerscorev1 "k8s.io/client-go/listers/core/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/core/v1" ) // PersistentVolumeClusterInformer provides access to a shared informer and lister for // PersistentVolumes. type PersistentVolumeClusterInformer interface { - Cluster(logicalcluster.Name) upstreamcorev1informers.PersistentVolumeInformer + Cluster(logicalcluster.Name) corev1.PersistentVolumeInformer + ClusterWithContext(context.Context, logicalcluster.Name) corev1.PersistentVolumeInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() corev1listers.PersistentVolumeClusterLister + Lister() kcpv1.PersistentVolumeClusterLister } type persistentVolumeClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewPersistentVolumeClusterInformer constructs a new informer for PersistentVolume type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewPersistentVolumeClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewPersistentVolumeClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredPersistentVolumeClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredPersistentVolumeClusterInformer constructs a new informer for PersistentVolume type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredPersistentVolumeClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredPersistentVolumeClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoreV1().PersistentVolumes().List(context.TODO(), options) + return client.CoreV1().PersistentVolumes().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoreV1().PersistentVolumes().Watch(context.TODO(), options) + return client.CoreV1().PersistentVolumes().Watch(context.Background(), options) }, }, - &corev1.PersistentVolume{}, + &apicorev1.PersistentVolume{}, resyncPeriod, indexers, ) } -func (f *persistentVolumeClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *persistentVolumeClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredPersistentVolumeClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *persistentVolumeClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apicorev1.PersistentVolume{}, i.defaultInformer) } -func (f *persistentVolumeClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&corev1.PersistentVolume{}, f.defaultInformer) +func (i *persistentVolumeClusterInformer) Lister() kcpv1.PersistentVolumeClusterLister { + return kcpv1.NewPersistentVolumeClusterLister(i.Informer().GetIndexer()) } -func (f *persistentVolumeClusterInformer) Lister() corev1listers.PersistentVolumeClusterLister { - return corev1listers.NewPersistentVolumeClusterLister(f.Informer().GetIndexer()) +func (i *persistentVolumeClusterInformer) Cluster(clusterName logicalcluster.Name) corev1.PersistentVolumeInformer { + return &persistentVolumeInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *persistentVolumeClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamcorev1informers.PersistentVolumeInformer { +func (i *persistentVolumeClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) corev1.PersistentVolumeInformer { return &persistentVolumeInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type persistentVolumeInformer struct { informer cache.SharedIndexInformer - lister upstreamcorev1listers.PersistentVolumeLister + lister listerscorev1.PersistentVolumeLister } -func (f *persistentVolumeInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *persistentVolumeInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *persistentVolumeInformer) Lister() upstreamcorev1listers.PersistentVolumeLister { - return f.lister +func (i *persistentVolumeInformer) Lister() listerscorev1.PersistentVolumeLister { + return i.lister } diff --git a/informers/core/v1/persistentvolumeclaim.go b/informers/core/v1/persistentvolumeclaim.go index b93852d7e..bfb3d9072 100644 --- a/informers/core/v1/persistentvolumeclaim.go +++ b/informers/core/v1/persistentvolumeclaim.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - corev1 "k8s.io/api/core/v1" + apicorev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamcorev1informers "k8s.io/client-go/informers/core/v1" - upstreamcorev1listers "k8s.io/client-go/listers/core/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - corev1listers "github.com/kcp-dev/client-go/listers/core/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + corev1 "k8s.io/client-go/informers/core/v1" + listerscorev1 "k8s.io/client-go/listers/core/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/core/v1" ) // PersistentVolumeClaimClusterInformer provides access to a shared informer and lister for // PersistentVolumeClaims. type PersistentVolumeClaimClusterInformer interface { - Cluster(logicalcluster.Name) upstreamcorev1informers.PersistentVolumeClaimInformer + Cluster(logicalcluster.Name) corev1.PersistentVolumeClaimInformer + ClusterWithContext(context.Context, logicalcluster.Name) corev1.PersistentVolumeClaimInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() corev1listers.PersistentVolumeClaimClusterLister + Lister() kcpv1.PersistentVolumeClaimClusterLister } type persistentVolumeClaimClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewPersistentVolumeClaimClusterInformer constructs a new informer for PersistentVolumeClaim type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewPersistentVolumeClaimClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewPersistentVolumeClaimClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredPersistentVolumeClaimClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredPersistentVolumeClaimClusterInformer constructs a new informer for PersistentVolumeClaim type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredPersistentVolumeClaimClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredPersistentVolumeClaimClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoreV1().PersistentVolumeClaims().List(context.TODO(), options) + return client.CoreV1().PersistentVolumeClaims().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoreV1().PersistentVolumeClaims().Watch(context.TODO(), options) + return client.CoreV1().PersistentVolumeClaims().Watch(context.Background(), options) }, }, - &corev1.PersistentVolumeClaim{}, + &apicorev1.PersistentVolumeClaim{}, resyncPeriod, indexers, ) } -func (f *persistentVolumeClaimClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *persistentVolumeClaimClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredPersistentVolumeClaimClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *persistentVolumeClaimClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apicorev1.PersistentVolumeClaim{}, i.defaultInformer) } -func (f *persistentVolumeClaimClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&corev1.PersistentVolumeClaim{}, f.defaultInformer) +func (i *persistentVolumeClaimClusterInformer) Lister() kcpv1.PersistentVolumeClaimClusterLister { + return kcpv1.NewPersistentVolumeClaimClusterLister(i.Informer().GetIndexer()) } -func (f *persistentVolumeClaimClusterInformer) Lister() corev1listers.PersistentVolumeClaimClusterLister { - return corev1listers.NewPersistentVolumeClaimClusterLister(f.Informer().GetIndexer()) +func (i *persistentVolumeClaimClusterInformer) Cluster(clusterName logicalcluster.Name) corev1.PersistentVolumeClaimInformer { + return &persistentVolumeClaimInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *persistentVolumeClaimClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamcorev1informers.PersistentVolumeClaimInformer { +func (i *persistentVolumeClaimClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) corev1.PersistentVolumeClaimInformer { return &persistentVolumeClaimInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type persistentVolumeClaimInformer struct { informer cache.SharedIndexInformer - lister upstreamcorev1listers.PersistentVolumeClaimLister + lister listerscorev1.PersistentVolumeClaimLister } -func (f *persistentVolumeClaimInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *persistentVolumeClaimInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *persistentVolumeClaimInformer) Lister() upstreamcorev1listers.PersistentVolumeClaimLister { - return f.lister +func (i *persistentVolumeClaimInformer) Lister() listerscorev1.PersistentVolumeClaimLister { + return i.lister } diff --git a/informers/core/v1/pod.go b/informers/core/v1/pod.go index 0e846bc0d..829329e97 100644 --- a/informers/core/v1/pod.go +++ b/informers/core/v1/pod.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - corev1 "k8s.io/api/core/v1" + apicorev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamcorev1informers "k8s.io/client-go/informers/core/v1" - upstreamcorev1listers "k8s.io/client-go/listers/core/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - corev1listers "github.com/kcp-dev/client-go/listers/core/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + corev1 "k8s.io/client-go/informers/core/v1" + listerscorev1 "k8s.io/client-go/listers/core/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/core/v1" ) // PodClusterInformer provides access to a shared informer and lister for // Pods. type PodClusterInformer interface { - Cluster(logicalcluster.Name) upstreamcorev1informers.PodInformer + Cluster(logicalcluster.Name) corev1.PodInformer + ClusterWithContext(context.Context, logicalcluster.Name) corev1.PodInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() corev1listers.PodClusterLister + Lister() kcpv1.PodClusterLister } type podClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewPodClusterInformer constructs a new informer for Pod type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewPodClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewPodClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredPodClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredPodClusterInformer constructs a new informer for Pod type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredPodClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredPodClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoreV1().Pods().List(context.TODO(), options) + return client.CoreV1().Pods().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoreV1().Pods().Watch(context.TODO(), options) + return client.CoreV1().Pods().Watch(context.Background(), options) }, }, - &corev1.Pod{}, + &apicorev1.Pod{}, resyncPeriod, indexers, ) } -func (f *podClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *podClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredPodClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *podClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apicorev1.Pod{}, i.defaultInformer) } -func (f *podClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&corev1.Pod{}, f.defaultInformer) +func (i *podClusterInformer) Lister() kcpv1.PodClusterLister { + return kcpv1.NewPodClusterLister(i.Informer().GetIndexer()) } -func (f *podClusterInformer) Lister() corev1listers.PodClusterLister { - return corev1listers.NewPodClusterLister(f.Informer().GetIndexer()) +func (i *podClusterInformer) Cluster(clusterName logicalcluster.Name) corev1.PodInformer { + return &podInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *podClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamcorev1informers.PodInformer { +func (i *podClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) corev1.PodInformer { return &podInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type podInformer struct { informer cache.SharedIndexInformer - lister upstreamcorev1listers.PodLister + lister listerscorev1.PodLister } -func (f *podInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *podInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *podInformer) Lister() upstreamcorev1listers.PodLister { - return f.lister +func (i *podInformer) Lister() listerscorev1.PodLister { + return i.lister } diff --git a/informers/core/v1/podtemplate.go b/informers/core/v1/podtemplate.go index 8f60d63da..137414e40 100644 --- a/informers/core/v1/podtemplate.go +++ b/informers/core/v1/podtemplate.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - corev1 "k8s.io/api/core/v1" + apicorev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamcorev1informers "k8s.io/client-go/informers/core/v1" - upstreamcorev1listers "k8s.io/client-go/listers/core/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - corev1listers "github.com/kcp-dev/client-go/listers/core/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + corev1 "k8s.io/client-go/informers/core/v1" + listerscorev1 "k8s.io/client-go/listers/core/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/core/v1" ) // PodTemplateClusterInformer provides access to a shared informer and lister for // PodTemplates. type PodTemplateClusterInformer interface { - Cluster(logicalcluster.Name) upstreamcorev1informers.PodTemplateInformer + Cluster(logicalcluster.Name) corev1.PodTemplateInformer + ClusterWithContext(context.Context, logicalcluster.Name) corev1.PodTemplateInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() corev1listers.PodTemplateClusterLister + Lister() kcpv1.PodTemplateClusterLister } type podTemplateClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewPodTemplateClusterInformer constructs a new informer for PodTemplate type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewPodTemplateClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewPodTemplateClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredPodTemplateClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredPodTemplateClusterInformer constructs a new informer for PodTemplate type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredPodTemplateClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredPodTemplateClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoreV1().PodTemplates().List(context.TODO(), options) + return client.CoreV1().PodTemplates().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoreV1().PodTemplates().Watch(context.TODO(), options) + return client.CoreV1().PodTemplates().Watch(context.Background(), options) }, }, - &corev1.PodTemplate{}, + &apicorev1.PodTemplate{}, resyncPeriod, indexers, ) } -func (f *podTemplateClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *podTemplateClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredPodTemplateClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *podTemplateClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apicorev1.PodTemplate{}, i.defaultInformer) } -func (f *podTemplateClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&corev1.PodTemplate{}, f.defaultInformer) +func (i *podTemplateClusterInformer) Lister() kcpv1.PodTemplateClusterLister { + return kcpv1.NewPodTemplateClusterLister(i.Informer().GetIndexer()) } -func (f *podTemplateClusterInformer) Lister() corev1listers.PodTemplateClusterLister { - return corev1listers.NewPodTemplateClusterLister(f.Informer().GetIndexer()) +func (i *podTemplateClusterInformer) Cluster(clusterName logicalcluster.Name) corev1.PodTemplateInformer { + return &podTemplateInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *podTemplateClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamcorev1informers.PodTemplateInformer { +func (i *podTemplateClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) corev1.PodTemplateInformer { return &podTemplateInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type podTemplateInformer struct { informer cache.SharedIndexInformer - lister upstreamcorev1listers.PodTemplateLister + lister listerscorev1.PodTemplateLister } -func (f *podTemplateInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *podTemplateInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *podTemplateInformer) Lister() upstreamcorev1listers.PodTemplateLister { - return f.lister +func (i *podTemplateInformer) Lister() listerscorev1.PodTemplateLister { + return i.lister } diff --git a/informers/core/v1/replicationcontroller.go b/informers/core/v1/replicationcontroller.go index b3ee45cf0..d3990629f 100644 --- a/informers/core/v1/replicationcontroller.go +++ b/informers/core/v1/replicationcontroller.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - corev1 "k8s.io/api/core/v1" + apicorev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamcorev1informers "k8s.io/client-go/informers/core/v1" - upstreamcorev1listers "k8s.io/client-go/listers/core/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - corev1listers "github.com/kcp-dev/client-go/listers/core/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + corev1 "k8s.io/client-go/informers/core/v1" + listerscorev1 "k8s.io/client-go/listers/core/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/core/v1" ) // ReplicationControllerClusterInformer provides access to a shared informer and lister for // ReplicationControllers. type ReplicationControllerClusterInformer interface { - Cluster(logicalcluster.Name) upstreamcorev1informers.ReplicationControllerInformer + Cluster(logicalcluster.Name) corev1.ReplicationControllerInformer + ClusterWithContext(context.Context, logicalcluster.Name) corev1.ReplicationControllerInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() corev1listers.ReplicationControllerClusterLister + Lister() kcpv1.ReplicationControllerClusterLister } type replicationControllerClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewReplicationControllerClusterInformer constructs a new informer for ReplicationController type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewReplicationControllerClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewReplicationControllerClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredReplicationControllerClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredReplicationControllerClusterInformer constructs a new informer for ReplicationController type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredReplicationControllerClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredReplicationControllerClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoreV1().ReplicationControllers().List(context.TODO(), options) + return client.CoreV1().ReplicationControllers().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoreV1().ReplicationControllers().Watch(context.TODO(), options) + return client.CoreV1().ReplicationControllers().Watch(context.Background(), options) }, }, - &corev1.ReplicationController{}, + &apicorev1.ReplicationController{}, resyncPeriod, indexers, ) } -func (f *replicationControllerClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *replicationControllerClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredReplicationControllerClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *replicationControllerClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apicorev1.ReplicationController{}, i.defaultInformer) } -func (f *replicationControllerClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&corev1.ReplicationController{}, f.defaultInformer) +func (i *replicationControllerClusterInformer) Lister() kcpv1.ReplicationControllerClusterLister { + return kcpv1.NewReplicationControllerClusterLister(i.Informer().GetIndexer()) } -func (f *replicationControllerClusterInformer) Lister() corev1listers.ReplicationControllerClusterLister { - return corev1listers.NewReplicationControllerClusterLister(f.Informer().GetIndexer()) +func (i *replicationControllerClusterInformer) Cluster(clusterName logicalcluster.Name) corev1.ReplicationControllerInformer { + return &replicationControllerInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *replicationControllerClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamcorev1informers.ReplicationControllerInformer { +func (i *replicationControllerClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) corev1.ReplicationControllerInformer { return &replicationControllerInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type replicationControllerInformer struct { informer cache.SharedIndexInformer - lister upstreamcorev1listers.ReplicationControllerLister + lister listerscorev1.ReplicationControllerLister } -func (f *replicationControllerInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *replicationControllerInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *replicationControllerInformer) Lister() upstreamcorev1listers.ReplicationControllerLister { - return f.lister +func (i *replicationControllerInformer) Lister() listerscorev1.ReplicationControllerLister { + return i.lister } diff --git a/informers/core/v1/resourcequota.go b/informers/core/v1/resourcequota.go index 7224a0c2d..3b9ace385 100644 --- a/informers/core/v1/resourcequota.go +++ b/informers/core/v1/resourcequota.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - corev1 "k8s.io/api/core/v1" + apicorev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamcorev1informers "k8s.io/client-go/informers/core/v1" - upstreamcorev1listers "k8s.io/client-go/listers/core/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - corev1listers "github.com/kcp-dev/client-go/listers/core/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + corev1 "k8s.io/client-go/informers/core/v1" + listerscorev1 "k8s.io/client-go/listers/core/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/core/v1" ) // ResourceQuotaClusterInformer provides access to a shared informer and lister for // ResourceQuotas. type ResourceQuotaClusterInformer interface { - Cluster(logicalcluster.Name) upstreamcorev1informers.ResourceQuotaInformer + Cluster(logicalcluster.Name) corev1.ResourceQuotaInformer + ClusterWithContext(context.Context, logicalcluster.Name) corev1.ResourceQuotaInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() corev1listers.ResourceQuotaClusterLister + Lister() kcpv1.ResourceQuotaClusterLister } type resourceQuotaClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewResourceQuotaClusterInformer constructs a new informer for ResourceQuota type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewResourceQuotaClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewResourceQuotaClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredResourceQuotaClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredResourceQuotaClusterInformer constructs a new informer for ResourceQuota type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredResourceQuotaClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredResourceQuotaClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoreV1().ResourceQuotas().List(context.TODO(), options) + return client.CoreV1().ResourceQuotas().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoreV1().ResourceQuotas().Watch(context.TODO(), options) + return client.CoreV1().ResourceQuotas().Watch(context.Background(), options) }, }, - &corev1.ResourceQuota{}, + &apicorev1.ResourceQuota{}, resyncPeriod, indexers, ) } -func (f *resourceQuotaClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *resourceQuotaClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredResourceQuotaClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *resourceQuotaClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apicorev1.ResourceQuota{}, i.defaultInformer) } -func (f *resourceQuotaClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&corev1.ResourceQuota{}, f.defaultInformer) +func (i *resourceQuotaClusterInformer) Lister() kcpv1.ResourceQuotaClusterLister { + return kcpv1.NewResourceQuotaClusterLister(i.Informer().GetIndexer()) } -func (f *resourceQuotaClusterInformer) Lister() corev1listers.ResourceQuotaClusterLister { - return corev1listers.NewResourceQuotaClusterLister(f.Informer().GetIndexer()) +func (i *resourceQuotaClusterInformer) Cluster(clusterName logicalcluster.Name) corev1.ResourceQuotaInformer { + return &resourceQuotaInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *resourceQuotaClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamcorev1informers.ResourceQuotaInformer { +func (i *resourceQuotaClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) corev1.ResourceQuotaInformer { return &resourceQuotaInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type resourceQuotaInformer struct { informer cache.SharedIndexInformer - lister upstreamcorev1listers.ResourceQuotaLister + lister listerscorev1.ResourceQuotaLister } -func (f *resourceQuotaInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *resourceQuotaInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *resourceQuotaInformer) Lister() upstreamcorev1listers.ResourceQuotaLister { - return f.lister +func (i *resourceQuotaInformer) Lister() listerscorev1.ResourceQuotaLister { + return i.lister } diff --git a/informers/core/v1/secret.go b/informers/core/v1/secret.go index 77e4a131a..17f071a98 100644 --- a/informers/core/v1/secret.go +++ b/informers/core/v1/secret.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - corev1 "k8s.io/api/core/v1" + apicorev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamcorev1informers "k8s.io/client-go/informers/core/v1" - upstreamcorev1listers "k8s.io/client-go/listers/core/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - corev1listers "github.com/kcp-dev/client-go/listers/core/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + corev1 "k8s.io/client-go/informers/core/v1" + listerscorev1 "k8s.io/client-go/listers/core/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/core/v1" ) // SecretClusterInformer provides access to a shared informer and lister for // Secrets. type SecretClusterInformer interface { - Cluster(logicalcluster.Name) upstreamcorev1informers.SecretInformer + Cluster(logicalcluster.Name) corev1.SecretInformer + ClusterWithContext(context.Context, logicalcluster.Name) corev1.SecretInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() corev1listers.SecretClusterLister + Lister() kcpv1.SecretClusterLister } type secretClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewSecretClusterInformer constructs a new informer for Secret type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewSecretClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewSecretClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredSecretClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredSecretClusterInformer constructs a new informer for Secret type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredSecretClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredSecretClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoreV1().Secrets().List(context.TODO(), options) + return client.CoreV1().Secrets().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoreV1().Secrets().Watch(context.TODO(), options) + return client.CoreV1().Secrets().Watch(context.Background(), options) }, }, - &corev1.Secret{}, + &apicorev1.Secret{}, resyncPeriod, indexers, ) } -func (f *secretClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *secretClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredSecretClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *secretClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apicorev1.Secret{}, i.defaultInformer) } -func (f *secretClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&corev1.Secret{}, f.defaultInformer) +func (i *secretClusterInformer) Lister() kcpv1.SecretClusterLister { + return kcpv1.NewSecretClusterLister(i.Informer().GetIndexer()) } -func (f *secretClusterInformer) Lister() corev1listers.SecretClusterLister { - return corev1listers.NewSecretClusterLister(f.Informer().GetIndexer()) +func (i *secretClusterInformer) Cluster(clusterName logicalcluster.Name) corev1.SecretInformer { + return &secretInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *secretClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamcorev1informers.SecretInformer { +func (i *secretClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) corev1.SecretInformer { return &secretInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type secretInformer struct { informer cache.SharedIndexInformer - lister upstreamcorev1listers.SecretLister + lister listerscorev1.SecretLister } -func (f *secretInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *secretInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *secretInformer) Lister() upstreamcorev1listers.SecretLister { - return f.lister +func (i *secretInformer) Lister() listerscorev1.SecretLister { + return i.lister } diff --git a/informers/core/v1/service.go b/informers/core/v1/service.go index a9e189e03..3eec65a04 100644 --- a/informers/core/v1/service.go +++ b/informers/core/v1/service.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - corev1 "k8s.io/api/core/v1" + apicorev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamcorev1informers "k8s.io/client-go/informers/core/v1" - upstreamcorev1listers "k8s.io/client-go/listers/core/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - corev1listers "github.com/kcp-dev/client-go/listers/core/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + corev1 "k8s.io/client-go/informers/core/v1" + listerscorev1 "k8s.io/client-go/listers/core/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/core/v1" ) // ServiceClusterInformer provides access to a shared informer and lister for // Services. type ServiceClusterInformer interface { - Cluster(logicalcluster.Name) upstreamcorev1informers.ServiceInformer + Cluster(logicalcluster.Name) corev1.ServiceInformer + ClusterWithContext(context.Context, logicalcluster.Name) corev1.ServiceInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() corev1listers.ServiceClusterLister + Lister() kcpv1.ServiceClusterLister } type serviceClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewServiceClusterInformer constructs a new informer for Service type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewServiceClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewServiceClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredServiceClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredServiceClusterInformer constructs a new informer for Service type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredServiceClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredServiceClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoreV1().Services().List(context.TODO(), options) + return client.CoreV1().Services().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoreV1().Services().Watch(context.TODO(), options) + return client.CoreV1().Services().Watch(context.Background(), options) }, }, - &corev1.Service{}, + &apicorev1.Service{}, resyncPeriod, indexers, ) } -func (f *serviceClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *serviceClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredServiceClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *serviceClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apicorev1.Service{}, i.defaultInformer) } -func (f *serviceClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&corev1.Service{}, f.defaultInformer) +func (i *serviceClusterInformer) Lister() kcpv1.ServiceClusterLister { + return kcpv1.NewServiceClusterLister(i.Informer().GetIndexer()) } -func (f *serviceClusterInformer) Lister() corev1listers.ServiceClusterLister { - return corev1listers.NewServiceClusterLister(f.Informer().GetIndexer()) +func (i *serviceClusterInformer) Cluster(clusterName logicalcluster.Name) corev1.ServiceInformer { + return &serviceInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *serviceClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamcorev1informers.ServiceInformer { +func (i *serviceClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) corev1.ServiceInformer { return &serviceInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type serviceInformer struct { informer cache.SharedIndexInformer - lister upstreamcorev1listers.ServiceLister + lister listerscorev1.ServiceLister } -func (f *serviceInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *serviceInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *serviceInformer) Lister() upstreamcorev1listers.ServiceLister { - return f.lister +func (i *serviceInformer) Lister() listerscorev1.ServiceLister { + return i.lister } diff --git a/informers/core/v1/serviceaccount.go b/informers/core/v1/serviceaccount.go index 6140ff628..0a1498d38 100644 --- a/informers/core/v1/serviceaccount.go +++ b/informers/core/v1/serviceaccount.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - corev1 "k8s.io/api/core/v1" + apicorev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamcorev1informers "k8s.io/client-go/informers/core/v1" - upstreamcorev1listers "k8s.io/client-go/listers/core/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - corev1listers "github.com/kcp-dev/client-go/listers/core/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + corev1 "k8s.io/client-go/informers/core/v1" + listerscorev1 "k8s.io/client-go/listers/core/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/core/v1" ) // ServiceAccountClusterInformer provides access to a shared informer and lister for // ServiceAccounts. type ServiceAccountClusterInformer interface { - Cluster(logicalcluster.Name) upstreamcorev1informers.ServiceAccountInformer + Cluster(logicalcluster.Name) corev1.ServiceAccountInformer + ClusterWithContext(context.Context, logicalcluster.Name) corev1.ServiceAccountInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() corev1listers.ServiceAccountClusterLister + Lister() kcpv1.ServiceAccountClusterLister } type serviceAccountClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewServiceAccountClusterInformer constructs a new informer for ServiceAccount type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewServiceAccountClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewServiceAccountClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredServiceAccountClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredServiceAccountClusterInformer constructs a new informer for ServiceAccount type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredServiceAccountClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredServiceAccountClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoreV1().ServiceAccounts().List(context.TODO(), options) + return client.CoreV1().ServiceAccounts().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.CoreV1().ServiceAccounts().Watch(context.TODO(), options) + return client.CoreV1().ServiceAccounts().Watch(context.Background(), options) }, }, - &corev1.ServiceAccount{}, + &apicorev1.ServiceAccount{}, resyncPeriod, indexers, ) } -func (f *serviceAccountClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *serviceAccountClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredServiceAccountClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *serviceAccountClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apicorev1.ServiceAccount{}, i.defaultInformer) } -func (f *serviceAccountClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&corev1.ServiceAccount{}, f.defaultInformer) +func (i *serviceAccountClusterInformer) Lister() kcpv1.ServiceAccountClusterLister { + return kcpv1.NewServiceAccountClusterLister(i.Informer().GetIndexer()) } -func (f *serviceAccountClusterInformer) Lister() corev1listers.ServiceAccountClusterLister { - return corev1listers.NewServiceAccountClusterLister(f.Informer().GetIndexer()) +func (i *serviceAccountClusterInformer) Cluster(clusterName logicalcluster.Name) corev1.ServiceAccountInformer { + return &serviceAccountInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *serviceAccountClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamcorev1informers.ServiceAccountInformer { +func (i *serviceAccountClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) corev1.ServiceAccountInformer { return &serviceAccountInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type serviceAccountInformer struct { informer cache.SharedIndexInformer - lister upstreamcorev1listers.ServiceAccountLister + lister listerscorev1.ServiceAccountLister } -func (f *serviceAccountInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *serviceAccountInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *serviceAccountInformer) Lister() upstreamcorev1listers.ServiceAccountLister { - return f.lister +func (i *serviceAccountInformer) Lister() listerscorev1.ServiceAccountLister { + return i.lister } diff --git a/informers/discovery/interface.go b/informers/discovery/interface.go index 5588243b9..464ef96fa 100644 --- a/informers/discovery/interface.go +++ b/informers/discovery/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,39 +14,40 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package discovery import ( - "github.com/kcp-dev/client-go/informers/discovery/v1" - "github.com/kcp-dev/client-go/informers/discovery/v1beta1" - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpv1 "github.com/kcp-dev/client-go/informers/discovery/v1" + kcpv1beta1 "github.com/kcp-dev/client-go/informers/discovery/v1beta1" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) +// ClusterInterface provides access to each of this group's versions. type ClusterInterface interface { - // V1 provides access to the shared informers in V1. - V1() v1.ClusterInterface - // V1beta1 provides access to the shared informers in V1beta1. - V1beta1() v1beta1.ClusterInterface + // V1 provides access to shared informers for resources in V1. + V1() kcpv1.ClusterInterface + // V1beta1 provides access to shared informers for resources in V1beta1. + V1beta1() kcpv1beta1.ClusterInterface } type group struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &group{factory: f, tweakListOptions: tweakListOptions} } -// V1 returns a new v1.ClusterInterface. -func (g *group) V1() v1.ClusterInterface { - return v1.New(g.factory, g.tweakListOptions) +// V1 returns a new kcpv1.ClusterInterface. +func (g *group) V1() kcpv1.ClusterInterface { + return kcpv1.New(g.factory, g.tweakListOptions) } -// V1beta1 returns a new v1beta1.ClusterInterface. -func (g *group) V1beta1() v1beta1.ClusterInterface { - return v1beta1.New(g.factory, g.tweakListOptions) +// V1beta1 returns a new kcpv1beta1.ClusterInterface. +func (g *group) V1beta1() kcpv1beta1.ClusterInterface { + return kcpv1beta1.New(g.factory, g.tweakListOptions) } diff --git a/informers/discovery/v1/endpointslice.go b/informers/discovery/v1/endpointslice.go index 1e7d6d146..e5c263589 100644 --- a/informers/discovery/v1/endpointslice.go +++ b/informers/discovery/v1/endpointslice.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - discoveryv1 "k8s.io/api/discovery/v1" + apidiscoveryv1 "k8s.io/api/discovery/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamdiscoveryv1informers "k8s.io/client-go/informers/discovery/v1" - upstreamdiscoveryv1listers "k8s.io/client-go/listers/discovery/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - discoveryv1listers "github.com/kcp-dev/client-go/listers/discovery/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + discoveryv1 "k8s.io/client-go/informers/discovery/v1" + listersdiscoveryv1 "k8s.io/client-go/listers/discovery/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/discovery/v1" ) // EndpointSliceClusterInformer provides access to a shared informer and lister for // EndpointSlices. type EndpointSliceClusterInformer interface { - Cluster(logicalcluster.Name) upstreamdiscoveryv1informers.EndpointSliceInformer + Cluster(logicalcluster.Name) discoveryv1.EndpointSliceInformer + ClusterWithContext(context.Context, logicalcluster.Name) discoveryv1.EndpointSliceInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() discoveryv1listers.EndpointSliceClusterLister + Lister() kcpv1.EndpointSliceClusterLister } type endpointSliceClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewEndpointSliceClusterInformer constructs a new informer for EndpointSlice type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewEndpointSliceClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewEndpointSliceClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredEndpointSliceClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredEndpointSliceClusterInformer constructs a new informer for EndpointSlice type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredEndpointSliceClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredEndpointSliceClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.DiscoveryV1().EndpointSlices().List(context.TODO(), options) + return client.DiscoveryV1().EndpointSlices().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.DiscoveryV1().EndpointSlices().Watch(context.TODO(), options) + return client.DiscoveryV1().EndpointSlices().Watch(context.Background(), options) }, }, - &discoveryv1.EndpointSlice{}, + &apidiscoveryv1.EndpointSlice{}, resyncPeriod, indexers, ) } -func (f *endpointSliceClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *endpointSliceClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredEndpointSliceClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *endpointSliceClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apidiscoveryv1.EndpointSlice{}, i.defaultInformer) } -func (f *endpointSliceClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&discoveryv1.EndpointSlice{}, f.defaultInformer) +func (i *endpointSliceClusterInformer) Lister() kcpv1.EndpointSliceClusterLister { + return kcpv1.NewEndpointSliceClusterLister(i.Informer().GetIndexer()) } -func (f *endpointSliceClusterInformer) Lister() discoveryv1listers.EndpointSliceClusterLister { - return discoveryv1listers.NewEndpointSliceClusterLister(f.Informer().GetIndexer()) +func (i *endpointSliceClusterInformer) Cluster(clusterName logicalcluster.Name) discoveryv1.EndpointSliceInformer { + return &endpointSliceInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *endpointSliceClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamdiscoveryv1informers.EndpointSliceInformer { +func (i *endpointSliceClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) discoveryv1.EndpointSliceInformer { return &endpointSliceInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type endpointSliceInformer struct { informer cache.SharedIndexInformer - lister upstreamdiscoveryv1listers.EndpointSliceLister + lister listersdiscoveryv1.EndpointSliceLister } -func (f *endpointSliceInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *endpointSliceInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *endpointSliceInformer) Lister() upstreamdiscoveryv1listers.EndpointSliceLister { - return f.lister +func (i *endpointSliceInformer) Lister() listersdiscoveryv1.EndpointSliceLister { + return i.lister } diff --git a/informers/discovery/v1/interface.go b/informers/discovery/v1/interface.go index 19ae569d5..29acbd12f 100644 --- a/informers/discovery/v1/interface.go +++ b/informers/discovery/v1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,30 +14,30 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // EndpointSlices returns a EndpointSliceClusterInformer + // EndpointSlices returns a EndpointSliceClusterInformer. EndpointSlices() EndpointSliceClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// EndpointSlices returns a EndpointSliceClusterInformer +// EndpointSlices returns a EndpointSliceClusterInformer. func (v *version) EndpointSlices() EndpointSliceClusterInformer { return &endpointSliceClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/discovery/v1beta1/endpointslice.go b/informers/discovery/v1beta1/endpointslice.go index 4ca6f8d4a..cae82c37f 100644 --- a/informers/discovery/v1beta1/endpointslice.go +++ b/informers/discovery/v1beta1/endpointslice.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - discoveryv1beta1 "k8s.io/api/discovery/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamdiscoveryv1beta1informers "k8s.io/client-go/informers/discovery/v1beta1" - upstreamdiscoveryv1beta1listers "k8s.io/client-go/listers/discovery/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - discoveryv1beta1listers "github.com/kcp-dev/client-go/listers/discovery/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apidiscoveryv1beta1 "k8s.io/api/discovery/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + discoveryv1beta1 "k8s.io/client-go/informers/discovery/v1beta1" + listersdiscoveryv1beta1 "k8s.io/client-go/listers/discovery/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/discovery/v1beta1" ) // EndpointSliceClusterInformer provides access to a shared informer and lister for // EndpointSlices. type EndpointSliceClusterInformer interface { - Cluster(logicalcluster.Name) upstreamdiscoveryv1beta1informers.EndpointSliceInformer + Cluster(logicalcluster.Name) discoveryv1beta1.EndpointSliceInformer + ClusterWithContext(context.Context, logicalcluster.Name) discoveryv1beta1.EndpointSliceInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() discoveryv1beta1listers.EndpointSliceClusterLister + Lister() kcpv1beta1.EndpointSliceClusterLister } type endpointSliceClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewEndpointSliceClusterInformer constructs a new informer for EndpointSlice type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewEndpointSliceClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewEndpointSliceClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredEndpointSliceClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredEndpointSliceClusterInformer constructs a new informer for EndpointSlice type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredEndpointSliceClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredEndpointSliceClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.DiscoveryV1beta1().EndpointSlices().List(context.TODO(), options) + return client.DiscoveryV1beta1().EndpointSlices().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.DiscoveryV1beta1().EndpointSlices().Watch(context.TODO(), options) + return client.DiscoveryV1beta1().EndpointSlices().Watch(context.Background(), options) }, }, - &discoveryv1beta1.EndpointSlice{}, + &apidiscoveryv1beta1.EndpointSlice{}, resyncPeriod, indexers, ) } -func (f *endpointSliceClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *endpointSliceClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredEndpointSliceClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *endpointSliceClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apidiscoveryv1beta1.EndpointSlice{}, i.defaultInformer) } -func (f *endpointSliceClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&discoveryv1beta1.EndpointSlice{}, f.defaultInformer) +func (i *endpointSliceClusterInformer) Lister() kcpv1beta1.EndpointSliceClusterLister { + return kcpv1beta1.NewEndpointSliceClusterLister(i.Informer().GetIndexer()) } -func (f *endpointSliceClusterInformer) Lister() discoveryv1beta1listers.EndpointSliceClusterLister { - return discoveryv1beta1listers.NewEndpointSliceClusterLister(f.Informer().GetIndexer()) +func (i *endpointSliceClusterInformer) Cluster(clusterName logicalcluster.Name) discoveryv1beta1.EndpointSliceInformer { + return &endpointSliceInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *endpointSliceClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamdiscoveryv1beta1informers.EndpointSliceInformer { +func (i *endpointSliceClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) discoveryv1beta1.EndpointSliceInformer { return &endpointSliceInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type endpointSliceInformer struct { informer cache.SharedIndexInformer - lister upstreamdiscoveryv1beta1listers.EndpointSliceLister + lister listersdiscoveryv1beta1.EndpointSliceLister } -func (f *endpointSliceInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *endpointSliceInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *endpointSliceInformer) Lister() upstreamdiscoveryv1beta1listers.EndpointSliceLister { - return f.lister +func (i *endpointSliceInformer) Lister() listersdiscoveryv1beta1.EndpointSliceLister { + return i.lister } diff --git a/informers/discovery/v1beta1/interface.go b/informers/discovery/v1beta1/interface.go index 13035f12d..51367b1cc 100644 --- a/informers/discovery/v1beta1/interface.go +++ b/informers/discovery/v1beta1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,30 +14,30 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // EndpointSlices returns a EndpointSliceClusterInformer + // EndpointSlices returns a EndpointSliceClusterInformer. EndpointSlices() EndpointSliceClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// EndpointSlices returns a EndpointSliceClusterInformer +// EndpointSlices returns a EndpointSliceClusterInformer. func (v *version) EndpointSlices() EndpointSliceClusterInformer { return &endpointSliceClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/events/interface.go b/informers/events/interface.go index bbc377f4a..285cabf82 100644 --- a/informers/events/interface.go +++ b/informers/events/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,39 +14,40 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package events import ( - "github.com/kcp-dev/client-go/informers/events/v1" - "github.com/kcp-dev/client-go/informers/events/v1beta1" - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpv1 "github.com/kcp-dev/client-go/informers/events/v1" + kcpv1beta1 "github.com/kcp-dev/client-go/informers/events/v1beta1" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) +// ClusterInterface provides access to each of this group's versions. type ClusterInterface interface { - // V1 provides access to the shared informers in V1. - V1() v1.ClusterInterface - // V1beta1 provides access to the shared informers in V1beta1. - V1beta1() v1beta1.ClusterInterface + // V1 provides access to shared informers for resources in V1. + V1() kcpv1.ClusterInterface + // V1beta1 provides access to shared informers for resources in V1beta1. + V1beta1() kcpv1beta1.ClusterInterface } type group struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &group{factory: f, tweakListOptions: tweakListOptions} } -// V1 returns a new v1.ClusterInterface. -func (g *group) V1() v1.ClusterInterface { - return v1.New(g.factory, g.tweakListOptions) +// V1 returns a new kcpv1.ClusterInterface. +func (g *group) V1() kcpv1.ClusterInterface { + return kcpv1.New(g.factory, g.tweakListOptions) } -// V1beta1 returns a new v1beta1.ClusterInterface. -func (g *group) V1beta1() v1beta1.ClusterInterface { - return v1beta1.New(g.factory, g.tweakListOptions) +// V1beta1 returns a new kcpv1beta1.ClusterInterface. +func (g *group) V1beta1() kcpv1beta1.ClusterInterface { + return kcpv1beta1.New(g.factory, g.tweakListOptions) } diff --git a/informers/events/v1/event.go b/informers/events/v1/event.go index fcc73eb20..459a49f03 100644 --- a/informers/events/v1/event.go +++ b/informers/events/v1/event.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - eventsv1 "k8s.io/api/events/v1" + apieventsv1 "k8s.io/api/events/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreameventsv1informers "k8s.io/client-go/informers/events/v1" - upstreameventsv1listers "k8s.io/client-go/listers/events/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - eventsv1listers "github.com/kcp-dev/client-go/listers/events/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + eventsv1 "k8s.io/client-go/informers/events/v1" + listerseventsv1 "k8s.io/client-go/listers/events/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/events/v1" ) // EventClusterInformer provides access to a shared informer and lister for // Events. type EventClusterInformer interface { - Cluster(logicalcluster.Name) upstreameventsv1informers.EventInformer + Cluster(logicalcluster.Name) eventsv1.EventInformer + ClusterWithContext(context.Context, logicalcluster.Name) eventsv1.EventInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() eventsv1listers.EventClusterLister + Lister() kcpv1.EventClusterLister } type eventClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewEventClusterInformer constructs a new informer for Event type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewEventClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewEventClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredEventClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredEventClusterInformer constructs a new informer for Event type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredEventClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredEventClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.EventsV1().Events().List(context.TODO(), options) + return client.EventsV1().Events().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.EventsV1().Events().Watch(context.TODO(), options) + return client.EventsV1().Events().Watch(context.Background(), options) }, }, - &eventsv1.Event{}, + &apieventsv1.Event{}, resyncPeriod, indexers, ) } -func (f *eventClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *eventClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredEventClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *eventClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apieventsv1.Event{}, i.defaultInformer) } -func (f *eventClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&eventsv1.Event{}, f.defaultInformer) +func (i *eventClusterInformer) Lister() kcpv1.EventClusterLister { + return kcpv1.NewEventClusterLister(i.Informer().GetIndexer()) } -func (f *eventClusterInformer) Lister() eventsv1listers.EventClusterLister { - return eventsv1listers.NewEventClusterLister(f.Informer().GetIndexer()) +func (i *eventClusterInformer) Cluster(clusterName logicalcluster.Name) eventsv1.EventInformer { + return &eventInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *eventClusterInformer) Cluster(clusterName logicalcluster.Name) upstreameventsv1informers.EventInformer { +func (i *eventClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) eventsv1.EventInformer { return &eventInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type eventInformer struct { informer cache.SharedIndexInformer - lister upstreameventsv1listers.EventLister + lister listerseventsv1.EventLister } -func (f *eventInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *eventInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *eventInformer) Lister() upstreameventsv1listers.EventLister { - return f.lister +func (i *eventInformer) Lister() listerseventsv1.EventLister { + return i.lister } diff --git a/informers/events/v1/interface.go b/informers/events/v1/interface.go index 06eaf5434..6421bc7cf 100644 --- a/informers/events/v1/interface.go +++ b/informers/events/v1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,30 +14,30 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // Events returns a EventClusterInformer + // Events returns a EventClusterInformer. Events() EventClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// Events returns a EventClusterInformer +// Events returns a EventClusterInformer. func (v *version) Events() EventClusterInformer { return &eventClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/events/v1beta1/event.go b/informers/events/v1beta1/event.go index 0973ab220..f554cadcf 100644 --- a/informers/events/v1beta1/event.go +++ b/informers/events/v1beta1/event.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - eventsv1beta1 "k8s.io/api/events/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreameventsv1beta1informers "k8s.io/client-go/informers/events/v1beta1" - upstreameventsv1beta1listers "k8s.io/client-go/listers/events/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - eventsv1beta1listers "github.com/kcp-dev/client-go/listers/events/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apieventsv1beta1 "k8s.io/api/events/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + eventsv1beta1 "k8s.io/client-go/informers/events/v1beta1" + listerseventsv1beta1 "k8s.io/client-go/listers/events/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/events/v1beta1" ) // EventClusterInformer provides access to a shared informer and lister for // Events. type EventClusterInformer interface { - Cluster(logicalcluster.Name) upstreameventsv1beta1informers.EventInformer + Cluster(logicalcluster.Name) eventsv1beta1.EventInformer + ClusterWithContext(context.Context, logicalcluster.Name) eventsv1beta1.EventInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() eventsv1beta1listers.EventClusterLister + Lister() kcpv1beta1.EventClusterLister } type eventClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewEventClusterInformer constructs a new informer for Event type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewEventClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewEventClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredEventClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredEventClusterInformer constructs a new informer for Event type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredEventClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredEventClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.EventsV1beta1().Events().List(context.TODO(), options) + return client.EventsV1beta1().Events().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.EventsV1beta1().Events().Watch(context.TODO(), options) + return client.EventsV1beta1().Events().Watch(context.Background(), options) }, }, - &eventsv1beta1.Event{}, + &apieventsv1beta1.Event{}, resyncPeriod, indexers, ) } -func (f *eventClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *eventClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredEventClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *eventClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apieventsv1beta1.Event{}, i.defaultInformer) } -func (f *eventClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&eventsv1beta1.Event{}, f.defaultInformer) +func (i *eventClusterInformer) Lister() kcpv1beta1.EventClusterLister { + return kcpv1beta1.NewEventClusterLister(i.Informer().GetIndexer()) } -func (f *eventClusterInformer) Lister() eventsv1beta1listers.EventClusterLister { - return eventsv1beta1listers.NewEventClusterLister(f.Informer().GetIndexer()) +func (i *eventClusterInformer) Cluster(clusterName logicalcluster.Name) eventsv1beta1.EventInformer { + return &eventInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *eventClusterInformer) Cluster(clusterName logicalcluster.Name) upstreameventsv1beta1informers.EventInformer { +func (i *eventClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) eventsv1beta1.EventInformer { return &eventInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type eventInformer struct { informer cache.SharedIndexInformer - lister upstreameventsv1beta1listers.EventLister + lister listerseventsv1beta1.EventLister } -func (f *eventInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *eventInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *eventInformer) Lister() upstreameventsv1beta1listers.EventLister { - return f.lister +func (i *eventInformer) Lister() listerseventsv1beta1.EventLister { + return i.lister } diff --git a/informers/events/v1beta1/interface.go b/informers/events/v1beta1/interface.go index 2cd7e249b..5b2dfaaad 100644 --- a/informers/events/v1beta1/interface.go +++ b/informers/events/v1beta1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,30 +14,30 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // Events returns a EventClusterInformer + // Events returns a EventClusterInformer. Events() EventClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// Events returns a EventClusterInformer +// Events returns a EventClusterInformer. func (v *version) Events() EventClusterInformer { return &eventClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/extensions/interface.go b/informers/extensions/interface.go index ea0901c92..e19677a37 100644 --- a/informers/extensions/interface.go +++ b/informers/extensions/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,31 +14,32 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package extensions import ( - "github.com/kcp-dev/client-go/informers/extensions/v1beta1" - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpv1beta1 "github.com/kcp-dev/client-go/informers/extensions/v1beta1" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) +// ClusterInterface provides access to each of this group's versions. type ClusterInterface interface { - // V1beta1 provides access to the shared informers in V1beta1. - V1beta1() v1beta1.ClusterInterface + // V1beta1 provides access to shared informers for resources in V1beta1. + V1beta1() kcpv1beta1.ClusterInterface } type group struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &group{factory: f, tweakListOptions: tweakListOptions} } -// V1beta1 returns a new v1beta1.ClusterInterface. -func (g *group) V1beta1() v1beta1.ClusterInterface { - return v1beta1.New(g.factory, g.tweakListOptions) +// V1beta1 returns a new kcpv1beta1.ClusterInterface. +func (g *group) V1beta1() kcpv1beta1.ClusterInterface { + return kcpv1beta1.New(g.factory, g.tweakListOptions) } diff --git a/informers/extensions/v1beta1/daemonset.go b/informers/extensions/v1beta1/daemonset.go index c45b90cec..4be7864bb 100644 --- a/informers/extensions/v1beta1/daemonset.go +++ b/informers/extensions/v1beta1/daemonset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - extensionsv1beta1 "k8s.io/api/extensions/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamextensionsv1beta1informers "k8s.io/client-go/informers/extensions/v1beta1" - upstreamextensionsv1beta1listers "k8s.io/client-go/listers/extensions/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - extensionsv1beta1listers "github.com/kcp-dev/client-go/listers/extensions/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiextensionsv1beta1 "k8s.io/api/extensions/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + extensionsv1beta1 "k8s.io/client-go/informers/extensions/v1beta1" + listersextensionsv1beta1 "k8s.io/client-go/listers/extensions/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/extensions/v1beta1" ) // DaemonSetClusterInformer provides access to a shared informer and lister for // DaemonSets. type DaemonSetClusterInformer interface { - Cluster(logicalcluster.Name) upstreamextensionsv1beta1informers.DaemonSetInformer + Cluster(logicalcluster.Name) extensionsv1beta1.DaemonSetInformer + ClusterWithContext(context.Context, logicalcluster.Name) extensionsv1beta1.DaemonSetInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() extensionsv1beta1listers.DaemonSetClusterLister + Lister() kcpv1beta1.DaemonSetClusterLister } type daemonSetClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewDaemonSetClusterInformer constructs a new informer for DaemonSet type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewDaemonSetClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewDaemonSetClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredDaemonSetClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredDaemonSetClusterInformer constructs a new informer for DaemonSet type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredDaemonSetClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredDaemonSetClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ExtensionsV1beta1().DaemonSets().List(context.TODO(), options) + return client.ExtensionsV1beta1().DaemonSets().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ExtensionsV1beta1().DaemonSets().Watch(context.TODO(), options) + return client.ExtensionsV1beta1().DaemonSets().Watch(context.Background(), options) }, }, - &extensionsv1beta1.DaemonSet{}, + &apiextensionsv1beta1.DaemonSet{}, resyncPeriod, indexers, ) } -func (f *daemonSetClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *daemonSetClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredDaemonSetClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *daemonSetClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiextensionsv1beta1.DaemonSet{}, i.defaultInformer) } -func (f *daemonSetClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&extensionsv1beta1.DaemonSet{}, f.defaultInformer) +func (i *daemonSetClusterInformer) Lister() kcpv1beta1.DaemonSetClusterLister { + return kcpv1beta1.NewDaemonSetClusterLister(i.Informer().GetIndexer()) } -func (f *daemonSetClusterInformer) Lister() extensionsv1beta1listers.DaemonSetClusterLister { - return extensionsv1beta1listers.NewDaemonSetClusterLister(f.Informer().GetIndexer()) +func (i *daemonSetClusterInformer) Cluster(clusterName logicalcluster.Name) extensionsv1beta1.DaemonSetInformer { + return &daemonSetInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *daemonSetClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamextensionsv1beta1informers.DaemonSetInformer { +func (i *daemonSetClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) extensionsv1beta1.DaemonSetInformer { return &daemonSetInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type daemonSetInformer struct { informer cache.SharedIndexInformer - lister upstreamextensionsv1beta1listers.DaemonSetLister + lister listersextensionsv1beta1.DaemonSetLister } -func (f *daemonSetInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *daemonSetInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *daemonSetInformer) Lister() upstreamextensionsv1beta1listers.DaemonSetLister { - return f.lister +func (i *daemonSetInformer) Lister() listersextensionsv1beta1.DaemonSetLister { + return i.lister } diff --git a/informers/extensions/v1beta1/deployment.go b/informers/extensions/v1beta1/deployment.go index a6e40991c..0db3e467a 100644 --- a/informers/extensions/v1beta1/deployment.go +++ b/informers/extensions/v1beta1/deployment.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - extensionsv1beta1 "k8s.io/api/extensions/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamextensionsv1beta1informers "k8s.io/client-go/informers/extensions/v1beta1" - upstreamextensionsv1beta1listers "k8s.io/client-go/listers/extensions/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - extensionsv1beta1listers "github.com/kcp-dev/client-go/listers/extensions/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiextensionsv1beta1 "k8s.io/api/extensions/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + extensionsv1beta1 "k8s.io/client-go/informers/extensions/v1beta1" + listersextensionsv1beta1 "k8s.io/client-go/listers/extensions/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/extensions/v1beta1" ) // DeploymentClusterInformer provides access to a shared informer and lister for // Deployments. type DeploymentClusterInformer interface { - Cluster(logicalcluster.Name) upstreamextensionsv1beta1informers.DeploymentInformer + Cluster(logicalcluster.Name) extensionsv1beta1.DeploymentInformer + ClusterWithContext(context.Context, logicalcluster.Name) extensionsv1beta1.DeploymentInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() extensionsv1beta1listers.DeploymentClusterLister + Lister() kcpv1beta1.DeploymentClusterLister } type deploymentClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewDeploymentClusterInformer constructs a new informer for Deployment type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewDeploymentClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewDeploymentClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredDeploymentClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredDeploymentClusterInformer constructs a new informer for Deployment type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredDeploymentClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredDeploymentClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ExtensionsV1beta1().Deployments().List(context.TODO(), options) + return client.ExtensionsV1beta1().Deployments().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ExtensionsV1beta1().Deployments().Watch(context.TODO(), options) + return client.ExtensionsV1beta1().Deployments().Watch(context.Background(), options) }, }, - &extensionsv1beta1.Deployment{}, + &apiextensionsv1beta1.Deployment{}, resyncPeriod, indexers, ) } -func (f *deploymentClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *deploymentClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredDeploymentClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *deploymentClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiextensionsv1beta1.Deployment{}, i.defaultInformer) } -func (f *deploymentClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&extensionsv1beta1.Deployment{}, f.defaultInformer) +func (i *deploymentClusterInformer) Lister() kcpv1beta1.DeploymentClusterLister { + return kcpv1beta1.NewDeploymentClusterLister(i.Informer().GetIndexer()) } -func (f *deploymentClusterInformer) Lister() extensionsv1beta1listers.DeploymentClusterLister { - return extensionsv1beta1listers.NewDeploymentClusterLister(f.Informer().GetIndexer()) +func (i *deploymentClusterInformer) Cluster(clusterName logicalcluster.Name) extensionsv1beta1.DeploymentInformer { + return &deploymentInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *deploymentClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamextensionsv1beta1informers.DeploymentInformer { +func (i *deploymentClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) extensionsv1beta1.DeploymentInformer { return &deploymentInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type deploymentInformer struct { informer cache.SharedIndexInformer - lister upstreamextensionsv1beta1listers.DeploymentLister + lister listersextensionsv1beta1.DeploymentLister } -func (f *deploymentInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *deploymentInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *deploymentInformer) Lister() upstreamextensionsv1beta1listers.DeploymentLister { - return f.lister +func (i *deploymentInformer) Lister() listersextensionsv1beta1.DeploymentLister { + return i.lister } diff --git a/informers/extensions/v1beta1/ingress.go b/informers/extensions/v1beta1/ingress.go index 4f193bc60..f5dd12089 100644 --- a/informers/extensions/v1beta1/ingress.go +++ b/informers/extensions/v1beta1/ingress.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - extensionsv1beta1 "k8s.io/api/extensions/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamextensionsv1beta1informers "k8s.io/client-go/informers/extensions/v1beta1" - upstreamextensionsv1beta1listers "k8s.io/client-go/listers/extensions/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - extensionsv1beta1listers "github.com/kcp-dev/client-go/listers/extensions/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiextensionsv1beta1 "k8s.io/api/extensions/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + extensionsv1beta1 "k8s.io/client-go/informers/extensions/v1beta1" + listersextensionsv1beta1 "k8s.io/client-go/listers/extensions/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/extensions/v1beta1" ) // IngressClusterInformer provides access to a shared informer and lister for // Ingresses. type IngressClusterInformer interface { - Cluster(logicalcluster.Name) upstreamextensionsv1beta1informers.IngressInformer + Cluster(logicalcluster.Name) extensionsv1beta1.IngressInformer + ClusterWithContext(context.Context, logicalcluster.Name) extensionsv1beta1.IngressInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() extensionsv1beta1listers.IngressClusterLister + Lister() kcpv1beta1.IngressClusterLister } type ingressClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewIngressClusterInformer constructs a new informer for Ingress type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewIngressClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewIngressClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredIngressClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredIngressClusterInformer constructs a new informer for Ingress type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredIngressClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredIngressClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ExtensionsV1beta1().Ingresses().List(context.TODO(), options) + return client.ExtensionsV1beta1().Ingresses().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ExtensionsV1beta1().Ingresses().Watch(context.TODO(), options) + return client.ExtensionsV1beta1().Ingresses().Watch(context.Background(), options) }, }, - &extensionsv1beta1.Ingress{}, + &apiextensionsv1beta1.Ingress{}, resyncPeriod, indexers, ) } -func (f *ingressClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *ingressClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredIngressClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *ingressClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiextensionsv1beta1.Ingress{}, i.defaultInformer) } -func (f *ingressClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&extensionsv1beta1.Ingress{}, f.defaultInformer) +func (i *ingressClusterInformer) Lister() kcpv1beta1.IngressClusterLister { + return kcpv1beta1.NewIngressClusterLister(i.Informer().GetIndexer()) } -func (f *ingressClusterInformer) Lister() extensionsv1beta1listers.IngressClusterLister { - return extensionsv1beta1listers.NewIngressClusterLister(f.Informer().GetIndexer()) +func (i *ingressClusterInformer) Cluster(clusterName logicalcluster.Name) extensionsv1beta1.IngressInformer { + return &ingressInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *ingressClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamextensionsv1beta1informers.IngressInformer { +func (i *ingressClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) extensionsv1beta1.IngressInformer { return &ingressInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type ingressInformer struct { informer cache.SharedIndexInformer - lister upstreamextensionsv1beta1listers.IngressLister + lister listersextensionsv1beta1.IngressLister } -func (f *ingressInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *ingressInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *ingressInformer) Lister() upstreamextensionsv1beta1listers.IngressLister { - return f.lister +func (i *ingressInformer) Lister() listersextensionsv1beta1.IngressLister { + return i.lister } diff --git a/informers/extensions/v1beta1/interface.go b/informers/extensions/v1beta1/interface.go index 420c06f40..91312d7ec 100644 --- a/informers/extensions/v1beta1/interface.go +++ b/informers/extensions/v1beta1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,58 +14,58 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // Deployments returns a DeploymentClusterInformer - Deployments() DeploymentClusterInformer - // DaemonSets returns a DaemonSetClusterInformer + // DaemonSets returns a DaemonSetClusterInformer. DaemonSets() DaemonSetClusterInformer - // Ingresses returns a IngressClusterInformer + // Deployments returns a DeploymentClusterInformer. + Deployments() DeploymentClusterInformer + // Ingresses returns a IngressClusterInformer. Ingresses() IngressClusterInformer - // ReplicaSets returns a ReplicaSetClusterInformer - ReplicaSets() ReplicaSetClusterInformer - // NetworkPolicies returns a NetworkPolicyClusterInformer + // NetworkPolicies returns a NetworkPolicyClusterInformer. NetworkPolicies() NetworkPolicyClusterInformer + // ReplicaSets returns a ReplicaSetClusterInformer. + ReplicaSets() ReplicaSetClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// Deployments returns a DeploymentClusterInformer -func (v *version) Deployments() DeploymentClusterInformer { - return &deploymentClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} - -// DaemonSets returns a DaemonSetClusterInformer +// DaemonSets returns a DaemonSetClusterInformer. func (v *version) DaemonSets() DaemonSetClusterInformer { return &daemonSetClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// Ingresses returns a IngressClusterInformer -func (v *version) Ingresses() IngressClusterInformer { - return &ingressClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +// Deployments returns a DeploymentClusterInformer. +func (v *version) Deployments() DeploymentClusterInformer { + return &deploymentClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// ReplicaSets returns a ReplicaSetClusterInformer -func (v *version) ReplicaSets() ReplicaSetClusterInformer { - return &replicaSetClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +// Ingresses returns a IngressClusterInformer. +func (v *version) Ingresses() IngressClusterInformer { + return &ingressClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// NetworkPolicies returns a NetworkPolicyClusterInformer +// NetworkPolicies returns a NetworkPolicyClusterInformer. func (v *version) NetworkPolicies() NetworkPolicyClusterInformer { return &networkPolicyClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } + +// ReplicaSets returns a ReplicaSetClusterInformer. +func (v *version) ReplicaSets() ReplicaSetClusterInformer { + return &replicaSetClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} diff --git a/informers/extensions/v1beta1/networkpolicy.go b/informers/extensions/v1beta1/networkpolicy.go index 318d7be0e..1cd76bf5f 100644 --- a/informers/extensions/v1beta1/networkpolicy.go +++ b/informers/extensions/v1beta1/networkpolicy.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - extensionsv1beta1 "k8s.io/api/extensions/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamextensionsv1beta1informers "k8s.io/client-go/informers/extensions/v1beta1" - upstreamextensionsv1beta1listers "k8s.io/client-go/listers/extensions/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - extensionsv1beta1listers "github.com/kcp-dev/client-go/listers/extensions/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiextensionsv1beta1 "k8s.io/api/extensions/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + extensionsv1beta1 "k8s.io/client-go/informers/extensions/v1beta1" + listersextensionsv1beta1 "k8s.io/client-go/listers/extensions/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/extensions/v1beta1" ) // NetworkPolicyClusterInformer provides access to a shared informer and lister for // NetworkPolicies. type NetworkPolicyClusterInformer interface { - Cluster(logicalcluster.Name) upstreamextensionsv1beta1informers.NetworkPolicyInformer + Cluster(logicalcluster.Name) extensionsv1beta1.NetworkPolicyInformer + ClusterWithContext(context.Context, logicalcluster.Name) extensionsv1beta1.NetworkPolicyInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() extensionsv1beta1listers.NetworkPolicyClusterLister + Lister() kcpv1beta1.NetworkPolicyClusterLister } type networkPolicyClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewNetworkPolicyClusterInformer constructs a new informer for NetworkPolicy type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewNetworkPolicyClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewNetworkPolicyClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredNetworkPolicyClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredNetworkPolicyClusterInformer constructs a new informer for NetworkPolicy type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredNetworkPolicyClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredNetworkPolicyClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ExtensionsV1beta1().NetworkPolicies().List(context.TODO(), options) + return client.ExtensionsV1beta1().NetworkPolicies().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ExtensionsV1beta1().NetworkPolicies().Watch(context.TODO(), options) + return client.ExtensionsV1beta1().NetworkPolicies().Watch(context.Background(), options) }, }, - &extensionsv1beta1.NetworkPolicy{}, + &apiextensionsv1beta1.NetworkPolicy{}, resyncPeriod, indexers, ) } -func (f *networkPolicyClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *networkPolicyClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredNetworkPolicyClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *networkPolicyClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiextensionsv1beta1.NetworkPolicy{}, i.defaultInformer) } -func (f *networkPolicyClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&extensionsv1beta1.NetworkPolicy{}, f.defaultInformer) +func (i *networkPolicyClusterInformer) Lister() kcpv1beta1.NetworkPolicyClusterLister { + return kcpv1beta1.NewNetworkPolicyClusterLister(i.Informer().GetIndexer()) } -func (f *networkPolicyClusterInformer) Lister() extensionsv1beta1listers.NetworkPolicyClusterLister { - return extensionsv1beta1listers.NewNetworkPolicyClusterLister(f.Informer().GetIndexer()) +func (i *networkPolicyClusterInformer) Cluster(clusterName logicalcluster.Name) extensionsv1beta1.NetworkPolicyInformer { + return &networkPolicyInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *networkPolicyClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamextensionsv1beta1informers.NetworkPolicyInformer { +func (i *networkPolicyClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) extensionsv1beta1.NetworkPolicyInformer { return &networkPolicyInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type networkPolicyInformer struct { informer cache.SharedIndexInformer - lister upstreamextensionsv1beta1listers.NetworkPolicyLister + lister listersextensionsv1beta1.NetworkPolicyLister } -func (f *networkPolicyInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *networkPolicyInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *networkPolicyInformer) Lister() upstreamextensionsv1beta1listers.NetworkPolicyLister { - return f.lister +func (i *networkPolicyInformer) Lister() listersextensionsv1beta1.NetworkPolicyLister { + return i.lister } diff --git a/informers/extensions/v1beta1/replicaset.go b/informers/extensions/v1beta1/replicaset.go index 0e58d4bf8..fe376877b 100644 --- a/informers/extensions/v1beta1/replicaset.go +++ b/informers/extensions/v1beta1/replicaset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - extensionsv1beta1 "k8s.io/api/extensions/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamextensionsv1beta1informers "k8s.io/client-go/informers/extensions/v1beta1" - upstreamextensionsv1beta1listers "k8s.io/client-go/listers/extensions/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - extensionsv1beta1listers "github.com/kcp-dev/client-go/listers/extensions/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiextensionsv1beta1 "k8s.io/api/extensions/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + extensionsv1beta1 "k8s.io/client-go/informers/extensions/v1beta1" + listersextensionsv1beta1 "k8s.io/client-go/listers/extensions/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/extensions/v1beta1" ) // ReplicaSetClusterInformer provides access to a shared informer and lister for // ReplicaSets. type ReplicaSetClusterInformer interface { - Cluster(logicalcluster.Name) upstreamextensionsv1beta1informers.ReplicaSetInformer + Cluster(logicalcluster.Name) extensionsv1beta1.ReplicaSetInformer + ClusterWithContext(context.Context, logicalcluster.Name) extensionsv1beta1.ReplicaSetInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() extensionsv1beta1listers.ReplicaSetClusterLister + Lister() kcpv1beta1.ReplicaSetClusterLister } type replicaSetClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewReplicaSetClusterInformer constructs a new informer for ReplicaSet type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewReplicaSetClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewReplicaSetClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredReplicaSetClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredReplicaSetClusterInformer constructs a new informer for ReplicaSet type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredReplicaSetClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredReplicaSetClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ExtensionsV1beta1().ReplicaSets().List(context.TODO(), options) + return client.ExtensionsV1beta1().ReplicaSets().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ExtensionsV1beta1().ReplicaSets().Watch(context.TODO(), options) + return client.ExtensionsV1beta1().ReplicaSets().Watch(context.Background(), options) }, }, - &extensionsv1beta1.ReplicaSet{}, + &apiextensionsv1beta1.ReplicaSet{}, resyncPeriod, indexers, ) } -func (f *replicaSetClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *replicaSetClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredReplicaSetClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *replicaSetClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiextensionsv1beta1.ReplicaSet{}, i.defaultInformer) } -func (f *replicaSetClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&extensionsv1beta1.ReplicaSet{}, f.defaultInformer) +func (i *replicaSetClusterInformer) Lister() kcpv1beta1.ReplicaSetClusterLister { + return kcpv1beta1.NewReplicaSetClusterLister(i.Informer().GetIndexer()) } -func (f *replicaSetClusterInformer) Lister() extensionsv1beta1listers.ReplicaSetClusterLister { - return extensionsv1beta1listers.NewReplicaSetClusterLister(f.Informer().GetIndexer()) +func (i *replicaSetClusterInformer) Cluster(clusterName logicalcluster.Name) extensionsv1beta1.ReplicaSetInformer { + return &replicaSetInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *replicaSetClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamextensionsv1beta1informers.ReplicaSetInformer { +func (i *replicaSetClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) extensionsv1beta1.ReplicaSetInformer { return &replicaSetInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type replicaSetInformer struct { informer cache.SharedIndexInformer - lister upstreamextensionsv1beta1listers.ReplicaSetLister + lister listersextensionsv1beta1.ReplicaSetLister } -func (f *replicaSetInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *replicaSetInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *replicaSetInformer) Lister() upstreamextensionsv1beta1listers.ReplicaSetLister { - return f.lister +func (i *replicaSetInformer) Lister() listersextensionsv1beta1.ReplicaSetLister { + return i.lister } diff --git a/informers/factory.go b/informers/factory.go index 019067686..36a7989e5 100644 --- a/informers/factory.go +++ b/informers/factory.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,46 +14,46 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package informers import ( - "reflect" - "sync" - "time" + reflect "reflect" + sync "sync" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" - "github.com/kcp-dev/logicalcluster/v3" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - upstreaminformers "k8s.io/client-go/informers" - "k8s.io/client-go/tools/cache" - - admissionregistrationinformers "github.com/kcp-dev/client-go/informers/admissionregistration" - apiserverinternalinformers "github.com/kcp-dev/client-go/informers/apiserverinternal" - appsinformers "github.com/kcp-dev/client-go/informers/apps" - autoscalinginformers "github.com/kcp-dev/client-go/informers/autoscaling" - batchinformers "github.com/kcp-dev/client-go/informers/batch" - certificatesinformers "github.com/kcp-dev/client-go/informers/certificates" - coordinationinformers "github.com/kcp-dev/client-go/informers/coordination" - coreinformers "github.com/kcp-dev/client-go/informers/core" - discoveryinformers "github.com/kcp-dev/client-go/informers/discovery" - eventsinformers "github.com/kcp-dev/client-go/informers/events" - extensionsinformers "github.com/kcp-dev/client-go/informers/extensions" - flowcontrolinformers "github.com/kcp-dev/client-go/informers/flowcontrol" - "github.com/kcp-dev/client-go/informers/internalinterfaces" - networkinginformers "github.com/kcp-dev/client-go/informers/networking" - nodeinformers "github.com/kcp-dev/client-go/informers/node" - policyinformers "github.com/kcp-dev/client-go/informers/policy" - rbacinformers "github.com/kcp-dev/client-go/informers/rbac" - resourceinformers "github.com/kcp-dev/client-go/informers/resource" - schedulinginformers "github.com/kcp-dev/client-go/informers/scheduling" - storageinformers "github.com/kcp-dev/client-go/informers/storage" - storagemigrationinformers "github.com/kcp-dev/client-go/informers/storagemigration" - clientset "github.com/kcp-dev/client-go/kubernetes" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + clientgoinformers "k8s.io/client-go/informers" + cache "k8s.io/client-go/tools/cache" + + kcpadmissionregistration "github.com/kcp-dev/client-go/informers/admissionregistration" + kcpapiserverinternal "github.com/kcp-dev/client-go/informers/apiserverinternal" + kcpapps "github.com/kcp-dev/client-go/informers/apps" + kcpautoscaling "github.com/kcp-dev/client-go/informers/autoscaling" + kcpbatch "github.com/kcp-dev/client-go/informers/batch" + kcpcertificates "github.com/kcp-dev/client-go/informers/certificates" + kcpcoordination "github.com/kcp-dev/client-go/informers/coordination" + kcpcore "github.com/kcp-dev/client-go/informers/core" + kcpdiscovery "github.com/kcp-dev/client-go/informers/discovery" + kcpevents "github.com/kcp-dev/client-go/informers/events" + kcpextensions "github.com/kcp-dev/client-go/informers/extensions" + kcpflowcontrol "github.com/kcp-dev/client-go/informers/flowcontrol" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpnetworking "github.com/kcp-dev/client-go/informers/networking" + kcpnode "github.com/kcp-dev/client-go/informers/node" + kcppolicy "github.com/kcp-dev/client-go/informers/policy" + kcprbac "github.com/kcp-dev/client-go/informers/rbac" + kcpresource "github.com/kcp-dev/client-go/informers/resource" + kcpscheduling "github.com/kcp-dev/client-go/informers/scheduling" + kcpstorage "github.com/kcp-dev/client-go/informers/storage" + kcpstoragemigration "github.com/kcp-dev/client-go/informers/storagemigration" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" ) // SharedInformerOption defines the functional option type for SharedInformerFactory. @@ -61,13 +61,14 @@ type SharedInformerOption func(*SharedInformerOptions) *SharedInformerOptions type SharedInformerOptions struct { customResync map[reflect.Type]time.Duration - tweakListOptions internalinterfaces.TweakListOptionsFunc + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc transform cache.TransformFunc + namespace string } type sharedInformerFactory struct { - client clientset.ClusterInterface - tweakListOptions internalinterfaces.TweakListOptionsFunc + client kcpkubernetes.ClusterInterface + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc lock sync.Mutex defaultResync time.Duration customResync map[reflect.Type]time.Duration @@ -85,7 +86,7 @@ type sharedInformerFactory struct { } // WithCustomResyncConfig sets a custom resync period for the specified informer types. -func WithCustomResyncConfig(resyncConfig map[metav1.Object]time.Duration) SharedInformerOption { +func WithCustomResyncConfig(resyncConfig map[v1.Object]time.Duration) SharedInformerOption { return func(opts *SharedInformerOptions) *SharedInformerOptions { for k, v := range resyncConfig { opts.customResync[reflect.TypeOf(k)] = v @@ -95,7 +96,7 @@ func WithCustomResyncConfig(resyncConfig map[metav1.Object]time.Duration) Shared } // WithTweakListOptions sets a custom filter on all listers of the configured SharedInformerFactory. -func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption { +func WithTweakListOptions(tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) SharedInformerOption { return func(opts *SharedInformerOptions) *SharedInformerOptions { opts.tweakListOptions = tweakListOptions return opts @@ -110,13 +111,21 @@ func WithTransform(transform cache.TransformFunc) SharedInformerOption { } } -// NewSharedInformerFactory constructs a new instance of SharedInformerFactory for all namespaces. -func NewSharedInformerFactory(client clientset.ClusterInterface, defaultResync time.Duration) SharedInformerFactory { +// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces. +func NewSharedInformerFactory(client kcpkubernetes.ClusterInterface, defaultResync time.Duration) SharedInformerFactory { return NewSharedInformerFactoryWithOptions(client, defaultResync) } +// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory. +// Listers obtained via this SharedInformerFactory will be subject to the same filters +// as specified here. +// Deprecated: Please use NewSharedInformerFactoryWithOptions instead +func NewFilteredSharedInformerFactory(client kcpkubernetes.ClusterInterface, defaultResync time.Duration, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) SharedInformerFactory { + return NewSharedInformerFactoryWithOptions(client, defaultResync, WithTweakListOptions(tweakListOptions)) +} + // NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options. -func NewSharedInformerFactoryWithOptions(client clientset.ClusterInterface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory { +func NewSharedInformerFactoryWithOptions(client kcpkubernetes.ClusterInterface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory { factory := &sharedInformerFactory{ client: client, defaultResync: defaultResync, @@ -142,7 +151,6 @@ func NewSharedInformerFactoryWithOptions(client clientset.ClusterInterface, defa return factory } -// Start initializes all requested informers. func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) { f.lock.Lock() defer f.lock.Unlock() @@ -176,7 +184,6 @@ func (f *sharedInformerFactory) Shutdown() { f.wg.Wait() } -// WaitForCacheSync waits for all started informers' cache were synced. func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool { informers := func() map[reflect.Type]kcpcache.ScopeableSharedIndexInformer { f.lock.Lock() @@ -195,11 +202,12 @@ func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[ref for informType, informer := range informers { res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced) } + return res } -// InformerFor returns the SharedIndexInformer for obj. -func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) kcpcache.ScopeableSharedIndexInformer { +// InformerFor returns the ScopeableSharedIndexInformer for obj using an internal client. +func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc kcpinternalinterfaces.NewInformerFunc) kcpcache.ScopeableSharedIndexInformer { f.lock.Lock() defer f.lock.Unlock() @@ -215,6 +223,7 @@ func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internal } informer = newFunc(f.client, resyncPeriod) + informer.SetTransform(f.transform) f.informers[informerType] = informer return informer @@ -222,7 +231,7 @@ func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internal type ScopedDynamicSharedInformerFactory interface { // ForResource gives generic access to a shared informer of the matching type. - ForResource(resource schema.GroupVersionResource) (upstreaminformers.GenericInformer, error) + ForResource(resource schema.GroupVersionResource) (clientgoinformers.GenericInformer, error) // Start initializes all requested informers. They are handled in goroutines // which run until the stop channel gets closed. @@ -236,11 +245,11 @@ type ScopedDynamicSharedInformerFactory interface { // // ctx, cancel := context.Background() // defer cancel() -// factory := NewSharedInformerFactoryWithOptions(client, resyncPeriod) -// defer factory.Shutdown() // Returns immediately if nothing was started. +// factory := NewSharedInformerFactory(client, resyncPeriod) +// defer factory.WaitForStop() // Returns immediately if nothing was started. // genericInformer := factory.ForResource(resource) // typedInformer := factory.SomeAPIGroup().V1().SomeType() -// factory.Start(ctx.Done()) // Start processing these informers. +// factory.Start(ctx.Done()) // Start processing these informers. // synced := factory.WaitForCacheSync(ctx.Done()) // for v, ok := range synced { // if !ok { @@ -254,12 +263,13 @@ type ScopedDynamicSharedInformerFactory interface { // anotherGenericInformer := factory.ForResource(resource) // factory.Start(ctx.Done()) type SharedInformerFactory interface { - internalinterfaces.SharedInformerFactory + kcpinternalinterfaces.SharedInformerFactory Cluster(logicalcluster.Name) ScopedDynamicSharedInformerFactory // Start initializes all requested informers. They are handled in goroutines // which run until the stop channel gets closed. + // Warning: Start does not block. When run in a go-routine, it will race with a later WaitForCacheSync. Start(stopCh <-chan struct{}) // Shutdown marks a factory as shutting down. At that point no new @@ -274,116 +284,117 @@ type SharedInformerFactory interface { // block until all goroutines have terminated. Shutdown() - // ForResource gives generic access to a shared informer of the matching type. - ForResource(resource schema.GroupVersionResource) (GenericClusterInformer, error) - // WaitForCacheSync blocks until all started informers' caches were synced // or the stop channel gets closed. WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool - // InformerFor returns the SharedIndexInformer for obj. - InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) kcpcache.ScopeableSharedIndexInformer + // ForResource gives generic access to a shared informer of the matching type. + ForResource(resource schema.GroupVersionResource) (GenericClusterInformer, error) + + // InformerFor returns the SharedIndexInformer for obj using an internal + // client. + InformerFor(obj runtime.Object, newFunc kcpinternalinterfaces.NewInformerFunc) kcpcache.ScopeableSharedIndexInformer - Admissionregistration() admissionregistrationinformers.ClusterInterface - Internal() apiserverinternalinformers.ClusterInterface - Apps() appsinformers.ClusterInterface - Autoscaling() autoscalinginformers.ClusterInterface - Batch() batchinformers.ClusterInterface - Certificates() certificatesinformers.ClusterInterface - Coordination() coordinationinformers.ClusterInterface - Core() coreinformers.ClusterInterface - Discovery() discoveryinformers.ClusterInterface - Events() eventsinformers.ClusterInterface - Extensions() extensionsinformers.ClusterInterface - Flowcontrol() flowcontrolinformers.ClusterInterface - Networking() networkinginformers.ClusterInterface - Node() nodeinformers.ClusterInterface - Policy() policyinformers.ClusterInterface - Rbac() rbacinformers.ClusterInterface - Resource() resourceinformers.ClusterInterface - Scheduling() schedulinginformers.ClusterInterface - Storage() storageinformers.ClusterInterface - Storagemigration() storagemigrationinformers.ClusterInterface + Admissionregistration() kcpadmissionregistration.ClusterInterface + Internal() kcpapiserverinternal.ClusterInterface + Apps() kcpapps.ClusterInterface + Autoscaling() kcpautoscaling.ClusterInterface + Batch() kcpbatch.ClusterInterface + Certificates() kcpcertificates.ClusterInterface + Coordination() kcpcoordination.ClusterInterface + Core() kcpcore.ClusterInterface + Discovery() kcpdiscovery.ClusterInterface + Events() kcpevents.ClusterInterface + Extensions() kcpextensions.ClusterInterface + Flowcontrol() kcpflowcontrol.ClusterInterface + Networking() kcpnetworking.ClusterInterface + Node() kcpnode.ClusterInterface + Policy() kcppolicy.ClusterInterface + Rbac() kcprbac.ClusterInterface + Resource() kcpresource.ClusterInterface + Scheduling() kcpscheduling.ClusterInterface + Storage() kcpstorage.ClusterInterface + Storagemigration() kcpstoragemigration.ClusterInterface } -func (f *sharedInformerFactory) Admissionregistration() admissionregistrationinformers.ClusterInterface { - return admissionregistrationinformers.New(f, f.tweakListOptions) +func (f *sharedInformerFactory) Admissionregistration() kcpadmissionregistration.ClusterInterface { + return kcpadmissionregistration.New(f, f.tweakListOptions) } -func (f *sharedInformerFactory) Internal() apiserverinternalinformers.ClusterInterface { - return apiserverinternalinformers.New(f, f.tweakListOptions) +func (f *sharedInformerFactory) Internal() kcpapiserverinternal.ClusterInterface { + return kcpapiserverinternal.New(f, f.tweakListOptions) } -func (f *sharedInformerFactory) Apps() appsinformers.ClusterInterface { - return appsinformers.New(f, f.tweakListOptions) +func (f *sharedInformerFactory) Apps() kcpapps.ClusterInterface { + return kcpapps.New(f, f.tweakListOptions) } -func (f *sharedInformerFactory) Autoscaling() autoscalinginformers.ClusterInterface { - return autoscalinginformers.New(f, f.tweakListOptions) +func (f *sharedInformerFactory) Autoscaling() kcpautoscaling.ClusterInterface { + return kcpautoscaling.New(f, f.tweakListOptions) } -func (f *sharedInformerFactory) Batch() batchinformers.ClusterInterface { - return batchinformers.New(f, f.tweakListOptions) +func (f *sharedInformerFactory) Batch() kcpbatch.ClusterInterface { + return kcpbatch.New(f, f.tweakListOptions) } -func (f *sharedInformerFactory) Certificates() certificatesinformers.ClusterInterface { - return certificatesinformers.New(f, f.tweakListOptions) +func (f *sharedInformerFactory) Certificates() kcpcertificates.ClusterInterface { + return kcpcertificates.New(f, f.tweakListOptions) } -func (f *sharedInformerFactory) Coordination() coordinationinformers.ClusterInterface { - return coordinationinformers.New(f, f.tweakListOptions) +func (f *sharedInformerFactory) Coordination() kcpcoordination.ClusterInterface { + return kcpcoordination.New(f, f.tweakListOptions) } -func (f *sharedInformerFactory) Core() coreinformers.ClusterInterface { - return coreinformers.New(f, f.tweakListOptions) +func (f *sharedInformerFactory) Core() kcpcore.ClusterInterface { + return kcpcore.New(f, f.tweakListOptions) } -func (f *sharedInformerFactory) Discovery() discoveryinformers.ClusterInterface { - return discoveryinformers.New(f, f.tweakListOptions) +func (f *sharedInformerFactory) Discovery() kcpdiscovery.ClusterInterface { + return kcpdiscovery.New(f, f.tweakListOptions) } -func (f *sharedInformerFactory) Events() eventsinformers.ClusterInterface { - return eventsinformers.New(f, f.tweakListOptions) +func (f *sharedInformerFactory) Events() kcpevents.ClusterInterface { + return kcpevents.New(f, f.tweakListOptions) } -func (f *sharedInformerFactory) Extensions() extensionsinformers.ClusterInterface { - return extensionsinformers.New(f, f.tweakListOptions) +func (f *sharedInformerFactory) Extensions() kcpextensions.ClusterInterface { + return kcpextensions.New(f, f.tweakListOptions) } -func (f *sharedInformerFactory) Flowcontrol() flowcontrolinformers.ClusterInterface { - return flowcontrolinformers.New(f, f.tweakListOptions) +func (f *sharedInformerFactory) Flowcontrol() kcpflowcontrol.ClusterInterface { + return kcpflowcontrol.New(f, f.tweakListOptions) } -func (f *sharedInformerFactory) Networking() networkinginformers.ClusterInterface { - return networkinginformers.New(f, f.tweakListOptions) +func (f *sharedInformerFactory) Networking() kcpnetworking.ClusterInterface { + return kcpnetworking.New(f, f.tweakListOptions) } -func (f *sharedInformerFactory) Node() nodeinformers.ClusterInterface { - return nodeinformers.New(f, f.tweakListOptions) +func (f *sharedInformerFactory) Node() kcpnode.ClusterInterface { + return kcpnode.New(f, f.tweakListOptions) } -func (f *sharedInformerFactory) Policy() policyinformers.ClusterInterface { - return policyinformers.New(f, f.tweakListOptions) +func (f *sharedInformerFactory) Policy() kcppolicy.ClusterInterface { + return kcppolicy.New(f, f.tweakListOptions) } -func (f *sharedInformerFactory) Rbac() rbacinformers.ClusterInterface { - return rbacinformers.New(f, f.tweakListOptions) +func (f *sharedInformerFactory) Rbac() kcprbac.ClusterInterface { + return kcprbac.New(f, f.tweakListOptions) } -func (f *sharedInformerFactory) Resource() resourceinformers.ClusterInterface { - return resourceinformers.New(f, f.tweakListOptions) +func (f *sharedInformerFactory) Resource() kcpresource.ClusterInterface { + return kcpresource.New(f, f.tweakListOptions) } -func (f *sharedInformerFactory) Scheduling() schedulinginformers.ClusterInterface { - return schedulinginformers.New(f, f.tweakListOptions) +func (f *sharedInformerFactory) Scheduling() kcpscheduling.ClusterInterface { + return kcpscheduling.New(f, f.tweakListOptions) } -func (f *sharedInformerFactory) Storage() storageinformers.ClusterInterface { - return storageinformers.New(f, f.tweakListOptions) +func (f *sharedInformerFactory) Storage() kcpstorage.ClusterInterface { + return kcpstorage.New(f, f.tweakListOptions) } -func (f *sharedInformerFactory) Storagemigration() storagemigrationinformers.ClusterInterface { - return storagemigrationinformers.New(f, f.tweakListOptions) +func (f *sharedInformerFactory) Storagemigration() kcpstoragemigration.ClusterInterface { + return kcpstoragemigration.New(f, f.tweakListOptions) } func (f *sharedInformerFactory) Cluster(clusterName logicalcluster.Name) ScopedDynamicSharedInformerFactory { @@ -398,7 +409,7 @@ type scopedDynamicSharedInformerFactory struct { clusterName logicalcluster.Name } -func (f *scopedDynamicSharedInformerFactory) ForResource(resource schema.GroupVersionResource) (upstreaminformers.GenericInformer, error) { +func (f *scopedDynamicSharedInformerFactory) ForResource(resource schema.GroupVersionResource) (clientgoinformers.GenericInformer, error) { clusterInformer, err := f.sharedInformerFactory.ForResource(resource) if err != nil { return nil, err diff --git a/informers/flowcontrol/interface.go b/informers/flowcontrol/interface.go index 2f2b126af..f3bfc47f4 100644 --- a/informers/flowcontrol/interface.go +++ b/informers/flowcontrol/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,55 +14,56 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package flowcontrol import ( - "github.com/kcp-dev/client-go/informers/flowcontrol/v1" - "github.com/kcp-dev/client-go/informers/flowcontrol/v1beta1" - "github.com/kcp-dev/client-go/informers/flowcontrol/v1beta2" - "github.com/kcp-dev/client-go/informers/flowcontrol/v1beta3" - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpv1 "github.com/kcp-dev/client-go/informers/flowcontrol/v1" + kcpv1beta1 "github.com/kcp-dev/client-go/informers/flowcontrol/v1beta1" + kcpv1beta2 "github.com/kcp-dev/client-go/informers/flowcontrol/v1beta2" + kcpv1beta3 "github.com/kcp-dev/client-go/informers/flowcontrol/v1beta3" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) +// ClusterInterface provides access to each of this group's versions. type ClusterInterface interface { - // V1 provides access to the shared informers in V1. - V1() v1.ClusterInterface - // V1beta1 provides access to the shared informers in V1beta1. - V1beta1() v1beta1.ClusterInterface - // V1beta2 provides access to the shared informers in V1beta2. - V1beta2() v1beta2.ClusterInterface - // V1beta3 provides access to the shared informers in V1beta3. - V1beta3() v1beta3.ClusterInterface + // V1 provides access to shared informers for resources in V1. + V1() kcpv1.ClusterInterface + // V1beta1 provides access to shared informers for resources in V1beta1. + V1beta1() kcpv1beta1.ClusterInterface + // V1beta2 provides access to shared informers for resources in V1beta2. + V1beta2() kcpv1beta2.ClusterInterface + // V1beta3 provides access to shared informers for resources in V1beta3. + V1beta3() kcpv1beta3.ClusterInterface } type group struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &group{factory: f, tweakListOptions: tweakListOptions} } -// V1 returns a new v1.ClusterInterface. -func (g *group) V1() v1.ClusterInterface { - return v1.New(g.factory, g.tweakListOptions) +// V1 returns a new kcpv1.ClusterInterface. +func (g *group) V1() kcpv1.ClusterInterface { + return kcpv1.New(g.factory, g.tweakListOptions) } -// V1beta1 returns a new v1beta1.ClusterInterface. -func (g *group) V1beta1() v1beta1.ClusterInterface { - return v1beta1.New(g.factory, g.tweakListOptions) +// V1beta1 returns a new kcpv1beta1.ClusterInterface. +func (g *group) V1beta1() kcpv1beta1.ClusterInterface { + return kcpv1beta1.New(g.factory, g.tweakListOptions) } -// V1beta2 returns a new v1beta2.ClusterInterface. -func (g *group) V1beta2() v1beta2.ClusterInterface { - return v1beta2.New(g.factory, g.tweakListOptions) +// V1beta2 returns a new kcpv1beta2.ClusterInterface. +func (g *group) V1beta2() kcpv1beta2.ClusterInterface { + return kcpv1beta2.New(g.factory, g.tweakListOptions) } -// V1beta3 returns a new v1beta3.ClusterInterface. -func (g *group) V1beta3() v1beta3.ClusterInterface { - return v1beta3.New(g.factory, g.tweakListOptions) +// V1beta3 returns a new kcpv1beta3.ClusterInterface. +func (g *group) V1beta3() kcpv1beta3.ClusterInterface { + return kcpv1beta3.New(g.factory, g.tweakListOptions) } diff --git a/informers/flowcontrol/v1/flowschema.go b/informers/flowcontrol/v1/flowschema.go index 66bb84f11..f5db19a5a 100644 --- a/informers/flowcontrol/v1/flowschema.go +++ b/informers/flowcontrol/v1/flowschema.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - flowcontrolv1 "k8s.io/api/flowcontrol/v1" + apiflowcontrolv1 "k8s.io/api/flowcontrol/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamflowcontrolv1informers "k8s.io/client-go/informers/flowcontrol/v1" - upstreamflowcontrolv1listers "k8s.io/client-go/listers/flowcontrol/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - flowcontrolv1listers "github.com/kcp-dev/client-go/listers/flowcontrol/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + flowcontrolv1 "k8s.io/client-go/informers/flowcontrol/v1" + listersflowcontrolv1 "k8s.io/client-go/listers/flowcontrol/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/flowcontrol/v1" ) // FlowSchemaClusterInformer provides access to a shared informer and lister for // FlowSchemas. type FlowSchemaClusterInformer interface { - Cluster(logicalcluster.Name) upstreamflowcontrolv1informers.FlowSchemaInformer + Cluster(logicalcluster.Name) flowcontrolv1.FlowSchemaInformer + ClusterWithContext(context.Context, logicalcluster.Name) flowcontrolv1.FlowSchemaInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() flowcontrolv1listers.FlowSchemaClusterLister + Lister() kcpv1.FlowSchemaClusterLister } type flowSchemaClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewFlowSchemaClusterInformer constructs a new informer for FlowSchema type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFlowSchemaClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewFlowSchemaClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredFlowSchemaClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredFlowSchemaClusterInformer constructs a new informer for FlowSchema type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredFlowSchemaClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredFlowSchemaClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.FlowcontrolV1().FlowSchemas().List(context.TODO(), options) + return client.FlowcontrolV1().FlowSchemas().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.FlowcontrolV1().FlowSchemas().Watch(context.TODO(), options) + return client.FlowcontrolV1().FlowSchemas().Watch(context.Background(), options) }, }, - &flowcontrolv1.FlowSchema{}, + &apiflowcontrolv1.FlowSchema{}, resyncPeriod, indexers, ) } -func (f *flowSchemaClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *flowSchemaClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredFlowSchemaClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *flowSchemaClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiflowcontrolv1.FlowSchema{}, i.defaultInformer) } -func (f *flowSchemaClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&flowcontrolv1.FlowSchema{}, f.defaultInformer) +func (i *flowSchemaClusterInformer) Lister() kcpv1.FlowSchemaClusterLister { + return kcpv1.NewFlowSchemaClusterLister(i.Informer().GetIndexer()) } -func (f *flowSchemaClusterInformer) Lister() flowcontrolv1listers.FlowSchemaClusterLister { - return flowcontrolv1listers.NewFlowSchemaClusterLister(f.Informer().GetIndexer()) +func (i *flowSchemaClusterInformer) Cluster(clusterName logicalcluster.Name) flowcontrolv1.FlowSchemaInformer { + return &flowSchemaInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *flowSchemaClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamflowcontrolv1informers.FlowSchemaInformer { +func (i *flowSchemaClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) flowcontrolv1.FlowSchemaInformer { return &flowSchemaInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type flowSchemaInformer struct { informer cache.SharedIndexInformer - lister upstreamflowcontrolv1listers.FlowSchemaLister + lister listersflowcontrolv1.FlowSchemaLister } -func (f *flowSchemaInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *flowSchemaInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *flowSchemaInformer) Lister() upstreamflowcontrolv1listers.FlowSchemaLister { - return f.lister +func (i *flowSchemaInformer) Lister() listersflowcontrolv1.FlowSchemaLister { + return i.lister } diff --git a/informers/flowcontrol/v1/interface.go b/informers/flowcontrol/v1/interface.go index 63d20dd98..a0f0e138a 100644 --- a/informers/flowcontrol/v1/interface.go +++ b/informers/flowcontrol/v1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,37 +14,37 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // FlowSchemas returns a FlowSchemaClusterInformer + // FlowSchemas returns a FlowSchemaClusterInformer. FlowSchemas() FlowSchemaClusterInformer - // PriorityLevelConfigurations returns a PriorityLevelConfigurationClusterInformer + // PriorityLevelConfigurations returns a PriorityLevelConfigurationClusterInformer. PriorityLevelConfigurations() PriorityLevelConfigurationClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// FlowSchemas returns a FlowSchemaClusterInformer +// FlowSchemas returns a FlowSchemaClusterInformer. func (v *version) FlowSchemas() FlowSchemaClusterInformer { return &flowSchemaClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// PriorityLevelConfigurations returns a PriorityLevelConfigurationClusterInformer +// PriorityLevelConfigurations returns a PriorityLevelConfigurationClusterInformer. func (v *version) PriorityLevelConfigurations() PriorityLevelConfigurationClusterInformer { return &priorityLevelConfigurationClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/flowcontrol/v1/prioritylevelconfiguration.go b/informers/flowcontrol/v1/prioritylevelconfiguration.go index 82401c786..4af1be476 100644 --- a/informers/flowcontrol/v1/prioritylevelconfiguration.go +++ b/informers/flowcontrol/v1/prioritylevelconfiguration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - flowcontrolv1 "k8s.io/api/flowcontrol/v1" + apiflowcontrolv1 "k8s.io/api/flowcontrol/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamflowcontrolv1informers "k8s.io/client-go/informers/flowcontrol/v1" - upstreamflowcontrolv1listers "k8s.io/client-go/listers/flowcontrol/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - flowcontrolv1listers "github.com/kcp-dev/client-go/listers/flowcontrol/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + flowcontrolv1 "k8s.io/client-go/informers/flowcontrol/v1" + listersflowcontrolv1 "k8s.io/client-go/listers/flowcontrol/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/flowcontrol/v1" ) // PriorityLevelConfigurationClusterInformer provides access to a shared informer and lister for // PriorityLevelConfigurations. type PriorityLevelConfigurationClusterInformer interface { - Cluster(logicalcluster.Name) upstreamflowcontrolv1informers.PriorityLevelConfigurationInformer + Cluster(logicalcluster.Name) flowcontrolv1.PriorityLevelConfigurationInformer + ClusterWithContext(context.Context, logicalcluster.Name) flowcontrolv1.PriorityLevelConfigurationInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() flowcontrolv1listers.PriorityLevelConfigurationClusterLister + Lister() kcpv1.PriorityLevelConfigurationClusterLister } type priorityLevelConfigurationClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewPriorityLevelConfigurationClusterInformer constructs a new informer for PriorityLevelConfiguration type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewPriorityLevelConfigurationClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewPriorityLevelConfigurationClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredPriorityLevelConfigurationClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredPriorityLevelConfigurationClusterInformer constructs a new informer for PriorityLevelConfiguration type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredPriorityLevelConfigurationClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredPriorityLevelConfigurationClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.FlowcontrolV1().PriorityLevelConfigurations().List(context.TODO(), options) + return client.FlowcontrolV1().PriorityLevelConfigurations().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.FlowcontrolV1().PriorityLevelConfigurations().Watch(context.TODO(), options) + return client.FlowcontrolV1().PriorityLevelConfigurations().Watch(context.Background(), options) }, }, - &flowcontrolv1.PriorityLevelConfiguration{}, + &apiflowcontrolv1.PriorityLevelConfiguration{}, resyncPeriod, indexers, ) } -func (f *priorityLevelConfigurationClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *priorityLevelConfigurationClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredPriorityLevelConfigurationClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *priorityLevelConfigurationClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiflowcontrolv1.PriorityLevelConfiguration{}, i.defaultInformer) } -func (f *priorityLevelConfigurationClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&flowcontrolv1.PriorityLevelConfiguration{}, f.defaultInformer) +func (i *priorityLevelConfigurationClusterInformer) Lister() kcpv1.PriorityLevelConfigurationClusterLister { + return kcpv1.NewPriorityLevelConfigurationClusterLister(i.Informer().GetIndexer()) } -func (f *priorityLevelConfigurationClusterInformer) Lister() flowcontrolv1listers.PriorityLevelConfigurationClusterLister { - return flowcontrolv1listers.NewPriorityLevelConfigurationClusterLister(f.Informer().GetIndexer()) +func (i *priorityLevelConfigurationClusterInformer) Cluster(clusterName logicalcluster.Name) flowcontrolv1.PriorityLevelConfigurationInformer { + return &priorityLevelConfigurationInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *priorityLevelConfigurationClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamflowcontrolv1informers.PriorityLevelConfigurationInformer { +func (i *priorityLevelConfigurationClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) flowcontrolv1.PriorityLevelConfigurationInformer { return &priorityLevelConfigurationInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type priorityLevelConfigurationInformer struct { informer cache.SharedIndexInformer - lister upstreamflowcontrolv1listers.PriorityLevelConfigurationLister + lister listersflowcontrolv1.PriorityLevelConfigurationLister } -func (f *priorityLevelConfigurationInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *priorityLevelConfigurationInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *priorityLevelConfigurationInformer) Lister() upstreamflowcontrolv1listers.PriorityLevelConfigurationLister { - return f.lister +func (i *priorityLevelConfigurationInformer) Lister() listersflowcontrolv1.PriorityLevelConfigurationLister { + return i.lister } diff --git a/informers/flowcontrol/v1beta1/flowschema.go b/informers/flowcontrol/v1beta1/flowschema.go index 0471e292b..18099aba3 100644 --- a/informers/flowcontrol/v1beta1/flowschema.go +++ b/informers/flowcontrol/v1beta1/flowschema.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - flowcontrolv1beta1 "k8s.io/api/flowcontrol/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamflowcontrolv1beta1informers "k8s.io/client-go/informers/flowcontrol/v1beta1" - upstreamflowcontrolv1beta1listers "k8s.io/client-go/listers/flowcontrol/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - flowcontrolv1beta1listers "github.com/kcp-dev/client-go/listers/flowcontrol/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiflowcontrolv1beta1 "k8s.io/api/flowcontrol/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + flowcontrolv1beta1 "k8s.io/client-go/informers/flowcontrol/v1beta1" + listersflowcontrolv1beta1 "k8s.io/client-go/listers/flowcontrol/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/flowcontrol/v1beta1" ) // FlowSchemaClusterInformer provides access to a shared informer and lister for // FlowSchemas. type FlowSchemaClusterInformer interface { - Cluster(logicalcluster.Name) upstreamflowcontrolv1beta1informers.FlowSchemaInformer + Cluster(logicalcluster.Name) flowcontrolv1beta1.FlowSchemaInformer + ClusterWithContext(context.Context, logicalcluster.Name) flowcontrolv1beta1.FlowSchemaInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() flowcontrolv1beta1listers.FlowSchemaClusterLister + Lister() kcpv1beta1.FlowSchemaClusterLister } type flowSchemaClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewFlowSchemaClusterInformer constructs a new informer for FlowSchema type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFlowSchemaClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewFlowSchemaClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredFlowSchemaClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredFlowSchemaClusterInformer constructs a new informer for FlowSchema type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredFlowSchemaClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredFlowSchemaClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.FlowcontrolV1beta1().FlowSchemas().List(context.TODO(), options) + return client.FlowcontrolV1beta1().FlowSchemas().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.FlowcontrolV1beta1().FlowSchemas().Watch(context.TODO(), options) + return client.FlowcontrolV1beta1().FlowSchemas().Watch(context.Background(), options) }, }, - &flowcontrolv1beta1.FlowSchema{}, + &apiflowcontrolv1beta1.FlowSchema{}, resyncPeriod, indexers, ) } -func (f *flowSchemaClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *flowSchemaClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredFlowSchemaClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *flowSchemaClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiflowcontrolv1beta1.FlowSchema{}, i.defaultInformer) } -func (f *flowSchemaClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&flowcontrolv1beta1.FlowSchema{}, f.defaultInformer) +func (i *flowSchemaClusterInformer) Lister() kcpv1beta1.FlowSchemaClusterLister { + return kcpv1beta1.NewFlowSchemaClusterLister(i.Informer().GetIndexer()) } -func (f *flowSchemaClusterInformer) Lister() flowcontrolv1beta1listers.FlowSchemaClusterLister { - return flowcontrolv1beta1listers.NewFlowSchemaClusterLister(f.Informer().GetIndexer()) +func (i *flowSchemaClusterInformer) Cluster(clusterName logicalcluster.Name) flowcontrolv1beta1.FlowSchemaInformer { + return &flowSchemaInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *flowSchemaClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamflowcontrolv1beta1informers.FlowSchemaInformer { +func (i *flowSchemaClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) flowcontrolv1beta1.FlowSchemaInformer { return &flowSchemaInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type flowSchemaInformer struct { informer cache.SharedIndexInformer - lister upstreamflowcontrolv1beta1listers.FlowSchemaLister + lister listersflowcontrolv1beta1.FlowSchemaLister } -func (f *flowSchemaInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *flowSchemaInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *flowSchemaInformer) Lister() upstreamflowcontrolv1beta1listers.FlowSchemaLister { - return f.lister +func (i *flowSchemaInformer) Lister() listersflowcontrolv1beta1.FlowSchemaLister { + return i.lister } diff --git a/informers/flowcontrol/v1beta1/interface.go b/informers/flowcontrol/v1beta1/interface.go index 6bfa83e86..dbb0144d5 100644 --- a/informers/flowcontrol/v1beta1/interface.go +++ b/informers/flowcontrol/v1beta1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,37 +14,37 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // FlowSchemas returns a FlowSchemaClusterInformer + // FlowSchemas returns a FlowSchemaClusterInformer. FlowSchemas() FlowSchemaClusterInformer - // PriorityLevelConfigurations returns a PriorityLevelConfigurationClusterInformer + // PriorityLevelConfigurations returns a PriorityLevelConfigurationClusterInformer. PriorityLevelConfigurations() PriorityLevelConfigurationClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// FlowSchemas returns a FlowSchemaClusterInformer +// FlowSchemas returns a FlowSchemaClusterInformer. func (v *version) FlowSchemas() FlowSchemaClusterInformer { return &flowSchemaClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// PriorityLevelConfigurations returns a PriorityLevelConfigurationClusterInformer +// PriorityLevelConfigurations returns a PriorityLevelConfigurationClusterInformer. func (v *version) PriorityLevelConfigurations() PriorityLevelConfigurationClusterInformer { return &priorityLevelConfigurationClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/flowcontrol/v1beta1/prioritylevelconfiguration.go b/informers/flowcontrol/v1beta1/prioritylevelconfiguration.go index 5ac425308..cfcbfcb13 100644 --- a/informers/flowcontrol/v1beta1/prioritylevelconfiguration.go +++ b/informers/flowcontrol/v1beta1/prioritylevelconfiguration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - flowcontrolv1beta1 "k8s.io/api/flowcontrol/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamflowcontrolv1beta1informers "k8s.io/client-go/informers/flowcontrol/v1beta1" - upstreamflowcontrolv1beta1listers "k8s.io/client-go/listers/flowcontrol/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - flowcontrolv1beta1listers "github.com/kcp-dev/client-go/listers/flowcontrol/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiflowcontrolv1beta1 "k8s.io/api/flowcontrol/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + flowcontrolv1beta1 "k8s.io/client-go/informers/flowcontrol/v1beta1" + listersflowcontrolv1beta1 "k8s.io/client-go/listers/flowcontrol/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/flowcontrol/v1beta1" ) // PriorityLevelConfigurationClusterInformer provides access to a shared informer and lister for // PriorityLevelConfigurations. type PriorityLevelConfigurationClusterInformer interface { - Cluster(logicalcluster.Name) upstreamflowcontrolv1beta1informers.PriorityLevelConfigurationInformer + Cluster(logicalcluster.Name) flowcontrolv1beta1.PriorityLevelConfigurationInformer + ClusterWithContext(context.Context, logicalcluster.Name) flowcontrolv1beta1.PriorityLevelConfigurationInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() flowcontrolv1beta1listers.PriorityLevelConfigurationClusterLister + Lister() kcpv1beta1.PriorityLevelConfigurationClusterLister } type priorityLevelConfigurationClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewPriorityLevelConfigurationClusterInformer constructs a new informer for PriorityLevelConfiguration type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewPriorityLevelConfigurationClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewPriorityLevelConfigurationClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredPriorityLevelConfigurationClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredPriorityLevelConfigurationClusterInformer constructs a new informer for PriorityLevelConfiguration type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredPriorityLevelConfigurationClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredPriorityLevelConfigurationClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.FlowcontrolV1beta1().PriorityLevelConfigurations().List(context.TODO(), options) + return client.FlowcontrolV1beta1().PriorityLevelConfigurations().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.FlowcontrolV1beta1().PriorityLevelConfigurations().Watch(context.TODO(), options) + return client.FlowcontrolV1beta1().PriorityLevelConfigurations().Watch(context.Background(), options) }, }, - &flowcontrolv1beta1.PriorityLevelConfiguration{}, + &apiflowcontrolv1beta1.PriorityLevelConfiguration{}, resyncPeriod, indexers, ) } -func (f *priorityLevelConfigurationClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *priorityLevelConfigurationClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredPriorityLevelConfigurationClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *priorityLevelConfigurationClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiflowcontrolv1beta1.PriorityLevelConfiguration{}, i.defaultInformer) } -func (f *priorityLevelConfigurationClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&flowcontrolv1beta1.PriorityLevelConfiguration{}, f.defaultInformer) +func (i *priorityLevelConfigurationClusterInformer) Lister() kcpv1beta1.PriorityLevelConfigurationClusterLister { + return kcpv1beta1.NewPriorityLevelConfigurationClusterLister(i.Informer().GetIndexer()) } -func (f *priorityLevelConfigurationClusterInformer) Lister() flowcontrolv1beta1listers.PriorityLevelConfigurationClusterLister { - return flowcontrolv1beta1listers.NewPriorityLevelConfigurationClusterLister(f.Informer().GetIndexer()) +func (i *priorityLevelConfigurationClusterInformer) Cluster(clusterName logicalcluster.Name) flowcontrolv1beta1.PriorityLevelConfigurationInformer { + return &priorityLevelConfigurationInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *priorityLevelConfigurationClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamflowcontrolv1beta1informers.PriorityLevelConfigurationInformer { +func (i *priorityLevelConfigurationClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) flowcontrolv1beta1.PriorityLevelConfigurationInformer { return &priorityLevelConfigurationInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type priorityLevelConfigurationInformer struct { informer cache.SharedIndexInformer - lister upstreamflowcontrolv1beta1listers.PriorityLevelConfigurationLister + lister listersflowcontrolv1beta1.PriorityLevelConfigurationLister } -func (f *priorityLevelConfigurationInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *priorityLevelConfigurationInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *priorityLevelConfigurationInformer) Lister() upstreamflowcontrolv1beta1listers.PriorityLevelConfigurationLister { - return f.lister +func (i *priorityLevelConfigurationInformer) Lister() listersflowcontrolv1beta1.PriorityLevelConfigurationLister { + return i.lister } diff --git a/informers/flowcontrol/v1beta2/flowschema.go b/informers/flowcontrol/v1beta2/flowschema.go index 3f04c044f..bcbfed6cf 100644 --- a/informers/flowcontrol/v1beta2/flowschema.go +++ b/informers/flowcontrol/v1beta2/flowschema.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta2 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - flowcontrolv1beta2 "k8s.io/api/flowcontrol/v1beta2" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamflowcontrolv1beta2informers "k8s.io/client-go/informers/flowcontrol/v1beta2" - upstreamflowcontrolv1beta2listers "k8s.io/client-go/listers/flowcontrol/v1beta2" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - flowcontrolv1beta2listers "github.com/kcp-dev/client-go/listers/flowcontrol/v1beta2" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiflowcontrolv1beta2 "k8s.io/api/flowcontrol/v1beta2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + flowcontrolv1beta2 "k8s.io/client-go/informers/flowcontrol/v1beta2" + listersflowcontrolv1beta2 "k8s.io/client-go/listers/flowcontrol/v1beta2" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta2 "github.com/kcp-dev/client-go/listers/flowcontrol/v1beta2" ) // FlowSchemaClusterInformer provides access to a shared informer and lister for // FlowSchemas. type FlowSchemaClusterInformer interface { - Cluster(logicalcluster.Name) upstreamflowcontrolv1beta2informers.FlowSchemaInformer + Cluster(logicalcluster.Name) flowcontrolv1beta2.FlowSchemaInformer + ClusterWithContext(context.Context, logicalcluster.Name) flowcontrolv1beta2.FlowSchemaInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() flowcontrolv1beta2listers.FlowSchemaClusterLister + Lister() kcpv1beta2.FlowSchemaClusterLister } type flowSchemaClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewFlowSchemaClusterInformer constructs a new informer for FlowSchema type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFlowSchemaClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewFlowSchemaClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredFlowSchemaClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredFlowSchemaClusterInformer constructs a new informer for FlowSchema type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredFlowSchemaClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredFlowSchemaClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.FlowcontrolV1beta2().FlowSchemas().List(context.TODO(), options) + return client.FlowcontrolV1beta2().FlowSchemas().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.FlowcontrolV1beta2().FlowSchemas().Watch(context.TODO(), options) + return client.FlowcontrolV1beta2().FlowSchemas().Watch(context.Background(), options) }, }, - &flowcontrolv1beta2.FlowSchema{}, + &apiflowcontrolv1beta2.FlowSchema{}, resyncPeriod, indexers, ) } -func (f *flowSchemaClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *flowSchemaClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredFlowSchemaClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *flowSchemaClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiflowcontrolv1beta2.FlowSchema{}, i.defaultInformer) } -func (f *flowSchemaClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&flowcontrolv1beta2.FlowSchema{}, f.defaultInformer) +func (i *flowSchemaClusterInformer) Lister() kcpv1beta2.FlowSchemaClusterLister { + return kcpv1beta2.NewFlowSchemaClusterLister(i.Informer().GetIndexer()) } -func (f *flowSchemaClusterInformer) Lister() flowcontrolv1beta2listers.FlowSchemaClusterLister { - return flowcontrolv1beta2listers.NewFlowSchemaClusterLister(f.Informer().GetIndexer()) +func (i *flowSchemaClusterInformer) Cluster(clusterName logicalcluster.Name) flowcontrolv1beta2.FlowSchemaInformer { + return &flowSchemaInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *flowSchemaClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamflowcontrolv1beta2informers.FlowSchemaInformer { +func (i *flowSchemaClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) flowcontrolv1beta2.FlowSchemaInformer { return &flowSchemaInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type flowSchemaInformer struct { informer cache.SharedIndexInformer - lister upstreamflowcontrolv1beta2listers.FlowSchemaLister + lister listersflowcontrolv1beta2.FlowSchemaLister } -func (f *flowSchemaInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *flowSchemaInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *flowSchemaInformer) Lister() upstreamflowcontrolv1beta2listers.FlowSchemaLister { - return f.lister +func (i *flowSchemaInformer) Lister() listersflowcontrolv1beta2.FlowSchemaLister { + return i.lister } diff --git a/informers/flowcontrol/v1beta2/interface.go b/informers/flowcontrol/v1beta2/interface.go index 7149c1c6d..df0c9f720 100644 --- a/informers/flowcontrol/v1beta2/interface.go +++ b/informers/flowcontrol/v1beta2/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,37 +14,37 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta2 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // FlowSchemas returns a FlowSchemaClusterInformer + // FlowSchemas returns a FlowSchemaClusterInformer. FlowSchemas() FlowSchemaClusterInformer - // PriorityLevelConfigurations returns a PriorityLevelConfigurationClusterInformer + // PriorityLevelConfigurations returns a PriorityLevelConfigurationClusterInformer. PriorityLevelConfigurations() PriorityLevelConfigurationClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// FlowSchemas returns a FlowSchemaClusterInformer +// FlowSchemas returns a FlowSchemaClusterInformer. func (v *version) FlowSchemas() FlowSchemaClusterInformer { return &flowSchemaClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// PriorityLevelConfigurations returns a PriorityLevelConfigurationClusterInformer +// PriorityLevelConfigurations returns a PriorityLevelConfigurationClusterInformer. func (v *version) PriorityLevelConfigurations() PriorityLevelConfigurationClusterInformer { return &priorityLevelConfigurationClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/flowcontrol/v1beta2/prioritylevelconfiguration.go b/informers/flowcontrol/v1beta2/prioritylevelconfiguration.go index 1c273dd0f..7ef6c782d 100644 --- a/informers/flowcontrol/v1beta2/prioritylevelconfiguration.go +++ b/informers/flowcontrol/v1beta2/prioritylevelconfiguration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta2 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - flowcontrolv1beta2 "k8s.io/api/flowcontrol/v1beta2" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamflowcontrolv1beta2informers "k8s.io/client-go/informers/flowcontrol/v1beta2" - upstreamflowcontrolv1beta2listers "k8s.io/client-go/listers/flowcontrol/v1beta2" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - flowcontrolv1beta2listers "github.com/kcp-dev/client-go/listers/flowcontrol/v1beta2" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiflowcontrolv1beta2 "k8s.io/api/flowcontrol/v1beta2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + flowcontrolv1beta2 "k8s.io/client-go/informers/flowcontrol/v1beta2" + listersflowcontrolv1beta2 "k8s.io/client-go/listers/flowcontrol/v1beta2" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta2 "github.com/kcp-dev/client-go/listers/flowcontrol/v1beta2" ) // PriorityLevelConfigurationClusterInformer provides access to a shared informer and lister for // PriorityLevelConfigurations. type PriorityLevelConfigurationClusterInformer interface { - Cluster(logicalcluster.Name) upstreamflowcontrolv1beta2informers.PriorityLevelConfigurationInformer + Cluster(logicalcluster.Name) flowcontrolv1beta2.PriorityLevelConfigurationInformer + ClusterWithContext(context.Context, logicalcluster.Name) flowcontrolv1beta2.PriorityLevelConfigurationInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() flowcontrolv1beta2listers.PriorityLevelConfigurationClusterLister + Lister() kcpv1beta2.PriorityLevelConfigurationClusterLister } type priorityLevelConfigurationClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewPriorityLevelConfigurationClusterInformer constructs a new informer for PriorityLevelConfiguration type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewPriorityLevelConfigurationClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewPriorityLevelConfigurationClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredPriorityLevelConfigurationClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredPriorityLevelConfigurationClusterInformer constructs a new informer for PriorityLevelConfiguration type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredPriorityLevelConfigurationClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredPriorityLevelConfigurationClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.FlowcontrolV1beta2().PriorityLevelConfigurations().List(context.TODO(), options) + return client.FlowcontrolV1beta2().PriorityLevelConfigurations().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.FlowcontrolV1beta2().PriorityLevelConfigurations().Watch(context.TODO(), options) + return client.FlowcontrolV1beta2().PriorityLevelConfigurations().Watch(context.Background(), options) }, }, - &flowcontrolv1beta2.PriorityLevelConfiguration{}, + &apiflowcontrolv1beta2.PriorityLevelConfiguration{}, resyncPeriod, indexers, ) } -func (f *priorityLevelConfigurationClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *priorityLevelConfigurationClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredPriorityLevelConfigurationClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *priorityLevelConfigurationClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiflowcontrolv1beta2.PriorityLevelConfiguration{}, i.defaultInformer) } -func (f *priorityLevelConfigurationClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&flowcontrolv1beta2.PriorityLevelConfiguration{}, f.defaultInformer) +func (i *priorityLevelConfigurationClusterInformer) Lister() kcpv1beta2.PriorityLevelConfigurationClusterLister { + return kcpv1beta2.NewPriorityLevelConfigurationClusterLister(i.Informer().GetIndexer()) } -func (f *priorityLevelConfigurationClusterInformer) Lister() flowcontrolv1beta2listers.PriorityLevelConfigurationClusterLister { - return flowcontrolv1beta2listers.NewPriorityLevelConfigurationClusterLister(f.Informer().GetIndexer()) +func (i *priorityLevelConfigurationClusterInformer) Cluster(clusterName logicalcluster.Name) flowcontrolv1beta2.PriorityLevelConfigurationInformer { + return &priorityLevelConfigurationInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *priorityLevelConfigurationClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamflowcontrolv1beta2informers.PriorityLevelConfigurationInformer { +func (i *priorityLevelConfigurationClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) flowcontrolv1beta2.PriorityLevelConfigurationInformer { return &priorityLevelConfigurationInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type priorityLevelConfigurationInformer struct { informer cache.SharedIndexInformer - lister upstreamflowcontrolv1beta2listers.PriorityLevelConfigurationLister + lister listersflowcontrolv1beta2.PriorityLevelConfigurationLister } -func (f *priorityLevelConfigurationInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *priorityLevelConfigurationInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *priorityLevelConfigurationInformer) Lister() upstreamflowcontrolv1beta2listers.PriorityLevelConfigurationLister { - return f.lister +func (i *priorityLevelConfigurationInformer) Lister() listersflowcontrolv1beta2.PriorityLevelConfigurationLister { + return i.lister } diff --git a/informers/flowcontrol/v1beta3/flowschema.go b/informers/flowcontrol/v1beta3/flowschema.go index b900fb32b..1ba143dde 100644 --- a/informers/flowcontrol/v1beta3/flowschema.go +++ b/informers/flowcontrol/v1beta3/flowschema.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta3 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamflowcontrolv1beta3informers "k8s.io/client-go/informers/flowcontrol/v1beta3" - upstreamflowcontrolv1beta3listers "k8s.io/client-go/listers/flowcontrol/v1beta3" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - flowcontrolv1beta3listers "github.com/kcp-dev/client-go/listers/flowcontrol/v1beta3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiflowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + flowcontrolv1beta3 "k8s.io/client-go/informers/flowcontrol/v1beta3" + listersflowcontrolv1beta3 "k8s.io/client-go/listers/flowcontrol/v1beta3" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta3 "github.com/kcp-dev/client-go/listers/flowcontrol/v1beta3" ) // FlowSchemaClusterInformer provides access to a shared informer and lister for // FlowSchemas. type FlowSchemaClusterInformer interface { - Cluster(logicalcluster.Name) upstreamflowcontrolv1beta3informers.FlowSchemaInformer + Cluster(logicalcluster.Name) flowcontrolv1beta3.FlowSchemaInformer + ClusterWithContext(context.Context, logicalcluster.Name) flowcontrolv1beta3.FlowSchemaInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() flowcontrolv1beta3listers.FlowSchemaClusterLister + Lister() kcpv1beta3.FlowSchemaClusterLister } type flowSchemaClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewFlowSchemaClusterInformer constructs a new informer for FlowSchema type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFlowSchemaClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewFlowSchemaClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredFlowSchemaClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredFlowSchemaClusterInformer constructs a new informer for FlowSchema type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredFlowSchemaClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredFlowSchemaClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.FlowcontrolV1beta3().FlowSchemas().List(context.TODO(), options) + return client.FlowcontrolV1beta3().FlowSchemas().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.FlowcontrolV1beta3().FlowSchemas().Watch(context.TODO(), options) + return client.FlowcontrolV1beta3().FlowSchemas().Watch(context.Background(), options) }, }, - &flowcontrolv1beta3.FlowSchema{}, + &apiflowcontrolv1beta3.FlowSchema{}, resyncPeriod, indexers, ) } -func (f *flowSchemaClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *flowSchemaClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredFlowSchemaClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *flowSchemaClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiflowcontrolv1beta3.FlowSchema{}, i.defaultInformer) } -func (f *flowSchemaClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&flowcontrolv1beta3.FlowSchema{}, f.defaultInformer) +func (i *flowSchemaClusterInformer) Lister() kcpv1beta3.FlowSchemaClusterLister { + return kcpv1beta3.NewFlowSchemaClusterLister(i.Informer().GetIndexer()) } -func (f *flowSchemaClusterInformer) Lister() flowcontrolv1beta3listers.FlowSchemaClusterLister { - return flowcontrolv1beta3listers.NewFlowSchemaClusterLister(f.Informer().GetIndexer()) +func (i *flowSchemaClusterInformer) Cluster(clusterName logicalcluster.Name) flowcontrolv1beta3.FlowSchemaInformer { + return &flowSchemaInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *flowSchemaClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamflowcontrolv1beta3informers.FlowSchemaInformer { +func (i *flowSchemaClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) flowcontrolv1beta3.FlowSchemaInformer { return &flowSchemaInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type flowSchemaInformer struct { informer cache.SharedIndexInformer - lister upstreamflowcontrolv1beta3listers.FlowSchemaLister + lister listersflowcontrolv1beta3.FlowSchemaLister } -func (f *flowSchemaInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *flowSchemaInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *flowSchemaInformer) Lister() upstreamflowcontrolv1beta3listers.FlowSchemaLister { - return f.lister +func (i *flowSchemaInformer) Lister() listersflowcontrolv1beta3.FlowSchemaLister { + return i.lister } diff --git a/informers/flowcontrol/v1beta3/interface.go b/informers/flowcontrol/v1beta3/interface.go index ced144c9b..f57a713ee 100644 --- a/informers/flowcontrol/v1beta3/interface.go +++ b/informers/flowcontrol/v1beta3/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,37 +14,37 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta3 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // FlowSchemas returns a FlowSchemaClusterInformer + // FlowSchemas returns a FlowSchemaClusterInformer. FlowSchemas() FlowSchemaClusterInformer - // PriorityLevelConfigurations returns a PriorityLevelConfigurationClusterInformer + // PriorityLevelConfigurations returns a PriorityLevelConfigurationClusterInformer. PriorityLevelConfigurations() PriorityLevelConfigurationClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// FlowSchemas returns a FlowSchemaClusterInformer +// FlowSchemas returns a FlowSchemaClusterInformer. func (v *version) FlowSchemas() FlowSchemaClusterInformer { return &flowSchemaClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// PriorityLevelConfigurations returns a PriorityLevelConfigurationClusterInformer +// PriorityLevelConfigurations returns a PriorityLevelConfigurationClusterInformer. func (v *version) PriorityLevelConfigurations() PriorityLevelConfigurationClusterInformer { return &priorityLevelConfigurationClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/flowcontrol/v1beta3/prioritylevelconfiguration.go b/informers/flowcontrol/v1beta3/prioritylevelconfiguration.go index b520ed0ec..c7d92bfaf 100644 --- a/informers/flowcontrol/v1beta3/prioritylevelconfiguration.go +++ b/informers/flowcontrol/v1beta3/prioritylevelconfiguration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta3 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamflowcontrolv1beta3informers "k8s.io/client-go/informers/flowcontrol/v1beta3" - upstreamflowcontrolv1beta3listers "k8s.io/client-go/listers/flowcontrol/v1beta3" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - flowcontrolv1beta3listers "github.com/kcp-dev/client-go/listers/flowcontrol/v1beta3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiflowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + flowcontrolv1beta3 "k8s.io/client-go/informers/flowcontrol/v1beta3" + listersflowcontrolv1beta3 "k8s.io/client-go/listers/flowcontrol/v1beta3" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta3 "github.com/kcp-dev/client-go/listers/flowcontrol/v1beta3" ) // PriorityLevelConfigurationClusterInformer provides access to a shared informer and lister for // PriorityLevelConfigurations. type PriorityLevelConfigurationClusterInformer interface { - Cluster(logicalcluster.Name) upstreamflowcontrolv1beta3informers.PriorityLevelConfigurationInformer + Cluster(logicalcluster.Name) flowcontrolv1beta3.PriorityLevelConfigurationInformer + ClusterWithContext(context.Context, logicalcluster.Name) flowcontrolv1beta3.PriorityLevelConfigurationInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() flowcontrolv1beta3listers.PriorityLevelConfigurationClusterLister + Lister() kcpv1beta3.PriorityLevelConfigurationClusterLister } type priorityLevelConfigurationClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewPriorityLevelConfigurationClusterInformer constructs a new informer for PriorityLevelConfiguration type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewPriorityLevelConfigurationClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewPriorityLevelConfigurationClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredPriorityLevelConfigurationClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredPriorityLevelConfigurationClusterInformer constructs a new informer for PriorityLevelConfiguration type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredPriorityLevelConfigurationClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredPriorityLevelConfigurationClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.FlowcontrolV1beta3().PriorityLevelConfigurations().List(context.TODO(), options) + return client.FlowcontrolV1beta3().PriorityLevelConfigurations().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.FlowcontrolV1beta3().PriorityLevelConfigurations().Watch(context.TODO(), options) + return client.FlowcontrolV1beta3().PriorityLevelConfigurations().Watch(context.Background(), options) }, }, - &flowcontrolv1beta3.PriorityLevelConfiguration{}, + &apiflowcontrolv1beta3.PriorityLevelConfiguration{}, resyncPeriod, indexers, ) } -func (f *priorityLevelConfigurationClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *priorityLevelConfigurationClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredPriorityLevelConfigurationClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *priorityLevelConfigurationClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiflowcontrolv1beta3.PriorityLevelConfiguration{}, i.defaultInformer) } -func (f *priorityLevelConfigurationClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&flowcontrolv1beta3.PriorityLevelConfiguration{}, f.defaultInformer) +func (i *priorityLevelConfigurationClusterInformer) Lister() kcpv1beta3.PriorityLevelConfigurationClusterLister { + return kcpv1beta3.NewPriorityLevelConfigurationClusterLister(i.Informer().GetIndexer()) } -func (f *priorityLevelConfigurationClusterInformer) Lister() flowcontrolv1beta3listers.PriorityLevelConfigurationClusterLister { - return flowcontrolv1beta3listers.NewPriorityLevelConfigurationClusterLister(f.Informer().GetIndexer()) +func (i *priorityLevelConfigurationClusterInformer) Cluster(clusterName logicalcluster.Name) flowcontrolv1beta3.PriorityLevelConfigurationInformer { + return &priorityLevelConfigurationInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *priorityLevelConfigurationClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamflowcontrolv1beta3informers.PriorityLevelConfigurationInformer { +func (i *priorityLevelConfigurationClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) flowcontrolv1beta3.PriorityLevelConfigurationInformer { return &priorityLevelConfigurationInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type priorityLevelConfigurationInformer struct { informer cache.SharedIndexInformer - lister upstreamflowcontrolv1beta3listers.PriorityLevelConfigurationLister + lister listersflowcontrolv1beta3.PriorityLevelConfigurationLister } -func (f *priorityLevelConfigurationInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *priorityLevelConfigurationInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *priorityLevelConfigurationInformer) Lister() upstreamflowcontrolv1beta3listers.PriorityLevelConfigurationLister { - return f.lister +func (i *priorityLevelConfigurationInformer) Lister() listersflowcontrolv1beta3.PriorityLevelConfigurationLister { + return i.lister } diff --git a/informers/generic.go b/informers/generic.go index 3652a1b75..0cf9b88db 100644 --- a/informers/generic.go +++ b/informers/generic.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,34 +14,35 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package informers import ( - "fmt" + context "context" + fmt "fmt" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - admissionregistrationv1 "k8s.io/api/admissionregistration/v1" - admissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1" - admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" - internalv1alpha1 "k8s.io/api/apiserverinternal/v1alpha1" + v1 "k8s.io/api/admissionregistration/v1" + v1alpha1 "k8s.io/api/admissionregistration/v1alpha1" + v1beta1 "k8s.io/api/admissionregistration/v1beta1" + apiserverinternalv1alpha1 "k8s.io/api/apiserverinternal/v1alpha1" appsv1 "k8s.io/api/apps/v1" appsv1beta1 "k8s.io/api/apps/v1beta1" - appsv1beta2 "k8s.io/api/apps/v1beta2" + v1beta2 "k8s.io/api/apps/v1beta2" autoscalingv1 "k8s.io/api/autoscaling/v1" - autoscalingv2 "k8s.io/api/autoscaling/v2" - autoscalingv2beta1 "k8s.io/api/autoscaling/v2beta1" - autoscalingv2beta2 "k8s.io/api/autoscaling/v2beta2" + v2 "k8s.io/api/autoscaling/v2" + v2beta1 "k8s.io/api/autoscaling/v2beta1" + v2beta2 "k8s.io/api/autoscaling/v2beta2" batchv1 "k8s.io/api/batch/v1" batchv1beta1 "k8s.io/api/batch/v1beta1" certificatesv1 "k8s.io/api/certificates/v1" certificatesv1alpha1 "k8s.io/api/certificates/v1alpha1" certificatesv1beta1 "k8s.io/api/certificates/v1beta1" coordinationv1 "k8s.io/api/coordination/v1" - coordinationv1alpha2 "k8s.io/api/coordination/v1alpha2" + v1alpha2 "k8s.io/api/coordination/v1alpha2" coordinationv1beta1 "k8s.io/api/coordination/v1beta1" corev1 "k8s.io/api/core/v1" discoveryv1 "k8s.io/api/discovery/v1" @@ -52,7 +53,7 @@ import ( flowcontrolv1 "k8s.io/api/flowcontrol/v1" flowcontrolv1beta1 "k8s.io/api/flowcontrol/v1beta1" flowcontrolv1beta2 "k8s.io/api/flowcontrol/v1beta2" - flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3" + v1beta3 "k8s.io/api/flowcontrol/v1beta3" networkingv1 "k8s.io/api/networking/v1" networkingv1alpha1 "k8s.io/api/networking/v1alpha1" networkingv1beta1 "k8s.io/api/networking/v1beta1" @@ -64,7 +65,7 @@ import ( rbacv1 "k8s.io/api/rbac/v1" rbacv1alpha1 "k8s.io/api/rbac/v1alpha1" rbacv1beta1 "k8s.io/api/rbac/v1beta1" - resourcev1alpha3 "k8s.io/api/resource/v1alpha3" + v1alpha3 "k8s.io/api/resource/v1alpha3" resourcev1beta1 "k8s.io/api/resource/v1beta1" schedulingv1 "k8s.io/api/scheduling/v1" schedulingv1alpha1 "k8s.io/api/scheduling/v1alpha1" @@ -73,13 +74,14 @@ import ( storagev1alpha1 "k8s.io/api/storage/v1alpha1" storagev1beta1 "k8s.io/api/storage/v1beta1" storagemigrationv1alpha1 "k8s.io/api/storagemigration/v1alpha1" - "k8s.io/apimachinery/pkg/runtime/schema" - upstreaminformers "k8s.io/client-go/informers" - "k8s.io/client-go/tools/cache" + schema "k8s.io/apimachinery/pkg/runtime/schema" + clientgoinformers "k8s.io/client-go/informers" + cache "k8s.io/client-go/tools/cache" ) type GenericClusterInformer interface { - Cluster(logicalcluster.Name) upstreaminformers.GenericInformer + Cluster(logicalcluster.Name) clientgoinformers.GenericInformer + ClusterWithContext(context.Context, logicalcluster.Name) clientgoinformers.GenericInformer Informer() kcpcache.ScopeableSharedIndexInformer Lister() kcpcache.GenericClusterLister } @@ -90,20 +92,29 @@ type genericClusterInformer struct { } // Informer returns the SharedIndexInformer. -func (f *genericClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.informer +func (i *genericClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.informer } -// Lister returns the GenericClusterLister. -func (f *genericClusterInformer) Lister() kcpcache.GenericClusterLister { - return kcpcache.NewGenericClusterLister(f.Informer().GetIndexer(), f.resource) +// Lister returns the GenericLister. +func (i *genericClusterInformer) Lister() kcpcache.GenericClusterLister { + return kcpcache.NewGenericClusterLister(i.Informer().GetIndexer(), i.resource) } // Cluster scopes to a GenericInformer. -func (f *genericClusterInformer) Cluster(clusterName logicalcluster.Name) upstreaminformers.GenericInformer { +func (i *genericClusterInformer) Cluster(clusterName logicalcluster.Name) clientgoinformers.GenericInformer { return &genericInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().ByCluster(clusterName), + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().ByCluster(clusterName), + } +} + +// ClusterWithContext scopes to a GenericInformer and unregisters all +// handles registered through it once the provided context is canceled. +func (i *genericClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) clientgoinformers.GenericInformer { + return &genericInformer{ + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().ByCluster(clusterName), } } @@ -113,114 +124,146 @@ type genericInformer struct { } // Informer returns the SharedIndexInformer. -func (f *genericInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *genericInformer) Informer() cache.SharedIndexInformer { + return i.informer } // Lister returns the GenericLister. -func (f *genericInformer) Lister() cache.GenericLister { - return f.lister +func (i *genericInformer) Lister() cache.GenericLister { + return i.lister } // ForResource gives generic access to a shared informer of the matching type // TODO extend this to unknown resources with a client pool func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericClusterInformer, error) { switch resource { - // Group=admissionregistration.k8s.io, Version=V1 - case admissionregistrationv1.SchemeGroupVersion.WithResource("validatingadmissionpolicies"): + // Group=admissionregistration.k8s.io, Version=v1 + case v1.SchemeGroupVersion.WithResource("mutatingwebhookconfigurations"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Admissionregistration().V1().MutatingWebhookConfigurations().Informer()}, nil + case v1.SchemeGroupVersion.WithResource("validatingadmissionpolicies"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Admissionregistration().V1().ValidatingAdmissionPolicies().Informer()}, nil - case admissionregistrationv1.SchemeGroupVersion.WithResource("validatingadmissionpolicybindings"): + case v1.SchemeGroupVersion.WithResource("validatingadmissionpolicybindings"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Admissionregistration().V1().ValidatingAdmissionPolicyBindings().Informer()}, nil - case admissionregistrationv1.SchemeGroupVersion.WithResource("validatingwebhookconfigurations"): + case v1.SchemeGroupVersion.WithResource("validatingwebhookconfigurations"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Admissionregistration().V1().ValidatingWebhookConfigurations().Informer()}, nil - case admissionregistrationv1.SchemeGroupVersion.WithResource("mutatingwebhookconfigurations"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Admissionregistration().V1().MutatingWebhookConfigurations().Informer()}, nil - // Group=admissionregistration.k8s.io, Version=V1alpha1 - case admissionregistrationv1alpha1.SchemeGroupVersion.WithResource("validatingadmissionpolicies"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Admissionregistration().V1alpha1().ValidatingAdmissionPolicies().Informer()}, nil - case admissionregistrationv1alpha1.SchemeGroupVersion.WithResource("validatingadmissionpolicybindings"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Admissionregistration().V1alpha1().ValidatingAdmissionPolicyBindings().Informer()}, nil - case admissionregistrationv1alpha1.SchemeGroupVersion.WithResource("mutatingadmissionpolicies"): + + // Group=admissionregistration.k8s.io, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithResource("mutatingadmissionpolicies"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Admissionregistration().V1alpha1().MutatingAdmissionPolicies().Informer()}, nil - case admissionregistrationv1alpha1.SchemeGroupVersion.WithResource("mutatingadmissionpolicybindings"): + case v1alpha1.SchemeGroupVersion.WithResource("mutatingadmissionpolicybindings"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Admissionregistration().V1alpha1().MutatingAdmissionPolicyBindings().Informer()}, nil - // Group=admissionregistration.k8s.io, Version=V1beta1 - case admissionregistrationv1beta1.SchemeGroupVersion.WithResource("validatingadmissionpolicies"): + case v1alpha1.SchemeGroupVersion.WithResource("validatingadmissionpolicies"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Admissionregistration().V1alpha1().ValidatingAdmissionPolicies().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("validatingadmissionpolicybindings"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Admissionregistration().V1alpha1().ValidatingAdmissionPolicyBindings().Informer()}, nil + + // Group=admissionregistration.k8s.io, Version=v1beta1 + case v1beta1.SchemeGroupVersion.WithResource("mutatingwebhookconfigurations"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Admissionregistration().V1beta1().MutatingWebhookConfigurations().Informer()}, nil + case v1beta1.SchemeGroupVersion.WithResource("validatingadmissionpolicies"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Admissionregistration().V1beta1().ValidatingAdmissionPolicies().Informer()}, nil - case admissionregistrationv1beta1.SchemeGroupVersion.WithResource("validatingadmissionpolicybindings"): + case v1beta1.SchemeGroupVersion.WithResource("validatingadmissionpolicybindings"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Admissionregistration().V1beta1().ValidatingAdmissionPolicyBindings().Informer()}, nil - case admissionregistrationv1beta1.SchemeGroupVersion.WithResource("validatingwebhookconfigurations"): + case v1beta1.SchemeGroupVersion.WithResource("validatingwebhookconfigurations"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Admissionregistration().V1beta1().ValidatingWebhookConfigurations().Informer()}, nil - case admissionregistrationv1beta1.SchemeGroupVersion.WithResource("mutatingwebhookconfigurations"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Admissionregistration().V1beta1().MutatingWebhookConfigurations().Informer()}, nil - // Group=apps, Version=V1 - case appsv1.SchemeGroupVersion.WithResource("statefulsets"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Apps().V1().StatefulSets().Informer()}, nil - case appsv1.SchemeGroupVersion.WithResource("deployments"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Apps().V1().Deployments().Informer()}, nil + + // Group=apps, Version=v1 + case appsv1.SchemeGroupVersion.WithResource("controllerrevisions"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Apps().V1().ControllerRevisions().Informer()}, nil case appsv1.SchemeGroupVersion.WithResource("daemonsets"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Apps().V1().DaemonSets().Informer()}, nil + case appsv1.SchemeGroupVersion.WithResource("deployments"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Apps().V1().Deployments().Informer()}, nil case appsv1.SchemeGroupVersion.WithResource("replicasets"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Apps().V1().ReplicaSets().Informer()}, nil - case appsv1.SchemeGroupVersion.WithResource("controllerrevisions"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Apps().V1().ControllerRevisions().Informer()}, nil - // Group=apps, Version=V1beta1 - case appsv1beta1.SchemeGroupVersion.WithResource("statefulsets"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Apps().V1beta1().StatefulSets().Informer()}, nil - case appsv1beta1.SchemeGroupVersion.WithResource("deployments"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Apps().V1beta1().Deployments().Informer()}, nil + case appsv1.SchemeGroupVersion.WithResource("statefulsets"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Apps().V1().StatefulSets().Informer()}, nil + + // Group=apps, Version=v1beta1 case appsv1beta1.SchemeGroupVersion.WithResource("controllerrevisions"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Apps().V1beta1().ControllerRevisions().Informer()}, nil - // Group=apps, Version=V1beta2 - case appsv1beta2.SchemeGroupVersion.WithResource("statefulsets"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Apps().V1beta2().StatefulSets().Informer()}, nil - case appsv1beta2.SchemeGroupVersion.WithResource("deployments"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Apps().V1beta2().Deployments().Informer()}, nil - case appsv1beta2.SchemeGroupVersion.WithResource("daemonsets"): + case appsv1beta1.SchemeGroupVersion.WithResource("deployments"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Apps().V1beta1().Deployments().Informer()}, nil + case appsv1beta1.SchemeGroupVersion.WithResource("statefulsets"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Apps().V1beta1().StatefulSets().Informer()}, nil + + // Group=apps, Version=v1beta2 + case v1beta2.SchemeGroupVersion.WithResource("controllerrevisions"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Apps().V1beta2().ControllerRevisions().Informer()}, nil + case v1beta2.SchemeGroupVersion.WithResource("daemonsets"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Apps().V1beta2().DaemonSets().Informer()}, nil - case appsv1beta2.SchemeGroupVersion.WithResource("replicasets"): + case v1beta2.SchemeGroupVersion.WithResource("deployments"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Apps().V1beta2().Deployments().Informer()}, nil + case v1beta2.SchemeGroupVersion.WithResource("replicasets"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Apps().V1beta2().ReplicaSets().Informer()}, nil - case appsv1beta2.SchemeGroupVersion.WithResource("controllerrevisions"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Apps().V1beta2().ControllerRevisions().Informer()}, nil - // Group=autoscaling, Version=V1 + case v1beta2.SchemeGroupVersion.WithResource("statefulsets"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Apps().V1beta2().StatefulSets().Informer()}, nil + + // Group=autoscaling, Version=v1 case autoscalingv1.SchemeGroupVersion.WithResource("horizontalpodautoscalers"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Autoscaling().V1().HorizontalPodAutoscalers().Informer()}, nil - // Group=autoscaling, Version=V2 - case autoscalingv2.SchemeGroupVersion.WithResource("horizontalpodautoscalers"): + + // Group=autoscaling, Version=v2 + case v2.SchemeGroupVersion.WithResource("horizontalpodautoscalers"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Autoscaling().V2().HorizontalPodAutoscalers().Informer()}, nil - // Group=autoscaling, Version=V2beta1 - case autoscalingv2beta1.SchemeGroupVersion.WithResource("horizontalpodautoscalers"): + + // Group=autoscaling, Version=v2beta1 + case v2beta1.SchemeGroupVersion.WithResource("horizontalpodautoscalers"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Autoscaling().V2beta1().HorizontalPodAutoscalers().Informer()}, nil - // Group=autoscaling, Version=V2beta2 - case autoscalingv2beta2.SchemeGroupVersion.WithResource("horizontalpodautoscalers"): + + // Group=autoscaling, Version=v2beta2 + case v2beta2.SchemeGroupVersion.WithResource("horizontalpodautoscalers"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Autoscaling().V2beta2().HorizontalPodAutoscalers().Informer()}, nil - // Group=batch, Version=V1 - case batchv1.SchemeGroupVersion.WithResource("jobs"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Batch().V1().Jobs().Informer()}, nil + + // Group=batch, Version=v1 case batchv1.SchemeGroupVersion.WithResource("cronjobs"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Batch().V1().CronJobs().Informer()}, nil - // Group=batch, Version=V1beta1 + case batchv1.SchemeGroupVersion.WithResource("jobs"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Batch().V1().Jobs().Informer()}, nil + + // Group=batch, Version=v1beta1 case batchv1beta1.SchemeGroupVersion.WithResource("cronjobs"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Batch().V1beta1().CronJobs().Informer()}, nil - // Group=certificates.k8s.io, Version=V1 + + // Group=certificates.k8s.io, Version=v1 case certificatesv1.SchemeGroupVersion.WithResource("certificatesigningrequests"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Certificates().V1().CertificateSigningRequests().Informer()}, nil - // Group=certificates.k8s.io, Version=V1alpha1 + + // Group=certificates.k8s.io, Version=v1alpha1 case certificatesv1alpha1.SchemeGroupVersion.WithResource("clustertrustbundles"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Certificates().V1alpha1().ClusterTrustBundles().Informer()}, nil - // Group=certificates.k8s.io, Version=V1beta1 + + // Group=certificates.k8s.io, Version=v1beta1 case certificatesv1beta1.SchemeGroupVersion.WithResource("certificatesigningrequests"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Certificates().V1beta1().CertificateSigningRequests().Informer()}, nil - // Group=coordination.k8s.io, Version=V1 + + // Group=coordination.k8s.io, Version=v1 case coordinationv1.SchemeGroupVersion.WithResource("leases"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Coordination().V1().Leases().Informer()}, nil - // Group=coordination.k8s.io, Version=V1alpha2 - case coordinationv1alpha2.SchemeGroupVersion.WithResource("leasecandidates"): + + // Group=coordination.k8s.io, Version=v1alpha2 + case v1alpha2.SchemeGroupVersion.WithResource("leasecandidates"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Coordination().V1alpha2().LeaseCandidates().Informer()}, nil - // Group=coordination.k8s.io, Version=V1beta1 + + // Group=coordination.k8s.io, Version=v1beta1 case coordinationv1beta1.SchemeGroupVersion.WithResource("leases"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Coordination().V1beta1().Leases().Informer()}, nil - // Group=core, Version=V1 + + // Group=core, Version=v1 + case corev1.SchemeGroupVersion.WithResource("componentstatuses"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Core().V1().ComponentStatuses().Informer()}, nil + case corev1.SchemeGroupVersion.WithResource("configmaps"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Core().V1().ConfigMaps().Informer()}, nil + case corev1.SchemeGroupVersion.WithResource("endpoints"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Core().V1().Endpoints().Informer()}, nil + case corev1.SchemeGroupVersion.WithResource("events"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Core().V1().Events().Informer()}, nil + case corev1.SchemeGroupVersion.WithResource("limitranges"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Core().V1().LimitRanges().Informer()}, nil + case corev1.SchemeGroupVersion.WithResource("namespaces"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Core().V1().Namespaces().Informer()}, nil + case corev1.SchemeGroupVersion.WithResource("nodes"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Core().V1().Nodes().Informer()}, nil case corev1.SchemeGroupVersion.WithResource("persistentvolumes"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Core().V1().PersistentVolumes().Informer()}, nil case corev1.SchemeGroupVersion.WithResource("persistentvolumeclaims"): @@ -231,198 +274,215 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Core().V1().PodTemplates().Informer()}, nil case corev1.SchemeGroupVersion.WithResource("replicationcontrollers"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Core().V1().ReplicationControllers().Informer()}, nil - case corev1.SchemeGroupVersion.WithResource("services"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Core().V1().Services().Informer()}, nil - case corev1.SchemeGroupVersion.WithResource("serviceaccounts"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Core().V1().ServiceAccounts().Informer()}, nil - case corev1.SchemeGroupVersion.WithResource("endpoints"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Core().V1().Endpoints().Informer()}, nil - case corev1.SchemeGroupVersion.WithResource("nodes"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Core().V1().Nodes().Informer()}, nil - case corev1.SchemeGroupVersion.WithResource("namespaces"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Core().V1().Namespaces().Informer()}, nil - case corev1.SchemeGroupVersion.WithResource("events"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Core().V1().Events().Informer()}, nil - case corev1.SchemeGroupVersion.WithResource("limitranges"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Core().V1().LimitRanges().Informer()}, nil case corev1.SchemeGroupVersion.WithResource("resourcequotas"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Core().V1().ResourceQuotas().Informer()}, nil case corev1.SchemeGroupVersion.WithResource("secrets"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Core().V1().Secrets().Informer()}, nil - case corev1.SchemeGroupVersion.WithResource("configmaps"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Core().V1().ConfigMaps().Informer()}, nil - case corev1.SchemeGroupVersion.WithResource("componentstatuses"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Core().V1().ComponentStatuses().Informer()}, nil - // Group=discovery.k8s.io, Version=V1 + case corev1.SchemeGroupVersion.WithResource("services"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Core().V1().Services().Informer()}, nil + case corev1.SchemeGroupVersion.WithResource("serviceaccounts"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Core().V1().ServiceAccounts().Informer()}, nil + + // Group=discovery.k8s.io, Version=v1 case discoveryv1.SchemeGroupVersion.WithResource("endpointslices"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Discovery().V1().EndpointSlices().Informer()}, nil - // Group=discovery.k8s.io, Version=V1beta1 + + // Group=discovery.k8s.io, Version=v1beta1 case discoveryv1beta1.SchemeGroupVersion.WithResource("endpointslices"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Discovery().V1beta1().EndpointSlices().Informer()}, nil - // Group=events.k8s.io, Version=V1 + + // Group=events.k8s.io, Version=v1 case eventsv1.SchemeGroupVersion.WithResource("events"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Events().V1().Events().Informer()}, nil - // Group=events.k8s.io, Version=V1beta1 + + // Group=events.k8s.io, Version=v1beta1 case eventsv1beta1.SchemeGroupVersion.WithResource("events"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Events().V1beta1().Events().Informer()}, nil - // Group=extensions, Version=V1beta1 - case extensionsv1beta1.SchemeGroupVersion.WithResource("deployments"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Extensions().V1beta1().Deployments().Informer()}, nil + + // Group=extensions, Version=v1beta1 case extensionsv1beta1.SchemeGroupVersion.WithResource("daemonsets"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Extensions().V1beta1().DaemonSets().Informer()}, nil + case extensionsv1beta1.SchemeGroupVersion.WithResource("deployments"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Extensions().V1beta1().Deployments().Informer()}, nil case extensionsv1beta1.SchemeGroupVersion.WithResource("ingresses"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Extensions().V1beta1().Ingresses().Informer()}, nil - case extensionsv1beta1.SchemeGroupVersion.WithResource("replicasets"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Extensions().V1beta1().ReplicaSets().Informer()}, nil case extensionsv1beta1.SchemeGroupVersion.WithResource("networkpolicies"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Extensions().V1beta1().NetworkPolicies().Informer()}, nil - // Group=flowcontrol.apiserver.k8s.io, Version=V1 + case extensionsv1beta1.SchemeGroupVersion.WithResource("replicasets"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Extensions().V1beta1().ReplicaSets().Informer()}, nil + + // Group=flowcontrol.apiserver.k8s.io, Version=v1 case flowcontrolv1.SchemeGroupVersion.WithResource("flowschemas"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Flowcontrol().V1().FlowSchemas().Informer()}, nil case flowcontrolv1.SchemeGroupVersion.WithResource("prioritylevelconfigurations"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Flowcontrol().V1().PriorityLevelConfigurations().Informer()}, nil - // Group=flowcontrol.apiserver.k8s.io, Version=V1beta1 + + // Group=flowcontrol.apiserver.k8s.io, Version=v1beta1 case flowcontrolv1beta1.SchemeGroupVersion.WithResource("flowschemas"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Flowcontrol().V1beta1().FlowSchemas().Informer()}, nil case flowcontrolv1beta1.SchemeGroupVersion.WithResource("prioritylevelconfigurations"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Flowcontrol().V1beta1().PriorityLevelConfigurations().Informer()}, nil - // Group=flowcontrol.apiserver.k8s.io, Version=V1beta2 + + // Group=flowcontrol.apiserver.k8s.io, Version=v1beta2 case flowcontrolv1beta2.SchemeGroupVersion.WithResource("flowschemas"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Flowcontrol().V1beta2().FlowSchemas().Informer()}, nil case flowcontrolv1beta2.SchemeGroupVersion.WithResource("prioritylevelconfigurations"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Flowcontrol().V1beta2().PriorityLevelConfigurations().Informer()}, nil - // Group=flowcontrol.apiserver.k8s.io, Version=V1beta3 - case flowcontrolv1beta3.SchemeGroupVersion.WithResource("flowschemas"): + + // Group=flowcontrol.apiserver.k8s.io, Version=v1beta3 + case v1beta3.SchemeGroupVersion.WithResource("flowschemas"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Flowcontrol().V1beta3().FlowSchemas().Informer()}, nil - case flowcontrolv1beta3.SchemeGroupVersion.WithResource("prioritylevelconfigurations"): + case v1beta3.SchemeGroupVersion.WithResource("prioritylevelconfigurations"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Flowcontrol().V1beta3().PriorityLevelConfigurations().Informer()}, nil - // Group=internal.apiserver.k8s.io, Version=V1alpha1 - case internalv1alpha1.SchemeGroupVersion.WithResource("storageversions"): + + // Group=internal.apiserver.k8s.io, Version=v1alpha1 + case apiserverinternalv1alpha1.SchemeGroupVersion.WithResource("storageversions"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Internal().V1alpha1().StorageVersions().Informer()}, nil - // Group=networking.k8s.io, Version=V1 - case networkingv1.SchemeGroupVersion.WithResource("networkpolicies"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Networking().V1().NetworkPolicies().Informer()}, nil + + // Group=networking.k8s.io, Version=v1 case networkingv1.SchemeGroupVersion.WithResource("ingresses"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Networking().V1().Ingresses().Informer()}, nil case networkingv1.SchemeGroupVersion.WithResource("ingressclasses"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Networking().V1().IngressClasses().Informer()}, nil - // Group=networking.k8s.io, Version=V1alpha1 + case networkingv1.SchemeGroupVersion.WithResource("networkpolicies"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Networking().V1().NetworkPolicies().Informer()}, nil + + // Group=networking.k8s.io, Version=v1alpha1 case networkingv1alpha1.SchemeGroupVersion.WithResource("ipaddresses"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Networking().V1alpha1().IPAddresses().Informer()}, nil case networkingv1alpha1.SchemeGroupVersion.WithResource("servicecidrs"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Networking().V1alpha1().ServiceCIDRs().Informer()}, nil - // Group=networking.k8s.io, Version=V1beta1 + + // Group=networking.k8s.io, Version=v1beta1 + case networkingv1beta1.SchemeGroupVersion.WithResource("ipaddresses"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Networking().V1beta1().IPAddresses().Informer()}, nil case networkingv1beta1.SchemeGroupVersion.WithResource("ingresses"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Networking().V1beta1().Ingresses().Informer()}, nil case networkingv1beta1.SchemeGroupVersion.WithResource("ingressclasses"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Networking().V1beta1().IngressClasses().Informer()}, nil - case networkingv1beta1.SchemeGroupVersion.WithResource("ipaddresses"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Networking().V1beta1().IPAddresses().Informer()}, nil case networkingv1beta1.SchemeGroupVersion.WithResource("servicecidrs"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Networking().V1beta1().ServiceCIDRs().Informer()}, nil - // Group=node.k8s.io, Version=V1 + + // Group=node.k8s.io, Version=v1 case nodev1.SchemeGroupVersion.WithResource("runtimeclasses"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Node().V1().RuntimeClasses().Informer()}, nil - // Group=node.k8s.io, Version=V1alpha1 + + // Group=node.k8s.io, Version=v1alpha1 case nodev1alpha1.SchemeGroupVersion.WithResource("runtimeclasses"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Node().V1alpha1().RuntimeClasses().Informer()}, nil - // Group=node.k8s.io, Version=V1beta1 + + // Group=node.k8s.io, Version=v1beta1 case nodev1beta1.SchemeGroupVersion.WithResource("runtimeclasses"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Node().V1beta1().RuntimeClasses().Informer()}, nil - // Group=policy, Version=V1 + + // Group=policy, Version=v1 case policyv1.SchemeGroupVersion.WithResource("poddisruptionbudgets"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Policy().V1().PodDisruptionBudgets().Informer()}, nil - // Group=policy, Version=V1beta1 + + // Group=policy, Version=v1beta1 case policyv1beta1.SchemeGroupVersion.WithResource("poddisruptionbudgets"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Policy().V1beta1().PodDisruptionBudgets().Informer()}, nil - // Group=rbac.authorization.k8s.io, Version=V1 - case rbacv1.SchemeGroupVersion.WithResource("roles"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Rbac().V1().Roles().Informer()}, nil - case rbacv1.SchemeGroupVersion.WithResource("rolebindings"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Rbac().V1().RoleBindings().Informer()}, nil + + // Group=rbac.authorization.k8s.io, Version=v1 case rbacv1.SchemeGroupVersion.WithResource("clusterroles"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Rbac().V1().ClusterRoles().Informer()}, nil case rbacv1.SchemeGroupVersion.WithResource("clusterrolebindings"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Rbac().V1().ClusterRoleBindings().Informer()}, nil - // Group=rbac.authorization.k8s.io, Version=V1alpha1 - case rbacv1alpha1.SchemeGroupVersion.WithResource("roles"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Rbac().V1alpha1().Roles().Informer()}, nil - case rbacv1alpha1.SchemeGroupVersion.WithResource("rolebindings"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Rbac().V1alpha1().RoleBindings().Informer()}, nil + case rbacv1.SchemeGroupVersion.WithResource("roles"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Rbac().V1().Roles().Informer()}, nil + case rbacv1.SchemeGroupVersion.WithResource("rolebindings"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Rbac().V1().RoleBindings().Informer()}, nil + + // Group=rbac.authorization.k8s.io, Version=v1alpha1 case rbacv1alpha1.SchemeGroupVersion.WithResource("clusterroles"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Rbac().V1alpha1().ClusterRoles().Informer()}, nil case rbacv1alpha1.SchemeGroupVersion.WithResource("clusterrolebindings"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Rbac().V1alpha1().ClusterRoleBindings().Informer()}, nil - // Group=rbac.authorization.k8s.io, Version=V1beta1 - case rbacv1beta1.SchemeGroupVersion.WithResource("roles"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Rbac().V1beta1().Roles().Informer()}, nil - case rbacv1beta1.SchemeGroupVersion.WithResource("rolebindings"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Rbac().V1beta1().RoleBindings().Informer()}, nil + case rbacv1alpha1.SchemeGroupVersion.WithResource("roles"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Rbac().V1alpha1().Roles().Informer()}, nil + case rbacv1alpha1.SchemeGroupVersion.WithResource("rolebindings"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Rbac().V1alpha1().RoleBindings().Informer()}, nil + + // Group=rbac.authorization.k8s.io, Version=v1beta1 case rbacv1beta1.SchemeGroupVersion.WithResource("clusterroles"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Rbac().V1beta1().ClusterRoles().Informer()}, nil case rbacv1beta1.SchemeGroupVersion.WithResource("clusterrolebindings"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Rbac().V1beta1().ClusterRoleBindings().Informer()}, nil - // Group=resource.k8s.io, Version=V1alpha3 - case resourcev1alpha3.SchemeGroupVersion.WithResource("resourceslices"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Resource().V1alpha3().ResourceSlices().Informer()}, nil - case resourcev1alpha3.SchemeGroupVersion.WithResource("resourceclaims"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Resource().V1alpha3().ResourceClaims().Informer()}, nil - case resourcev1alpha3.SchemeGroupVersion.WithResource("deviceclasses"): + case rbacv1beta1.SchemeGroupVersion.WithResource("roles"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Rbac().V1beta1().Roles().Informer()}, nil + case rbacv1beta1.SchemeGroupVersion.WithResource("rolebindings"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Rbac().V1beta1().RoleBindings().Informer()}, nil + + // Group=resource.k8s.io, Version=v1alpha3 + case v1alpha3.SchemeGroupVersion.WithResource("deviceclasses"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Resource().V1alpha3().DeviceClasses().Informer()}, nil - case resourcev1alpha3.SchemeGroupVersion.WithResource("resourceclaimtemplates"): + case v1alpha3.SchemeGroupVersion.WithResource("resourceclaims"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Resource().V1alpha3().ResourceClaims().Informer()}, nil + case v1alpha3.SchemeGroupVersion.WithResource("resourceclaimtemplates"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Resource().V1alpha3().ResourceClaimTemplates().Informer()}, nil - // Group=resource.k8s.io, Version=V1beta1 - case resourcev1beta1.SchemeGroupVersion.WithResource("resourceslices"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Resource().V1beta1().ResourceSlices().Informer()}, nil - case resourcev1beta1.SchemeGroupVersion.WithResource("resourceclaims"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Resource().V1beta1().ResourceClaims().Informer()}, nil + case v1alpha3.SchemeGroupVersion.WithResource("resourceslices"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Resource().V1alpha3().ResourceSlices().Informer()}, nil + + // Group=resource.k8s.io, Version=v1beta1 case resourcev1beta1.SchemeGroupVersion.WithResource("deviceclasses"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Resource().V1beta1().DeviceClasses().Informer()}, nil + case resourcev1beta1.SchemeGroupVersion.WithResource("resourceclaims"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Resource().V1beta1().ResourceClaims().Informer()}, nil case resourcev1beta1.SchemeGroupVersion.WithResource("resourceclaimtemplates"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Resource().V1beta1().ResourceClaimTemplates().Informer()}, nil - // Group=scheduling.k8s.io, Version=V1 + case resourcev1beta1.SchemeGroupVersion.WithResource("resourceslices"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Resource().V1beta1().ResourceSlices().Informer()}, nil + + // Group=scheduling.k8s.io, Version=v1 case schedulingv1.SchemeGroupVersion.WithResource("priorityclasses"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Scheduling().V1().PriorityClasses().Informer()}, nil - // Group=scheduling.k8s.io, Version=V1alpha1 + + // Group=scheduling.k8s.io, Version=v1alpha1 case schedulingv1alpha1.SchemeGroupVersion.WithResource("priorityclasses"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Scheduling().V1alpha1().PriorityClasses().Informer()}, nil - // Group=scheduling.k8s.io, Version=V1beta1 + + // Group=scheduling.k8s.io, Version=v1beta1 case schedulingv1beta1.SchemeGroupVersion.WithResource("priorityclasses"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Scheduling().V1beta1().PriorityClasses().Informer()}, nil - // Group=storagemigration.k8s.io, Version=V1alpha1 - case storagemigrationv1alpha1.SchemeGroupVersion.WithResource("storageversionmigrations"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Storagemigration().V1alpha1().StorageVersionMigrations().Informer()}, nil - // Group=storage.k8s.io, Version=V1 - case storagev1.SchemeGroupVersion.WithResource("storageclasses"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Storage().V1().StorageClasses().Informer()}, nil - case storagev1.SchemeGroupVersion.WithResource("volumeattachments"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Storage().V1().VolumeAttachments().Informer()}, nil + + // Group=storage.k8s.io, Version=v1 case storagev1.SchemeGroupVersion.WithResource("csidrivers"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Storage().V1().CSIDrivers().Informer()}, nil case storagev1.SchemeGroupVersion.WithResource("csinodes"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Storage().V1().CSINodes().Informer()}, nil case storagev1.SchemeGroupVersion.WithResource("csistoragecapacities"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Storage().V1().CSIStorageCapacities().Informer()}, nil - // Group=storage.k8s.io, Version=V1alpha1 - case storagev1alpha1.SchemeGroupVersion.WithResource("volumeattachments"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Storage().V1alpha1().VolumeAttachments().Informer()}, nil + case storagev1.SchemeGroupVersion.WithResource("storageclasses"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Storage().V1().StorageClasses().Informer()}, nil + case storagev1.SchemeGroupVersion.WithResource("volumeattachments"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Storage().V1().VolumeAttachments().Informer()}, nil + + // Group=storage.k8s.io, Version=v1alpha1 case storagev1alpha1.SchemeGroupVersion.WithResource("csistoragecapacities"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Storage().V1alpha1().CSIStorageCapacities().Informer()}, nil + case storagev1alpha1.SchemeGroupVersion.WithResource("volumeattachments"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Storage().V1alpha1().VolumeAttachments().Informer()}, nil case storagev1alpha1.SchemeGroupVersion.WithResource("volumeattributesclasses"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Storage().V1alpha1().VolumeAttributesClasses().Informer()}, nil - // Group=storage.k8s.io, Version=V1beta1 - case storagev1beta1.SchemeGroupVersion.WithResource("storageclasses"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Storage().V1beta1().StorageClasses().Informer()}, nil - case storagev1beta1.SchemeGroupVersion.WithResource("volumeattachments"): - return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Storage().V1beta1().VolumeAttachments().Informer()}, nil + + // Group=storage.k8s.io, Version=v1beta1 case storagev1beta1.SchemeGroupVersion.WithResource("csidrivers"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Storage().V1beta1().CSIDrivers().Informer()}, nil case storagev1beta1.SchemeGroupVersion.WithResource("csinodes"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Storage().V1beta1().CSINodes().Informer()}, nil case storagev1beta1.SchemeGroupVersion.WithResource("csistoragecapacities"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Storage().V1beta1().CSIStorageCapacities().Informer()}, nil + case storagev1beta1.SchemeGroupVersion.WithResource("storageclasses"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Storage().V1beta1().StorageClasses().Informer()}, nil + case storagev1beta1.SchemeGroupVersion.WithResource("volumeattachments"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Storage().V1beta1().VolumeAttachments().Informer()}, nil case storagev1beta1.SchemeGroupVersion.WithResource("volumeattributesclasses"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Storage().V1beta1().VolumeAttributesClasses().Informer()}, nil + + // Group=storagemigration.k8s.io, Version=v1alpha1 + case storagemigrationv1alpha1.SchemeGroupVersion.WithResource("storageversionmigrations"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.Storagemigration().V1alpha1().StorageVersionMigrations().Informer()}, nil + } return nil, fmt.Errorf("no informer found for %v", resource) diff --git a/informers/internalinterfaces/factory_interfaces.go b/informers/internalinterfaces/factory_interfaces.go index 6a719802a..7f65aeba7 100644 --- a/informers/internalinterfaces/factory_interfaces.go +++ b/informers/internalinterfaces/factory_interfaces.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package internalinterfaces @@ -23,20 +23,20 @@ import ( kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" - clientset "github.com/kcp-dev/client-go/kubernetes" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" ) -// NewInformerFunc takes clientset.ClusterInterface and time.Duration to return a ScopeableSharedIndexInformer. -type NewInformerFunc func(clientset.ClusterInterface, time.Duration) kcpcache.ScopeableSharedIndexInformer +// TweakListOptionsFunc is a function that transforms a v1.ListOptions. +type TweakListOptionsFunc func(*v1.ListOptions) -// SharedInformerFactory a small interface to allow for adding an informer without an import cycle +// NewInformerFunc takes kcpkubernetes.ClusterInterface and time.Duration to return a kcpcache.ScopeableSharedIndexInformer. +type NewInformerFunc func(kcpkubernetes.ClusterInterface, time.Duration) kcpcache.ScopeableSharedIndexInformer + +// SharedInformerFactory a small interface to allow for adding an informer without an import cycle. type SharedInformerFactory interface { Start(stopCh <-chan struct{}) InformerFor(obj runtime.Object, newFunc NewInformerFunc) kcpcache.ScopeableSharedIndexInformer } - -// TweakListOptionsFunc is a function that transforms a metav1.ListOptions. -type TweakListOptionsFunc func(*metav1.ListOptions) diff --git a/informers/networking/interface.go b/informers/networking/interface.go index fb6d81fd4..d302a4e81 100644 --- a/informers/networking/interface.go +++ b/informers/networking/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,47 +14,48 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package networking import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" - "github.com/kcp-dev/client-go/informers/networking/v1" - "github.com/kcp-dev/client-go/informers/networking/v1alpha1" - "github.com/kcp-dev/client-go/informers/networking/v1beta1" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpv1 "github.com/kcp-dev/client-go/informers/networking/v1" + kcpv1alpha1 "github.com/kcp-dev/client-go/informers/networking/v1alpha1" + kcpv1beta1 "github.com/kcp-dev/client-go/informers/networking/v1beta1" ) +// ClusterInterface provides access to each of this group's versions. type ClusterInterface interface { - // V1 provides access to the shared informers in V1. - V1() v1.ClusterInterface - // V1alpha1 provides access to the shared informers in V1alpha1. - V1alpha1() v1alpha1.ClusterInterface - // V1beta1 provides access to the shared informers in V1beta1. - V1beta1() v1beta1.ClusterInterface + // V1 provides access to shared informers for resources in V1. + V1() kcpv1.ClusterInterface + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() kcpv1alpha1.ClusterInterface + // V1beta1 provides access to shared informers for resources in V1beta1. + V1beta1() kcpv1beta1.ClusterInterface } type group struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &group{factory: f, tweakListOptions: tweakListOptions} } -// V1 returns a new v1.ClusterInterface. -func (g *group) V1() v1.ClusterInterface { - return v1.New(g.factory, g.tweakListOptions) +// V1 returns a new kcpv1.ClusterInterface. +func (g *group) V1() kcpv1.ClusterInterface { + return kcpv1.New(g.factory, g.tweakListOptions) } -// V1alpha1 returns a new v1alpha1.ClusterInterface. -func (g *group) V1alpha1() v1alpha1.ClusterInterface { - return v1alpha1.New(g.factory, g.tweakListOptions) +// V1alpha1 returns a new kcpv1alpha1.ClusterInterface. +func (g *group) V1alpha1() kcpv1alpha1.ClusterInterface { + return kcpv1alpha1.New(g.factory, g.tweakListOptions) } -// V1beta1 returns a new v1beta1.ClusterInterface. -func (g *group) V1beta1() v1beta1.ClusterInterface { - return v1beta1.New(g.factory, g.tweakListOptions) +// V1beta1 returns a new kcpv1beta1.ClusterInterface. +func (g *group) V1beta1() kcpv1beta1.ClusterInterface { + return kcpv1beta1.New(g.factory, g.tweakListOptions) } diff --git a/informers/networking/v1/ingress.go b/informers/networking/v1/ingress.go index 3c656feed..f7e529d0f 100644 --- a/informers/networking/v1/ingress.go +++ b/informers/networking/v1/ingress.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - networkingv1 "k8s.io/api/networking/v1" + apinetworkingv1 "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamnetworkingv1informers "k8s.io/client-go/informers/networking/v1" - upstreamnetworkingv1listers "k8s.io/client-go/listers/networking/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - networkingv1listers "github.com/kcp-dev/client-go/listers/networking/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + networkingv1 "k8s.io/client-go/informers/networking/v1" + listersnetworkingv1 "k8s.io/client-go/listers/networking/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/networking/v1" ) // IngressClusterInformer provides access to a shared informer and lister for // Ingresses. type IngressClusterInformer interface { - Cluster(logicalcluster.Name) upstreamnetworkingv1informers.IngressInformer + Cluster(logicalcluster.Name) networkingv1.IngressInformer + ClusterWithContext(context.Context, logicalcluster.Name) networkingv1.IngressInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() networkingv1listers.IngressClusterLister + Lister() kcpv1.IngressClusterLister } type ingressClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewIngressClusterInformer constructs a new informer for Ingress type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewIngressClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewIngressClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredIngressClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredIngressClusterInformer constructs a new informer for Ingress type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredIngressClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredIngressClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.NetworkingV1().Ingresses().List(context.TODO(), options) + return client.NetworkingV1().Ingresses().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.NetworkingV1().Ingresses().Watch(context.TODO(), options) + return client.NetworkingV1().Ingresses().Watch(context.Background(), options) }, }, - &networkingv1.Ingress{}, + &apinetworkingv1.Ingress{}, resyncPeriod, indexers, ) } -func (f *ingressClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *ingressClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredIngressClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *ingressClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apinetworkingv1.Ingress{}, i.defaultInformer) } -func (f *ingressClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&networkingv1.Ingress{}, f.defaultInformer) +func (i *ingressClusterInformer) Lister() kcpv1.IngressClusterLister { + return kcpv1.NewIngressClusterLister(i.Informer().GetIndexer()) } -func (f *ingressClusterInformer) Lister() networkingv1listers.IngressClusterLister { - return networkingv1listers.NewIngressClusterLister(f.Informer().GetIndexer()) +func (i *ingressClusterInformer) Cluster(clusterName logicalcluster.Name) networkingv1.IngressInformer { + return &ingressInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *ingressClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamnetworkingv1informers.IngressInformer { +func (i *ingressClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) networkingv1.IngressInformer { return &ingressInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type ingressInformer struct { informer cache.SharedIndexInformer - lister upstreamnetworkingv1listers.IngressLister + lister listersnetworkingv1.IngressLister } -func (f *ingressInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *ingressInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *ingressInformer) Lister() upstreamnetworkingv1listers.IngressLister { - return f.lister +func (i *ingressInformer) Lister() listersnetworkingv1.IngressLister { + return i.lister } diff --git a/informers/networking/v1/ingressclass.go b/informers/networking/v1/ingressclass.go index 0af340d02..8464e706f 100644 --- a/informers/networking/v1/ingressclass.go +++ b/informers/networking/v1/ingressclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - networkingv1 "k8s.io/api/networking/v1" + apinetworkingv1 "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamnetworkingv1informers "k8s.io/client-go/informers/networking/v1" - upstreamnetworkingv1listers "k8s.io/client-go/listers/networking/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - networkingv1listers "github.com/kcp-dev/client-go/listers/networking/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + networkingv1 "k8s.io/client-go/informers/networking/v1" + listersnetworkingv1 "k8s.io/client-go/listers/networking/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/networking/v1" ) // IngressClassClusterInformer provides access to a shared informer and lister for // IngressClasses. type IngressClassClusterInformer interface { - Cluster(logicalcluster.Name) upstreamnetworkingv1informers.IngressClassInformer + Cluster(logicalcluster.Name) networkingv1.IngressClassInformer + ClusterWithContext(context.Context, logicalcluster.Name) networkingv1.IngressClassInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() networkingv1listers.IngressClassClusterLister + Lister() kcpv1.IngressClassClusterLister } type ingressClassClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewIngressClassClusterInformer constructs a new informer for IngressClass type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewIngressClassClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewIngressClassClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredIngressClassClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredIngressClassClusterInformer constructs a new informer for IngressClass type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredIngressClassClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredIngressClassClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.NetworkingV1().IngressClasses().List(context.TODO(), options) + return client.NetworkingV1().IngressClasses().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.NetworkingV1().IngressClasses().Watch(context.TODO(), options) + return client.NetworkingV1().IngressClasses().Watch(context.Background(), options) }, }, - &networkingv1.IngressClass{}, + &apinetworkingv1.IngressClass{}, resyncPeriod, indexers, ) } -func (f *ingressClassClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *ingressClassClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredIngressClassClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *ingressClassClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apinetworkingv1.IngressClass{}, i.defaultInformer) } -func (f *ingressClassClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&networkingv1.IngressClass{}, f.defaultInformer) +func (i *ingressClassClusterInformer) Lister() kcpv1.IngressClassClusterLister { + return kcpv1.NewIngressClassClusterLister(i.Informer().GetIndexer()) } -func (f *ingressClassClusterInformer) Lister() networkingv1listers.IngressClassClusterLister { - return networkingv1listers.NewIngressClassClusterLister(f.Informer().GetIndexer()) +func (i *ingressClassClusterInformer) Cluster(clusterName logicalcluster.Name) networkingv1.IngressClassInformer { + return &ingressClassInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *ingressClassClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamnetworkingv1informers.IngressClassInformer { +func (i *ingressClassClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) networkingv1.IngressClassInformer { return &ingressClassInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type ingressClassInformer struct { informer cache.SharedIndexInformer - lister upstreamnetworkingv1listers.IngressClassLister + lister listersnetworkingv1.IngressClassLister } -func (f *ingressClassInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *ingressClassInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *ingressClassInformer) Lister() upstreamnetworkingv1listers.IngressClassLister { - return f.lister +func (i *ingressClassInformer) Lister() listersnetworkingv1.IngressClassLister { + return i.lister } diff --git a/informers/networking/v1/interface.go b/informers/networking/v1/interface.go index 075d74d54..c1f84c416 100644 --- a/informers/networking/v1/interface.go +++ b/informers/networking/v1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,44 +14,44 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // NetworkPolicies returns a NetworkPolicyClusterInformer - NetworkPolicies() NetworkPolicyClusterInformer - // Ingresses returns a IngressClusterInformer + // Ingresses returns a IngressClusterInformer. Ingresses() IngressClusterInformer - // IngressClasses returns a IngressClassClusterInformer + // IngressClasses returns a IngressClassClusterInformer. IngressClasses() IngressClassClusterInformer + // NetworkPolicies returns a NetworkPolicyClusterInformer. + NetworkPolicies() NetworkPolicyClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// NetworkPolicies returns a NetworkPolicyClusterInformer -func (v *version) NetworkPolicies() NetworkPolicyClusterInformer { - return &networkPolicyClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} - -// Ingresses returns a IngressClusterInformer +// Ingresses returns a IngressClusterInformer. func (v *version) Ingresses() IngressClusterInformer { return &ingressClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// IngressClasses returns a IngressClassClusterInformer +// IngressClasses returns a IngressClassClusterInformer. func (v *version) IngressClasses() IngressClassClusterInformer { return &ingressClassClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } + +// NetworkPolicies returns a NetworkPolicyClusterInformer. +func (v *version) NetworkPolicies() NetworkPolicyClusterInformer { + return &networkPolicyClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} diff --git a/informers/networking/v1/networkpolicy.go b/informers/networking/v1/networkpolicy.go index 442afb8ee..ecba5cc61 100644 --- a/informers/networking/v1/networkpolicy.go +++ b/informers/networking/v1/networkpolicy.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - networkingv1 "k8s.io/api/networking/v1" + apinetworkingv1 "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamnetworkingv1informers "k8s.io/client-go/informers/networking/v1" - upstreamnetworkingv1listers "k8s.io/client-go/listers/networking/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - networkingv1listers "github.com/kcp-dev/client-go/listers/networking/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + networkingv1 "k8s.io/client-go/informers/networking/v1" + listersnetworkingv1 "k8s.io/client-go/listers/networking/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/networking/v1" ) // NetworkPolicyClusterInformer provides access to a shared informer and lister for // NetworkPolicies. type NetworkPolicyClusterInformer interface { - Cluster(logicalcluster.Name) upstreamnetworkingv1informers.NetworkPolicyInformer + Cluster(logicalcluster.Name) networkingv1.NetworkPolicyInformer + ClusterWithContext(context.Context, logicalcluster.Name) networkingv1.NetworkPolicyInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() networkingv1listers.NetworkPolicyClusterLister + Lister() kcpv1.NetworkPolicyClusterLister } type networkPolicyClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewNetworkPolicyClusterInformer constructs a new informer for NetworkPolicy type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewNetworkPolicyClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewNetworkPolicyClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredNetworkPolicyClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredNetworkPolicyClusterInformer constructs a new informer for NetworkPolicy type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredNetworkPolicyClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredNetworkPolicyClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.NetworkingV1().NetworkPolicies().List(context.TODO(), options) + return client.NetworkingV1().NetworkPolicies().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.NetworkingV1().NetworkPolicies().Watch(context.TODO(), options) + return client.NetworkingV1().NetworkPolicies().Watch(context.Background(), options) }, }, - &networkingv1.NetworkPolicy{}, + &apinetworkingv1.NetworkPolicy{}, resyncPeriod, indexers, ) } -func (f *networkPolicyClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *networkPolicyClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredNetworkPolicyClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *networkPolicyClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apinetworkingv1.NetworkPolicy{}, i.defaultInformer) } -func (f *networkPolicyClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&networkingv1.NetworkPolicy{}, f.defaultInformer) +func (i *networkPolicyClusterInformer) Lister() kcpv1.NetworkPolicyClusterLister { + return kcpv1.NewNetworkPolicyClusterLister(i.Informer().GetIndexer()) } -func (f *networkPolicyClusterInformer) Lister() networkingv1listers.NetworkPolicyClusterLister { - return networkingv1listers.NewNetworkPolicyClusterLister(f.Informer().GetIndexer()) +func (i *networkPolicyClusterInformer) Cluster(clusterName logicalcluster.Name) networkingv1.NetworkPolicyInformer { + return &networkPolicyInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *networkPolicyClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamnetworkingv1informers.NetworkPolicyInformer { +func (i *networkPolicyClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) networkingv1.NetworkPolicyInformer { return &networkPolicyInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type networkPolicyInformer struct { informer cache.SharedIndexInformer - lister upstreamnetworkingv1listers.NetworkPolicyLister + lister listersnetworkingv1.NetworkPolicyLister } -func (f *networkPolicyInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *networkPolicyInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *networkPolicyInformer) Lister() upstreamnetworkingv1listers.NetworkPolicyLister { - return f.lister +func (i *networkPolicyInformer) Lister() listersnetworkingv1.NetworkPolicyLister { + return i.lister } diff --git a/informers/networking/v1alpha1/interface.go b/informers/networking/v1alpha1/interface.go index d1fc9d682..aead27ace 100644 --- a/informers/networking/v1alpha1/interface.go +++ b/informers/networking/v1alpha1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,37 +14,37 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // IPAddresses returns a IPAddressClusterInformer + // IPAddresses returns a IPAddressClusterInformer. IPAddresses() IPAddressClusterInformer - // ServiceCIDRs returns a ServiceCIDRClusterInformer + // ServiceCIDRs returns a ServiceCIDRClusterInformer. ServiceCIDRs() ServiceCIDRClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// IPAddresses returns a IPAddressClusterInformer +// IPAddresses returns a IPAddressClusterInformer. func (v *version) IPAddresses() IPAddressClusterInformer { return &iPAddressClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// ServiceCIDRs returns a ServiceCIDRClusterInformer +// ServiceCIDRs returns a ServiceCIDRClusterInformer. func (v *version) ServiceCIDRs() ServiceCIDRClusterInformer { return &serviceCIDRClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/networking/v1alpha1/ipaddress.go b/informers/networking/v1alpha1/ipaddress.go index 63540a6b5..f6e70b1d8 100644 --- a/informers/networking/v1alpha1/ipaddress.go +++ b/informers/networking/v1alpha1/ipaddress.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - networkingv1alpha1 "k8s.io/api/networking/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamnetworkingv1alpha1informers "k8s.io/client-go/informers/networking/v1alpha1" - upstreamnetworkingv1alpha1listers "k8s.io/client-go/listers/networking/v1alpha1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - networkingv1alpha1listers "github.com/kcp-dev/client-go/listers/networking/v1alpha1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apinetworkingv1alpha1 "k8s.io/api/networking/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + networkingv1alpha1 "k8s.io/client-go/informers/networking/v1alpha1" + listersnetworkingv1alpha1 "k8s.io/client-go/listers/networking/v1alpha1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1alpha1 "github.com/kcp-dev/client-go/listers/networking/v1alpha1" ) // IPAddressClusterInformer provides access to a shared informer and lister for // IPAddresses. type IPAddressClusterInformer interface { - Cluster(logicalcluster.Name) upstreamnetworkingv1alpha1informers.IPAddressInformer + Cluster(logicalcluster.Name) networkingv1alpha1.IPAddressInformer + ClusterWithContext(context.Context, logicalcluster.Name) networkingv1alpha1.IPAddressInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() networkingv1alpha1listers.IPAddressClusterLister + Lister() kcpv1alpha1.IPAddressClusterLister } type iPAddressClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewIPAddressClusterInformer constructs a new informer for IPAddress type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewIPAddressClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewIPAddressClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredIPAddressClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredIPAddressClusterInformer constructs a new informer for IPAddress type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredIPAddressClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredIPAddressClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.NetworkingV1alpha1().IPAddresses().List(context.TODO(), options) + return client.NetworkingV1alpha1().IPAddresses().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.NetworkingV1alpha1().IPAddresses().Watch(context.TODO(), options) + return client.NetworkingV1alpha1().IPAddresses().Watch(context.Background(), options) }, }, - &networkingv1alpha1.IPAddress{}, + &apinetworkingv1alpha1.IPAddress{}, resyncPeriod, indexers, ) } -func (f *iPAddressClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *iPAddressClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredIPAddressClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *iPAddressClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apinetworkingv1alpha1.IPAddress{}, i.defaultInformer) } -func (f *iPAddressClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&networkingv1alpha1.IPAddress{}, f.defaultInformer) +func (i *iPAddressClusterInformer) Lister() kcpv1alpha1.IPAddressClusterLister { + return kcpv1alpha1.NewIPAddressClusterLister(i.Informer().GetIndexer()) } -func (f *iPAddressClusterInformer) Lister() networkingv1alpha1listers.IPAddressClusterLister { - return networkingv1alpha1listers.NewIPAddressClusterLister(f.Informer().GetIndexer()) +func (i *iPAddressClusterInformer) Cluster(clusterName logicalcluster.Name) networkingv1alpha1.IPAddressInformer { + return &iPAddressInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *iPAddressClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamnetworkingv1alpha1informers.IPAddressInformer { +func (i *iPAddressClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) networkingv1alpha1.IPAddressInformer { return &iPAddressInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type iPAddressInformer struct { informer cache.SharedIndexInformer - lister upstreamnetworkingv1alpha1listers.IPAddressLister + lister listersnetworkingv1alpha1.IPAddressLister } -func (f *iPAddressInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *iPAddressInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *iPAddressInformer) Lister() upstreamnetworkingv1alpha1listers.IPAddressLister { - return f.lister +func (i *iPAddressInformer) Lister() listersnetworkingv1alpha1.IPAddressLister { + return i.lister } diff --git a/informers/networking/v1alpha1/servicecidr.go b/informers/networking/v1alpha1/servicecidr.go index 3802fa1b1..f2d21899f 100644 --- a/informers/networking/v1alpha1/servicecidr.go +++ b/informers/networking/v1alpha1/servicecidr.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - networkingv1alpha1 "k8s.io/api/networking/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamnetworkingv1alpha1informers "k8s.io/client-go/informers/networking/v1alpha1" - upstreamnetworkingv1alpha1listers "k8s.io/client-go/listers/networking/v1alpha1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - networkingv1alpha1listers "github.com/kcp-dev/client-go/listers/networking/v1alpha1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apinetworkingv1alpha1 "k8s.io/api/networking/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + networkingv1alpha1 "k8s.io/client-go/informers/networking/v1alpha1" + listersnetworkingv1alpha1 "k8s.io/client-go/listers/networking/v1alpha1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1alpha1 "github.com/kcp-dev/client-go/listers/networking/v1alpha1" ) // ServiceCIDRClusterInformer provides access to a shared informer and lister for // ServiceCIDRs. type ServiceCIDRClusterInformer interface { - Cluster(logicalcluster.Name) upstreamnetworkingv1alpha1informers.ServiceCIDRInformer + Cluster(logicalcluster.Name) networkingv1alpha1.ServiceCIDRInformer + ClusterWithContext(context.Context, logicalcluster.Name) networkingv1alpha1.ServiceCIDRInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() networkingv1alpha1listers.ServiceCIDRClusterLister + Lister() kcpv1alpha1.ServiceCIDRClusterLister } type serviceCIDRClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewServiceCIDRClusterInformer constructs a new informer for ServiceCIDR type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewServiceCIDRClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewServiceCIDRClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredServiceCIDRClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredServiceCIDRClusterInformer constructs a new informer for ServiceCIDR type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredServiceCIDRClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredServiceCIDRClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.NetworkingV1alpha1().ServiceCIDRs().List(context.TODO(), options) + return client.NetworkingV1alpha1().ServiceCIDRs().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.NetworkingV1alpha1().ServiceCIDRs().Watch(context.TODO(), options) + return client.NetworkingV1alpha1().ServiceCIDRs().Watch(context.Background(), options) }, }, - &networkingv1alpha1.ServiceCIDR{}, + &apinetworkingv1alpha1.ServiceCIDR{}, resyncPeriod, indexers, ) } -func (f *serviceCIDRClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *serviceCIDRClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredServiceCIDRClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *serviceCIDRClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apinetworkingv1alpha1.ServiceCIDR{}, i.defaultInformer) } -func (f *serviceCIDRClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&networkingv1alpha1.ServiceCIDR{}, f.defaultInformer) +func (i *serviceCIDRClusterInformer) Lister() kcpv1alpha1.ServiceCIDRClusterLister { + return kcpv1alpha1.NewServiceCIDRClusterLister(i.Informer().GetIndexer()) } -func (f *serviceCIDRClusterInformer) Lister() networkingv1alpha1listers.ServiceCIDRClusterLister { - return networkingv1alpha1listers.NewServiceCIDRClusterLister(f.Informer().GetIndexer()) +func (i *serviceCIDRClusterInformer) Cluster(clusterName logicalcluster.Name) networkingv1alpha1.ServiceCIDRInformer { + return &serviceCIDRInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *serviceCIDRClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamnetworkingv1alpha1informers.ServiceCIDRInformer { +func (i *serviceCIDRClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) networkingv1alpha1.ServiceCIDRInformer { return &serviceCIDRInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type serviceCIDRInformer struct { informer cache.SharedIndexInformer - lister upstreamnetworkingv1alpha1listers.ServiceCIDRLister + lister listersnetworkingv1alpha1.ServiceCIDRLister } -func (f *serviceCIDRInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *serviceCIDRInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *serviceCIDRInformer) Lister() upstreamnetworkingv1alpha1listers.ServiceCIDRLister { - return f.lister +func (i *serviceCIDRInformer) Lister() listersnetworkingv1alpha1.ServiceCIDRLister { + return i.lister } diff --git a/informers/networking/v1beta1/ingress.go b/informers/networking/v1beta1/ingress.go index 0d88107ef..6da58c85d 100644 --- a/informers/networking/v1beta1/ingress.go +++ b/informers/networking/v1beta1/ingress.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - networkingv1beta1 "k8s.io/api/networking/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamnetworkingv1beta1informers "k8s.io/client-go/informers/networking/v1beta1" - upstreamnetworkingv1beta1listers "k8s.io/client-go/listers/networking/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - networkingv1beta1listers "github.com/kcp-dev/client-go/listers/networking/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apinetworkingv1beta1 "k8s.io/api/networking/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + networkingv1beta1 "k8s.io/client-go/informers/networking/v1beta1" + listersnetworkingv1beta1 "k8s.io/client-go/listers/networking/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/networking/v1beta1" ) // IngressClusterInformer provides access to a shared informer and lister for // Ingresses. type IngressClusterInformer interface { - Cluster(logicalcluster.Name) upstreamnetworkingv1beta1informers.IngressInformer + Cluster(logicalcluster.Name) networkingv1beta1.IngressInformer + ClusterWithContext(context.Context, logicalcluster.Name) networkingv1beta1.IngressInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() networkingv1beta1listers.IngressClusterLister + Lister() kcpv1beta1.IngressClusterLister } type ingressClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewIngressClusterInformer constructs a new informer for Ingress type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewIngressClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewIngressClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredIngressClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredIngressClusterInformer constructs a new informer for Ingress type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredIngressClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredIngressClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.NetworkingV1beta1().Ingresses().List(context.TODO(), options) + return client.NetworkingV1beta1().Ingresses().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.NetworkingV1beta1().Ingresses().Watch(context.TODO(), options) + return client.NetworkingV1beta1().Ingresses().Watch(context.Background(), options) }, }, - &networkingv1beta1.Ingress{}, + &apinetworkingv1beta1.Ingress{}, resyncPeriod, indexers, ) } -func (f *ingressClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *ingressClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredIngressClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *ingressClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apinetworkingv1beta1.Ingress{}, i.defaultInformer) } -func (f *ingressClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&networkingv1beta1.Ingress{}, f.defaultInformer) +func (i *ingressClusterInformer) Lister() kcpv1beta1.IngressClusterLister { + return kcpv1beta1.NewIngressClusterLister(i.Informer().GetIndexer()) } -func (f *ingressClusterInformer) Lister() networkingv1beta1listers.IngressClusterLister { - return networkingv1beta1listers.NewIngressClusterLister(f.Informer().GetIndexer()) +func (i *ingressClusterInformer) Cluster(clusterName logicalcluster.Name) networkingv1beta1.IngressInformer { + return &ingressInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *ingressClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamnetworkingv1beta1informers.IngressInformer { +func (i *ingressClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) networkingv1beta1.IngressInformer { return &ingressInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type ingressInformer struct { informer cache.SharedIndexInformer - lister upstreamnetworkingv1beta1listers.IngressLister + lister listersnetworkingv1beta1.IngressLister } -func (f *ingressInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *ingressInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *ingressInformer) Lister() upstreamnetworkingv1beta1listers.IngressLister { - return f.lister +func (i *ingressInformer) Lister() listersnetworkingv1beta1.IngressLister { + return i.lister } diff --git a/informers/networking/v1beta1/ingressclass.go b/informers/networking/v1beta1/ingressclass.go index 56e3f36ff..aa4f6045f 100644 --- a/informers/networking/v1beta1/ingressclass.go +++ b/informers/networking/v1beta1/ingressclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - networkingv1beta1 "k8s.io/api/networking/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamnetworkingv1beta1informers "k8s.io/client-go/informers/networking/v1beta1" - upstreamnetworkingv1beta1listers "k8s.io/client-go/listers/networking/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - networkingv1beta1listers "github.com/kcp-dev/client-go/listers/networking/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apinetworkingv1beta1 "k8s.io/api/networking/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + networkingv1beta1 "k8s.io/client-go/informers/networking/v1beta1" + listersnetworkingv1beta1 "k8s.io/client-go/listers/networking/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/networking/v1beta1" ) // IngressClassClusterInformer provides access to a shared informer and lister for // IngressClasses. type IngressClassClusterInformer interface { - Cluster(logicalcluster.Name) upstreamnetworkingv1beta1informers.IngressClassInformer + Cluster(logicalcluster.Name) networkingv1beta1.IngressClassInformer + ClusterWithContext(context.Context, logicalcluster.Name) networkingv1beta1.IngressClassInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() networkingv1beta1listers.IngressClassClusterLister + Lister() kcpv1beta1.IngressClassClusterLister } type ingressClassClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewIngressClassClusterInformer constructs a new informer for IngressClass type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewIngressClassClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewIngressClassClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredIngressClassClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredIngressClassClusterInformer constructs a new informer for IngressClass type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredIngressClassClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredIngressClassClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.NetworkingV1beta1().IngressClasses().List(context.TODO(), options) + return client.NetworkingV1beta1().IngressClasses().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.NetworkingV1beta1().IngressClasses().Watch(context.TODO(), options) + return client.NetworkingV1beta1().IngressClasses().Watch(context.Background(), options) }, }, - &networkingv1beta1.IngressClass{}, + &apinetworkingv1beta1.IngressClass{}, resyncPeriod, indexers, ) } -func (f *ingressClassClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *ingressClassClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredIngressClassClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *ingressClassClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apinetworkingv1beta1.IngressClass{}, i.defaultInformer) } -func (f *ingressClassClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&networkingv1beta1.IngressClass{}, f.defaultInformer) +func (i *ingressClassClusterInformer) Lister() kcpv1beta1.IngressClassClusterLister { + return kcpv1beta1.NewIngressClassClusterLister(i.Informer().GetIndexer()) } -func (f *ingressClassClusterInformer) Lister() networkingv1beta1listers.IngressClassClusterLister { - return networkingv1beta1listers.NewIngressClassClusterLister(f.Informer().GetIndexer()) +func (i *ingressClassClusterInformer) Cluster(clusterName logicalcluster.Name) networkingv1beta1.IngressClassInformer { + return &ingressClassInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *ingressClassClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamnetworkingv1beta1informers.IngressClassInformer { +func (i *ingressClassClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) networkingv1beta1.IngressClassInformer { return &ingressClassInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type ingressClassInformer struct { informer cache.SharedIndexInformer - lister upstreamnetworkingv1beta1listers.IngressClassLister + lister listersnetworkingv1beta1.IngressClassLister } -func (f *ingressClassInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *ingressClassInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *ingressClassInformer) Lister() upstreamnetworkingv1beta1listers.IngressClassLister { - return f.lister +func (i *ingressClassInformer) Lister() listersnetworkingv1beta1.IngressClassLister { + return i.lister } diff --git a/informers/networking/v1beta1/interface.go b/informers/networking/v1beta1/interface.go index 6e02477cd..212db64bf 100644 --- a/informers/networking/v1beta1/interface.go +++ b/informers/networking/v1beta1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,51 +14,51 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // Ingresses returns a IngressClusterInformer + // IPAddresses returns a IPAddressClusterInformer. + IPAddresses() IPAddressClusterInformer + // Ingresses returns a IngressClusterInformer. Ingresses() IngressClusterInformer - // IngressClasses returns a IngressClassClusterInformer + // IngressClasses returns a IngressClassClusterInformer. IngressClasses() IngressClassClusterInformer - // IPAddresses returns a IPAddressClusterInformer - IPAddresses() IPAddressClusterInformer - // ServiceCIDRs returns a ServiceCIDRClusterInformer + // ServiceCIDRs returns a ServiceCIDRClusterInformer. ServiceCIDRs() ServiceCIDRClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// Ingresses returns a IngressClusterInformer +// IPAddresses returns a IPAddressClusterInformer. +func (v *version) IPAddresses() IPAddressClusterInformer { + return &iPAddressClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + +// Ingresses returns a IngressClusterInformer. func (v *version) Ingresses() IngressClusterInformer { return &ingressClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// IngressClasses returns a IngressClassClusterInformer +// IngressClasses returns a IngressClassClusterInformer. func (v *version) IngressClasses() IngressClassClusterInformer { return &ingressClassClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// IPAddresses returns a IPAddressClusterInformer -func (v *version) IPAddresses() IPAddressClusterInformer { - return &iPAddressClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} - -// ServiceCIDRs returns a ServiceCIDRClusterInformer +// ServiceCIDRs returns a ServiceCIDRClusterInformer. func (v *version) ServiceCIDRs() ServiceCIDRClusterInformer { return &serviceCIDRClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/networking/v1beta1/ipaddress.go b/informers/networking/v1beta1/ipaddress.go index 761b4aeb1..e03d5e77f 100644 --- a/informers/networking/v1beta1/ipaddress.go +++ b/informers/networking/v1beta1/ipaddress.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - networkingv1beta1 "k8s.io/api/networking/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamnetworkingv1beta1informers "k8s.io/client-go/informers/networking/v1beta1" - upstreamnetworkingv1beta1listers "k8s.io/client-go/listers/networking/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - networkingv1beta1listers "github.com/kcp-dev/client-go/listers/networking/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apinetworkingv1beta1 "k8s.io/api/networking/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + networkingv1beta1 "k8s.io/client-go/informers/networking/v1beta1" + listersnetworkingv1beta1 "k8s.io/client-go/listers/networking/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/networking/v1beta1" ) // IPAddressClusterInformer provides access to a shared informer and lister for // IPAddresses. type IPAddressClusterInformer interface { - Cluster(logicalcluster.Name) upstreamnetworkingv1beta1informers.IPAddressInformer + Cluster(logicalcluster.Name) networkingv1beta1.IPAddressInformer + ClusterWithContext(context.Context, logicalcluster.Name) networkingv1beta1.IPAddressInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() networkingv1beta1listers.IPAddressClusterLister + Lister() kcpv1beta1.IPAddressClusterLister } type iPAddressClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewIPAddressClusterInformer constructs a new informer for IPAddress type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewIPAddressClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewIPAddressClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredIPAddressClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredIPAddressClusterInformer constructs a new informer for IPAddress type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredIPAddressClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredIPAddressClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.NetworkingV1beta1().IPAddresses().List(context.TODO(), options) + return client.NetworkingV1beta1().IPAddresses().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.NetworkingV1beta1().IPAddresses().Watch(context.TODO(), options) + return client.NetworkingV1beta1().IPAddresses().Watch(context.Background(), options) }, }, - &networkingv1beta1.IPAddress{}, + &apinetworkingv1beta1.IPAddress{}, resyncPeriod, indexers, ) } -func (f *iPAddressClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *iPAddressClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredIPAddressClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *iPAddressClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apinetworkingv1beta1.IPAddress{}, i.defaultInformer) } -func (f *iPAddressClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&networkingv1beta1.IPAddress{}, f.defaultInformer) +func (i *iPAddressClusterInformer) Lister() kcpv1beta1.IPAddressClusterLister { + return kcpv1beta1.NewIPAddressClusterLister(i.Informer().GetIndexer()) } -func (f *iPAddressClusterInformer) Lister() networkingv1beta1listers.IPAddressClusterLister { - return networkingv1beta1listers.NewIPAddressClusterLister(f.Informer().GetIndexer()) +func (i *iPAddressClusterInformer) Cluster(clusterName logicalcluster.Name) networkingv1beta1.IPAddressInformer { + return &iPAddressInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *iPAddressClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamnetworkingv1beta1informers.IPAddressInformer { +func (i *iPAddressClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) networkingv1beta1.IPAddressInformer { return &iPAddressInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type iPAddressInformer struct { informer cache.SharedIndexInformer - lister upstreamnetworkingv1beta1listers.IPAddressLister + lister listersnetworkingv1beta1.IPAddressLister } -func (f *iPAddressInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *iPAddressInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *iPAddressInformer) Lister() upstreamnetworkingv1beta1listers.IPAddressLister { - return f.lister +func (i *iPAddressInformer) Lister() listersnetworkingv1beta1.IPAddressLister { + return i.lister } diff --git a/informers/networking/v1beta1/servicecidr.go b/informers/networking/v1beta1/servicecidr.go index 9d301e366..ecb8339b9 100644 --- a/informers/networking/v1beta1/servicecidr.go +++ b/informers/networking/v1beta1/servicecidr.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - networkingv1beta1 "k8s.io/api/networking/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamnetworkingv1beta1informers "k8s.io/client-go/informers/networking/v1beta1" - upstreamnetworkingv1beta1listers "k8s.io/client-go/listers/networking/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - networkingv1beta1listers "github.com/kcp-dev/client-go/listers/networking/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apinetworkingv1beta1 "k8s.io/api/networking/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + networkingv1beta1 "k8s.io/client-go/informers/networking/v1beta1" + listersnetworkingv1beta1 "k8s.io/client-go/listers/networking/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/networking/v1beta1" ) // ServiceCIDRClusterInformer provides access to a shared informer and lister for // ServiceCIDRs. type ServiceCIDRClusterInformer interface { - Cluster(logicalcluster.Name) upstreamnetworkingv1beta1informers.ServiceCIDRInformer + Cluster(logicalcluster.Name) networkingv1beta1.ServiceCIDRInformer + ClusterWithContext(context.Context, logicalcluster.Name) networkingv1beta1.ServiceCIDRInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() networkingv1beta1listers.ServiceCIDRClusterLister + Lister() kcpv1beta1.ServiceCIDRClusterLister } type serviceCIDRClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewServiceCIDRClusterInformer constructs a new informer for ServiceCIDR type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewServiceCIDRClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewServiceCIDRClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredServiceCIDRClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredServiceCIDRClusterInformer constructs a new informer for ServiceCIDR type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredServiceCIDRClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredServiceCIDRClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.NetworkingV1beta1().ServiceCIDRs().List(context.TODO(), options) + return client.NetworkingV1beta1().ServiceCIDRs().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.NetworkingV1beta1().ServiceCIDRs().Watch(context.TODO(), options) + return client.NetworkingV1beta1().ServiceCIDRs().Watch(context.Background(), options) }, }, - &networkingv1beta1.ServiceCIDR{}, + &apinetworkingv1beta1.ServiceCIDR{}, resyncPeriod, indexers, ) } -func (f *serviceCIDRClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *serviceCIDRClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredServiceCIDRClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *serviceCIDRClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apinetworkingv1beta1.ServiceCIDR{}, i.defaultInformer) } -func (f *serviceCIDRClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&networkingv1beta1.ServiceCIDR{}, f.defaultInformer) +func (i *serviceCIDRClusterInformer) Lister() kcpv1beta1.ServiceCIDRClusterLister { + return kcpv1beta1.NewServiceCIDRClusterLister(i.Informer().GetIndexer()) } -func (f *serviceCIDRClusterInformer) Lister() networkingv1beta1listers.ServiceCIDRClusterLister { - return networkingv1beta1listers.NewServiceCIDRClusterLister(f.Informer().GetIndexer()) +func (i *serviceCIDRClusterInformer) Cluster(clusterName logicalcluster.Name) networkingv1beta1.ServiceCIDRInformer { + return &serviceCIDRInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *serviceCIDRClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamnetworkingv1beta1informers.ServiceCIDRInformer { +func (i *serviceCIDRClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) networkingv1beta1.ServiceCIDRInformer { return &serviceCIDRInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type serviceCIDRInformer struct { informer cache.SharedIndexInformer - lister upstreamnetworkingv1beta1listers.ServiceCIDRLister + lister listersnetworkingv1beta1.ServiceCIDRLister } -func (f *serviceCIDRInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *serviceCIDRInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *serviceCIDRInformer) Lister() upstreamnetworkingv1beta1listers.ServiceCIDRLister { - return f.lister +func (i *serviceCIDRInformer) Lister() listersnetworkingv1beta1.ServiceCIDRLister { + return i.lister } diff --git a/informers/node/interface.go b/informers/node/interface.go index 73bab4744..d6d040445 100644 --- a/informers/node/interface.go +++ b/informers/node/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,47 +14,48 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package node import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" - "github.com/kcp-dev/client-go/informers/node/v1" - "github.com/kcp-dev/client-go/informers/node/v1alpha1" - "github.com/kcp-dev/client-go/informers/node/v1beta1" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpv1 "github.com/kcp-dev/client-go/informers/node/v1" + kcpv1alpha1 "github.com/kcp-dev/client-go/informers/node/v1alpha1" + kcpv1beta1 "github.com/kcp-dev/client-go/informers/node/v1beta1" ) +// ClusterInterface provides access to each of this group's versions. type ClusterInterface interface { - // V1 provides access to the shared informers in V1. - V1() v1.ClusterInterface - // V1alpha1 provides access to the shared informers in V1alpha1. - V1alpha1() v1alpha1.ClusterInterface - // V1beta1 provides access to the shared informers in V1beta1. - V1beta1() v1beta1.ClusterInterface + // V1 provides access to shared informers for resources in V1. + V1() kcpv1.ClusterInterface + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() kcpv1alpha1.ClusterInterface + // V1beta1 provides access to shared informers for resources in V1beta1. + V1beta1() kcpv1beta1.ClusterInterface } type group struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &group{factory: f, tweakListOptions: tweakListOptions} } -// V1 returns a new v1.ClusterInterface. -func (g *group) V1() v1.ClusterInterface { - return v1.New(g.factory, g.tweakListOptions) +// V1 returns a new kcpv1.ClusterInterface. +func (g *group) V1() kcpv1.ClusterInterface { + return kcpv1.New(g.factory, g.tweakListOptions) } -// V1alpha1 returns a new v1alpha1.ClusterInterface. -func (g *group) V1alpha1() v1alpha1.ClusterInterface { - return v1alpha1.New(g.factory, g.tweakListOptions) +// V1alpha1 returns a new kcpv1alpha1.ClusterInterface. +func (g *group) V1alpha1() kcpv1alpha1.ClusterInterface { + return kcpv1alpha1.New(g.factory, g.tweakListOptions) } -// V1beta1 returns a new v1beta1.ClusterInterface. -func (g *group) V1beta1() v1beta1.ClusterInterface { - return v1beta1.New(g.factory, g.tweakListOptions) +// V1beta1 returns a new kcpv1beta1.ClusterInterface. +func (g *group) V1beta1() kcpv1beta1.ClusterInterface { + return kcpv1beta1.New(g.factory, g.tweakListOptions) } diff --git a/informers/node/v1/interface.go b/informers/node/v1/interface.go index 0e4b617ce..671b5c51a 100644 --- a/informers/node/v1/interface.go +++ b/informers/node/v1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,30 +14,30 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // RuntimeClasses returns a RuntimeClassClusterInformer + // RuntimeClasses returns a RuntimeClassClusterInformer. RuntimeClasses() RuntimeClassClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// RuntimeClasses returns a RuntimeClassClusterInformer +// RuntimeClasses returns a RuntimeClassClusterInformer. func (v *version) RuntimeClasses() RuntimeClassClusterInformer { return &runtimeClassClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/node/v1/runtimeclass.go b/informers/node/v1/runtimeclass.go index 929b4b01f..02abe706b 100644 --- a/informers/node/v1/runtimeclass.go +++ b/informers/node/v1/runtimeclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - nodev1 "k8s.io/api/node/v1" + apinodev1 "k8s.io/api/node/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamnodev1informers "k8s.io/client-go/informers/node/v1" - upstreamnodev1listers "k8s.io/client-go/listers/node/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - nodev1listers "github.com/kcp-dev/client-go/listers/node/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + nodev1 "k8s.io/client-go/informers/node/v1" + listersnodev1 "k8s.io/client-go/listers/node/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/node/v1" ) // RuntimeClassClusterInformer provides access to a shared informer and lister for // RuntimeClasses. type RuntimeClassClusterInformer interface { - Cluster(logicalcluster.Name) upstreamnodev1informers.RuntimeClassInformer + Cluster(logicalcluster.Name) nodev1.RuntimeClassInformer + ClusterWithContext(context.Context, logicalcluster.Name) nodev1.RuntimeClassInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() nodev1listers.RuntimeClassClusterLister + Lister() kcpv1.RuntimeClassClusterLister } type runtimeClassClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewRuntimeClassClusterInformer constructs a new informer for RuntimeClass type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewRuntimeClassClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewRuntimeClassClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredRuntimeClassClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredRuntimeClassClusterInformer constructs a new informer for RuntimeClass type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredRuntimeClassClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredRuntimeClassClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.NodeV1().RuntimeClasses().List(context.TODO(), options) + return client.NodeV1().RuntimeClasses().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.NodeV1().RuntimeClasses().Watch(context.TODO(), options) + return client.NodeV1().RuntimeClasses().Watch(context.Background(), options) }, }, - &nodev1.RuntimeClass{}, + &apinodev1.RuntimeClass{}, resyncPeriod, indexers, ) } -func (f *runtimeClassClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *runtimeClassClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredRuntimeClassClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *runtimeClassClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apinodev1.RuntimeClass{}, i.defaultInformer) } -func (f *runtimeClassClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&nodev1.RuntimeClass{}, f.defaultInformer) +func (i *runtimeClassClusterInformer) Lister() kcpv1.RuntimeClassClusterLister { + return kcpv1.NewRuntimeClassClusterLister(i.Informer().GetIndexer()) } -func (f *runtimeClassClusterInformer) Lister() nodev1listers.RuntimeClassClusterLister { - return nodev1listers.NewRuntimeClassClusterLister(f.Informer().GetIndexer()) +func (i *runtimeClassClusterInformer) Cluster(clusterName logicalcluster.Name) nodev1.RuntimeClassInformer { + return &runtimeClassInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *runtimeClassClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamnodev1informers.RuntimeClassInformer { +func (i *runtimeClassClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) nodev1.RuntimeClassInformer { return &runtimeClassInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type runtimeClassInformer struct { informer cache.SharedIndexInformer - lister upstreamnodev1listers.RuntimeClassLister + lister listersnodev1.RuntimeClassLister } -func (f *runtimeClassInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *runtimeClassInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *runtimeClassInformer) Lister() upstreamnodev1listers.RuntimeClassLister { - return f.lister +func (i *runtimeClassInformer) Lister() listersnodev1.RuntimeClassLister { + return i.lister } diff --git a/informers/node/v1alpha1/interface.go b/informers/node/v1alpha1/interface.go index 99ce1335b..4b20e9258 100644 --- a/informers/node/v1alpha1/interface.go +++ b/informers/node/v1alpha1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,30 +14,30 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // RuntimeClasses returns a RuntimeClassClusterInformer + // RuntimeClasses returns a RuntimeClassClusterInformer. RuntimeClasses() RuntimeClassClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// RuntimeClasses returns a RuntimeClassClusterInformer +// RuntimeClasses returns a RuntimeClassClusterInformer. func (v *version) RuntimeClasses() RuntimeClassClusterInformer { return &runtimeClassClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/node/v1alpha1/runtimeclass.go b/informers/node/v1alpha1/runtimeclass.go index 982d96796..d83f0f3b6 100644 --- a/informers/node/v1alpha1/runtimeclass.go +++ b/informers/node/v1alpha1/runtimeclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - nodev1alpha1 "k8s.io/api/node/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamnodev1alpha1informers "k8s.io/client-go/informers/node/v1alpha1" - upstreamnodev1alpha1listers "k8s.io/client-go/listers/node/v1alpha1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - nodev1alpha1listers "github.com/kcp-dev/client-go/listers/node/v1alpha1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apinodev1alpha1 "k8s.io/api/node/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + nodev1alpha1 "k8s.io/client-go/informers/node/v1alpha1" + listersnodev1alpha1 "k8s.io/client-go/listers/node/v1alpha1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1alpha1 "github.com/kcp-dev/client-go/listers/node/v1alpha1" ) // RuntimeClassClusterInformer provides access to a shared informer and lister for // RuntimeClasses. type RuntimeClassClusterInformer interface { - Cluster(logicalcluster.Name) upstreamnodev1alpha1informers.RuntimeClassInformer + Cluster(logicalcluster.Name) nodev1alpha1.RuntimeClassInformer + ClusterWithContext(context.Context, logicalcluster.Name) nodev1alpha1.RuntimeClassInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() nodev1alpha1listers.RuntimeClassClusterLister + Lister() kcpv1alpha1.RuntimeClassClusterLister } type runtimeClassClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewRuntimeClassClusterInformer constructs a new informer for RuntimeClass type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewRuntimeClassClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewRuntimeClassClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredRuntimeClassClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredRuntimeClassClusterInformer constructs a new informer for RuntimeClass type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredRuntimeClassClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredRuntimeClassClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.NodeV1alpha1().RuntimeClasses().List(context.TODO(), options) + return client.NodeV1alpha1().RuntimeClasses().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.NodeV1alpha1().RuntimeClasses().Watch(context.TODO(), options) + return client.NodeV1alpha1().RuntimeClasses().Watch(context.Background(), options) }, }, - &nodev1alpha1.RuntimeClass{}, + &apinodev1alpha1.RuntimeClass{}, resyncPeriod, indexers, ) } -func (f *runtimeClassClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *runtimeClassClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredRuntimeClassClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *runtimeClassClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apinodev1alpha1.RuntimeClass{}, i.defaultInformer) } -func (f *runtimeClassClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&nodev1alpha1.RuntimeClass{}, f.defaultInformer) +func (i *runtimeClassClusterInformer) Lister() kcpv1alpha1.RuntimeClassClusterLister { + return kcpv1alpha1.NewRuntimeClassClusterLister(i.Informer().GetIndexer()) } -func (f *runtimeClassClusterInformer) Lister() nodev1alpha1listers.RuntimeClassClusterLister { - return nodev1alpha1listers.NewRuntimeClassClusterLister(f.Informer().GetIndexer()) +func (i *runtimeClassClusterInformer) Cluster(clusterName logicalcluster.Name) nodev1alpha1.RuntimeClassInformer { + return &runtimeClassInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *runtimeClassClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamnodev1alpha1informers.RuntimeClassInformer { +func (i *runtimeClassClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) nodev1alpha1.RuntimeClassInformer { return &runtimeClassInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type runtimeClassInformer struct { informer cache.SharedIndexInformer - lister upstreamnodev1alpha1listers.RuntimeClassLister + lister listersnodev1alpha1.RuntimeClassLister } -func (f *runtimeClassInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *runtimeClassInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *runtimeClassInformer) Lister() upstreamnodev1alpha1listers.RuntimeClassLister { - return f.lister +func (i *runtimeClassInformer) Lister() listersnodev1alpha1.RuntimeClassLister { + return i.lister } diff --git a/informers/node/v1beta1/interface.go b/informers/node/v1beta1/interface.go index 0d3a23f79..c2b328dec 100644 --- a/informers/node/v1beta1/interface.go +++ b/informers/node/v1beta1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,30 +14,30 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // RuntimeClasses returns a RuntimeClassClusterInformer + // RuntimeClasses returns a RuntimeClassClusterInformer. RuntimeClasses() RuntimeClassClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// RuntimeClasses returns a RuntimeClassClusterInformer +// RuntimeClasses returns a RuntimeClassClusterInformer. func (v *version) RuntimeClasses() RuntimeClassClusterInformer { return &runtimeClassClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/node/v1beta1/runtimeclass.go b/informers/node/v1beta1/runtimeclass.go index cbe9087e4..42f2e3ea6 100644 --- a/informers/node/v1beta1/runtimeclass.go +++ b/informers/node/v1beta1/runtimeclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - nodev1beta1 "k8s.io/api/node/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamnodev1beta1informers "k8s.io/client-go/informers/node/v1beta1" - upstreamnodev1beta1listers "k8s.io/client-go/listers/node/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - nodev1beta1listers "github.com/kcp-dev/client-go/listers/node/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apinodev1beta1 "k8s.io/api/node/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + nodev1beta1 "k8s.io/client-go/informers/node/v1beta1" + listersnodev1beta1 "k8s.io/client-go/listers/node/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/node/v1beta1" ) // RuntimeClassClusterInformer provides access to a shared informer and lister for // RuntimeClasses. type RuntimeClassClusterInformer interface { - Cluster(logicalcluster.Name) upstreamnodev1beta1informers.RuntimeClassInformer + Cluster(logicalcluster.Name) nodev1beta1.RuntimeClassInformer + ClusterWithContext(context.Context, logicalcluster.Name) nodev1beta1.RuntimeClassInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() nodev1beta1listers.RuntimeClassClusterLister + Lister() kcpv1beta1.RuntimeClassClusterLister } type runtimeClassClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewRuntimeClassClusterInformer constructs a new informer for RuntimeClass type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewRuntimeClassClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewRuntimeClassClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredRuntimeClassClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredRuntimeClassClusterInformer constructs a new informer for RuntimeClass type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredRuntimeClassClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredRuntimeClassClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.NodeV1beta1().RuntimeClasses().List(context.TODO(), options) + return client.NodeV1beta1().RuntimeClasses().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.NodeV1beta1().RuntimeClasses().Watch(context.TODO(), options) + return client.NodeV1beta1().RuntimeClasses().Watch(context.Background(), options) }, }, - &nodev1beta1.RuntimeClass{}, + &apinodev1beta1.RuntimeClass{}, resyncPeriod, indexers, ) } -func (f *runtimeClassClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *runtimeClassClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredRuntimeClassClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *runtimeClassClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apinodev1beta1.RuntimeClass{}, i.defaultInformer) } -func (f *runtimeClassClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&nodev1beta1.RuntimeClass{}, f.defaultInformer) +func (i *runtimeClassClusterInformer) Lister() kcpv1beta1.RuntimeClassClusterLister { + return kcpv1beta1.NewRuntimeClassClusterLister(i.Informer().GetIndexer()) } -func (f *runtimeClassClusterInformer) Lister() nodev1beta1listers.RuntimeClassClusterLister { - return nodev1beta1listers.NewRuntimeClassClusterLister(f.Informer().GetIndexer()) +func (i *runtimeClassClusterInformer) Cluster(clusterName logicalcluster.Name) nodev1beta1.RuntimeClassInformer { + return &runtimeClassInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *runtimeClassClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamnodev1beta1informers.RuntimeClassInformer { +func (i *runtimeClassClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) nodev1beta1.RuntimeClassInformer { return &runtimeClassInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type runtimeClassInformer struct { informer cache.SharedIndexInformer - lister upstreamnodev1beta1listers.RuntimeClassLister + lister listersnodev1beta1.RuntimeClassLister } -func (f *runtimeClassInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *runtimeClassInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *runtimeClassInformer) Lister() upstreamnodev1beta1listers.RuntimeClassLister { - return f.lister +func (i *runtimeClassInformer) Lister() listersnodev1beta1.RuntimeClassLister { + return i.lister } diff --git a/informers/policy/interface.go b/informers/policy/interface.go index 462d8ee3d..c43452f32 100644 --- a/informers/policy/interface.go +++ b/informers/policy/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,39 +14,40 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package policy import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" - "github.com/kcp-dev/client-go/informers/policy/v1" - "github.com/kcp-dev/client-go/informers/policy/v1beta1" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpv1 "github.com/kcp-dev/client-go/informers/policy/v1" + kcpv1beta1 "github.com/kcp-dev/client-go/informers/policy/v1beta1" ) +// ClusterInterface provides access to each of this group's versions. type ClusterInterface interface { - // V1 provides access to the shared informers in V1. - V1() v1.ClusterInterface - // V1beta1 provides access to the shared informers in V1beta1. - V1beta1() v1beta1.ClusterInterface + // V1 provides access to shared informers for resources in V1. + V1() kcpv1.ClusterInterface + // V1beta1 provides access to shared informers for resources in V1beta1. + V1beta1() kcpv1beta1.ClusterInterface } type group struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &group{factory: f, tweakListOptions: tweakListOptions} } -// V1 returns a new v1.ClusterInterface. -func (g *group) V1() v1.ClusterInterface { - return v1.New(g.factory, g.tweakListOptions) +// V1 returns a new kcpv1.ClusterInterface. +func (g *group) V1() kcpv1.ClusterInterface { + return kcpv1.New(g.factory, g.tweakListOptions) } -// V1beta1 returns a new v1beta1.ClusterInterface. -func (g *group) V1beta1() v1beta1.ClusterInterface { - return v1beta1.New(g.factory, g.tweakListOptions) +// V1beta1 returns a new kcpv1beta1.ClusterInterface. +func (g *group) V1beta1() kcpv1beta1.ClusterInterface { + return kcpv1beta1.New(g.factory, g.tweakListOptions) } diff --git a/informers/policy/v1/interface.go b/informers/policy/v1/interface.go index 4b2a45c7f..152a1abe9 100644 --- a/informers/policy/v1/interface.go +++ b/informers/policy/v1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,30 +14,30 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // PodDisruptionBudgets returns a PodDisruptionBudgetClusterInformer + // PodDisruptionBudgets returns a PodDisruptionBudgetClusterInformer. PodDisruptionBudgets() PodDisruptionBudgetClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// PodDisruptionBudgets returns a PodDisruptionBudgetClusterInformer +// PodDisruptionBudgets returns a PodDisruptionBudgetClusterInformer. func (v *version) PodDisruptionBudgets() PodDisruptionBudgetClusterInformer { return &podDisruptionBudgetClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/policy/v1/poddisruptionbudget.go b/informers/policy/v1/poddisruptionbudget.go index c20465a75..7bfcc0267 100644 --- a/informers/policy/v1/poddisruptionbudget.go +++ b/informers/policy/v1/poddisruptionbudget.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - policyv1 "k8s.io/api/policy/v1" + apipolicyv1 "k8s.io/api/policy/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreampolicyv1informers "k8s.io/client-go/informers/policy/v1" - upstreampolicyv1listers "k8s.io/client-go/listers/policy/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - policyv1listers "github.com/kcp-dev/client-go/listers/policy/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + policyv1 "k8s.io/client-go/informers/policy/v1" + listerspolicyv1 "k8s.io/client-go/listers/policy/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/policy/v1" ) // PodDisruptionBudgetClusterInformer provides access to a shared informer and lister for // PodDisruptionBudgets. type PodDisruptionBudgetClusterInformer interface { - Cluster(logicalcluster.Name) upstreampolicyv1informers.PodDisruptionBudgetInformer + Cluster(logicalcluster.Name) policyv1.PodDisruptionBudgetInformer + ClusterWithContext(context.Context, logicalcluster.Name) policyv1.PodDisruptionBudgetInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() policyv1listers.PodDisruptionBudgetClusterLister + Lister() kcpv1.PodDisruptionBudgetClusterLister } type podDisruptionBudgetClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewPodDisruptionBudgetClusterInformer constructs a new informer for PodDisruptionBudget type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewPodDisruptionBudgetClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewPodDisruptionBudgetClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredPodDisruptionBudgetClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredPodDisruptionBudgetClusterInformer constructs a new informer for PodDisruptionBudget type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredPodDisruptionBudgetClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredPodDisruptionBudgetClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.PolicyV1().PodDisruptionBudgets().List(context.TODO(), options) + return client.PolicyV1().PodDisruptionBudgets().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.PolicyV1().PodDisruptionBudgets().Watch(context.TODO(), options) + return client.PolicyV1().PodDisruptionBudgets().Watch(context.Background(), options) }, }, - &policyv1.PodDisruptionBudget{}, + &apipolicyv1.PodDisruptionBudget{}, resyncPeriod, indexers, ) } -func (f *podDisruptionBudgetClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *podDisruptionBudgetClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredPodDisruptionBudgetClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *podDisruptionBudgetClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apipolicyv1.PodDisruptionBudget{}, i.defaultInformer) } -func (f *podDisruptionBudgetClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&policyv1.PodDisruptionBudget{}, f.defaultInformer) +func (i *podDisruptionBudgetClusterInformer) Lister() kcpv1.PodDisruptionBudgetClusterLister { + return kcpv1.NewPodDisruptionBudgetClusterLister(i.Informer().GetIndexer()) } -func (f *podDisruptionBudgetClusterInformer) Lister() policyv1listers.PodDisruptionBudgetClusterLister { - return policyv1listers.NewPodDisruptionBudgetClusterLister(f.Informer().GetIndexer()) +func (i *podDisruptionBudgetClusterInformer) Cluster(clusterName logicalcluster.Name) policyv1.PodDisruptionBudgetInformer { + return &podDisruptionBudgetInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *podDisruptionBudgetClusterInformer) Cluster(clusterName logicalcluster.Name) upstreampolicyv1informers.PodDisruptionBudgetInformer { +func (i *podDisruptionBudgetClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) policyv1.PodDisruptionBudgetInformer { return &podDisruptionBudgetInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type podDisruptionBudgetInformer struct { informer cache.SharedIndexInformer - lister upstreampolicyv1listers.PodDisruptionBudgetLister + lister listerspolicyv1.PodDisruptionBudgetLister } -func (f *podDisruptionBudgetInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *podDisruptionBudgetInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *podDisruptionBudgetInformer) Lister() upstreampolicyv1listers.PodDisruptionBudgetLister { - return f.lister +func (i *podDisruptionBudgetInformer) Lister() listerspolicyv1.PodDisruptionBudgetLister { + return i.lister } diff --git a/informers/policy/v1beta1/interface.go b/informers/policy/v1beta1/interface.go index f8874a09d..29bd91efb 100644 --- a/informers/policy/v1beta1/interface.go +++ b/informers/policy/v1beta1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,30 +14,30 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // PodDisruptionBudgets returns a PodDisruptionBudgetClusterInformer + // PodDisruptionBudgets returns a PodDisruptionBudgetClusterInformer. PodDisruptionBudgets() PodDisruptionBudgetClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// PodDisruptionBudgets returns a PodDisruptionBudgetClusterInformer +// PodDisruptionBudgets returns a PodDisruptionBudgetClusterInformer. func (v *version) PodDisruptionBudgets() PodDisruptionBudgetClusterInformer { return &podDisruptionBudgetClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/policy/v1beta1/poddisruptionbudget.go b/informers/policy/v1beta1/poddisruptionbudget.go index 338383dbd..e14022137 100644 --- a/informers/policy/v1beta1/poddisruptionbudget.go +++ b/informers/policy/v1beta1/poddisruptionbudget.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - policyv1beta1 "k8s.io/api/policy/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreampolicyv1beta1informers "k8s.io/client-go/informers/policy/v1beta1" - upstreampolicyv1beta1listers "k8s.io/client-go/listers/policy/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - policyv1beta1listers "github.com/kcp-dev/client-go/listers/policy/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apipolicyv1beta1 "k8s.io/api/policy/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + policyv1beta1 "k8s.io/client-go/informers/policy/v1beta1" + listerspolicyv1beta1 "k8s.io/client-go/listers/policy/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/policy/v1beta1" ) // PodDisruptionBudgetClusterInformer provides access to a shared informer and lister for // PodDisruptionBudgets. type PodDisruptionBudgetClusterInformer interface { - Cluster(logicalcluster.Name) upstreampolicyv1beta1informers.PodDisruptionBudgetInformer + Cluster(logicalcluster.Name) policyv1beta1.PodDisruptionBudgetInformer + ClusterWithContext(context.Context, logicalcluster.Name) policyv1beta1.PodDisruptionBudgetInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() policyv1beta1listers.PodDisruptionBudgetClusterLister + Lister() kcpv1beta1.PodDisruptionBudgetClusterLister } type podDisruptionBudgetClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewPodDisruptionBudgetClusterInformer constructs a new informer for PodDisruptionBudget type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewPodDisruptionBudgetClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewPodDisruptionBudgetClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredPodDisruptionBudgetClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredPodDisruptionBudgetClusterInformer constructs a new informer for PodDisruptionBudget type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredPodDisruptionBudgetClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredPodDisruptionBudgetClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.PolicyV1beta1().PodDisruptionBudgets().List(context.TODO(), options) + return client.PolicyV1beta1().PodDisruptionBudgets().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.PolicyV1beta1().PodDisruptionBudgets().Watch(context.TODO(), options) + return client.PolicyV1beta1().PodDisruptionBudgets().Watch(context.Background(), options) }, }, - &policyv1beta1.PodDisruptionBudget{}, + &apipolicyv1beta1.PodDisruptionBudget{}, resyncPeriod, indexers, ) } -func (f *podDisruptionBudgetClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *podDisruptionBudgetClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredPodDisruptionBudgetClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *podDisruptionBudgetClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apipolicyv1beta1.PodDisruptionBudget{}, i.defaultInformer) } -func (f *podDisruptionBudgetClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&policyv1beta1.PodDisruptionBudget{}, f.defaultInformer) +func (i *podDisruptionBudgetClusterInformer) Lister() kcpv1beta1.PodDisruptionBudgetClusterLister { + return kcpv1beta1.NewPodDisruptionBudgetClusterLister(i.Informer().GetIndexer()) } -func (f *podDisruptionBudgetClusterInformer) Lister() policyv1beta1listers.PodDisruptionBudgetClusterLister { - return policyv1beta1listers.NewPodDisruptionBudgetClusterLister(f.Informer().GetIndexer()) +func (i *podDisruptionBudgetClusterInformer) Cluster(clusterName logicalcluster.Name) policyv1beta1.PodDisruptionBudgetInformer { + return &podDisruptionBudgetInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *podDisruptionBudgetClusterInformer) Cluster(clusterName logicalcluster.Name) upstreampolicyv1beta1informers.PodDisruptionBudgetInformer { +func (i *podDisruptionBudgetClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) policyv1beta1.PodDisruptionBudgetInformer { return &podDisruptionBudgetInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type podDisruptionBudgetInformer struct { informer cache.SharedIndexInformer - lister upstreampolicyv1beta1listers.PodDisruptionBudgetLister + lister listerspolicyv1beta1.PodDisruptionBudgetLister } -func (f *podDisruptionBudgetInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *podDisruptionBudgetInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *podDisruptionBudgetInformer) Lister() upstreampolicyv1beta1listers.PodDisruptionBudgetLister { - return f.lister +func (i *podDisruptionBudgetInformer) Lister() listerspolicyv1beta1.PodDisruptionBudgetLister { + return i.lister } diff --git a/informers/rbac/interface.go b/informers/rbac/interface.go index 9c3bc3f71..deb5be460 100644 --- a/informers/rbac/interface.go +++ b/informers/rbac/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,47 +14,48 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package rbac import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" - "github.com/kcp-dev/client-go/informers/rbac/v1" - "github.com/kcp-dev/client-go/informers/rbac/v1alpha1" - "github.com/kcp-dev/client-go/informers/rbac/v1beta1" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpv1 "github.com/kcp-dev/client-go/informers/rbac/v1" + kcpv1alpha1 "github.com/kcp-dev/client-go/informers/rbac/v1alpha1" + kcpv1beta1 "github.com/kcp-dev/client-go/informers/rbac/v1beta1" ) +// ClusterInterface provides access to each of this group's versions. type ClusterInterface interface { - // V1 provides access to the shared informers in V1. - V1() v1.ClusterInterface - // V1alpha1 provides access to the shared informers in V1alpha1. - V1alpha1() v1alpha1.ClusterInterface - // V1beta1 provides access to the shared informers in V1beta1. - V1beta1() v1beta1.ClusterInterface + // V1 provides access to shared informers for resources in V1. + V1() kcpv1.ClusterInterface + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() kcpv1alpha1.ClusterInterface + // V1beta1 provides access to shared informers for resources in V1beta1. + V1beta1() kcpv1beta1.ClusterInterface } type group struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &group{factory: f, tweakListOptions: tweakListOptions} } -// V1 returns a new v1.ClusterInterface. -func (g *group) V1() v1.ClusterInterface { - return v1.New(g.factory, g.tweakListOptions) +// V1 returns a new kcpv1.ClusterInterface. +func (g *group) V1() kcpv1.ClusterInterface { + return kcpv1.New(g.factory, g.tweakListOptions) } -// V1alpha1 returns a new v1alpha1.ClusterInterface. -func (g *group) V1alpha1() v1alpha1.ClusterInterface { - return v1alpha1.New(g.factory, g.tweakListOptions) +// V1alpha1 returns a new kcpv1alpha1.ClusterInterface. +func (g *group) V1alpha1() kcpv1alpha1.ClusterInterface { + return kcpv1alpha1.New(g.factory, g.tweakListOptions) } -// V1beta1 returns a new v1beta1.ClusterInterface. -func (g *group) V1beta1() v1beta1.ClusterInterface { - return v1beta1.New(g.factory, g.tweakListOptions) +// V1beta1 returns a new kcpv1beta1.ClusterInterface. +func (g *group) V1beta1() kcpv1beta1.ClusterInterface { + return kcpv1beta1.New(g.factory, g.tweakListOptions) } diff --git a/informers/rbac/v1/clusterrole.go b/informers/rbac/v1/clusterrole.go index 9787676b3..1ab3f1302 100644 --- a/informers/rbac/v1/clusterrole.go +++ b/informers/rbac/v1/clusterrole.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - rbacv1 "k8s.io/api/rbac/v1" + apirbacv1 "k8s.io/api/rbac/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamrbacv1informers "k8s.io/client-go/informers/rbac/v1" - upstreamrbacv1listers "k8s.io/client-go/listers/rbac/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - rbacv1listers "github.com/kcp-dev/client-go/listers/rbac/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + rbacv1 "k8s.io/client-go/informers/rbac/v1" + listersrbacv1 "k8s.io/client-go/listers/rbac/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/rbac/v1" ) // ClusterRoleClusterInformer provides access to a shared informer and lister for // ClusterRoles. type ClusterRoleClusterInformer interface { - Cluster(logicalcluster.Name) upstreamrbacv1informers.ClusterRoleInformer + Cluster(logicalcluster.Name) rbacv1.ClusterRoleInformer + ClusterWithContext(context.Context, logicalcluster.Name) rbacv1.ClusterRoleInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() rbacv1listers.ClusterRoleClusterLister + Lister() kcpv1.ClusterRoleClusterLister } type clusterRoleClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewClusterRoleClusterInformer constructs a new informer for ClusterRole type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewClusterRoleClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewClusterRoleClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredClusterRoleClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredClusterRoleClusterInformer constructs a new informer for ClusterRole type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredClusterRoleClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredClusterRoleClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.RbacV1().ClusterRoles().List(context.TODO(), options) + return client.RbacV1().ClusterRoles().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.RbacV1().ClusterRoles().Watch(context.TODO(), options) + return client.RbacV1().ClusterRoles().Watch(context.Background(), options) }, }, - &rbacv1.ClusterRole{}, + &apirbacv1.ClusterRole{}, resyncPeriod, indexers, ) } -func (f *clusterRoleClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *clusterRoleClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredClusterRoleClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *clusterRoleClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apirbacv1.ClusterRole{}, i.defaultInformer) } -func (f *clusterRoleClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&rbacv1.ClusterRole{}, f.defaultInformer) +func (i *clusterRoleClusterInformer) Lister() kcpv1.ClusterRoleClusterLister { + return kcpv1.NewClusterRoleClusterLister(i.Informer().GetIndexer()) } -func (f *clusterRoleClusterInformer) Lister() rbacv1listers.ClusterRoleClusterLister { - return rbacv1listers.NewClusterRoleClusterLister(f.Informer().GetIndexer()) +func (i *clusterRoleClusterInformer) Cluster(clusterName logicalcluster.Name) rbacv1.ClusterRoleInformer { + return &clusterRoleInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *clusterRoleClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamrbacv1informers.ClusterRoleInformer { +func (i *clusterRoleClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) rbacv1.ClusterRoleInformer { return &clusterRoleInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type clusterRoleInformer struct { informer cache.SharedIndexInformer - lister upstreamrbacv1listers.ClusterRoleLister + lister listersrbacv1.ClusterRoleLister } -func (f *clusterRoleInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *clusterRoleInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *clusterRoleInformer) Lister() upstreamrbacv1listers.ClusterRoleLister { - return f.lister +func (i *clusterRoleInformer) Lister() listersrbacv1.ClusterRoleLister { + return i.lister } diff --git a/informers/rbac/v1/clusterrolebinding.go b/informers/rbac/v1/clusterrolebinding.go index 1ab19f81a..ee3ebf5ef 100644 --- a/informers/rbac/v1/clusterrolebinding.go +++ b/informers/rbac/v1/clusterrolebinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - rbacv1 "k8s.io/api/rbac/v1" + apirbacv1 "k8s.io/api/rbac/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamrbacv1informers "k8s.io/client-go/informers/rbac/v1" - upstreamrbacv1listers "k8s.io/client-go/listers/rbac/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - rbacv1listers "github.com/kcp-dev/client-go/listers/rbac/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + rbacv1 "k8s.io/client-go/informers/rbac/v1" + listersrbacv1 "k8s.io/client-go/listers/rbac/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/rbac/v1" ) // ClusterRoleBindingClusterInformer provides access to a shared informer and lister for // ClusterRoleBindings. type ClusterRoleBindingClusterInformer interface { - Cluster(logicalcluster.Name) upstreamrbacv1informers.ClusterRoleBindingInformer + Cluster(logicalcluster.Name) rbacv1.ClusterRoleBindingInformer + ClusterWithContext(context.Context, logicalcluster.Name) rbacv1.ClusterRoleBindingInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() rbacv1listers.ClusterRoleBindingClusterLister + Lister() kcpv1.ClusterRoleBindingClusterLister } type clusterRoleBindingClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewClusterRoleBindingClusterInformer constructs a new informer for ClusterRoleBinding type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewClusterRoleBindingClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewClusterRoleBindingClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredClusterRoleBindingClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredClusterRoleBindingClusterInformer constructs a new informer for ClusterRoleBinding type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredClusterRoleBindingClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredClusterRoleBindingClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.RbacV1().ClusterRoleBindings().List(context.TODO(), options) + return client.RbacV1().ClusterRoleBindings().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.RbacV1().ClusterRoleBindings().Watch(context.TODO(), options) + return client.RbacV1().ClusterRoleBindings().Watch(context.Background(), options) }, }, - &rbacv1.ClusterRoleBinding{}, + &apirbacv1.ClusterRoleBinding{}, resyncPeriod, indexers, ) } -func (f *clusterRoleBindingClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *clusterRoleBindingClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredClusterRoleBindingClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *clusterRoleBindingClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apirbacv1.ClusterRoleBinding{}, i.defaultInformer) } -func (f *clusterRoleBindingClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&rbacv1.ClusterRoleBinding{}, f.defaultInformer) +func (i *clusterRoleBindingClusterInformer) Lister() kcpv1.ClusterRoleBindingClusterLister { + return kcpv1.NewClusterRoleBindingClusterLister(i.Informer().GetIndexer()) } -func (f *clusterRoleBindingClusterInformer) Lister() rbacv1listers.ClusterRoleBindingClusterLister { - return rbacv1listers.NewClusterRoleBindingClusterLister(f.Informer().GetIndexer()) +func (i *clusterRoleBindingClusterInformer) Cluster(clusterName logicalcluster.Name) rbacv1.ClusterRoleBindingInformer { + return &clusterRoleBindingInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *clusterRoleBindingClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamrbacv1informers.ClusterRoleBindingInformer { +func (i *clusterRoleBindingClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) rbacv1.ClusterRoleBindingInformer { return &clusterRoleBindingInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type clusterRoleBindingInformer struct { informer cache.SharedIndexInformer - lister upstreamrbacv1listers.ClusterRoleBindingLister + lister listersrbacv1.ClusterRoleBindingLister } -func (f *clusterRoleBindingInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *clusterRoleBindingInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *clusterRoleBindingInformer) Lister() upstreamrbacv1listers.ClusterRoleBindingLister { - return f.lister +func (i *clusterRoleBindingInformer) Lister() listersrbacv1.ClusterRoleBindingLister { + return i.lister } diff --git a/informers/rbac/v1/interface.go b/informers/rbac/v1/interface.go index 7d8db7e75..2a832130b 100644 --- a/informers/rbac/v1/interface.go +++ b/informers/rbac/v1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,51 +14,51 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // Roles returns a RoleClusterInformer - Roles() RoleClusterInformer - // RoleBindings returns a RoleBindingClusterInformer - RoleBindings() RoleBindingClusterInformer - // ClusterRoles returns a ClusterRoleClusterInformer + // ClusterRoles returns a ClusterRoleClusterInformer. ClusterRoles() ClusterRoleClusterInformer - // ClusterRoleBindings returns a ClusterRoleBindingClusterInformer + // ClusterRoleBindings returns a ClusterRoleBindingClusterInformer. ClusterRoleBindings() ClusterRoleBindingClusterInformer + // Roles returns a RoleClusterInformer. + Roles() RoleClusterInformer + // RoleBindings returns a RoleBindingClusterInformer. + RoleBindings() RoleBindingClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// Roles returns a RoleClusterInformer -func (v *version) Roles() RoleClusterInformer { - return &roleClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} - -// RoleBindings returns a RoleBindingClusterInformer -func (v *version) RoleBindings() RoleBindingClusterInformer { - return &roleBindingClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} - -// ClusterRoles returns a ClusterRoleClusterInformer +// ClusterRoles returns a ClusterRoleClusterInformer. func (v *version) ClusterRoles() ClusterRoleClusterInformer { return &clusterRoleClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// ClusterRoleBindings returns a ClusterRoleBindingClusterInformer +// ClusterRoleBindings returns a ClusterRoleBindingClusterInformer. func (v *version) ClusterRoleBindings() ClusterRoleBindingClusterInformer { return &clusterRoleBindingClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } + +// Roles returns a RoleClusterInformer. +func (v *version) Roles() RoleClusterInformer { + return &roleClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + +// RoleBindings returns a RoleBindingClusterInformer. +func (v *version) RoleBindings() RoleBindingClusterInformer { + return &roleBindingClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} diff --git a/informers/rbac/v1/role.go b/informers/rbac/v1/role.go index 8f7294c6b..26d88ddca 100644 --- a/informers/rbac/v1/role.go +++ b/informers/rbac/v1/role.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - rbacv1 "k8s.io/api/rbac/v1" + apirbacv1 "k8s.io/api/rbac/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamrbacv1informers "k8s.io/client-go/informers/rbac/v1" - upstreamrbacv1listers "k8s.io/client-go/listers/rbac/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - rbacv1listers "github.com/kcp-dev/client-go/listers/rbac/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + rbacv1 "k8s.io/client-go/informers/rbac/v1" + listersrbacv1 "k8s.io/client-go/listers/rbac/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/rbac/v1" ) // RoleClusterInformer provides access to a shared informer and lister for // Roles. type RoleClusterInformer interface { - Cluster(logicalcluster.Name) upstreamrbacv1informers.RoleInformer + Cluster(logicalcluster.Name) rbacv1.RoleInformer + ClusterWithContext(context.Context, logicalcluster.Name) rbacv1.RoleInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() rbacv1listers.RoleClusterLister + Lister() kcpv1.RoleClusterLister } type roleClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewRoleClusterInformer constructs a new informer for Role type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewRoleClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewRoleClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredRoleClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredRoleClusterInformer constructs a new informer for Role type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredRoleClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredRoleClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.RbacV1().Roles().List(context.TODO(), options) + return client.RbacV1().Roles().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.RbacV1().Roles().Watch(context.TODO(), options) + return client.RbacV1().Roles().Watch(context.Background(), options) }, }, - &rbacv1.Role{}, + &apirbacv1.Role{}, resyncPeriod, indexers, ) } -func (f *roleClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *roleClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredRoleClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *roleClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apirbacv1.Role{}, i.defaultInformer) } -func (f *roleClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&rbacv1.Role{}, f.defaultInformer) +func (i *roleClusterInformer) Lister() kcpv1.RoleClusterLister { + return kcpv1.NewRoleClusterLister(i.Informer().GetIndexer()) } -func (f *roleClusterInformer) Lister() rbacv1listers.RoleClusterLister { - return rbacv1listers.NewRoleClusterLister(f.Informer().GetIndexer()) +func (i *roleClusterInformer) Cluster(clusterName logicalcluster.Name) rbacv1.RoleInformer { + return &roleInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *roleClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamrbacv1informers.RoleInformer { +func (i *roleClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) rbacv1.RoleInformer { return &roleInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type roleInformer struct { informer cache.SharedIndexInformer - lister upstreamrbacv1listers.RoleLister + lister listersrbacv1.RoleLister } -func (f *roleInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *roleInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *roleInformer) Lister() upstreamrbacv1listers.RoleLister { - return f.lister +func (i *roleInformer) Lister() listersrbacv1.RoleLister { + return i.lister } diff --git a/informers/rbac/v1/rolebinding.go b/informers/rbac/v1/rolebinding.go index d06137c21..6d882ba86 100644 --- a/informers/rbac/v1/rolebinding.go +++ b/informers/rbac/v1/rolebinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - rbacv1 "k8s.io/api/rbac/v1" + apirbacv1 "k8s.io/api/rbac/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamrbacv1informers "k8s.io/client-go/informers/rbac/v1" - upstreamrbacv1listers "k8s.io/client-go/listers/rbac/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - rbacv1listers "github.com/kcp-dev/client-go/listers/rbac/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + rbacv1 "k8s.io/client-go/informers/rbac/v1" + listersrbacv1 "k8s.io/client-go/listers/rbac/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/rbac/v1" ) // RoleBindingClusterInformer provides access to a shared informer and lister for // RoleBindings. type RoleBindingClusterInformer interface { - Cluster(logicalcluster.Name) upstreamrbacv1informers.RoleBindingInformer + Cluster(logicalcluster.Name) rbacv1.RoleBindingInformer + ClusterWithContext(context.Context, logicalcluster.Name) rbacv1.RoleBindingInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() rbacv1listers.RoleBindingClusterLister + Lister() kcpv1.RoleBindingClusterLister } type roleBindingClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewRoleBindingClusterInformer constructs a new informer for RoleBinding type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewRoleBindingClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewRoleBindingClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredRoleBindingClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredRoleBindingClusterInformer constructs a new informer for RoleBinding type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredRoleBindingClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredRoleBindingClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.RbacV1().RoleBindings().List(context.TODO(), options) + return client.RbacV1().RoleBindings().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.RbacV1().RoleBindings().Watch(context.TODO(), options) + return client.RbacV1().RoleBindings().Watch(context.Background(), options) }, }, - &rbacv1.RoleBinding{}, + &apirbacv1.RoleBinding{}, resyncPeriod, indexers, ) } -func (f *roleBindingClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *roleBindingClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredRoleBindingClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *roleBindingClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apirbacv1.RoleBinding{}, i.defaultInformer) } -func (f *roleBindingClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&rbacv1.RoleBinding{}, f.defaultInformer) +func (i *roleBindingClusterInformer) Lister() kcpv1.RoleBindingClusterLister { + return kcpv1.NewRoleBindingClusterLister(i.Informer().GetIndexer()) } -func (f *roleBindingClusterInformer) Lister() rbacv1listers.RoleBindingClusterLister { - return rbacv1listers.NewRoleBindingClusterLister(f.Informer().GetIndexer()) +func (i *roleBindingClusterInformer) Cluster(clusterName logicalcluster.Name) rbacv1.RoleBindingInformer { + return &roleBindingInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *roleBindingClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamrbacv1informers.RoleBindingInformer { +func (i *roleBindingClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) rbacv1.RoleBindingInformer { return &roleBindingInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type roleBindingInformer struct { informer cache.SharedIndexInformer - lister upstreamrbacv1listers.RoleBindingLister + lister listersrbacv1.RoleBindingLister } -func (f *roleBindingInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *roleBindingInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *roleBindingInformer) Lister() upstreamrbacv1listers.RoleBindingLister { - return f.lister +func (i *roleBindingInformer) Lister() listersrbacv1.RoleBindingLister { + return i.lister } diff --git a/informers/rbac/v1alpha1/clusterrole.go b/informers/rbac/v1alpha1/clusterrole.go index f1ab65436..842b0cf3a 100644 --- a/informers/rbac/v1alpha1/clusterrole.go +++ b/informers/rbac/v1alpha1/clusterrole.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - rbacv1alpha1 "k8s.io/api/rbac/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamrbacv1alpha1informers "k8s.io/client-go/informers/rbac/v1alpha1" - upstreamrbacv1alpha1listers "k8s.io/client-go/listers/rbac/v1alpha1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - rbacv1alpha1listers "github.com/kcp-dev/client-go/listers/rbac/v1alpha1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apirbacv1alpha1 "k8s.io/api/rbac/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + rbacv1alpha1 "k8s.io/client-go/informers/rbac/v1alpha1" + listersrbacv1alpha1 "k8s.io/client-go/listers/rbac/v1alpha1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1alpha1 "github.com/kcp-dev/client-go/listers/rbac/v1alpha1" ) // ClusterRoleClusterInformer provides access to a shared informer and lister for // ClusterRoles. type ClusterRoleClusterInformer interface { - Cluster(logicalcluster.Name) upstreamrbacv1alpha1informers.ClusterRoleInformer + Cluster(logicalcluster.Name) rbacv1alpha1.ClusterRoleInformer + ClusterWithContext(context.Context, logicalcluster.Name) rbacv1alpha1.ClusterRoleInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() rbacv1alpha1listers.ClusterRoleClusterLister + Lister() kcpv1alpha1.ClusterRoleClusterLister } type clusterRoleClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewClusterRoleClusterInformer constructs a new informer for ClusterRole type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewClusterRoleClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewClusterRoleClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredClusterRoleClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredClusterRoleClusterInformer constructs a new informer for ClusterRole type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredClusterRoleClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredClusterRoleClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.RbacV1alpha1().ClusterRoles().List(context.TODO(), options) + return client.RbacV1alpha1().ClusterRoles().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.RbacV1alpha1().ClusterRoles().Watch(context.TODO(), options) + return client.RbacV1alpha1().ClusterRoles().Watch(context.Background(), options) }, }, - &rbacv1alpha1.ClusterRole{}, + &apirbacv1alpha1.ClusterRole{}, resyncPeriod, indexers, ) } -func (f *clusterRoleClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *clusterRoleClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredClusterRoleClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *clusterRoleClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apirbacv1alpha1.ClusterRole{}, i.defaultInformer) } -func (f *clusterRoleClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&rbacv1alpha1.ClusterRole{}, f.defaultInformer) +func (i *clusterRoleClusterInformer) Lister() kcpv1alpha1.ClusterRoleClusterLister { + return kcpv1alpha1.NewClusterRoleClusterLister(i.Informer().GetIndexer()) } -func (f *clusterRoleClusterInformer) Lister() rbacv1alpha1listers.ClusterRoleClusterLister { - return rbacv1alpha1listers.NewClusterRoleClusterLister(f.Informer().GetIndexer()) +func (i *clusterRoleClusterInformer) Cluster(clusterName logicalcluster.Name) rbacv1alpha1.ClusterRoleInformer { + return &clusterRoleInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *clusterRoleClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamrbacv1alpha1informers.ClusterRoleInformer { +func (i *clusterRoleClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) rbacv1alpha1.ClusterRoleInformer { return &clusterRoleInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type clusterRoleInformer struct { informer cache.SharedIndexInformer - lister upstreamrbacv1alpha1listers.ClusterRoleLister + lister listersrbacv1alpha1.ClusterRoleLister } -func (f *clusterRoleInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *clusterRoleInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *clusterRoleInformer) Lister() upstreamrbacv1alpha1listers.ClusterRoleLister { - return f.lister +func (i *clusterRoleInformer) Lister() listersrbacv1alpha1.ClusterRoleLister { + return i.lister } diff --git a/informers/rbac/v1alpha1/clusterrolebinding.go b/informers/rbac/v1alpha1/clusterrolebinding.go index df7eff514..d49ec6630 100644 --- a/informers/rbac/v1alpha1/clusterrolebinding.go +++ b/informers/rbac/v1alpha1/clusterrolebinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - rbacv1alpha1 "k8s.io/api/rbac/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamrbacv1alpha1informers "k8s.io/client-go/informers/rbac/v1alpha1" - upstreamrbacv1alpha1listers "k8s.io/client-go/listers/rbac/v1alpha1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - rbacv1alpha1listers "github.com/kcp-dev/client-go/listers/rbac/v1alpha1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apirbacv1alpha1 "k8s.io/api/rbac/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + rbacv1alpha1 "k8s.io/client-go/informers/rbac/v1alpha1" + listersrbacv1alpha1 "k8s.io/client-go/listers/rbac/v1alpha1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1alpha1 "github.com/kcp-dev/client-go/listers/rbac/v1alpha1" ) // ClusterRoleBindingClusterInformer provides access to a shared informer and lister for // ClusterRoleBindings. type ClusterRoleBindingClusterInformer interface { - Cluster(logicalcluster.Name) upstreamrbacv1alpha1informers.ClusterRoleBindingInformer + Cluster(logicalcluster.Name) rbacv1alpha1.ClusterRoleBindingInformer + ClusterWithContext(context.Context, logicalcluster.Name) rbacv1alpha1.ClusterRoleBindingInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() rbacv1alpha1listers.ClusterRoleBindingClusterLister + Lister() kcpv1alpha1.ClusterRoleBindingClusterLister } type clusterRoleBindingClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewClusterRoleBindingClusterInformer constructs a new informer for ClusterRoleBinding type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewClusterRoleBindingClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewClusterRoleBindingClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredClusterRoleBindingClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredClusterRoleBindingClusterInformer constructs a new informer for ClusterRoleBinding type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredClusterRoleBindingClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredClusterRoleBindingClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.RbacV1alpha1().ClusterRoleBindings().List(context.TODO(), options) + return client.RbacV1alpha1().ClusterRoleBindings().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.RbacV1alpha1().ClusterRoleBindings().Watch(context.TODO(), options) + return client.RbacV1alpha1().ClusterRoleBindings().Watch(context.Background(), options) }, }, - &rbacv1alpha1.ClusterRoleBinding{}, + &apirbacv1alpha1.ClusterRoleBinding{}, resyncPeriod, indexers, ) } -func (f *clusterRoleBindingClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *clusterRoleBindingClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredClusterRoleBindingClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *clusterRoleBindingClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apirbacv1alpha1.ClusterRoleBinding{}, i.defaultInformer) } -func (f *clusterRoleBindingClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&rbacv1alpha1.ClusterRoleBinding{}, f.defaultInformer) +func (i *clusterRoleBindingClusterInformer) Lister() kcpv1alpha1.ClusterRoleBindingClusterLister { + return kcpv1alpha1.NewClusterRoleBindingClusterLister(i.Informer().GetIndexer()) } -func (f *clusterRoleBindingClusterInformer) Lister() rbacv1alpha1listers.ClusterRoleBindingClusterLister { - return rbacv1alpha1listers.NewClusterRoleBindingClusterLister(f.Informer().GetIndexer()) +func (i *clusterRoleBindingClusterInformer) Cluster(clusterName logicalcluster.Name) rbacv1alpha1.ClusterRoleBindingInformer { + return &clusterRoleBindingInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *clusterRoleBindingClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamrbacv1alpha1informers.ClusterRoleBindingInformer { +func (i *clusterRoleBindingClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) rbacv1alpha1.ClusterRoleBindingInformer { return &clusterRoleBindingInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type clusterRoleBindingInformer struct { informer cache.SharedIndexInformer - lister upstreamrbacv1alpha1listers.ClusterRoleBindingLister + lister listersrbacv1alpha1.ClusterRoleBindingLister } -func (f *clusterRoleBindingInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *clusterRoleBindingInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *clusterRoleBindingInformer) Lister() upstreamrbacv1alpha1listers.ClusterRoleBindingLister { - return f.lister +func (i *clusterRoleBindingInformer) Lister() listersrbacv1alpha1.ClusterRoleBindingLister { + return i.lister } diff --git a/informers/rbac/v1alpha1/interface.go b/informers/rbac/v1alpha1/interface.go index 6df606f56..afcba9f22 100644 --- a/informers/rbac/v1alpha1/interface.go +++ b/informers/rbac/v1alpha1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,51 +14,51 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // Roles returns a RoleClusterInformer - Roles() RoleClusterInformer - // RoleBindings returns a RoleBindingClusterInformer - RoleBindings() RoleBindingClusterInformer - // ClusterRoles returns a ClusterRoleClusterInformer + // ClusterRoles returns a ClusterRoleClusterInformer. ClusterRoles() ClusterRoleClusterInformer - // ClusterRoleBindings returns a ClusterRoleBindingClusterInformer + // ClusterRoleBindings returns a ClusterRoleBindingClusterInformer. ClusterRoleBindings() ClusterRoleBindingClusterInformer + // Roles returns a RoleClusterInformer. + Roles() RoleClusterInformer + // RoleBindings returns a RoleBindingClusterInformer. + RoleBindings() RoleBindingClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// Roles returns a RoleClusterInformer -func (v *version) Roles() RoleClusterInformer { - return &roleClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} - -// RoleBindings returns a RoleBindingClusterInformer -func (v *version) RoleBindings() RoleBindingClusterInformer { - return &roleBindingClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} - -// ClusterRoles returns a ClusterRoleClusterInformer +// ClusterRoles returns a ClusterRoleClusterInformer. func (v *version) ClusterRoles() ClusterRoleClusterInformer { return &clusterRoleClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// ClusterRoleBindings returns a ClusterRoleBindingClusterInformer +// ClusterRoleBindings returns a ClusterRoleBindingClusterInformer. func (v *version) ClusterRoleBindings() ClusterRoleBindingClusterInformer { return &clusterRoleBindingClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } + +// Roles returns a RoleClusterInformer. +func (v *version) Roles() RoleClusterInformer { + return &roleClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + +// RoleBindings returns a RoleBindingClusterInformer. +func (v *version) RoleBindings() RoleBindingClusterInformer { + return &roleBindingClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} diff --git a/informers/rbac/v1alpha1/role.go b/informers/rbac/v1alpha1/role.go index 7d10fb791..49b89d2ee 100644 --- a/informers/rbac/v1alpha1/role.go +++ b/informers/rbac/v1alpha1/role.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - rbacv1alpha1 "k8s.io/api/rbac/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamrbacv1alpha1informers "k8s.io/client-go/informers/rbac/v1alpha1" - upstreamrbacv1alpha1listers "k8s.io/client-go/listers/rbac/v1alpha1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - rbacv1alpha1listers "github.com/kcp-dev/client-go/listers/rbac/v1alpha1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apirbacv1alpha1 "k8s.io/api/rbac/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + rbacv1alpha1 "k8s.io/client-go/informers/rbac/v1alpha1" + listersrbacv1alpha1 "k8s.io/client-go/listers/rbac/v1alpha1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1alpha1 "github.com/kcp-dev/client-go/listers/rbac/v1alpha1" ) // RoleClusterInformer provides access to a shared informer and lister for // Roles. type RoleClusterInformer interface { - Cluster(logicalcluster.Name) upstreamrbacv1alpha1informers.RoleInformer + Cluster(logicalcluster.Name) rbacv1alpha1.RoleInformer + ClusterWithContext(context.Context, logicalcluster.Name) rbacv1alpha1.RoleInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() rbacv1alpha1listers.RoleClusterLister + Lister() kcpv1alpha1.RoleClusterLister } type roleClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewRoleClusterInformer constructs a new informer for Role type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewRoleClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewRoleClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredRoleClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredRoleClusterInformer constructs a new informer for Role type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredRoleClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredRoleClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.RbacV1alpha1().Roles().List(context.TODO(), options) + return client.RbacV1alpha1().Roles().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.RbacV1alpha1().Roles().Watch(context.TODO(), options) + return client.RbacV1alpha1().Roles().Watch(context.Background(), options) }, }, - &rbacv1alpha1.Role{}, + &apirbacv1alpha1.Role{}, resyncPeriod, indexers, ) } -func (f *roleClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *roleClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredRoleClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *roleClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apirbacv1alpha1.Role{}, i.defaultInformer) } -func (f *roleClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&rbacv1alpha1.Role{}, f.defaultInformer) +func (i *roleClusterInformer) Lister() kcpv1alpha1.RoleClusterLister { + return kcpv1alpha1.NewRoleClusterLister(i.Informer().GetIndexer()) } -func (f *roleClusterInformer) Lister() rbacv1alpha1listers.RoleClusterLister { - return rbacv1alpha1listers.NewRoleClusterLister(f.Informer().GetIndexer()) +func (i *roleClusterInformer) Cluster(clusterName logicalcluster.Name) rbacv1alpha1.RoleInformer { + return &roleInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *roleClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamrbacv1alpha1informers.RoleInformer { +func (i *roleClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) rbacv1alpha1.RoleInformer { return &roleInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type roleInformer struct { informer cache.SharedIndexInformer - lister upstreamrbacv1alpha1listers.RoleLister + lister listersrbacv1alpha1.RoleLister } -func (f *roleInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *roleInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *roleInformer) Lister() upstreamrbacv1alpha1listers.RoleLister { - return f.lister +func (i *roleInformer) Lister() listersrbacv1alpha1.RoleLister { + return i.lister } diff --git a/informers/rbac/v1alpha1/rolebinding.go b/informers/rbac/v1alpha1/rolebinding.go index 971b71a3e..ce9154d8b 100644 --- a/informers/rbac/v1alpha1/rolebinding.go +++ b/informers/rbac/v1alpha1/rolebinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - rbacv1alpha1 "k8s.io/api/rbac/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamrbacv1alpha1informers "k8s.io/client-go/informers/rbac/v1alpha1" - upstreamrbacv1alpha1listers "k8s.io/client-go/listers/rbac/v1alpha1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - rbacv1alpha1listers "github.com/kcp-dev/client-go/listers/rbac/v1alpha1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apirbacv1alpha1 "k8s.io/api/rbac/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + rbacv1alpha1 "k8s.io/client-go/informers/rbac/v1alpha1" + listersrbacv1alpha1 "k8s.io/client-go/listers/rbac/v1alpha1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1alpha1 "github.com/kcp-dev/client-go/listers/rbac/v1alpha1" ) // RoleBindingClusterInformer provides access to a shared informer and lister for // RoleBindings. type RoleBindingClusterInformer interface { - Cluster(logicalcluster.Name) upstreamrbacv1alpha1informers.RoleBindingInformer + Cluster(logicalcluster.Name) rbacv1alpha1.RoleBindingInformer + ClusterWithContext(context.Context, logicalcluster.Name) rbacv1alpha1.RoleBindingInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() rbacv1alpha1listers.RoleBindingClusterLister + Lister() kcpv1alpha1.RoleBindingClusterLister } type roleBindingClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewRoleBindingClusterInformer constructs a new informer for RoleBinding type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewRoleBindingClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewRoleBindingClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredRoleBindingClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredRoleBindingClusterInformer constructs a new informer for RoleBinding type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredRoleBindingClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredRoleBindingClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.RbacV1alpha1().RoleBindings().List(context.TODO(), options) + return client.RbacV1alpha1().RoleBindings().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.RbacV1alpha1().RoleBindings().Watch(context.TODO(), options) + return client.RbacV1alpha1().RoleBindings().Watch(context.Background(), options) }, }, - &rbacv1alpha1.RoleBinding{}, + &apirbacv1alpha1.RoleBinding{}, resyncPeriod, indexers, ) } -func (f *roleBindingClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *roleBindingClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredRoleBindingClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *roleBindingClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apirbacv1alpha1.RoleBinding{}, i.defaultInformer) } -func (f *roleBindingClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&rbacv1alpha1.RoleBinding{}, f.defaultInformer) +func (i *roleBindingClusterInformer) Lister() kcpv1alpha1.RoleBindingClusterLister { + return kcpv1alpha1.NewRoleBindingClusterLister(i.Informer().GetIndexer()) } -func (f *roleBindingClusterInformer) Lister() rbacv1alpha1listers.RoleBindingClusterLister { - return rbacv1alpha1listers.NewRoleBindingClusterLister(f.Informer().GetIndexer()) +func (i *roleBindingClusterInformer) Cluster(clusterName logicalcluster.Name) rbacv1alpha1.RoleBindingInformer { + return &roleBindingInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *roleBindingClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamrbacv1alpha1informers.RoleBindingInformer { +func (i *roleBindingClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) rbacv1alpha1.RoleBindingInformer { return &roleBindingInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type roleBindingInformer struct { informer cache.SharedIndexInformer - lister upstreamrbacv1alpha1listers.RoleBindingLister + lister listersrbacv1alpha1.RoleBindingLister } -func (f *roleBindingInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *roleBindingInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *roleBindingInformer) Lister() upstreamrbacv1alpha1listers.RoleBindingLister { - return f.lister +func (i *roleBindingInformer) Lister() listersrbacv1alpha1.RoleBindingLister { + return i.lister } diff --git a/informers/rbac/v1beta1/clusterrole.go b/informers/rbac/v1beta1/clusterrole.go index 48368b657..c4b7b07c2 100644 --- a/informers/rbac/v1beta1/clusterrole.go +++ b/informers/rbac/v1beta1/clusterrole.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - rbacv1beta1 "k8s.io/api/rbac/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamrbacv1beta1informers "k8s.io/client-go/informers/rbac/v1beta1" - upstreamrbacv1beta1listers "k8s.io/client-go/listers/rbac/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - rbacv1beta1listers "github.com/kcp-dev/client-go/listers/rbac/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apirbacv1beta1 "k8s.io/api/rbac/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + rbacv1beta1 "k8s.io/client-go/informers/rbac/v1beta1" + listersrbacv1beta1 "k8s.io/client-go/listers/rbac/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/rbac/v1beta1" ) // ClusterRoleClusterInformer provides access to a shared informer and lister for // ClusterRoles. type ClusterRoleClusterInformer interface { - Cluster(logicalcluster.Name) upstreamrbacv1beta1informers.ClusterRoleInformer + Cluster(logicalcluster.Name) rbacv1beta1.ClusterRoleInformer + ClusterWithContext(context.Context, logicalcluster.Name) rbacv1beta1.ClusterRoleInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() rbacv1beta1listers.ClusterRoleClusterLister + Lister() kcpv1beta1.ClusterRoleClusterLister } type clusterRoleClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewClusterRoleClusterInformer constructs a new informer for ClusterRole type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewClusterRoleClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewClusterRoleClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredClusterRoleClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredClusterRoleClusterInformer constructs a new informer for ClusterRole type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredClusterRoleClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredClusterRoleClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.RbacV1beta1().ClusterRoles().List(context.TODO(), options) + return client.RbacV1beta1().ClusterRoles().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.RbacV1beta1().ClusterRoles().Watch(context.TODO(), options) + return client.RbacV1beta1().ClusterRoles().Watch(context.Background(), options) }, }, - &rbacv1beta1.ClusterRole{}, + &apirbacv1beta1.ClusterRole{}, resyncPeriod, indexers, ) } -func (f *clusterRoleClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *clusterRoleClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredClusterRoleClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *clusterRoleClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apirbacv1beta1.ClusterRole{}, i.defaultInformer) } -func (f *clusterRoleClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&rbacv1beta1.ClusterRole{}, f.defaultInformer) +func (i *clusterRoleClusterInformer) Lister() kcpv1beta1.ClusterRoleClusterLister { + return kcpv1beta1.NewClusterRoleClusterLister(i.Informer().GetIndexer()) } -func (f *clusterRoleClusterInformer) Lister() rbacv1beta1listers.ClusterRoleClusterLister { - return rbacv1beta1listers.NewClusterRoleClusterLister(f.Informer().GetIndexer()) +func (i *clusterRoleClusterInformer) Cluster(clusterName logicalcluster.Name) rbacv1beta1.ClusterRoleInformer { + return &clusterRoleInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *clusterRoleClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamrbacv1beta1informers.ClusterRoleInformer { +func (i *clusterRoleClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) rbacv1beta1.ClusterRoleInformer { return &clusterRoleInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type clusterRoleInformer struct { informer cache.SharedIndexInformer - lister upstreamrbacv1beta1listers.ClusterRoleLister + lister listersrbacv1beta1.ClusterRoleLister } -func (f *clusterRoleInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *clusterRoleInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *clusterRoleInformer) Lister() upstreamrbacv1beta1listers.ClusterRoleLister { - return f.lister +func (i *clusterRoleInformer) Lister() listersrbacv1beta1.ClusterRoleLister { + return i.lister } diff --git a/informers/rbac/v1beta1/clusterrolebinding.go b/informers/rbac/v1beta1/clusterrolebinding.go index abe140094..660cfbcd9 100644 --- a/informers/rbac/v1beta1/clusterrolebinding.go +++ b/informers/rbac/v1beta1/clusterrolebinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - rbacv1beta1 "k8s.io/api/rbac/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamrbacv1beta1informers "k8s.io/client-go/informers/rbac/v1beta1" - upstreamrbacv1beta1listers "k8s.io/client-go/listers/rbac/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - rbacv1beta1listers "github.com/kcp-dev/client-go/listers/rbac/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apirbacv1beta1 "k8s.io/api/rbac/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + rbacv1beta1 "k8s.io/client-go/informers/rbac/v1beta1" + listersrbacv1beta1 "k8s.io/client-go/listers/rbac/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/rbac/v1beta1" ) // ClusterRoleBindingClusterInformer provides access to a shared informer and lister for // ClusterRoleBindings. type ClusterRoleBindingClusterInformer interface { - Cluster(logicalcluster.Name) upstreamrbacv1beta1informers.ClusterRoleBindingInformer + Cluster(logicalcluster.Name) rbacv1beta1.ClusterRoleBindingInformer + ClusterWithContext(context.Context, logicalcluster.Name) rbacv1beta1.ClusterRoleBindingInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() rbacv1beta1listers.ClusterRoleBindingClusterLister + Lister() kcpv1beta1.ClusterRoleBindingClusterLister } type clusterRoleBindingClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewClusterRoleBindingClusterInformer constructs a new informer for ClusterRoleBinding type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewClusterRoleBindingClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewClusterRoleBindingClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredClusterRoleBindingClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredClusterRoleBindingClusterInformer constructs a new informer for ClusterRoleBinding type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredClusterRoleBindingClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredClusterRoleBindingClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.RbacV1beta1().ClusterRoleBindings().List(context.TODO(), options) + return client.RbacV1beta1().ClusterRoleBindings().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.RbacV1beta1().ClusterRoleBindings().Watch(context.TODO(), options) + return client.RbacV1beta1().ClusterRoleBindings().Watch(context.Background(), options) }, }, - &rbacv1beta1.ClusterRoleBinding{}, + &apirbacv1beta1.ClusterRoleBinding{}, resyncPeriod, indexers, ) } -func (f *clusterRoleBindingClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *clusterRoleBindingClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredClusterRoleBindingClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *clusterRoleBindingClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apirbacv1beta1.ClusterRoleBinding{}, i.defaultInformer) } -func (f *clusterRoleBindingClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&rbacv1beta1.ClusterRoleBinding{}, f.defaultInformer) +func (i *clusterRoleBindingClusterInformer) Lister() kcpv1beta1.ClusterRoleBindingClusterLister { + return kcpv1beta1.NewClusterRoleBindingClusterLister(i.Informer().GetIndexer()) } -func (f *clusterRoleBindingClusterInformer) Lister() rbacv1beta1listers.ClusterRoleBindingClusterLister { - return rbacv1beta1listers.NewClusterRoleBindingClusterLister(f.Informer().GetIndexer()) +func (i *clusterRoleBindingClusterInformer) Cluster(clusterName logicalcluster.Name) rbacv1beta1.ClusterRoleBindingInformer { + return &clusterRoleBindingInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *clusterRoleBindingClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamrbacv1beta1informers.ClusterRoleBindingInformer { +func (i *clusterRoleBindingClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) rbacv1beta1.ClusterRoleBindingInformer { return &clusterRoleBindingInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type clusterRoleBindingInformer struct { informer cache.SharedIndexInformer - lister upstreamrbacv1beta1listers.ClusterRoleBindingLister + lister listersrbacv1beta1.ClusterRoleBindingLister } -func (f *clusterRoleBindingInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *clusterRoleBindingInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *clusterRoleBindingInformer) Lister() upstreamrbacv1beta1listers.ClusterRoleBindingLister { - return f.lister +func (i *clusterRoleBindingInformer) Lister() listersrbacv1beta1.ClusterRoleBindingLister { + return i.lister } diff --git a/informers/rbac/v1beta1/interface.go b/informers/rbac/v1beta1/interface.go index af8394493..b01aca32b 100644 --- a/informers/rbac/v1beta1/interface.go +++ b/informers/rbac/v1beta1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,51 +14,51 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // Roles returns a RoleClusterInformer - Roles() RoleClusterInformer - // RoleBindings returns a RoleBindingClusterInformer - RoleBindings() RoleBindingClusterInformer - // ClusterRoles returns a ClusterRoleClusterInformer + // ClusterRoles returns a ClusterRoleClusterInformer. ClusterRoles() ClusterRoleClusterInformer - // ClusterRoleBindings returns a ClusterRoleBindingClusterInformer + // ClusterRoleBindings returns a ClusterRoleBindingClusterInformer. ClusterRoleBindings() ClusterRoleBindingClusterInformer + // Roles returns a RoleClusterInformer. + Roles() RoleClusterInformer + // RoleBindings returns a RoleBindingClusterInformer. + RoleBindings() RoleBindingClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// Roles returns a RoleClusterInformer -func (v *version) Roles() RoleClusterInformer { - return &roleClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} - -// RoleBindings returns a RoleBindingClusterInformer -func (v *version) RoleBindings() RoleBindingClusterInformer { - return &roleBindingClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} - -// ClusterRoles returns a ClusterRoleClusterInformer +// ClusterRoles returns a ClusterRoleClusterInformer. func (v *version) ClusterRoles() ClusterRoleClusterInformer { return &clusterRoleClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// ClusterRoleBindings returns a ClusterRoleBindingClusterInformer +// ClusterRoleBindings returns a ClusterRoleBindingClusterInformer. func (v *version) ClusterRoleBindings() ClusterRoleBindingClusterInformer { return &clusterRoleBindingClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } + +// Roles returns a RoleClusterInformer. +func (v *version) Roles() RoleClusterInformer { + return &roleClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + +// RoleBindings returns a RoleBindingClusterInformer. +func (v *version) RoleBindings() RoleBindingClusterInformer { + return &roleBindingClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} diff --git a/informers/rbac/v1beta1/role.go b/informers/rbac/v1beta1/role.go index 145a31ea0..c237e8321 100644 --- a/informers/rbac/v1beta1/role.go +++ b/informers/rbac/v1beta1/role.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - rbacv1beta1 "k8s.io/api/rbac/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamrbacv1beta1informers "k8s.io/client-go/informers/rbac/v1beta1" - upstreamrbacv1beta1listers "k8s.io/client-go/listers/rbac/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - rbacv1beta1listers "github.com/kcp-dev/client-go/listers/rbac/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apirbacv1beta1 "k8s.io/api/rbac/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + rbacv1beta1 "k8s.io/client-go/informers/rbac/v1beta1" + listersrbacv1beta1 "k8s.io/client-go/listers/rbac/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/rbac/v1beta1" ) // RoleClusterInformer provides access to a shared informer and lister for // Roles. type RoleClusterInformer interface { - Cluster(logicalcluster.Name) upstreamrbacv1beta1informers.RoleInformer + Cluster(logicalcluster.Name) rbacv1beta1.RoleInformer + ClusterWithContext(context.Context, logicalcluster.Name) rbacv1beta1.RoleInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() rbacv1beta1listers.RoleClusterLister + Lister() kcpv1beta1.RoleClusterLister } type roleClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewRoleClusterInformer constructs a new informer for Role type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewRoleClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewRoleClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredRoleClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredRoleClusterInformer constructs a new informer for Role type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredRoleClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredRoleClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.RbacV1beta1().Roles().List(context.TODO(), options) + return client.RbacV1beta1().Roles().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.RbacV1beta1().Roles().Watch(context.TODO(), options) + return client.RbacV1beta1().Roles().Watch(context.Background(), options) }, }, - &rbacv1beta1.Role{}, + &apirbacv1beta1.Role{}, resyncPeriod, indexers, ) } -func (f *roleClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *roleClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredRoleClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *roleClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apirbacv1beta1.Role{}, i.defaultInformer) } -func (f *roleClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&rbacv1beta1.Role{}, f.defaultInformer) +func (i *roleClusterInformer) Lister() kcpv1beta1.RoleClusterLister { + return kcpv1beta1.NewRoleClusterLister(i.Informer().GetIndexer()) } -func (f *roleClusterInformer) Lister() rbacv1beta1listers.RoleClusterLister { - return rbacv1beta1listers.NewRoleClusterLister(f.Informer().GetIndexer()) +func (i *roleClusterInformer) Cluster(clusterName logicalcluster.Name) rbacv1beta1.RoleInformer { + return &roleInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *roleClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamrbacv1beta1informers.RoleInformer { +func (i *roleClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) rbacv1beta1.RoleInformer { return &roleInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type roleInformer struct { informer cache.SharedIndexInformer - lister upstreamrbacv1beta1listers.RoleLister + lister listersrbacv1beta1.RoleLister } -func (f *roleInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *roleInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *roleInformer) Lister() upstreamrbacv1beta1listers.RoleLister { - return f.lister +func (i *roleInformer) Lister() listersrbacv1beta1.RoleLister { + return i.lister } diff --git a/informers/rbac/v1beta1/rolebinding.go b/informers/rbac/v1beta1/rolebinding.go index a5fcc75cd..09b4208a5 100644 --- a/informers/rbac/v1beta1/rolebinding.go +++ b/informers/rbac/v1beta1/rolebinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - rbacv1beta1 "k8s.io/api/rbac/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamrbacv1beta1informers "k8s.io/client-go/informers/rbac/v1beta1" - upstreamrbacv1beta1listers "k8s.io/client-go/listers/rbac/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - rbacv1beta1listers "github.com/kcp-dev/client-go/listers/rbac/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apirbacv1beta1 "k8s.io/api/rbac/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + rbacv1beta1 "k8s.io/client-go/informers/rbac/v1beta1" + listersrbacv1beta1 "k8s.io/client-go/listers/rbac/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/rbac/v1beta1" ) // RoleBindingClusterInformer provides access to a shared informer and lister for // RoleBindings. type RoleBindingClusterInformer interface { - Cluster(logicalcluster.Name) upstreamrbacv1beta1informers.RoleBindingInformer + Cluster(logicalcluster.Name) rbacv1beta1.RoleBindingInformer + ClusterWithContext(context.Context, logicalcluster.Name) rbacv1beta1.RoleBindingInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() rbacv1beta1listers.RoleBindingClusterLister + Lister() kcpv1beta1.RoleBindingClusterLister } type roleBindingClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewRoleBindingClusterInformer constructs a new informer for RoleBinding type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewRoleBindingClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewRoleBindingClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredRoleBindingClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredRoleBindingClusterInformer constructs a new informer for RoleBinding type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredRoleBindingClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredRoleBindingClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.RbacV1beta1().RoleBindings().List(context.TODO(), options) + return client.RbacV1beta1().RoleBindings().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.RbacV1beta1().RoleBindings().Watch(context.TODO(), options) + return client.RbacV1beta1().RoleBindings().Watch(context.Background(), options) }, }, - &rbacv1beta1.RoleBinding{}, + &apirbacv1beta1.RoleBinding{}, resyncPeriod, indexers, ) } -func (f *roleBindingClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *roleBindingClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredRoleBindingClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *roleBindingClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apirbacv1beta1.RoleBinding{}, i.defaultInformer) } -func (f *roleBindingClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&rbacv1beta1.RoleBinding{}, f.defaultInformer) +func (i *roleBindingClusterInformer) Lister() kcpv1beta1.RoleBindingClusterLister { + return kcpv1beta1.NewRoleBindingClusterLister(i.Informer().GetIndexer()) } -func (f *roleBindingClusterInformer) Lister() rbacv1beta1listers.RoleBindingClusterLister { - return rbacv1beta1listers.NewRoleBindingClusterLister(f.Informer().GetIndexer()) +func (i *roleBindingClusterInformer) Cluster(clusterName logicalcluster.Name) rbacv1beta1.RoleBindingInformer { + return &roleBindingInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *roleBindingClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamrbacv1beta1informers.RoleBindingInformer { +func (i *roleBindingClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) rbacv1beta1.RoleBindingInformer { return &roleBindingInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type roleBindingInformer struct { informer cache.SharedIndexInformer - lister upstreamrbacv1beta1listers.RoleBindingLister + lister listersrbacv1beta1.RoleBindingLister } -func (f *roleBindingInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *roleBindingInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *roleBindingInformer) Lister() upstreamrbacv1beta1listers.RoleBindingLister { - return f.lister +func (i *roleBindingInformer) Lister() listersrbacv1beta1.RoleBindingLister { + return i.lister } diff --git a/informers/resource/interface.go b/informers/resource/interface.go index 758c184f4..14f79224b 100644 --- a/informers/resource/interface.go +++ b/informers/resource/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,39 +14,40 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package resource import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" - "github.com/kcp-dev/client-go/informers/resource/v1alpha3" - "github.com/kcp-dev/client-go/informers/resource/v1beta1" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpv1alpha3 "github.com/kcp-dev/client-go/informers/resource/v1alpha3" + kcpv1beta1 "github.com/kcp-dev/client-go/informers/resource/v1beta1" ) +// ClusterInterface provides access to each of this group's versions. type ClusterInterface interface { - // V1alpha3 provides access to the shared informers in V1alpha3. - V1alpha3() v1alpha3.ClusterInterface - // V1beta1 provides access to the shared informers in V1beta1. - V1beta1() v1beta1.ClusterInterface + // V1alpha3 provides access to shared informers for resources in V1alpha3. + V1alpha3() kcpv1alpha3.ClusterInterface + // V1beta1 provides access to shared informers for resources in V1beta1. + V1beta1() kcpv1beta1.ClusterInterface } type group struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &group{factory: f, tweakListOptions: tweakListOptions} } -// V1alpha3 returns a new v1alpha3.ClusterInterface. -func (g *group) V1alpha3() v1alpha3.ClusterInterface { - return v1alpha3.New(g.factory, g.tweakListOptions) +// V1alpha3 returns a new kcpv1alpha3.ClusterInterface. +func (g *group) V1alpha3() kcpv1alpha3.ClusterInterface { + return kcpv1alpha3.New(g.factory, g.tweakListOptions) } -// V1beta1 returns a new v1beta1.ClusterInterface. -func (g *group) V1beta1() v1beta1.ClusterInterface { - return v1beta1.New(g.factory, g.tweakListOptions) +// V1beta1 returns a new kcpv1beta1.ClusterInterface. +func (g *group) V1beta1() kcpv1beta1.ClusterInterface { + return kcpv1beta1.New(g.factory, g.tweakListOptions) } diff --git a/informers/resource/v1alpha3/deviceclass.go b/informers/resource/v1alpha3/deviceclass.go index 11b8e11f2..6589da4cb 100644 --- a/informers/resource/v1alpha3/deviceclass.go +++ b/informers/resource/v1alpha3/deviceclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha3 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - resourcev1alpha3 "k8s.io/api/resource/v1alpha3" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamresourcev1alpha3informers "k8s.io/client-go/informers/resource/v1alpha3" - upstreamresourcev1alpha3listers "k8s.io/client-go/listers/resource/v1alpha3" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - resourcev1alpha3listers "github.com/kcp-dev/client-go/listers/resource/v1alpha3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiresourcev1alpha3 "k8s.io/api/resource/v1alpha3" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + resourcev1alpha3 "k8s.io/client-go/informers/resource/v1alpha3" + listersresourcev1alpha3 "k8s.io/client-go/listers/resource/v1alpha3" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1alpha3 "github.com/kcp-dev/client-go/listers/resource/v1alpha3" ) // DeviceClassClusterInformer provides access to a shared informer and lister for // DeviceClasses. type DeviceClassClusterInformer interface { - Cluster(logicalcluster.Name) upstreamresourcev1alpha3informers.DeviceClassInformer + Cluster(logicalcluster.Name) resourcev1alpha3.DeviceClassInformer + ClusterWithContext(context.Context, logicalcluster.Name) resourcev1alpha3.DeviceClassInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() resourcev1alpha3listers.DeviceClassClusterLister + Lister() kcpv1alpha3.DeviceClassClusterLister } type deviceClassClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewDeviceClassClusterInformer constructs a new informer for DeviceClass type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewDeviceClassClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewDeviceClassClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredDeviceClassClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredDeviceClassClusterInformer constructs a new informer for DeviceClass type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredDeviceClassClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredDeviceClassClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ResourceV1alpha3().DeviceClasses().List(context.TODO(), options) + return client.ResourceV1alpha3().DeviceClasses().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ResourceV1alpha3().DeviceClasses().Watch(context.TODO(), options) + return client.ResourceV1alpha3().DeviceClasses().Watch(context.Background(), options) }, }, - &resourcev1alpha3.DeviceClass{}, + &apiresourcev1alpha3.DeviceClass{}, resyncPeriod, indexers, ) } -func (f *deviceClassClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *deviceClassClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredDeviceClassClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *deviceClassClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiresourcev1alpha3.DeviceClass{}, i.defaultInformer) } -func (f *deviceClassClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&resourcev1alpha3.DeviceClass{}, f.defaultInformer) +func (i *deviceClassClusterInformer) Lister() kcpv1alpha3.DeviceClassClusterLister { + return kcpv1alpha3.NewDeviceClassClusterLister(i.Informer().GetIndexer()) } -func (f *deviceClassClusterInformer) Lister() resourcev1alpha3listers.DeviceClassClusterLister { - return resourcev1alpha3listers.NewDeviceClassClusterLister(f.Informer().GetIndexer()) +func (i *deviceClassClusterInformer) Cluster(clusterName logicalcluster.Name) resourcev1alpha3.DeviceClassInformer { + return &deviceClassInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *deviceClassClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamresourcev1alpha3informers.DeviceClassInformer { +func (i *deviceClassClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) resourcev1alpha3.DeviceClassInformer { return &deviceClassInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type deviceClassInformer struct { informer cache.SharedIndexInformer - lister upstreamresourcev1alpha3listers.DeviceClassLister + lister listersresourcev1alpha3.DeviceClassLister } -func (f *deviceClassInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *deviceClassInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *deviceClassInformer) Lister() upstreamresourcev1alpha3listers.DeviceClassLister { - return f.lister +func (i *deviceClassInformer) Lister() listersresourcev1alpha3.DeviceClassLister { + return i.lister } diff --git a/informers/resource/v1alpha3/interface.go b/informers/resource/v1alpha3/interface.go index 8727a3efb..cbea8c236 100644 --- a/informers/resource/v1alpha3/interface.go +++ b/informers/resource/v1alpha3/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,51 +14,51 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha3 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // ResourceSlices returns a ResourceSliceClusterInformer - ResourceSlices() ResourceSliceClusterInformer - // ResourceClaims returns a ResourceClaimClusterInformer - ResourceClaims() ResourceClaimClusterInformer - // DeviceClasses returns a DeviceClassClusterInformer + // DeviceClasses returns a DeviceClassClusterInformer. DeviceClasses() DeviceClassClusterInformer - // ResourceClaimTemplates returns a ResourceClaimTemplateClusterInformer + // ResourceClaims returns a ResourceClaimClusterInformer. + ResourceClaims() ResourceClaimClusterInformer + // ResourceClaimTemplates returns a ResourceClaimTemplateClusterInformer. ResourceClaimTemplates() ResourceClaimTemplateClusterInformer + // ResourceSlices returns a ResourceSliceClusterInformer. + ResourceSlices() ResourceSliceClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// ResourceSlices returns a ResourceSliceClusterInformer -func (v *version) ResourceSlices() ResourceSliceClusterInformer { - return &resourceSliceClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +// DeviceClasses returns a DeviceClassClusterInformer. +func (v *version) DeviceClasses() DeviceClassClusterInformer { + return &deviceClassClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// ResourceClaims returns a ResourceClaimClusterInformer +// ResourceClaims returns a ResourceClaimClusterInformer. func (v *version) ResourceClaims() ResourceClaimClusterInformer { return &resourceClaimClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// DeviceClasses returns a DeviceClassClusterInformer -func (v *version) DeviceClasses() DeviceClassClusterInformer { - return &deviceClassClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} - -// ResourceClaimTemplates returns a ResourceClaimTemplateClusterInformer +// ResourceClaimTemplates returns a ResourceClaimTemplateClusterInformer. func (v *version) ResourceClaimTemplates() ResourceClaimTemplateClusterInformer { return &resourceClaimTemplateClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } + +// ResourceSlices returns a ResourceSliceClusterInformer. +func (v *version) ResourceSlices() ResourceSliceClusterInformer { + return &resourceSliceClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} diff --git a/informers/resource/v1alpha3/resourceclaim.go b/informers/resource/v1alpha3/resourceclaim.go index 2cf420705..a8c80fc12 100644 --- a/informers/resource/v1alpha3/resourceclaim.go +++ b/informers/resource/v1alpha3/resourceclaim.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha3 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - resourcev1alpha3 "k8s.io/api/resource/v1alpha3" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamresourcev1alpha3informers "k8s.io/client-go/informers/resource/v1alpha3" - upstreamresourcev1alpha3listers "k8s.io/client-go/listers/resource/v1alpha3" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - resourcev1alpha3listers "github.com/kcp-dev/client-go/listers/resource/v1alpha3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiresourcev1alpha3 "k8s.io/api/resource/v1alpha3" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + resourcev1alpha3 "k8s.io/client-go/informers/resource/v1alpha3" + listersresourcev1alpha3 "k8s.io/client-go/listers/resource/v1alpha3" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1alpha3 "github.com/kcp-dev/client-go/listers/resource/v1alpha3" ) // ResourceClaimClusterInformer provides access to a shared informer and lister for // ResourceClaims. type ResourceClaimClusterInformer interface { - Cluster(logicalcluster.Name) upstreamresourcev1alpha3informers.ResourceClaimInformer + Cluster(logicalcluster.Name) resourcev1alpha3.ResourceClaimInformer + ClusterWithContext(context.Context, logicalcluster.Name) resourcev1alpha3.ResourceClaimInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() resourcev1alpha3listers.ResourceClaimClusterLister + Lister() kcpv1alpha3.ResourceClaimClusterLister } type resourceClaimClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewResourceClaimClusterInformer constructs a new informer for ResourceClaim type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewResourceClaimClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewResourceClaimClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredResourceClaimClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredResourceClaimClusterInformer constructs a new informer for ResourceClaim type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredResourceClaimClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredResourceClaimClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ResourceV1alpha3().ResourceClaims().List(context.TODO(), options) + return client.ResourceV1alpha3().ResourceClaims().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ResourceV1alpha3().ResourceClaims().Watch(context.TODO(), options) + return client.ResourceV1alpha3().ResourceClaims().Watch(context.Background(), options) }, }, - &resourcev1alpha3.ResourceClaim{}, + &apiresourcev1alpha3.ResourceClaim{}, resyncPeriod, indexers, ) } -func (f *resourceClaimClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *resourceClaimClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredResourceClaimClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *resourceClaimClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiresourcev1alpha3.ResourceClaim{}, i.defaultInformer) } -func (f *resourceClaimClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&resourcev1alpha3.ResourceClaim{}, f.defaultInformer) +func (i *resourceClaimClusterInformer) Lister() kcpv1alpha3.ResourceClaimClusterLister { + return kcpv1alpha3.NewResourceClaimClusterLister(i.Informer().GetIndexer()) } -func (f *resourceClaimClusterInformer) Lister() resourcev1alpha3listers.ResourceClaimClusterLister { - return resourcev1alpha3listers.NewResourceClaimClusterLister(f.Informer().GetIndexer()) +func (i *resourceClaimClusterInformer) Cluster(clusterName logicalcluster.Name) resourcev1alpha3.ResourceClaimInformer { + return &resourceClaimInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *resourceClaimClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamresourcev1alpha3informers.ResourceClaimInformer { +func (i *resourceClaimClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) resourcev1alpha3.ResourceClaimInformer { return &resourceClaimInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type resourceClaimInformer struct { informer cache.SharedIndexInformer - lister upstreamresourcev1alpha3listers.ResourceClaimLister + lister listersresourcev1alpha3.ResourceClaimLister } -func (f *resourceClaimInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *resourceClaimInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *resourceClaimInformer) Lister() upstreamresourcev1alpha3listers.ResourceClaimLister { - return f.lister +func (i *resourceClaimInformer) Lister() listersresourcev1alpha3.ResourceClaimLister { + return i.lister } diff --git a/informers/resource/v1alpha3/resourceclaimtemplate.go b/informers/resource/v1alpha3/resourceclaimtemplate.go index 66849176f..0ec1ab25b 100644 --- a/informers/resource/v1alpha3/resourceclaimtemplate.go +++ b/informers/resource/v1alpha3/resourceclaimtemplate.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha3 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - resourcev1alpha3 "k8s.io/api/resource/v1alpha3" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamresourcev1alpha3informers "k8s.io/client-go/informers/resource/v1alpha3" - upstreamresourcev1alpha3listers "k8s.io/client-go/listers/resource/v1alpha3" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - resourcev1alpha3listers "github.com/kcp-dev/client-go/listers/resource/v1alpha3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiresourcev1alpha3 "k8s.io/api/resource/v1alpha3" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + resourcev1alpha3 "k8s.io/client-go/informers/resource/v1alpha3" + listersresourcev1alpha3 "k8s.io/client-go/listers/resource/v1alpha3" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1alpha3 "github.com/kcp-dev/client-go/listers/resource/v1alpha3" ) // ResourceClaimTemplateClusterInformer provides access to a shared informer and lister for // ResourceClaimTemplates. type ResourceClaimTemplateClusterInformer interface { - Cluster(logicalcluster.Name) upstreamresourcev1alpha3informers.ResourceClaimTemplateInformer + Cluster(logicalcluster.Name) resourcev1alpha3.ResourceClaimTemplateInformer + ClusterWithContext(context.Context, logicalcluster.Name) resourcev1alpha3.ResourceClaimTemplateInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() resourcev1alpha3listers.ResourceClaimTemplateClusterLister + Lister() kcpv1alpha3.ResourceClaimTemplateClusterLister } type resourceClaimTemplateClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewResourceClaimTemplateClusterInformer constructs a new informer for ResourceClaimTemplate type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewResourceClaimTemplateClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewResourceClaimTemplateClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredResourceClaimTemplateClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredResourceClaimTemplateClusterInformer constructs a new informer for ResourceClaimTemplate type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredResourceClaimTemplateClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredResourceClaimTemplateClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ResourceV1alpha3().ResourceClaimTemplates().List(context.TODO(), options) + return client.ResourceV1alpha3().ResourceClaimTemplates().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ResourceV1alpha3().ResourceClaimTemplates().Watch(context.TODO(), options) + return client.ResourceV1alpha3().ResourceClaimTemplates().Watch(context.Background(), options) }, }, - &resourcev1alpha3.ResourceClaimTemplate{}, + &apiresourcev1alpha3.ResourceClaimTemplate{}, resyncPeriod, indexers, ) } -func (f *resourceClaimTemplateClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *resourceClaimTemplateClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredResourceClaimTemplateClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *resourceClaimTemplateClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiresourcev1alpha3.ResourceClaimTemplate{}, i.defaultInformer) } -func (f *resourceClaimTemplateClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&resourcev1alpha3.ResourceClaimTemplate{}, f.defaultInformer) +func (i *resourceClaimTemplateClusterInformer) Lister() kcpv1alpha3.ResourceClaimTemplateClusterLister { + return kcpv1alpha3.NewResourceClaimTemplateClusterLister(i.Informer().GetIndexer()) } -func (f *resourceClaimTemplateClusterInformer) Lister() resourcev1alpha3listers.ResourceClaimTemplateClusterLister { - return resourcev1alpha3listers.NewResourceClaimTemplateClusterLister(f.Informer().GetIndexer()) +func (i *resourceClaimTemplateClusterInformer) Cluster(clusterName logicalcluster.Name) resourcev1alpha3.ResourceClaimTemplateInformer { + return &resourceClaimTemplateInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *resourceClaimTemplateClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamresourcev1alpha3informers.ResourceClaimTemplateInformer { +func (i *resourceClaimTemplateClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) resourcev1alpha3.ResourceClaimTemplateInformer { return &resourceClaimTemplateInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type resourceClaimTemplateInformer struct { informer cache.SharedIndexInformer - lister upstreamresourcev1alpha3listers.ResourceClaimTemplateLister + lister listersresourcev1alpha3.ResourceClaimTemplateLister } -func (f *resourceClaimTemplateInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *resourceClaimTemplateInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *resourceClaimTemplateInformer) Lister() upstreamresourcev1alpha3listers.ResourceClaimTemplateLister { - return f.lister +func (i *resourceClaimTemplateInformer) Lister() listersresourcev1alpha3.ResourceClaimTemplateLister { + return i.lister } diff --git a/informers/resource/v1alpha3/resourceslice.go b/informers/resource/v1alpha3/resourceslice.go index 3fe3723fe..c0a55cd1b 100644 --- a/informers/resource/v1alpha3/resourceslice.go +++ b/informers/resource/v1alpha3/resourceslice.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha3 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - resourcev1alpha3 "k8s.io/api/resource/v1alpha3" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamresourcev1alpha3informers "k8s.io/client-go/informers/resource/v1alpha3" - upstreamresourcev1alpha3listers "k8s.io/client-go/listers/resource/v1alpha3" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - resourcev1alpha3listers "github.com/kcp-dev/client-go/listers/resource/v1alpha3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiresourcev1alpha3 "k8s.io/api/resource/v1alpha3" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + resourcev1alpha3 "k8s.io/client-go/informers/resource/v1alpha3" + listersresourcev1alpha3 "k8s.io/client-go/listers/resource/v1alpha3" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1alpha3 "github.com/kcp-dev/client-go/listers/resource/v1alpha3" ) // ResourceSliceClusterInformer provides access to a shared informer and lister for // ResourceSlices. type ResourceSliceClusterInformer interface { - Cluster(logicalcluster.Name) upstreamresourcev1alpha3informers.ResourceSliceInformer + Cluster(logicalcluster.Name) resourcev1alpha3.ResourceSliceInformer + ClusterWithContext(context.Context, logicalcluster.Name) resourcev1alpha3.ResourceSliceInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() resourcev1alpha3listers.ResourceSliceClusterLister + Lister() kcpv1alpha3.ResourceSliceClusterLister } type resourceSliceClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewResourceSliceClusterInformer constructs a new informer for ResourceSlice type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewResourceSliceClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewResourceSliceClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredResourceSliceClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredResourceSliceClusterInformer constructs a new informer for ResourceSlice type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredResourceSliceClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredResourceSliceClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ResourceV1alpha3().ResourceSlices().List(context.TODO(), options) + return client.ResourceV1alpha3().ResourceSlices().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ResourceV1alpha3().ResourceSlices().Watch(context.TODO(), options) + return client.ResourceV1alpha3().ResourceSlices().Watch(context.Background(), options) }, }, - &resourcev1alpha3.ResourceSlice{}, + &apiresourcev1alpha3.ResourceSlice{}, resyncPeriod, indexers, ) } -func (f *resourceSliceClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *resourceSliceClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredResourceSliceClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *resourceSliceClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiresourcev1alpha3.ResourceSlice{}, i.defaultInformer) } -func (f *resourceSliceClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&resourcev1alpha3.ResourceSlice{}, f.defaultInformer) +func (i *resourceSliceClusterInformer) Lister() kcpv1alpha3.ResourceSliceClusterLister { + return kcpv1alpha3.NewResourceSliceClusterLister(i.Informer().GetIndexer()) } -func (f *resourceSliceClusterInformer) Lister() resourcev1alpha3listers.ResourceSliceClusterLister { - return resourcev1alpha3listers.NewResourceSliceClusterLister(f.Informer().GetIndexer()) +func (i *resourceSliceClusterInformer) Cluster(clusterName logicalcluster.Name) resourcev1alpha3.ResourceSliceInformer { + return &resourceSliceInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *resourceSliceClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamresourcev1alpha3informers.ResourceSliceInformer { +func (i *resourceSliceClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) resourcev1alpha3.ResourceSliceInformer { return &resourceSliceInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type resourceSliceInformer struct { informer cache.SharedIndexInformer - lister upstreamresourcev1alpha3listers.ResourceSliceLister + lister listersresourcev1alpha3.ResourceSliceLister } -func (f *resourceSliceInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *resourceSliceInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *resourceSliceInformer) Lister() upstreamresourcev1alpha3listers.ResourceSliceLister { - return f.lister +func (i *resourceSliceInformer) Lister() listersresourcev1alpha3.ResourceSliceLister { + return i.lister } diff --git a/informers/resource/v1beta1/deviceclass.go b/informers/resource/v1beta1/deviceclass.go index 5a328522f..9b9da3cb2 100644 --- a/informers/resource/v1beta1/deviceclass.go +++ b/informers/resource/v1beta1/deviceclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - resourcev1beta1 "k8s.io/api/resource/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamresourcev1beta1informers "k8s.io/client-go/informers/resource/v1beta1" - upstreamresourcev1beta1listers "k8s.io/client-go/listers/resource/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - resourcev1beta1listers "github.com/kcp-dev/client-go/listers/resource/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiresourcev1beta1 "k8s.io/api/resource/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + resourcev1beta1 "k8s.io/client-go/informers/resource/v1beta1" + listersresourcev1beta1 "k8s.io/client-go/listers/resource/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/resource/v1beta1" ) // DeviceClassClusterInformer provides access to a shared informer and lister for // DeviceClasses. type DeviceClassClusterInformer interface { - Cluster(logicalcluster.Name) upstreamresourcev1beta1informers.DeviceClassInformer + Cluster(logicalcluster.Name) resourcev1beta1.DeviceClassInformer + ClusterWithContext(context.Context, logicalcluster.Name) resourcev1beta1.DeviceClassInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() resourcev1beta1listers.DeviceClassClusterLister + Lister() kcpv1beta1.DeviceClassClusterLister } type deviceClassClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewDeviceClassClusterInformer constructs a new informer for DeviceClass type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewDeviceClassClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewDeviceClassClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredDeviceClassClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredDeviceClassClusterInformer constructs a new informer for DeviceClass type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredDeviceClassClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredDeviceClassClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ResourceV1beta1().DeviceClasses().List(context.TODO(), options) + return client.ResourceV1beta1().DeviceClasses().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ResourceV1beta1().DeviceClasses().Watch(context.TODO(), options) + return client.ResourceV1beta1().DeviceClasses().Watch(context.Background(), options) }, }, - &resourcev1beta1.DeviceClass{}, + &apiresourcev1beta1.DeviceClass{}, resyncPeriod, indexers, ) } -func (f *deviceClassClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *deviceClassClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredDeviceClassClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *deviceClassClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiresourcev1beta1.DeviceClass{}, i.defaultInformer) } -func (f *deviceClassClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&resourcev1beta1.DeviceClass{}, f.defaultInformer) +func (i *deviceClassClusterInformer) Lister() kcpv1beta1.DeviceClassClusterLister { + return kcpv1beta1.NewDeviceClassClusterLister(i.Informer().GetIndexer()) } -func (f *deviceClassClusterInformer) Lister() resourcev1beta1listers.DeviceClassClusterLister { - return resourcev1beta1listers.NewDeviceClassClusterLister(f.Informer().GetIndexer()) +func (i *deviceClassClusterInformer) Cluster(clusterName logicalcluster.Name) resourcev1beta1.DeviceClassInformer { + return &deviceClassInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *deviceClassClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamresourcev1beta1informers.DeviceClassInformer { +func (i *deviceClassClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) resourcev1beta1.DeviceClassInformer { return &deviceClassInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type deviceClassInformer struct { informer cache.SharedIndexInformer - lister upstreamresourcev1beta1listers.DeviceClassLister + lister listersresourcev1beta1.DeviceClassLister } -func (f *deviceClassInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *deviceClassInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *deviceClassInformer) Lister() upstreamresourcev1beta1listers.DeviceClassLister { - return f.lister +func (i *deviceClassInformer) Lister() listersresourcev1beta1.DeviceClassLister { + return i.lister } diff --git a/informers/resource/v1beta1/interface.go b/informers/resource/v1beta1/interface.go index e90d40d95..9766d4ba1 100644 --- a/informers/resource/v1beta1/interface.go +++ b/informers/resource/v1beta1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,51 +14,51 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // ResourceSlices returns a ResourceSliceClusterInformer - ResourceSlices() ResourceSliceClusterInformer - // ResourceClaims returns a ResourceClaimClusterInformer - ResourceClaims() ResourceClaimClusterInformer - // DeviceClasses returns a DeviceClassClusterInformer + // DeviceClasses returns a DeviceClassClusterInformer. DeviceClasses() DeviceClassClusterInformer - // ResourceClaimTemplates returns a ResourceClaimTemplateClusterInformer + // ResourceClaims returns a ResourceClaimClusterInformer. + ResourceClaims() ResourceClaimClusterInformer + // ResourceClaimTemplates returns a ResourceClaimTemplateClusterInformer. ResourceClaimTemplates() ResourceClaimTemplateClusterInformer + // ResourceSlices returns a ResourceSliceClusterInformer. + ResourceSlices() ResourceSliceClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// ResourceSlices returns a ResourceSliceClusterInformer -func (v *version) ResourceSlices() ResourceSliceClusterInformer { - return &resourceSliceClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +// DeviceClasses returns a DeviceClassClusterInformer. +func (v *version) DeviceClasses() DeviceClassClusterInformer { + return &deviceClassClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// ResourceClaims returns a ResourceClaimClusterInformer +// ResourceClaims returns a ResourceClaimClusterInformer. func (v *version) ResourceClaims() ResourceClaimClusterInformer { return &resourceClaimClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// DeviceClasses returns a DeviceClassClusterInformer -func (v *version) DeviceClasses() DeviceClassClusterInformer { - return &deviceClassClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} - -// ResourceClaimTemplates returns a ResourceClaimTemplateClusterInformer +// ResourceClaimTemplates returns a ResourceClaimTemplateClusterInformer. func (v *version) ResourceClaimTemplates() ResourceClaimTemplateClusterInformer { return &resourceClaimTemplateClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } + +// ResourceSlices returns a ResourceSliceClusterInformer. +func (v *version) ResourceSlices() ResourceSliceClusterInformer { + return &resourceSliceClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} diff --git a/informers/resource/v1beta1/resourceclaim.go b/informers/resource/v1beta1/resourceclaim.go index b588d75dc..e634dd1bc 100644 --- a/informers/resource/v1beta1/resourceclaim.go +++ b/informers/resource/v1beta1/resourceclaim.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - resourcev1beta1 "k8s.io/api/resource/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamresourcev1beta1informers "k8s.io/client-go/informers/resource/v1beta1" - upstreamresourcev1beta1listers "k8s.io/client-go/listers/resource/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - resourcev1beta1listers "github.com/kcp-dev/client-go/listers/resource/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiresourcev1beta1 "k8s.io/api/resource/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + resourcev1beta1 "k8s.io/client-go/informers/resource/v1beta1" + listersresourcev1beta1 "k8s.io/client-go/listers/resource/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/resource/v1beta1" ) // ResourceClaimClusterInformer provides access to a shared informer and lister for // ResourceClaims. type ResourceClaimClusterInformer interface { - Cluster(logicalcluster.Name) upstreamresourcev1beta1informers.ResourceClaimInformer + Cluster(logicalcluster.Name) resourcev1beta1.ResourceClaimInformer + ClusterWithContext(context.Context, logicalcluster.Name) resourcev1beta1.ResourceClaimInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() resourcev1beta1listers.ResourceClaimClusterLister + Lister() kcpv1beta1.ResourceClaimClusterLister } type resourceClaimClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewResourceClaimClusterInformer constructs a new informer for ResourceClaim type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewResourceClaimClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewResourceClaimClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredResourceClaimClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredResourceClaimClusterInformer constructs a new informer for ResourceClaim type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredResourceClaimClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredResourceClaimClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ResourceV1beta1().ResourceClaims().List(context.TODO(), options) + return client.ResourceV1beta1().ResourceClaims().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ResourceV1beta1().ResourceClaims().Watch(context.TODO(), options) + return client.ResourceV1beta1().ResourceClaims().Watch(context.Background(), options) }, }, - &resourcev1beta1.ResourceClaim{}, + &apiresourcev1beta1.ResourceClaim{}, resyncPeriod, indexers, ) } -func (f *resourceClaimClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *resourceClaimClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredResourceClaimClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *resourceClaimClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiresourcev1beta1.ResourceClaim{}, i.defaultInformer) } -func (f *resourceClaimClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&resourcev1beta1.ResourceClaim{}, f.defaultInformer) +func (i *resourceClaimClusterInformer) Lister() kcpv1beta1.ResourceClaimClusterLister { + return kcpv1beta1.NewResourceClaimClusterLister(i.Informer().GetIndexer()) } -func (f *resourceClaimClusterInformer) Lister() resourcev1beta1listers.ResourceClaimClusterLister { - return resourcev1beta1listers.NewResourceClaimClusterLister(f.Informer().GetIndexer()) +func (i *resourceClaimClusterInformer) Cluster(clusterName logicalcluster.Name) resourcev1beta1.ResourceClaimInformer { + return &resourceClaimInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *resourceClaimClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamresourcev1beta1informers.ResourceClaimInformer { +func (i *resourceClaimClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) resourcev1beta1.ResourceClaimInformer { return &resourceClaimInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type resourceClaimInformer struct { informer cache.SharedIndexInformer - lister upstreamresourcev1beta1listers.ResourceClaimLister + lister listersresourcev1beta1.ResourceClaimLister } -func (f *resourceClaimInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *resourceClaimInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *resourceClaimInformer) Lister() upstreamresourcev1beta1listers.ResourceClaimLister { - return f.lister +func (i *resourceClaimInformer) Lister() listersresourcev1beta1.ResourceClaimLister { + return i.lister } diff --git a/informers/resource/v1beta1/resourceclaimtemplate.go b/informers/resource/v1beta1/resourceclaimtemplate.go index 6b1fd9661..0fd03f6d4 100644 --- a/informers/resource/v1beta1/resourceclaimtemplate.go +++ b/informers/resource/v1beta1/resourceclaimtemplate.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - resourcev1beta1 "k8s.io/api/resource/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamresourcev1beta1informers "k8s.io/client-go/informers/resource/v1beta1" - upstreamresourcev1beta1listers "k8s.io/client-go/listers/resource/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - resourcev1beta1listers "github.com/kcp-dev/client-go/listers/resource/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiresourcev1beta1 "k8s.io/api/resource/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + resourcev1beta1 "k8s.io/client-go/informers/resource/v1beta1" + listersresourcev1beta1 "k8s.io/client-go/listers/resource/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/resource/v1beta1" ) // ResourceClaimTemplateClusterInformer provides access to a shared informer and lister for // ResourceClaimTemplates. type ResourceClaimTemplateClusterInformer interface { - Cluster(logicalcluster.Name) upstreamresourcev1beta1informers.ResourceClaimTemplateInformer + Cluster(logicalcluster.Name) resourcev1beta1.ResourceClaimTemplateInformer + ClusterWithContext(context.Context, logicalcluster.Name) resourcev1beta1.ResourceClaimTemplateInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() resourcev1beta1listers.ResourceClaimTemplateClusterLister + Lister() kcpv1beta1.ResourceClaimTemplateClusterLister } type resourceClaimTemplateClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewResourceClaimTemplateClusterInformer constructs a new informer for ResourceClaimTemplate type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewResourceClaimTemplateClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewResourceClaimTemplateClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredResourceClaimTemplateClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredResourceClaimTemplateClusterInformer constructs a new informer for ResourceClaimTemplate type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredResourceClaimTemplateClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredResourceClaimTemplateClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ResourceV1beta1().ResourceClaimTemplates().List(context.TODO(), options) + return client.ResourceV1beta1().ResourceClaimTemplates().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ResourceV1beta1().ResourceClaimTemplates().Watch(context.TODO(), options) + return client.ResourceV1beta1().ResourceClaimTemplates().Watch(context.Background(), options) }, }, - &resourcev1beta1.ResourceClaimTemplate{}, + &apiresourcev1beta1.ResourceClaimTemplate{}, resyncPeriod, indexers, ) } -func (f *resourceClaimTemplateClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *resourceClaimTemplateClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredResourceClaimTemplateClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *resourceClaimTemplateClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiresourcev1beta1.ResourceClaimTemplate{}, i.defaultInformer) } -func (f *resourceClaimTemplateClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&resourcev1beta1.ResourceClaimTemplate{}, f.defaultInformer) +func (i *resourceClaimTemplateClusterInformer) Lister() kcpv1beta1.ResourceClaimTemplateClusterLister { + return kcpv1beta1.NewResourceClaimTemplateClusterLister(i.Informer().GetIndexer()) } -func (f *resourceClaimTemplateClusterInformer) Lister() resourcev1beta1listers.ResourceClaimTemplateClusterLister { - return resourcev1beta1listers.NewResourceClaimTemplateClusterLister(f.Informer().GetIndexer()) +func (i *resourceClaimTemplateClusterInformer) Cluster(clusterName logicalcluster.Name) resourcev1beta1.ResourceClaimTemplateInformer { + return &resourceClaimTemplateInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *resourceClaimTemplateClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamresourcev1beta1informers.ResourceClaimTemplateInformer { +func (i *resourceClaimTemplateClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) resourcev1beta1.ResourceClaimTemplateInformer { return &resourceClaimTemplateInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type resourceClaimTemplateInformer struct { informer cache.SharedIndexInformer - lister upstreamresourcev1beta1listers.ResourceClaimTemplateLister + lister listersresourcev1beta1.ResourceClaimTemplateLister } -func (f *resourceClaimTemplateInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *resourceClaimTemplateInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *resourceClaimTemplateInformer) Lister() upstreamresourcev1beta1listers.ResourceClaimTemplateLister { - return f.lister +func (i *resourceClaimTemplateInformer) Lister() listersresourcev1beta1.ResourceClaimTemplateLister { + return i.lister } diff --git a/informers/resource/v1beta1/resourceslice.go b/informers/resource/v1beta1/resourceslice.go index 366f4b63a..6d1b6ca85 100644 --- a/informers/resource/v1beta1/resourceslice.go +++ b/informers/resource/v1beta1/resourceslice.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - resourcev1beta1 "k8s.io/api/resource/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamresourcev1beta1informers "k8s.io/client-go/informers/resource/v1beta1" - upstreamresourcev1beta1listers "k8s.io/client-go/listers/resource/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - resourcev1beta1listers "github.com/kcp-dev/client-go/listers/resource/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apiresourcev1beta1 "k8s.io/api/resource/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + resourcev1beta1 "k8s.io/client-go/informers/resource/v1beta1" + listersresourcev1beta1 "k8s.io/client-go/listers/resource/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/resource/v1beta1" ) // ResourceSliceClusterInformer provides access to a shared informer and lister for // ResourceSlices. type ResourceSliceClusterInformer interface { - Cluster(logicalcluster.Name) upstreamresourcev1beta1informers.ResourceSliceInformer + Cluster(logicalcluster.Name) resourcev1beta1.ResourceSliceInformer + ClusterWithContext(context.Context, logicalcluster.Name) resourcev1beta1.ResourceSliceInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() resourcev1beta1listers.ResourceSliceClusterLister + Lister() kcpv1beta1.ResourceSliceClusterLister } type resourceSliceClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewResourceSliceClusterInformer constructs a new informer for ResourceSlice type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewResourceSliceClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewResourceSliceClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredResourceSliceClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredResourceSliceClusterInformer constructs a new informer for ResourceSlice type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredResourceSliceClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredResourceSliceClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ResourceV1beta1().ResourceSlices().List(context.TODO(), options) + return client.ResourceV1beta1().ResourceSlices().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ResourceV1beta1().ResourceSlices().Watch(context.TODO(), options) + return client.ResourceV1beta1().ResourceSlices().Watch(context.Background(), options) }, }, - &resourcev1beta1.ResourceSlice{}, + &apiresourcev1beta1.ResourceSlice{}, resyncPeriod, indexers, ) } -func (f *resourceSliceClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *resourceSliceClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredResourceSliceClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *resourceSliceClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apiresourcev1beta1.ResourceSlice{}, i.defaultInformer) } -func (f *resourceSliceClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&resourcev1beta1.ResourceSlice{}, f.defaultInformer) +func (i *resourceSliceClusterInformer) Lister() kcpv1beta1.ResourceSliceClusterLister { + return kcpv1beta1.NewResourceSliceClusterLister(i.Informer().GetIndexer()) } -func (f *resourceSliceClusterInformer) Lister() resourcev1beta1listers.ResourceSliceClusterLister { - return resourcev1beta1listers.NewResourceSliceClusterLister(f.Informer().GetIndexer()) +func (i *resourceSliceClusterInformer) Cluster(clusterName logicalcluster.Name) resourcev1beta1.ResourceSliceInformer { + return &resourceSliceInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *resourceSliceClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamresourcev1beta1informers.ResourceSliceInformer { +func (i *resourceSliceClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) resourcev1beta1.ResourceSliceInformer { return &resourceSliceInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type resourceSliceInformer struct { informer cache.SharedIndexInformer - lister upstreamresourcev1beta1listers.ResourceSliceLister + lister listersresourcev1beta1.ResourceSliceLister } -func (f *resourceSliceInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *resourceSliceInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *resourceSliceInformer) Lister() upstreamresourcev1beta1listers.ResourceSliceLister { - return f.lister +func (i *resourceSliceInformer) Lister() listersresourcev1beta1.ResourceSliceLister { + return i.lister } diff --git a/informers/scheduling/interface.go b/informers/scheduling/interface.go index bac57de4f..febcf3f2d 100644 --- a/informers/scheduling/interface.go +++ b/informers/scheduling/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,47 +14,48 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package scheduling import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" - "github.com/kcp-dev/client-go/informers/scheduling/v1" - "github.com/kcp-dev/client-go/informers/scheduling/v1alpha1" - "github.com/kcp-dev/client-go/informers/scheduling/v1beta1" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpv1 "github.com/kcp-dev/client-go/informers/scheduling/v1" + kcpv1alpha1 "github.com/kcp-dev/client-go/informers/scheduling/v1alpha1" + kcpv1beta1 "github.com/kcp-dev/client-go/informers/scheduling/v1beta1" ) +// ClusterInterface provides access to each of this group's versions. type ClusterInterface interface { - // V1 provides access to the shared informers in V1. - V1() v1.ClusterInterface - // V1alpha1 provides access to the shared informers in V1alpha1. - V1alpha1() v1alpha1.ClusterInterface - // V1beta1 provides access to the shared informers in V1beta1. - V1beta1() v1beta1.ClusterInterface + // V1 provides access to shared informers for resources in V1. + V1() kcpv1.ClusterInterface + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() kcpv1alpha1.ClusterInterface + // V1beta1 provides access to shared informers for resources in V1beta1. + V1beta1() kcpv1beta1.ClusterInterface } type group struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &group{factory: f, tweakListOptions: tweakListOptions} } -// V1 returns a new v1.ClusterInterface. -func (g *group) V1() v1.ClusterInterface { - return v1.New(g.factory, g.tweakListOptions) +// V1 returns a new kcpv1.ClusterInterface. +func (g *group) V1() kcpv1.ClusterInterface { + return kcpv1.New(g.factory, g.tweakListOptions) } -// V1alpha1 returns a new v1alpha1.ClusterInterface. -func (g *group) V1alpha1() v1alpha1.ClusterInterface { - return v1alpha1.New(g.factory, g.tweakListOptions) +// V1alpha1 returns a new kcpv1alpha1.ClusterInterface. +func (g *group) V1alpha1() kcpv1alpha1.ClusterInterface { + return kcpv1alpha1.New(g.factory, g.tweakListOptions) } -// V1beta1 returns a new v1beta1.ClusterInterface. -func (g *group) V1beta1() v1beta1.ClusterInterface { - return v1beta1.New(g.factory, g.tweakListOptions) +// V1beta1 returns a new kcpv1beta1.ClusterInterface. +func (g *group) V1beta1() kcpv1beta1.ClusterInterface { + return kcpv1beta1.New(g.factory, g.tweakListOptions) } diff --git a/informers/scheduling/v1/interface.go b/informers/scheduling/v1/interface.go index 085b87606..5cba2c63e 100644 --- a/informers/scheduling/v1/interface.go +++ b/informers/scheduling/v1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,30 +14,30 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // PriorityClasses returns a PriorityClassClusterInformer + // PriorityClasses returns a PriorityClassClusterInformer. PriorityClasses() PriorityClassClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// PriorityClasses returns a PriorityClassClusterInformer +// PriorityClasses returns a PriorityClassClusterInformer. func (v *version) PriorityClasses() PriorityClassClusterInformer { return &priorityClassClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/scheduling/v1/priorityclass.go b/informers/scheduling/v1/priorityclass.go index 296fe2326..35bb0ea37 100644 --- a/informers/scheduling/v1/priorityclass.go +++ b/informers/scheduling/v1/priorityclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - schedulingv1 "k8s.io/api/scheduling/v1" + apischedulingv1 "k8s.io/api/scheduling/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamschedulingv1informers "k8s.io/client-go/informers/scheduling/v1" - upstreamschedulingv1listers "k8s.io/client-go/listers/scheduling/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - schedulingv1listers "github.com/kcp-dev/client-go/listers/scheduling/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + schedulingv1 "k8s.io/client-go/informers/scheduling/v1" + listersschedulingv1 "k8s.io/client-go/listers/scheduling/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/scheduling/v1" ) // PriorityClassClusterInformer provides access to a shared informer and lister for // PriorityClasses. type PriorityClassClusterInformer interface { - Cluster(logicalcluster.Name) upstreamschedulingv1informers.PriorityClassInformer + Cluster(logicalcluster.Name) schedulingv1.PriorityClassInformer + ClusterWithContext(context.Context, logicalcluster.Name) schedulingv1.PriorityClassInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() schedulingv1listers.PriorityClassClusterLister + Lister() kcpv1.PriorityClassClusterLister } type priorityClassClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewPriorityClassClusterInformer constructs a new informer for PriorityClass type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewPriorityClassClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewPriorityClassClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredPriorityClassClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredPriorityClassClusterInformer constructs a new informer for PriorityClass type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredPriorityClassClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredPriorityClassClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.SchedulingV1().PriorityClasses().List(context.TODO(), options) + return client.SchedulingV1().PriorityClasses().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.SchedulingV1().PriorityClasses().Watch(context.TODO(), options) + return client.SchedulingV1().PriorityClasses().Watch(context.Background(), options) }, }, - &schedulingv1.PriorityClass{}, + &apischedulingv1.PriorityClass{}, resyncPeriod, indexers, ) } -func (f *priorityClassClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *priorityClassClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredPriorityClassClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *priorityClassClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apischedulingv1.PriorityClass{}, i.defaultInformer) } -func (f *priorityClassClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&schedulingv1.PriorityClass{}, f.defaultInformer) +func (i *priorityClassClusterInformer) Lister() kcpv1.PriorityClassClusterLister { + return kcpv1.NewPriorityClassClusterLister(i.Informer().GetIndexer()) } -func (f *priorityClassClusterInformer) Lister() schedulingv1listers.PriorityClassClusterLister { - return schedulingv1listers.NewPriorityClassClusterLister(f.Informer().GetIndexer()) +func (i *priorityClassClusterInformer) Cluster(clusterName logicalcluster.Name) schedulingv1.PriorityClassInformer { + return &priorityClassInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *priorityClassClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamschedulingv1informers.PriorityClassInformer { +func (i *priorityClassClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) schedulingv1.PriorityClassInformer { return &priorityClassInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type priorityClassInformer struct { informer cache.SharedIndexInformer - lister upstreamschedulingv1listers.PriorityClassLister + lister listersschedulingv1.PriorityClassLister } -func (f *priorityClassInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *priorityClassInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *priorityClassInformer) Lister() upstreamschedulingv1listers.PriorityClassLister { - return f.lister +func (i *priorityClassInformer) Lister() listersschedulingv1.PriorityClassLister { + return i.lister } diff --git a/informers/scheduling/v1alpha1/interface.go b/informers/scheduling/v1alpha1/interface.go index d081ef176..d77bc7fab 100644 --- a/informers/scheduling/v1alpha1/interface.go +++ b/informers/scheduling/v1alpha1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,30 +14,30 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // PriorityClasses returns a PriorityClassClusterInformer + // PriorityClasses returns a PriorityClassClusterInformer. PriorityClasses() PriorityClassClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// PriorityClasses returns a PriorityClassClusterInformer +// PriorityClasses returns a PriorityClassClusterInformer. func (v *version) PriorityClasses() PriorityClassClusterInformer { return &priorityClassClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/scheduling/v1alpha1/priorityclass.go b/informers/scheduling/v1alpha1/priorityclass.go index 7bb2e839b..27774710a 100644 --- a/informers/scheduling/v1alpha1/priorityclass.go +++ b/informers/scheduling/v1alpha1/priorityclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - schedulingv1alpha1 "k8s.io/api/scheduling/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamschedulingv1alpha1informers "k8s.io/client-go/informers/scheduling/v1alpha1" - upstreamschedulingv1alpha1listers "k8s.io/client-go/listers/scheduling/v1alpha1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - schedulingv1alpha1listers "github.com/kcp-dev/client-go/listers/scheduling/v1alpha1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apischedulingv1alpha1 "k8s.io/api/scheduling/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + schedulingv1alpha1 "k8s.io/client-go/informers/scheduling/v1alpha1" + listersschedulingv1alpha1 "k8s.io/client-go/listers/scheduling/v1alpha1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1alpha1 "github.com/kcp-dev/client-go/listers/scheduling/v1alpha1" ) // PriorityClassClusterInformer provides access to a shared informer and lister for // PriorityClasses. type PriorityClassClusterInformer interface { - Cluster(logicalcluster.Name) upstreamschedulingv1alpha1informers.PriorityClassInformer + Cluster(logicalcluster.Name) schedulingv1alpha1.PriorityClassInformer + ClusterWithContext(context.Context, logicalcluster.Name) schedulingv1alpha1.PriorityClassInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() schedulingv1alpha1listers.PriorityClassClusterLister + Lister() kcpv1alpha1.PriorityClassClusterLister } type priorityClassClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewPriorityClassClusterInformer constructs a new informer for PriorityClass type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewPriorityClassClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewPriorityClassClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredPriorityClassClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredPriorityClassClusterInformer constructs a new informer for PriorityClass type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredPriorityClassClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredPriorityClassClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.SchedulingV1alpha1().PriorityClasses().List(context.TODO(), options) + return client.SchedulingV1alpha1().PriorityClasses().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.SchedulingV1alpha1().PriorityClasses().Watch(context.TODO(), options) + return client.SchedulingV1alpha1().PriorityClasses().Watch(context.Background(), options) }, }, - &schedulingv1alpha1.PriorityClass{}, + &apischedulingv1alpha1.PriorityClass{}, resyncPeriod, indexers, ) } -func (f *priorityClassClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *priorityClassClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredPriorityClassClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *priorityClassClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apischedulingv1alpha1.PriorityClass{}, i.defaultInformer) } -func (f *priorityClassClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&schedulingv1alpha1.PriorityClass{}, f.defaultInformer) +func (i *priorityClassClusterInformer) Lister() kcpv1alpha1.PriorityClassClusterLister { + return kcpv1alpha1.NewPriorityClassClusterLister(i.Informer().GetIndexer()) } -func (f *priorityClassClusterInformer) Lister() schedulingv1alpha1listers.PriorityClassClusterLister { - return schedulingv1alpha1listers.NewPriorityClassClusterLister(f.Informer().GetIndexer()) +func (i *priorityClassClusterInformer) Cluster(clusterName logicalcluster.Name) schedulingv1alpha1.PriorityClassInformer { + return &priorityClassInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *priorityClassClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamschedulingv1alpha1informers.PriorityClassInformer { +func (i *priorityClassClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) schedulingv1alpha1.PriorityClassInformer { return &priorityClassInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type priorityClassInformer struct { informer cache.SharedIndexInformer - lister upstreamschedulingv1alpha1listers.PriorityClassLister + lister listersschedulingv1alpha1.PriorityClassLister } -func (f *priorityClassInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *priorityClassInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *priorityClassInformer) Lister() upstreamschedulingv1alpha1listers.PriorityClassLister { - return f.lister +func (i *priorityClassInformer) Lister() listersschedulingv1alpha1.PriorityClassLister { + return i.lister } diff --git a/informers/scheduling/v1beta1/interface.go b/informers/scheduling/v1beta1/interface.go index f41c8f9a7..9de5dce35 100644 --- a/informers/scheduling/v1beta1/interface.go +++ b/informers/scheduling/v1beta1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,30 +14,30 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // PriorityClasses returns a PriorityClassClusterInformer + // PriorityClasses returns a PriorityClassClusterInformer. PriorityClasses() PriorityClassClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// PriorityClasses returns a PriorityClassClusterInformer +// PriorityClasses returns a PriorityClassClusterInformer. func (v *version) PriorityClasses() PriorityClassClusterInformer { return &priorityClassClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/scheduling/v1beta1/priorityclass.go b/informers/scheduling/v1beta1/priorityclass.go index eef8861ae..b5fe9362e 100644 --- a/informers/scheduling/v1beta1/priorityclass.go +++ b/informers/scheduling/v1beta1/priorityclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - schedulingv1beta1 "k8s.io/api/scheduling/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamschedulingv1beta1informers "k8s.io/client-go/informers/scheduling/v1beta1" - upstreamschedulingv1beta1listers "k8s.io/client-go/listers/scheduling/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - schedulingv1beta1listers "github.com/kcp-dev/client-go/listers/scheduling/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apischedulingv1beta1 "k8s.io/api/scheduling/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + schedulingv1beta1 "k8s.io/client-go/informers/scheduling/v1beta1" + listersschedulingv1beta1 "k8s.io/client-go/listers/scheduling/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/scheduling/v1beta1" ) // PriorityClassClusterInformer provides access to a shared informer and lister for // PriorityClasses. type PriorityClassClusterInformer interface { - Cluster(logicalcluster.Name) upstreamschedulingv1beta1informers.PriorityClassInformer + Cluster(logicalcluster.Name) schedulingv1beta1.PriorityClassInformer + ClusterWithContext(context.Context, logicalcluster.Name) schedulingv1beta1.PriorityClassInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() schedulingv1beta1listers.PriorityClassClusterLister + Lister() kcpv1beta1.PriorityClassClusterLister } type priorityClassClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewPriorityClassClusterInformer constructs a new informer for PriorityClass type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewPriorityClassClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewPriorityClassClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredPriorityClassClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredPriorityClassClusterInformer constructs a new informer for PriorityClass type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredPriorityClassClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredPriorityClassClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.SchedulingV1beta1().PriorityClasses().List(context.TODO(), options) + return client.SchedulingV1beta1().PriorityClasses().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.SchedulingV1beta1().PriorityClasses().Watch(context.TODO(), options) + return client.SchedulingV1beta1().PriorityClasses().Watch(context.Background(), options) }, }, - &schedulingv1beta1.PriorityClass{}, + &apischedulingv1beta1.PriorityClass{}, resyncPeriod, indexers, ) } -func (f *priorityClassClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *priorityClassClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredPriorityClassClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *priorityClassClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apischedulingv1beta1.PriorityClass{}, i.defaultInformer) } -func (f *priorityClassClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&schedulingv1beta1.PriorityClass{}, f.defaultInformer) +func (i *priorityClassClusterInformer) Lister() kcpv1beta1.PriorityClassClusterLister { + return kcpv1beta1.NewPriorityClassClusterLister(i.Informer().GetIndexer()) } -func (f *priorityClassClusterInformer) Lister() schedulingv1beta1listers.PriorityClassClusterLister { - return schedulingv1beta1listers.NewPriorityClassClusterLister(f.Informer().GetIndexer()) +func (i *priorityClassClusterInformer) Cluster(clusterName logicalcluster.Name) schedulingv1beta1.PriorityClassInformer { + return &priorityClassInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *priorityClassClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamschedulingv1beta1informers.PriorityClassInformer { +func (i *priorityClassClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) schedulingv1beta1.PriorityClassInformer { return &priorityClassInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type priorityClassInformer struct { informer cache.SharedIndexInformer - lister upstreamschedulingv1beta1listers.PriorityClassLister + lister listersschedulingv1beta1.PriorityClassLister } -func (f *priorityClassInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *priorityClassInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *priorityClassInformer) Lister() upstreamschedulingv1beta1listers.PriorityClassLister { - return f.lister +func (i *priorityClassInformer) Lister() listersschedulingv1beta1.PriorityClassLister { + return i.lister } diff --git a/informers/storage/interface.go b/informers/storage/interface.go index 200390200..c9bc8271f 100644 --- a/informers/storage/interface.go +++ b/informers/storage/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,47 +14,48 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package storage import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" - "github.com/kcp-dev/client-go/informers/storage/v1" - "github.com/kcp-dev/client-go/informers/storage/v1alpha1" - "github.com/kcp-dev/client-go/informers/storage/v1beta1" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpv1 "github.com/kcp-dev/client-go/informers/storage/v1" + kcpv1alpha1 "github.com/kcp-dev/client-go/informers/storage/v1alpha1" + kcpv1beta1 "github.com/kcp-dev/client-go/informers/storage/v1beta1" ) +// ClusterInterface provides access to each of this group's versions. type ClusterInterface interface { - // V1 provides access to the shared informers in V1. - V1() v1.ClusterInterface - // V1alpha1 provides access to the shared informers in V1alpha1. - V1alpha1() v1alpha1.ClusterInterface - // V1beta1 provides access to the shared informers in V1beta1. - V1beta1() v1beta1.ClusterInterface + // V1 provides access to shared informers for resources in V1. + V1() kcpv1.ClusterInterface + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() kcpv1alpha1.ClusterInterface + // V1beta1 provides access to shared informers for resources in V1beta1. + V1beta1() kcpv1beta1.ClusterInterface } type group struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &group{factory: f, tweakListOptions: tweakListOptions} } -// V1 returns a new v1.ClusterInterface. -func (g *group) V1() v1.ClusterInterface { - return v1.New(g.factory, g.tweakListOptions) +// V1 returns a new kcpv1.ClusterInterface. +func (g *group) V1() kcpv1.ClusterInterface { + return kcpv1.New(g.factory, g.tweakListOptions) } -// V1alpha1 returns a new v1alpha1.ClusterInterface. -func (g *group) V1alpha1() v1alpha1.ClusterInterface { - return v1alpha1.New(g.factory, g.tweakListOptions) +// V1alpha1 returns a new kcpv1alpha1.ClusterInterface. +func (g *group) V1alpha1() kcpv1alpha1.ClusterInterface { + return kcpv1alpha1.New(g.factory, g.tweakListOptions) } -// V1beta1 returns a new v1beta1.ClusterInterface. -func (g *group) V1beta1() v1beta1.ClusterInterface { - return v1beta1.New(g.factory, g.tweakListOptions) +// V1beta1 returns a new kcpv1beta1.ClusterInterface. +func (g *group) V1beta1() kcpv1beta1.ClusterInterface { + return kcpv1beta1.New(g.factory, g.tweakListOptions) } diff --git a/informers/storage/v1/csidriver.go b/informers/storage/v1/csidriver.go index 6e67066c5..9381ea440 100644 --- a/informers/storage/v1/csidriver.go +++ b/informers/storage/v1/csidriver.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - storagev1 "k8s.io/api/storage/v1" + apistoragev1 "k8s.io/api/storage/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamstoragev1informers "k8s.io/client-go/informers/storage/v1" - upstreamstoragev1listers "k8s.io/client-go/listers/storage/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - storagev1listers "github.com/kcp-dev/client-go/listers/storage/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + storagev1 "k8s.io/client-go/informers/storage/v1" + listersstoragev1 "k8s.io/client-go/listers/storage/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/storage/v1" ) // CSIDriverClusterInformer provides access to a shared informer and lister for // CSIDrivers. type CSIDriverClusterInformer interface { - Cluster(logicalcluster.Name) upstreamstoragev1informers.CSIDriverInformer + Cluster(logicalcluster.Name) storagev1.CSIDriverInformer + ClusterWithContext(context.Context, logicalcluster.Name) storagev1.CSIDriverInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() storagev1listers.CSIDriverClusterLister + Lister() kcpv1.CSIDriverClusterLister } type cSIDriverClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewCSIDriverClusterInformer constructs a new informer for CSIDriver type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewCSIDriverClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewCSIDriverClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredCSIDriverClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredCSIDriverClusterInformer constructs a new informer for CSIDriver type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredCSIDriverClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredCSIDriverClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.StorageV1().CSIDrivers().List(context.TODO(), options) + return client.StorageV1().CSIDrivers().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.StorageV1().CSIDrivers().Watch(context.TODO(), options) + return client.StorageV1().CSIDrivers().Watch(context.Background(), options) }, }, - &storagev1.CSIDriver{}, + &apistoragev1.CSIDriver{}, resyncPeriod, indexers, ) } -func (f *cSIDriverClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *cSIDriverClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredCSIDriverClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *cSIDriverClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apistoragev1.CSIDriver{}, i.defaultInformer) } -func (f *cSIDriverClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&storagev1.CSIDriver{}, f.defaultInformer) +func (i *cSIDriverClusterInformer) Lister() kcpv1.CSIDriverClusterLister { + return kcpv1.NewCSIDriverClusterLister(i.Informer().GetIndexer()) } -func (f *cSIDriverClusterInformer) Lister() storagev1listers.CSIDriverClusterLister { - return storagev1listers.NewCSIDriverClusterLister(f.Informer().GetIndexer()) +func (i *cSIDriverClusterInformer) Cluster(clusterName logicalcluster.Name) storagev1.CSIDriverInformer { + return &cSIDriverInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *cSIDriverClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamstoragev1informers.CSIDriverInformer { +func (i *cSIDriverClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) storagev1.CSIDriverInformer { return &cSIDriverInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type cSIDriverInformer struct { informer cache.SharedIndexInformer - lister upstreamstoragev1listers.CSIDriverLister + lister listersstoragev1.CSIDriverLister } -func (f *cSIDriverInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *cSIDriverInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *cSIDriverInformer) Lister() upstreamstoragev1listers.CSIDriverLister { - return f.lister +func (i *cSIDriverInformer) Lister() listersstoragev1.CSIDriverLister { + return i.lister } diff --git a/informers/storage/v1/csinode.go b/informers/storage/v1/csinode.go index 917090fa6..bd5905137 100644 --- a/informers/storage/v1/csinode.go +++ b/informers/storage/v1/csinode.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - storagev1 "k8s.io/api/storage/v1" + apistoragev1 "k8s.io/api/storage/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamstoragev1informers "k8s.io/client-go/informers/storage/v1" - upstreamstoragev1listers "k8s.io/client-go/listers/storage/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - storagev1listers "github.com/kcp-dev/client-go/listers/storage/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + storagev1 "k8s.io/client-go/informers/storage/v1" + listersstoragev1 "k8s.io/client-go/listers/storage/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/storage/v1" ) // CSINodeClusterInformer provides access to a shared informer and lister for // CSINodes. type CSINodeClusterInformer interface { - Cluster(logicalcluster.Name) upstreamstoragev1informers.CSINodeInformer + Cluster(logicalcluster.Name) storagev1.CSINodeInformer + ClusterWithContext(context.Context, logicalcluster.Name) storagev1.CSINodeInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() storagev1listers.CSINodeClusterLister + Lister() kcpv1.CSINodeClusterLister } type cSINodeClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewCSINodeClusterInformer constructs a new informer for CSINode type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewCSINodeClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewCSINodeClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredCSINodeClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredCSINodeClusterInformer constructs a new informer for CSINode type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredCSINodeClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredCSINodeClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.StorageV1().CSINodes().List(context.TODO(), options) + return client.StorageV1().CSINodes().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.StorageV1().CSINodes().Watch(context.TODO(), options) + return client.StorageV1().CSINodes().Watch(context.Background(), options) }, }, - &storagev1.CSINode{}, + &apistoragev1.CSINode{}, resyncPeriod, indexers, ) } -func (f *cSINodeClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *cSINodeClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredCSINodeClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *cSINodeClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apistoragev1.CSINode{}, i.defaultInformer) } -func (f *cSINodeClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&storagev1.CSINode{}, f.defaultInformer) +func (i *cSINodeClusterInformer) Lister() kcpv1.CSINodeClusterLister { + return kcpv1.NewCSINodeClusterLister(i.Informer().GetIndexer()) } -func (f *cSINodeClusterInformer) Lister() storagev1listers.CSINodeClusterLister { - return storagev1listers.NewCSINodeClusterLister(f.Informer().GetIndexer()) +func (i *cSINodeClusterInformer) Cluster(clusterName logicalcluster.Name) storagev1.CSINodeInformer { + return &cSINodeInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *cSINodeClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamstoragev1informers.CSINodeInformer { +func (i *cSINodeClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) storagev1.CSINodeInformer { return &cSINodeInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type cSINodeInformer struct { informer cache.SharedIndexInformer - lister upstreamstoragev1listers.CSINodeLister + lister listersstoragev1.CSINodeLister } -func (f *cSINodeInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *cSINodeInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *cSINodeInformer) Lister() upstreamstoragev1listers.CSINodeLister { - return f.lister +func (i *cSINodeInformer) Lister() listersstoragev1.CSINodeLister { + return i.lister } diff --git a/informers/storage/v1/csistoragecapacity.go b/informers/storage/v1/csistoragecapacity.go index 88efd4729..6c5c4bc8a 100644 --- a/informers/storage/v1/csistoragecapacity.go +++ b/informers/storage/v1/csistoragecapacity.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - storagev1 "k8s.io/api/storage/v1" + apistoragev1 "k8s.io/api/storage/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamstoragev1informers "k8s.io/client-go/informers/storage/v1" - upstreamstoragev1listers "k8s.io/client-go/listers/storage/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - storagev1listers "github.com/kcp-dev/client-go/listers/storage/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + storagev1 "k8s.io/client-go/informers/storage/v1" + listersstoragev1 "k8s.io/client-go/listers/storage/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/storage/v1" ) // CSIStorageCapacityClusterInformer provides access to a shared informer and lister for // CSIStorageCapacities. type CSIStorageCapacityClusterInformer interface { - Cluster(logicalcluster.Name) upstreamstoragev1informers.CSIStorageCapacityInformer + Cluster(logicalcluster.Name) storagev1.CSIStorageCapacityInformer + ClusterWithContext(context.Context, logicalcluster.Name) storagev1.CSIStorageCapacityInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() storagev1listers.CSIStorageCapacityClusterLister + Lister() kcpv1.CSIStorageCapacityClusterLister } type cSIStorageCapacityClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewCSIStorageCapacityClusterInformer constructs a new informer for CSIStorageCapacity type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewCSIStorageCapacityClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewCSIStorageCapacityClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredCSIStorageCapacityClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredCSIStorageCapacityClusterInformer constructs a new informer for CSIStorageCapacity type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredCSIStorageCapacityClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredCSIStorageCapacityClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.StorageV1().CSIStorageCapacities().List(context.TODO(), options) + return client.StorageV1().CSIStorageCapacities().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.StorageV1().CSIStorageCapacities().Watch(context.TODO(), options) + return client.StorageV1().CSIStorageCapacities().Watch(context.Background(), options) }, }, - &storagev1.CSIStorageCapacity{}, + &apistoragev1.CSIStorageCapacity{}, resyncPeriod, indexers, ) } -func (f *cSIStorageCapacityClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *cSIStorageCapacityClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredCSIStorageCapacityClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *cSIStorageCapacityClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apistoragev1.CSIStorageCapacity{}, i.defaultInformer) } -func (f *cSIStorageCapacityClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&storagev1.CSIStorageCapacity{}, f.defaultInformer) +func (i *cSIStorageCapacityClusterInformer) Lister() kcpv1.CSIStorageCapacityClusterLister { + return kcpv1.NewCSIStorageCapacityClusterLister(i.Informer().GetIndexer()) } -func (f *cSIStorageCapacityClusterInformer) Lister() storagev1listers.CSIStorageCapacityClusterLister { - return storagev1listers.NewCSIStorageCapacityClusterLister(f.Informer().GetIndexer()) +func (i *cSIStorageCapacityClusterInformer) Cluster(clusterName logicalcluster.Name) storagev1.CSIStorageCapacityInformer { + return &cSIStorageCapacityInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *cSIStorageCapacityClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamstoragev1informers.CSIStorageCapacityInformer { +func (i *cSIStorageCapacityClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) storagev1.CSIStorageCapacityInformer { return &cSIStorageCapacityInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type cSIStorageCapacityInformer struct { informer cache.SharedIndexInformer - lister upstreamstoragev1listers.CSIStorageCapacityLister + lister listersstoragev1.CSIStorageCapacityLister } -func (f *cSIStorageCapacityInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *cSIStorageCapacityInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *cSIStorageCapacityInformer) Lister() upstreamstoragev1listers.CSIStorageCapacityLister { - return f.lister +func (i *cSIStorageCapacityInformer) Lister() listersstoragev1.CSIStorageCapacityLister { + return i.lister } diff --git a/informers/storage/v1/interface.go b/informers/storage/v1/interface.go index ade984a86..a64dffb37 100644 --- a/informers/storage/v1/interface.go +++ b/informers/storage/v1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,58 +14,58 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // StorageClasses returns a StorageClassClusterInformer - StorageClasses() StorageClassClusterInformer - // VolumeAttachments returns a VolumeAttachmentClusterInformer - VolumeAttachments() VolumeAttachmentClusterInformer - // CSIDrivers returns a CSIDriverClusterInformer + // CSIDrivers returns a CSIDriverClusterInformer. CSIDrivers() CSIDriverClusterInformer - // CSINodes returns a CSINodeClusterInformer + // CSINodes returns a CSINodeClusterInformer. CSINodes() CSINodeClusterInformer - // CSIStorageCapacities returns a CSIStorageCapacityClusterInformer + // CSIStorageCapacities returns a CSIStorageCapacityClusterInformer. CSIStorageCapacities() CSIStorageCapacityClusterInformer + // StorageClasses returns a StorageClassClusterInformer. + StorageClasses() StorageClassClusterInformer + // VolumeAttachments returns a VolumeAttachmentClusterInformer. + VolumeAttachments() VolumeAttachmentClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// StorageClasses returns a StorageClassClusterInformer -func (v *version) StorageClasses() StorageClassClusterInformer { - return &storageClassClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} - -// VolumeAttachments returns a VolumeAttachmentClusterInformer -func (v *version) VolumeAttachments() VolumeAttachmentClusterInformer { - return &volumeAttachmentClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} - -// CSIDrivers returns a CSIDriverClusterInformer +// CSIDrivers returns a CSIDriverClusterInformer. func (v *version) CSIDrivers() CSIDriverClusterInformer { return &cSIDriverClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// CSINodes returns a CSINodeClusterInformer +// CSINodes returns a CSINodeClusterInformer. func (v *version) CSINodes() CSINodeClusterInformer { return &cSINodeClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// CSIStorageCapacities returns a CSIStorageCapacityClusterInformer +// CSIStorageCapacities returns a CSIStorageCapacityClusterInformer. func (v *version) CSIStorageCapacities() CSIStorageCapacityClusterInformer { return &cSIStorageCapacityClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } + +// StorageClasses returns a StorageClassClusterInformer. +func (v *version) StorageClasses() StorageClassClusterInformer { + return &storageClassClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + +// VolumeAttachments returns a VolumeAttachmentClusterInformer. +func (v *version) VolumeAttachments() VolumeAttachmentClusterInformer { + return &volumeAttachmentClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} diff --git a/informers/storage/v1/storageclass.go b/informers/storage/v1/storageclass.go index 12aef41bf..b073a16d6 100644 --- a/informers/storage/v1/storageclass.go +++ b/informers/storage/v1/storageclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - storagev1 "k8s.io/api/storage/v1" + apistoragev1 "k8s.io/api/storage/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamstoragev1informers "k8s.io/client-go/informers/storage/v1" - upstreamstoragev1listers "k8s.io/client-go/listers/storage/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - storagev1listers "github.com/kcp-dev/client-go/listers/storage/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + storagev1 "k8s.io/client-go/informers/storage/v1" + listersstoragev1 "k8s.io/client-go/listers/storage/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/storage/v1" ) // StorageClassClusterInformer provides access to a shared informer and lister for // StorageClasses. type StorageClassClusterInformer interface { - Cluster(logicalcluster.Name) upstreamstoragev1informers.StorageClassInformer + Cluster(logicalcluster.Name) storagev1.StorageClassInformer + ClusterWithContext(context.Context, logicalcluster.Name) storagev1.StorageClassInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() storagev1listers.StorageClassClusterLister + Lister() kcpv1.StorageClassClusterLister } type storageClassClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewStorageClassClusterInformer constructs a new informer for StorageClass type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewStorageClassClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewStorageClassClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredStorageClassClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredStorageClassClusterInformer constructs a new informer for StorageClass type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredStorageClassClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredStorageClassClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.StorageV1().StorageClasses().List(context.TODO(), options) + return client.StorageV1().StorageClasses().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.StorageV1().StorageClasses().Watch(context.TODO(), options) + return client.StorageV1().StorageClasses().Watch(context.Background(), options) }, }, - &storagev1.StorageClass{}, + &apistoragev1.StorageClass{}, resyncPeriod, indexers, ) } -func (f *storageClassClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *storageClassClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredStorageClassClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *storageClassClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apistoragev1.StorageClass{}, i.defaultInformer) } -func (f *storageClassClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&storagev1.StorageClass{}, f.defaultInformer) +func (i *storageClassClusterInformer) Lister() kcpv1.StorageClassClusterLister { + return kcpv1.NewStorageClassClusterLister(i.Informer().GetIndexer()) } -func (f *storageClassClusterInformer) Lister() storagev1listers.StorageClassClusterLister { - return storagev1listers.NewStorageClassClusterLister(f.Informer().GetIndexer()) +func (i *storageClassClusterInformer) Cluster(clusterName logicalcluster.Name) storagev1.StorageClassInformer { + return &storageClassInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *storageClassClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamstoragev1informers.StorageClassInformer { +func (i *storageClassClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) storagev1.StorageClassInformer { return &storageClassInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type storageClassInformer struct { informer cache.SharedIndexInformer - lister upstreamstoragev1listers.StorageClassLister + lister listersstoragev1.StorageClassLister } -func (f *storageClassInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *storageClassInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *storageClassInformer) Lister() upstreamstoragev1listers.StorageClassLister { - return f.lister +func (i *storageClassInformer) Lister() listersstoragev1.StorageClassLister { + return i.lister } diff --git a/informers/storage/v1/volumeattachment.go b/informers/storage/v1/volumeattachment.go index d381d537b..e76d08cee 100644 --- a/informers/storage/v1/volumeattachment.go +++ b/informers/storage/v1/volumeattachment.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" - storagev1 "k8s.io/api/storage/v1" + apistoragev1 "k8s.io/api/storage/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamstoragev1informers "k8s.io/client-go/informers/storage/v1" - upstreamstoragev1listers "k8s.io/client-go/listers/storage/v1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - storagev1listers "github.com/kcp-dev/client-go/listers/storage/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + storagev1 "k8s.io/client-go/informers/storage/v1" + listersstoragev1 "k8s.io/client-go/listers/storage/v1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1 "github.com/kcp-dev/client-go/listers/storage/v1" ) // VolumeAttachmentClusterInformer provides access to a shared informer and lister for // VolumeAttachments. type VolumeAttachmentClusterInformer interface { - Cluster(logicalcluster.Name) upstreamstoragev1informers.VolumeAttachmentInformer + Cluster(logicalcluster.Name) storagev1.VolumeAttachmentInformer + ClusterWithContext(context.Context, logicalcluster.Name) storagev1.VolumeAttachmentInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() storagev1listers.VolumeAttachmentClusterLister + Lister() kcpv1.VolumeAttachmentClusterLister } type volumeAttachmentClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewVolumeAttachmentClusterInformer constructs a new informer for VolumeAttachment type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewVolumeAttachmentClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewVolumeAttachmentClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredVolumeAttachmentClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredVolumeAttachmentClusterInformer constructs a new informer for VolumeAttachment type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredVolumeAttachmentClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredVolumeAttachmentClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.StorageV1().VolumeAttachments().List(context.TODO(), options) + return client.StorageV1().VolumeAttachments().List(context.Background(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.StorageV1().VolumeAttachments().Watch(context.TODO(), options) + return client.StorageV1().VolumeAttachments().Watch(context.Background(), options) }, }, - &storagev1.VolumeAttachment{}, + &apistoragev1.VolumeAttachment{}, resyncPeriod, indexers, ) } -func (f *volumeAttachmentClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *volumeAttachmentClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredVolumeAttachmentClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *volumeAttachmentClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apistoragev1.VolumeAttachment{}, i.defaultInformer) } -func (f *volumeAttachmentClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&storagev1.VolumeAttachment{}, f.defaultInformer) +func (i *volumeAttachmentClusterInformer) Lister() kcpv1.VolumeAttachmentClusterLister { + return kcpv1.NewVolumeAttachmentClusterLister(i.Informer().GetIndexer()) } -func (f *volumeAttachmentClusterInformer) Lister() storagev1listers.VolumeAttachmentClusterLister { - return storagev1listers.NewVolumeAttachmentClusterLister(f.Informer().GetIndexer()) +func (i *volumeAttachmentClusterInformer) Cluster(clusterName logicalcluster.Name) storagev1.VolumeAttachmentInformer { + return &volumeAttachmentInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *volumeAttachmentClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamstoragev1informers.VolumeAttachmentInformer { +func (i *volumeAttachmentClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) storagev1.VolumeAttachmentInformer { return &volumeAttachmentInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type volumeAttachmentInformer struct { informer cache.SharedIndexInformer - lister upstreamstoragev1listers.VolumeAttachmentLister + lister listersstoragev1.VolumeAttachmentLister } -func (f *volumeAttachmentInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *volumeAttachmentInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *volumeAttachmentInformer) Lister() upstreamstoragev1listers.VolumeAttachmentLister { - return f.lister +func (i *volumeAttachmentInformer) Lister() listersstoragev1.VolumeAttachmentLister { + return i.lister } diff --git a/informers/storage/v1alpha1/csistoragecapacity.go b/informers/storage/v1alpha1/csistoragecapacity.go index a6aa2ae6b..cb5b77d08 100644 --- a/informers/storage/v1alpha1/csistoragecapacity.go +++ b/informers/storage/v1alpha1/csistoragecapacity.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - storagev1alpha1 "k8s.io/api/storage/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamstoragev1alpha1informers "k8s.io/client-go/informers/storage/v1alpha1" - upstreamstoragev1alpha1listers "k8s.io/client-go/listers/storage/v1alpha1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - storagev1alpha1listers "github.com/kcp-dev/client-go/listers/storage/v1alpha1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apistoragev1alpha1 "k8s.io/api/storage/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + storagev1alpha1 "k8s.io/client-go/informers/storage/v1alpha1" + listersstoragev1alpha1 "k8s.io/client-go/listers/storage/v1alpha1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1alpha1 "github.com/kcp-dev/client-go/listers/storage/v1alpha1" ) // CSIStorageCapacityClusterInformer provides access to a shared informer and lister for // CSIStorageCapacities. type CSIStorageCapacityClusterInformer interface { - Cluster(logicalcluster.Name) upstreamstoragev1alpha1informers.CSIStorageCapacityInformer + Cluster(logicalcluster.Name) storagev1alpha1.CSIStorageCapacityInformer + ClusterWithContext(context.Context, logicalcluster.Name) storagev1alpha1.CSIStorageCapacityInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() storagev1alpha1listers.CSIStorageCapacityClusterLister + Lister() kcpv1alpha1.CSIStorageCapacityClusterLister } type cSIStorageCapacityClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewCSIStorageCapacityClusterInformer constructs a new informer for CSIStorageCapacity type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewCSIStorageCapacityClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewCSIStorageCapacityClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredCSIStorageCapacityClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredCSIStorageCapacityClusterInformer constructs a new informer for CSIStorageCapacity type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredCSIStorageCapacityClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredCSIStorageCapacityClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.StorageV1alpha1().CSIStorageCapacities().List(context.TODO(), options) + return client.StorageV1alpha1().CSIStorageCapacities().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.StorageV1alpha1().CSIStorageCapacities().Watch(context.TODO(), options) + return client.StorageV1alpha1().CSIStorageCapacities().Watch(context.Background(), options) }, }, - &storagev1alpha1.CSIStorageCapacity{}, + &apistoragev1alpha1.CSIStorageCapacity{}, resyncPeriod, indexers, ) } -func (f *cSIStorageCapacityClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *cSIStorageCapacityClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredCSIStorageCapacityClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *cSIStorageCapacityClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apistoragev1alpha1.CSIStorageCapacity{}, i.defaultInformer) } -func (f *cSIStorageCapacityClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&storagev1alpha1.CSIStorageCapacity{}, f.defaultInformer) +func (i *cSIStorageCapacityClusterInformer) Lister() kcpv1alpha1.CSIStorageCapacityClusterLister { + return kcpv1alpha1.NewCSIStorageCapacityClusterLister(i.Informer().GetIndexer()) } -func (f *cSIStorageCapacityClusterInformer) Lister() storagev1alpha1listers.CSIStorageCapacityClusterLister { - return storagev1alpha1listers.NewCSIStorageCapacityClusterLister(f.Informer().GetIndexer()) +func (i *cSIStorageCapacityClusterInformer) Cluster(clusterName logicalcluster.Name) storagev1alpha1.CSIStorageCapacityInformer { + return &cSIStorageCapacityInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *cSIStorageCapacityClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamstoragev1alpha1informers.CSIStorageCapacityInformer { +func (i *cSIStorageCapacityClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) storagev1alpha1.CSIStorageCapacityInformer { return &cSIStorageCapacityInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type cSIStorageCapacityInformer struct { informer cache.SharedIndexInformer - lister upstreamstoragev1alpha1listers.CSIStorageCapacityLister + lister listersstoragev1alpha1.CSIStorageCapacityLister } -func (f *cSIStorageCapacityInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *cSIStorageCapacityInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *cSIStorageCapacityInformer) Lister() upstreamstoragev1alpha1listers.CSIStorageCapacityLister { - return f.lister +func (i *cSIStorageCapacityInformer) Lister() listersstoragev1alpha1.CSIStorageCapacityLister { + return i.lister } diff --git a/informers/storage/v1alpha1/interface.go b/informers/storage/v1alpha1/interface.go index 790710ee6..fddc5fcb2 100644 --- a/informers/storage/v1alpha1/interface.go +++ b/informers/storage/v1alpha1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,44 +14,44 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // VolumeAttachments returns a VolumeAttachmentClusterInformer - VolumeAttachments() VolumeAttachmentClusterInformer - // CSIStorageCapacities returns a CSIStorageCapacityClusterInformer + // CSIStorageCapacities returns a CSIStorageCapacityClusterInformer. CSIStorageCapacities() CSIStorageCapacityClusterInformer - // VolumeAttributesClasses returns a VolumeAttributesClassClusterInformer + // VolumeAttachments returns a VolumeAttachmentClusterInformer. + VolumeAttachments() VolumeAttachmentClusterInformer + // VolumeAttributesClasses returns a VolumeAttributesClassClusterInformer. VolumeAttributesClasses() VolumeAttributesClassClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// VolumeAttachments returns a VolumeAttachmentClusterInformer -func (v *version) VolumeAttachments() VolumeAttachmentClusterInformer { - return &volumeAttachmentClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} - -// CSIStorageCapacities returns a CSIStorageCapacityClusterInformer +// CSIStorageCapacities returns a CSIStorageCapacityClusterInformer. func (v *version) CSIStorageCapacities() CSIStorageCapacityClusterInformer { return &cSIStorageCapacityClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// VolumeAttributesClasses returns a VolumeAttributesClassClusterInformer +// VolumeAttachments returns a VolumeAttachmentClusterInformer. +func (v *version) VolumeAttachments() VolumeAttachmentClusterInformer { + return &volumeAttachmentClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + +// VolumeAttributesClasses returns a VolumeAttributesClassClusterInformer. func (v *version) VolumeAttributesClasses() VolumeAttributesClassClusterInformer { return &volumeAttributesClassClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/storage/v1alpha1/volumeattachment.go b/informers/storage/v1alpha1/volumeattachment.go index 76202f019..1a2b5f0de 100644 --- a/informers/storage/v1alpha1/volumeattachment.go +++ b/informers/storage/v1alpha1/volumeattachment.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - storagev1alpha1 "k8s.io/api/storage/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamstoragev1alpha1informers "k8s.io/client-go/informers/storage/v1alpha1" - upstreamstoragev1alpha1listers "k8s.io/client-go/listers/storage/v1alpha1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - storagev1alpha1listers "github.com/kcp-dev/client-go/listers/storage/v1alpha1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apistoragev1alpha1 "k8s.io/api/storage/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + storagev1alpha1 "k8s.io/client-go/informers/storage/v1alpha1" + listersstoragev1alpha1 "k8s.io/client-go/listers/storage/v1alpha1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1alpha1 "github.com/kcp-dev/client-go/listers/storage/v1alpha1" ) // VolumeAttachmentClusterInformer provides access to a shared informer and lister for // VolumeAttachments. type VolumeAttachmentClusterInformer interface { - Cluster(logicalcluster.Name) upstreamstoragev1alpha1informers.VolumeAttachmentInformer + Cluster(logicalcluster.Name) storagev1alpha1.VolumeAttachmentInformer + ClusterWithContext(context.Context, logicalcluster.Name) storagev1alpha1.VolumeAttachmentInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() storagev1alpha1listers.VolumeAttachmentClusterLister + Lister() kcpv1alpha1.VolumeAttachmentClusterLister } type volumeAttachmentClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewVolumeAttachmentClusterInformer constructs a new informer for VolumeAttachment type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewVolumeAttachmentClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewVolumeAttachmentClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredVolumeAttachmentClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredVolumeAttachmentClusterInformer constructs a new informer for VolumeAttachment type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredVolumeAttachmentClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredVolumeAttachmentClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.StorageV1alpha1().VolumeAttachments().List(context.TODO(), options) + return client.StorageV1alpha1().VolumeAttachments().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.StorageV1alpha1().VolumeAttachments().Watch(context.TODO(), options) + return client.StorageV1alpha1().VolumeAttachments().Watch(context.Background(), options) }, }, - &storagev1alpha1.VolumeAttachment{}, + &apistoragev1alpha1.VolumeAttachment{}, resyncPeriod, indexers, ) } -func (f *volumeAttachmentClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *volumeAttachmentClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredVolumeAttachmentClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *volumeAttachmentClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apistoragev1alpha1.VolumeAttachment{}, i.defaultInformer) } -func (f *volumeAttachmentClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&storagev1alpha1.VolumeAttachment{}, f.defaultInformer) +func (i *volumeAttachmentClusterInformer) Lister() kcpv1alpha1.VolumeAttachmentClusterLister { + return kcpv1alpha1.NewVolumeAttachmentClusterLister(i.Informer().GetIndexer()) } -func (f *volumeAttachmentClusterInformer) Lister() storagev1alpha1listers.VolumeAttachmentClusterLister { - return storagev1alpha1listers.NewVolumeAttachmentClusterLister(f.Informer().GetIndexer()) +func (i *volumeAttachmentClusterInformer) Cluster(clusterName logicalcluster.Name) storagev1alpha1.VolumeAttachmentInformer { + return &volumeAttachmentInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *volumeAttachmentClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamstoragev1alpha1informers.VolumeAttachmentInformer { +func (i *volumeAttachmentClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) storagev1alpha1.VolumeAttachmentInformer { return &volumeAttachmentInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type volumeAttachmentInformer struct { informer cache.SharedIndexInformer - lister upstreamstoragev1alpha1listers.VolumeAttachmentLister + lister listersstoragev1alpha1.VolumeAttachmentLister } -func (f *volumeAttachmentInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *volumeAttachmentInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *volumeAttachmentInformer) Lister() upstreamstoragev1alpha1listers.VolumeAttachmentLister { - return f.lister +func (i *volumeAttachmentInformer) Lister() listersstoragev1alpha1.VolumeAttachmentLister { + return i.lister } diff --git a/informers/storage/v1alpha1/volumeattributesclass.go b/informers/storage/v1alpha1/volumeattributesclass.go index 273cafbce..f7aa1bf79 100644 --- a/informers/storage/v1alpha1/volumeattributesclass.go +++ b/informers/storage/v1alpha1/volumeattributesclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - storagev1alpha1 "k8s.io/api/storage/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamstoragev1alpha1informers "k8s.io/client-go/informers/storage/v1alpha1" - upstreamstoragev1alpha1listers "k8s.io/client-go/listers/storage/v1alpha1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - storagev1alpha1listers "github.com/kcp-dev/client-go/listers/storage/v1alpha1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apistoragev1alpha1 "k8s.io/api/storage/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + storagev1alpha1 "k8s.io/client-go/informers/storage/v1alpha1" + listersstoragev1alpha1 "k8s.io/client-go/listers/storage/v1alpha1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1alpha1 "github.com/kcp-dev/client-go/listers/storage/v1alpha1" ) // VolumeAttributesClassClusterInformer provides access to a shared informer and lister for // VolumeAttributesClasses. type VolumeAttributesClassClusterInformer interface { - Cluster(logicalcluster.Name) upstreamstoragev1alpha1informers.VolumeAttributesClassInformer + Cluster(logicalcluster.Name) storagev1alpha1.VolumeAttributesClassInformer + ClusterWithContext(context.Context, logicalcluster.Name) storagev1alpha1.VolumeAttributesClassInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() storagev1alpha1listers.VolumeAttributesClassClusterLister + Lister() kcpv1alpha1.VolumeAttributesClassClusterLister } type volumeAttributesClassClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewVolumeAttributesClassClusterInformer constructs a new informer for VolumeAttributesClass type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewVolumeAttributesClassClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewVolumeAttributesClassClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredVolumeAttributesClassClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredVolumeAttributesClassClusterInformer constructs a new informer for VolumeAttributesClass type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredVolumeAttributesClassClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredVolumeAttributesClassClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.StorageV1alpha1().VolumeAttributesClasses().List(context.TODO(), options) + return client.StorageV1alpha1().VolumeAttributesClasses().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.StorageV1alpha1().VolumeAttributesClasses().Watch(context.TODO(), options) + return client.StorageV1alpha1().VolumeAttributesClasses().Watch(context.Background(), options) }, }, - &storagev1alpha1.VolumeAttributesClass{}, + &apistoragev1alpha1.VolumeAttributesClass{}, resyncPeriod, indexers, ) } -func (f *volumeAttributesClassClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *volumeAttributesClassClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredVolumeAttributesClassClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *volumeAttributesClassClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apistoragev1alpha1.VolumeAttributesClass{}, i.defaultInformer) } -func (f *volumeAttributesClassClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&storagev1alpha1.VolumeAttributesClass{}, f.defaultInformer) +func (i *volumeAttributesClassClusterInformer) Lister() kcpv1alpha1.VolumeAttributesClassClusterLister { + return kcpv1alpha1.NewVolumeAttributesClassClusterLister(i.Informer().GetIndexer()) } -func (f *volumeAttributesClassClusterInformer) Lister() storagev1alpha1listers.VolumeAttributesClassClusterLister { - return storagev1alpha1listers.NewVolumeAttributesClassClusterLister(f.Informer().GetIndexer()) +func (i *volumeAttributesClassClusterInformer) Cluster(clusterName logicalcluster.Name) storagev1alpha1.VolumeAttributesClassInformer { + return &volumeAttributesClassInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *volumeAttributesClassClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamstoragev1alpha1informers.VolumeAttributesClassInformer { +func (i *volumeAttributesClassClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) storagev1alpha1.VolumeAttributesClassInformer { return &volumeAttributesClassInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type volumeAttributesClassInformer struct { informer cache.SharedIndexInformer - lister upstreamstoragev1alpha1listers.VolumeAttributesClassLister + lister listersstoragev1alpha1.VolumeAttributesClassLister } -func (f *volumeAttributesClassInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *volumeAttributesClassInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *volumeAttributesClassInformer) Lister() upstreamstoragev1alpha1listers.VolumeAttributesClassLister { - return f.lister +func (i *volumeAttributesClassInformer) Lister() listersstoragev1alpha1.VolumeAttributesClassLister { + return i.lister } diff --git a/informers/storage/v1beta1/csidriver.go b/informers/storage/v1beta1/csidriver.go index 4da05ef99..6927a7552 100644 --- a/informers/storage/v1beta1/csidriver.go +++ b/informers/storage/v1beta1/csidriver.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - storagev1beta1 "k8s.io/api/storage/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamstoragev1beta1informers "k8s.io/client-go/informers/storage/v1beta1" - upstreamstoragev1beta1listers "k8s.io/client-go/listers/storage/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - storagev1beta1listers "github.com/kcp-dev/client-go/listers/storage/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apistoragev1beta1 "k8s.io/api/storage/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + storagev1beta1 "k8s.io/client-go/informers/storage/v1beta1" + listersstoragev1beta1 "k8s.io/client-go/listers/storage/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/storage/v1beta1" ) // CSIDriverClusterInformer provides access to a shared informer and lister for // CSIDrivers. type CSIDriverClusterInformer interface { - Cluster(logicalcluster.Name) upstreamstoragev1beta1informers.CSIDriverInformer + Cluster(logicalcluster.Name) storagev1beta1.CSIDriverInformer + ClusterWithContext(context.Context, logicalcluster.Name) storagev1beta1.CSIDriverInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() storagev1beta1listers.CSIDriverClusterLister + Lister() kcpv1beta1.CSIDriverClusterLister } type cSIDriverClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewCSIDriverClusterInformer constructs a new informer for CSIDriver type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewCSIDriverClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewCSIDriverClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredCSIDriverClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredCSIDriverClusterInformer constructs a new informer for CSIDriver type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredCSIDriverClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredCSIDriverClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.StorageV1beta1().CSIDrivers().List(context.TODO(), options) + return client.StorageV1beta1().CSIDrivers().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.StorageV1beta1().CSIDrivers().Watch(context.TODO(), options) + return client.StorageV1beta1().CSIDrivers().Watch(context.Background(), options) }, }, - &storagev1beta1.CSIDriver{}, + &apistoragev1beta1.CSIDriver{}, resyncPeriod, indexers, ) } -func (f *cSIDriverClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *cSIDriverClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredCSIDriverClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *cSIDriverClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apistoragev1beta1.CSIDriver{}, i.defaultInformer) } -func (f *cSIDriverClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&storagev1beta1.CSIDriver{}, f.defaultInformer) +func (i *cSIDriverClusterInformer) Lister() kcpv1beta1.CSIDriverClusterLister { + return kcpv1beta1.NewCSIDriverClusterLister(i.Informer().GetIndexer()) } -func (f *cSIDriverClusterInformer) Lister() storagev1beta1listers.CSIDriverClusterLister { - return storagev1beta1listers.NewCSIDriverClusterLister(f.Informer().GetIndexer()) +func (i *cSIDriverClusterInformer) Cluster(clusterName logicalcluster.Name) storagev1beta1.CSIDriverInformer { + return &cSIDriverInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *cSIDriverClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamstoragev1beta1informers.CSIDriverInformer { +func (i *cSIDriverClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) storagev1beta1.CSIDriverInformer { return &cSIDriverInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type cSIDriverInformer struct { informer cache.SharedIndexInformer - lister upstreamstoragev1beta1listers.CSIDriverLister + lister listersstoragev1beta1.CSIDriverLister } -func (f *cSIDriverInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *cSIDriverInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *cSIDriverInformer) Lister() upstreamstoragev1beta1listers.CSIDriverLister { - return f.lister +func (i *cSIDriverInformer) Lister() listersstoragev1beta1.CSIDriverLister { + return i.lister } diff --git a/informers/storage/v1beta1/csinode.go b/informers/storage/v1beta1/csinode.go index a7cd734dc..2d633f535 100644 --- a/informers/storage/v1beta1/csinode.go +++ b/informers/storage/v1beta1/csinode.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - storagev1beta1 "k8s.io/api/storage/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamstoragev1beta1informers "k8s.io/client-go/informers/storage/v1beta1" - upstreamstoragev1beta1listers "k8s.io/client-go/listers/storage/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - storagev1beta1listers "github.com/kcp-dev/client-go/listers/storage/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apistoragev1beta1 "k8s.io/api/storage/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + storagev1beta1 "k8s.io/client-go/informers/storage/v1beta1" + listersstoragev1beta1 "k8s.io/client-go/listers/storage/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/storage/v1beta1" ) // CSINodeClusterInformer provides access to a shared informer and lister for // CSINodes. type CSINodeClusterInformer interface { - Cluster(logicalcluster.Name) upstreamstoragev1beta1informers.CSINodeInformer + Cluster(logicalcluster.Name) storagev1beta1.CSINodeInformer + ClusterWithContext(context.Context, logicalcluster.Name) storagev1beta1.CSINodeInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() storagev1beta1listers.CSINodeClusterLister + Lister() kcpv1beta1.CSINodeClusterLister } type cSINodeClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewCSINodeClusterInformer constructs a new informer for CSINode type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewCSINodeClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewCSINodeClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredCSINodeClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredCSINodeClusterInformer constructs a new informer for CSINode type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredCSINodeClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredCSINodeClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.StorageV1beta1().CSINodes().List(context.TODO(), options) + return client.StorageV1beta1().CSINodes().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.StorageV1beta1().CSINodes().Watch(context.TODO(), options) + return client.StorageV1beta1().CSINodes().Watch(context.Background(), options) }, }, - &storagev1beta1.CSINode{}, + &apistoragev1beta1.CSINode{}, resyncPeriod, indexers, ) } -func (f *cSINodeClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *cSINodeClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredCSINodeClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *cSINodeClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apistoragev1beta1.CSINode{}, i.defaultInformer) } -func (f *cSINodeClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&storagev1beta1.CSINode{}, f.defaultInformer) +func (i *cSINodeClusterInformer) Lister() kcpv1beta1.CSINodeClusterLister { + return kcpv1beta1.NewCSINodeClusterLister(i.Informer().GetIndexer()) } -func (f *cSINodeClusterInformer) Lister() storagev1beta1listers.CSINodeClusterLister { - return storagev1beta1listers.NewCSINodeClusterLister(f.Informer().GetIndexer()) +func (i *cSINodeClusterInformer) Cluster(clusterName logicalcluster.Name) storagev1beta1.CSINodeInformer { + return &cSINodeInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *cSINodeClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamstoragev1beta1informers.CSINodeInformer { +func (i *cSINodeClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) storagev1beta1.CSINodeInformer { return &cSINodeInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type cSINodeInformer struct { informer cache.SharedIndexInformer - lister upstreamstoragev1beta1listers.CSINodeLister + lister listersstoragev1beta1.CSINodeLister } -func (f *cSINodeInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *cSINodeInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *cSINodeInformer) Lister() upstreamstoragev1beta1listers.CSINodeLister { - return f.lister +func (i *cSINodeInformer) Lister() listersstoragev1beta1.CSINodeLister { + return i.lister } diff --git a/informers/storage/v1beta1/csistoragecapacity.go b/informers/storage/v1beta1/csistoragecapacity.go index 23dfddcc4..0ac095107 100644 --- a/informers/storage/v1beta1/csistoragecapacity.go +++ b/informers/storage/v1beta1/csistoragecapacity.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - storagev1beta1 "k8s.io/api/storage/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamstoragev1beta1informers "k8s.io/client-go/informers/storage/v1beta1" - upstreamstoragev1beta1listers "k8s.io/client-go/listers/storage/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - storagev1beta1listers "github.com/kcp-dev/client-go/listers/storage/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apistoragev1beta1 "k8s.io/api/storage/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + storagev1beta1 "k8s.io/client-go/informers/storage/v1beta1" + listersstoragev1beta1 "k8s.io/client-go/listers/storage/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/storage/v1beta1" ) // CSIStorageCapacityClusterInformer provides access to a shared informer and lister for // CSIStorageCapacities. type CSIStorageCapacityClusterInformer interface { - Cluster(logicalcluster.Name) upstreamstoragev1beta1informers.CSIStorageCapacityInformer + Cluster(logicalcluster.Name) storagev1beta1.CSIStorageCapacityInformer + ClusterWithContext(context.Context, logicalcluster.Name) storagev1beta1.CSIStorageCapacityInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() storagev1beta1listers.CSIStorageCapacityClusterLister + Lister() kcpv1beta1.CSIStorageCapacityClusterLister } type cSIStorageCapacityClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewCSIStorageCapacityClusterInformer constructs a new informer for CSIStorageCapacity type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewCSIStorageCapacityClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewCSIStorageCapacityClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredCSIStorageCapacityClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredCSIStorageCapacityClusterInformer constructs a new informer for CSIStorageCapacity type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredCSIStorageCapacityClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredCSIStorageCapacityClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.StorageV1beta1().CSIStorageCapacities().List(context.TODO(), options) + return client.StorageV1beta1().CSIStorageCapacities().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.StorageV1beta1().CSIStorageCapacities().Watch(context.TODO(), options) + return client.StorageV1beta1().CSIStorageCapacities().Watch(context.Background(), options) }, }, - &storagev1beta1.CSIStorageCapacity{}, + &apistoragev1beta1.CSIStorageCapacity{}, resyncPeriod, indexers, ) } -func (f *cSIStorageCapacityClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *cSIStorageCapacityClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredCSIStorageCapacityClusterInformer(client, resyncPeriod, cache.Indexers{ kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, - f.tweakListOptions, - ) + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *cSIStorageCapacityClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apistoragev1beta1.CSIStorageCapacity{}, i.defaultInformer) } -func (f *cSIStorageCapacityClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&storagev1beta1.CSIStorageCapacity{}, f.defaultInformer) +func (i *cSIStorageCapacityClusterInformer) Lister() kcpv1beta1.CSIStorageCapacityClusterLister { + return kcpv1beta1.NewCSIStorageCapacityClusterLister(i.Informer().GetIndexer()) } -func (f *cSIStorageCapacityClusterInformer) Lister() storagev1beta1listers.CSIStorageCapacityClusterLister { - return storagev1beta1listers.NewCSIStorageCapacityClusterLister(f.Informer().GetIndexer()) +func (i *cSIStorageCapacityClusterInformer) Cluster(clusterName logicalcluster.Name) storagev1beta1.CSIStorageCapacityInformer { + return &cSIStorageCapacityInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *cSIStorageCapacityClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamstoragev1beta1informers.CSIStorageCapacityInformer { +func (i *cSIStorageCapacityClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) storagev1beta1.CSIStorageCapacityInformer { return &cSIStorageCapacityInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type cSIStorageCapacityInformer struct { informer cache.SharedIndexInformer - lister upstreamstoragev1beta1listers.CSIStorageCapacityLister + lister listersstoragev1beta1.CSIStorageCapacityLister } -func (f *cSIStorageCapacityInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *cSIStorageCapacityInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *cSIStorageCapacityInformer) Lister() upstreamstoragev1beta1listers.CSIStorageCapacityLister { - return f.lister +func (i *cSIStorageCapacityInformer) Lister() listersstoragev1beta1.CSIStorageCapacityLister { + return i.lister } diff --git a/informers/storage/v1beta1/interface.go b/informers/storage/v1beta1/interface.go index d4ba41efd..46fe4b1bd 100644 --- a/informers/storage/v1beta1/interface.go +++ b/informers/storage/v1beta1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,65 +14,65 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // StorageClasses returns a StorageClassClusterInformer - StorageClasses() StorageClassClusterInformer - // VolumeAttachments returns a VolumeAttachmentClusterInformer - VolumeAttachments() VolumeAttachmentClusterInformer - // CSIDrivers returns a CSIDriverClusterInformer + // CSIDrivers returns a CSIDriverClusterInformer. CSIDrivers() CSIDriverClusterInformer - // CSINodes returns a CSINodeClusterInformer + // CSINodes returns a CSINodeClusterInformer. CSINodes() CSINodeClusterInformer - // CSIStorageCapacities returns a CSIStorageCapacityClusterInformer + // CSIStorageCapacities returns a CSIStorageCapacityClusterInformer. CSIStorageCapacities() CSIStorageCapacityClusterInformer - // VolumeAttributesClasses returns a VolumeAttributesClassClusterInformer + // StorageClasses returns a StorageClassClusterInformer. + StorageClasses() StorageClassClusterInformer + // VolumeAttachments returns a VolumeAttachmentClusterInformer. + VolumeAttachments() VolumeAttachmentClusterInformer + // VolumeAttributesClasses returns a VolumeAttributesClassClusterInformer. VolumeAttributesClasses() VolumeAttributesClassClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// StorageClasses returns a StorageClassClusterInformer -func (v *version) StorageClasses() StorageClassClusterInformer { - return &storageClassClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} - -// VolumeAttachments returns a VolumeAttachmentClusterInformer -func (v *version) VolumeAttachments() VolumeAttachmentClusterInformer { - return &volumeAttachmentClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} - -// CSIDrivers returns a CSIDriverClusterInformer +// CSIDrivers returns a CSIDriverClusterInformer. func (v *version) CSIDrivers() CSIDriverClusterInformer { return &cSIDriverClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// CSINodes returns a CSINodeClusterInformer +// CSINodes returns a CSINodeClusterInformer. func (v *version) CSINodes() CSINodeClusterInformer { return &cSINodeClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// CSIStorageCapacities returns a CSIStorageCapacityClusterInformer +// CSIStorageCapacities returns a CSIStorageCapacityClusterInformer. func (v *version) CSIStorageCapacities() CSIStorageCapacityClusterInformer { return &cSIStorageCapacityClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// VolumeAttributesClasses returns a VolumeAttributesClassClusterInformer +// StorageClasses returns a StorageClassClusterInformer. +func (v *version) StorageClasses() StorageClassClusterInformer { + return &storageClassClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + +// VolumeAttachments returns a VolumeAttachmentClusterInformer. +func (v *version) VolumeAttachments() VolumeAttachmentClusterInformer { + return &volumeAttachmentClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + +// VolumeAttributesClasses returns a VolumeAttributesClassClusterInformer. func (v *version) VolumeAttributesClasses() VolumeAttributesClassClusterInformer { return &volumeAttributesClassClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/storage/v1beta1/storageclass.go b/informers/storage/v1beta1/storageclass.go index 1b571b5d6..11d325565 100644 --- a/informers/storage/v1beta1/storageclass.go +++ b/informers/storage/v1beta1/storageclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - storagev1beta1 "k8s.io/api/storage/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamstoragev1beta1informers "k8s.io/client-go/informers/storage/v1beta1" - upstreamstoragev1beta1listers "k8s.io/client-go/listers/storage/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - storagev1beta1listers "github.com/kcp-dev/client-go/listers/storage/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apistoragev1beta1 "k8s.io/api/storage/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + storagev1beta1 "k8s.io/client-go/informers/storage/v1beta1" + listersstoragev1beta1 "k8s.io/client-go/listers/storage/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/storage/v1beta1" ) // StorageClassClusterInformer provides access to a shared informer and lister for // StorageClasses. type StorageClassClusterInformer interface { - Cluster(logicalcluster.Name) upstreamstoragev1beta1informers.StorageClassInformer + Cluster(logicalcluster.Name) storagev1beta1.StorageClassInformer + ClusterWithContext(context.Context, logicalcluster.Name) storagev1beta1.StorageClassInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() storagev1beta1listers.StorageClassClusterLister + Lister() kcpv1beta1.StorageClassClusterLister } type storageClassClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewStorageClassClusterInformer constructs a new informer for StorageClass type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewStorageClassClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewStorageClassClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredStorageClassClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredStorageClassClusterInformer constructs a new informer for StorageClass type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredStorageClassClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredStorageClassClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.StorageV1beta1().StorageClasses().List(context.TODO(), options) + return client.StorageV1beta1().StorageClasses().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.StorageV1beta1().StorageClasses().Watch(context.TODO(), options) + return client.StorageV1beta1().StorageClasses().Watch(context.Background(), options) }, }, - &storagev1beta1.StorageClass{}, + &apistoragev1beta1.StorageClass{}, resyncPeriod, indexers, ) } -func (f *storageClassClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *storageClassClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredStorageClassClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *storageClassClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apistoragev1beta1.StorageClass{}, i.defaultInformer) } -func (f *storageClassClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&storagev1beta1.StorageClass{}, f.defaultInformer) +func (i *storageClassClusterInformer) Lister() kcpv1beta1.StorageClassClusterLister { + return kcpv1beta1.NewStorageClassClusterLister(i.Informer().GetIndexer()) } -func (f *storageClassClusterInformer) Lister() storagev1beta1listers.StorageClassClusterLister { - return storagev1beta1listers.NewStorageClassClusterLister(f.Informer().GetIndexer()) +func (i *storageClassClusterInformer) Cluster(clusterName logicalcluster.Name) storagev1beta1.StorageClassInformer { + return &storageClassInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *storageClassClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamstoragev1beta1informers.StorageClassInformer { +func (i *storageClassClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) storagev1beta1.StorageClassInformer { return &storageClassInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type storageClassInformer struct { informer cache.SharedIndexInformer - lister upstreamstoragev1beta1listers.StorageClassLister + lister listersstoragev1beta1.StorageClassLister } -func (f *storageClassInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *storageClassInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *storageClassInformer) Lister() upstreamstoragev1beta1listers.StorageClassLister { - return f.lister +func (i *storageClassInformer) Lister() listersstoragev1beta1.StorageClassLister { + return i.lister } diff --git a/informers/storage/v1beta1/volumeattachment.go b/informers/storage/v1beta1/volumeattachment.go index 4832f10c2..09bbc733b 100644 --- a/informers/storage/v1beta1/volumeattachment.go +++ b/informers/storage/v1beta1/volumeattachment.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - storagev1beta1 "k8s.io/api/storage/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamstoragev1beta1informers "k8s.io/client-go/informers/storage/v1beta1" - upstreamstoragev1beta1listers "k8s.io/client-go/listers/storage/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - storagev1beta1listers "github.com/kcp-dev/client-go/listers/storage/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apistoragev1beta1 "k8s.io/api/storage/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + storagev1beta1 "k8s.io/client-go/informers/storage/v1beta1" + listersstoragev1beta1 "k8s.io/client-go/listers/storage/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/storage/v1beta1" ) // VolumeAttachmentClusterInformer provides access to a shared informer and lister for // VolumeAttachments. type VolumeAttachmentClusterInformer interface { - Cluster(logicalcluster.Name) upstreamstoragev1beta1informers.VolumeAttachmentInformer + Cluster(logicalcluster.Name) storagev1beta1.VolumeAttachmentInformer + ClusterWithContext(context.Context, logicalcluster.Name) storagev1beta1.VolumeAttachmentInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() storagev1beta1listers.VolumeAttachmentClusterLister + Lister() kcpv1beta1.VolumeAttachmentClusterLister } type volumeAttachmentClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewVolumeAttachmentClusterInformer constructs a new informer for VolumeAttachment type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewVolumeAttachmentClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewVolumeAttachmentClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredVolumeAttachmentClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredVolumeAttachmentClusterInformer constructs a new informer for VolumeAttachment type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredVolumeAttachmentClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredVolumeAttachmentClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.StorageV1beta1().VolumeAttachments().List(context.TODO(), options) + return client.StorageV1beta1().VolumeAttachments().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.StorageV1beta1().VolumeAttachments().Watch(context.TODO(), options) + return client.StorageV1beta1().VolumeAttachments().Watch(context.Background(), options) }, }, - &storagev1beta1.VolumeAttachment{}, + &apistoragev1beta1.VolumeAttachment{}, resyncPeriod, indexers, ) } -func (f *volumeAttachmentClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *volumeAttachmentClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredVolumeAttachmentClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *volumeAttachmentClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apistoragev1beta1.VolumeAttachment{}, i.defaultInformer) } -func (f *volumeAttachmentClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&storagev1beta1.VolumeAttachment{}, f.defaultInformer) +func (i *volumeAttachmentClusterInformer) Lister() kcpv1beta1.VolumeAttachmentClusterLister { + return kcpv1beta1.NewVolumeAttachmentClusterLister(i.Informer().GetIndexer()) } -func (f *volumeAttachmentClusterInformer) Lister() storagev1beta1listers.VolumeAttachmentClusterLister { - return storagev1beta1listers.NewVolumeAttachmentClusterLister(f.Informer().GetIndexer()) +func (i *volumeAttachmentClusterInformer) Cluster(clusterName logicalcluster.Name) storagev1beta1.VolumeAttachmentInformer { + return &volumeAttachmentInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *volumeAttachmentClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamstoragev1beta1informers.VolumeAttachmentInformer { +func (i *volumeAttachmentClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) storagev1beta1.VolumeAttachmentInformer { return &volumeAttachmentInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type volumeAttachmentInformer struct { informer cache.SharedIndexInformer - lister upstreamstoragev1beta1listers.VolumeAttachmentLister + lister listersstoragev1beta1.VolumeAttachmentLister } -func (f *volumeAttachmentInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *volumeAttachmentInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *volumeAttachmentInformer) Lister() upstreamstoragev1beta1listers.VolumeAttachmentLister { - return f.lister +func (i *volumeAttachmentInformer) Lister() listersstoragev1beta1.VolumeAttachmentLister { + return i.lister } diff --git a/informers/storage/v1beta1/volumeattributesclass.go b/informers/storage/v1beta1/volumeattributesclass.go index c76304929..22f257f8b 100644 --- a/informers/storage/v1beta1/volumeattributesclass.go +++ b/informers/storage/v1beta1/volumeattributesclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1beta1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - storagev1beta1 "k8s.io/api/storage/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamstoragev1beta1informers "k8s.io/client-go/informers/storage/v1beta1" - upstreamstoragev1beta1listers "k8s.io/client-go/listers/storage/v1beta1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - storagev1beta1listers "github.com/kcp-dev/client-go/listers/storage/v1beta1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apistoragev1beta1 "k8s.io/api/storage/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + storagev1beta1 "k8s.io/client-go/informers/storage/v1beta1" + listersstoragev1beta1 "k8s.io/client-go/listers/storage/v1beta1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1beta1 "github.com/kcp-dev/client-go/listers/storage/v1beta1" ) // VolumeAttributesClassClusterInformer provides access to a shared informer and lister for // VolumeAttributesClasses. type VolumeAttributesClassClusterInformer interface { - Cluster(logicalcluster.Name) upstreamstoragev1beta1informers.VolumeAttributesClassInformer + Cluster(logicalcluster.Name) storagev1beta1.VolumeAttributesClassInformer + ClusterWithContext(context.Context, logicalcluster.Name) storagev1beta1.VolumeAttributesClassInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() storagev1beta1listers.VolumeAttributesClassClusterLister + Lister() kcpv1beta1.VolumeAttributesClassClusterLister } type volumeAttributesClassClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewVolumeAttributesClassClusterInformer constructs a new informer for VolumeAttributesClass type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewVolumeAttributesClassClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewVolumeAttributesClassClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredVolumeAttributesClassClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredVolumeAttributesClassClusterInformer constructs a new informer for VolumeAttributesClass type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredVolumeAttributesClassClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredVolumeAttributesClassClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.StorageV1beta1().VolumeAttributesClasses().List(context.TODO(), options) + return client.StorageV1beta1().VolumeAttributesClasses().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.StorageV1beta1().VolumeAttributesClasses().Watch(context.TODO(), options) + return client.StorageV1beta1().VolumeAttributesClasses().Watch(context.Background(), options) }, }, - &storagev1beta1.VolumeAttributesClass{}, + &apistoragev1beta1.VolumeAttributesClass{}, resyncPeriod, indexers, ) } -func (f *volumeAttributesClassClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *volumeAttributesClassClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredVolumeAttributesClassClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *volumeAttributesClassClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apistoragev1beta1.VolumeAttributesClass{}, i.defaultInformer) } -func (f *volumeAttributesClassClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&storagev1beta1.VolumeAttributesClass{}, f.defaultInformer) +func (i *volumeAttributesClassClusterInformer) Lister() kcpv1beta1.VolumeAttributesClassClusterLister { + return kcpv1beta1.NewVolumeAttributesClassClusterLister(i.Informer().GetIndexer()) } -func (f *volumeAttributesClassClusterInformer) Lister() storagev1beta1listers.VolumeAttributesClassClusterLister { - return storagev1beta1listers.NewVolumeAttributesClassClusterLister(f.Informer().GetIndexer()) +func (i *volumeAttributesClassClusterInformer) Cluster(clusterName logicalcluster.Name) storagev1beta1.VolumeAttributesClassInformer { + return &volumeAttributesClassInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *volumeAttributesClassClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamstoragev1beta1informers.VolumeAttributesClassInformer { +func (i *volumeAttributesClassClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) storagev1beta1.VolumeAttributesClassInformer { return &volumeAttributesClassInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type volumeAttributesClassInformer struct { informer cache.SharedIndexInformer - lister upstreamstoragev1beta1listers.VolumeAttributesClassLister + lister listersstoragev1beta1.VolumeAttributesClassLister } -func (f *volumeAttributesClassInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *volumeAttributesClassInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *volumeAttributesClassInformer) Lister() upstreamstoragev1beta1listers.VolumeAttributesClassLister { - return f.lister +func (i *volumeAttributesClassInformer) Lister() listersstoragev1beta1.VolumeAttributesClassLister { + return i.lister } diff --git a/informers/storagemigration/interface.go b/informers/storagemigration/interface.go index 17958466b..efe2fb45f 100644 --- a/informers/storagemigration/interface.go +++ b/informers/storagemigration/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,31 +14,32 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package storagemigration import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" - "github.com/kcp-dev/client-go/informers/storagemigration/v1alpha1" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpv1alpha1 "github.com/kcp-dev/client-go/informers/storagemigration/v1alpha1" ) +// ClusterInterface provides access to each of this group's versions. type ClusterInterface interface { - // V1alpha1 provides access to the shared informers in V1alpha1. - V1alpha1() v1alpha1.ClusterInterface + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() kcpv1alpha1.ClusterInterface } type group struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &group{factory: f, tweakListOptions: tweakListOptions} } -// V1alpha1 returns a new v1alpha1.ClusterInterface. -func (g *group) V1alpha1() v1alpha1.ClusterInterface { - return v1alpha1.New(g.factory, g.tweakListOptions) +// V1alpha1 returns a new kcpv1alpha1.ClusterInterface. +func (g *group) V1alpha1() kcpv1alpha1.ClusterInterface { + return kcpv1alpha1.New(g.factory, g.tweakListOptions) } diff --git a/informers/storagemigration/v1alpha1/interface.go b/informers/storagemigration/v1alpha1/interface.go index 7bc692392..662e605e5 100644 --- a/informers/storagemigration/v1alpha1/interface.go +++ b/informers/storagemigration/v1alpha1/interface.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,30 +14,30 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha1 import ( - "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" ) type ClusterInterface interface { - // StorageVersionMigrations returns a StorageVersionMigrationClusterInformer + // StorageVersionMigrations returns a StorageVersionMigrationClusterInformer. StorageVersionMigrations() StorageVersionMigrationClusterInformer } type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } -// New returns a new ClusterInterface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) ClusterInterface { +// New returns a new Interface. +func New(f kcpinternalinterfaces.SharedInformerFactory, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) ClusterInterface { return &version{factory: f, tweakListOptions: tweakListOptions} } -// StorageVersionMigrations returns a StorageVersionMigrationClusterInformer +// StorageVersionMigrations returns a StorageVersionMigrationClusterInformer. func (v *version) StorageVersionMigrations() StorageVersionMigrationClusterInformer { return &storageVersionMigrationClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/informers/storagemigration/v1alpha1/storageversionmigration.go b/informers/storagemigration/v1alpha1/storageversionmigration.go index 49fd83bbd..a2509dd84 100644 --- a/informers/storagemigration/v1alpha1/storageversionmigration.go +++ b/informers/storagemigration/v1alpha1/storageversionmigration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,108 +14,115 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-informer-gen. DO NOT EDIT. package v1alpha1 import ( - "context" - "time" + context "context" + time "time" kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" - "github.com/kcp-dev/logicalcluster/v3" - - storagemigrationv1alpha1 "k8s.io/api/storagemigration/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - upstreamstoragemigrationv1alpha1informers "k8s.io/client-go/informers/storagemigration/v1alpha1" - upstreamstoragemigrationv1alpha1listers "k8s.io/client-go/listers/storagemigration/v1alpha1" - "k8s.io/client-go/tools/cache" - - "github.com/kcp-dev/client-go/informers/internalinterfaces" - clientset "github.com/kcp-dev/client-go/kubernetes" - storagemigrationv1alpha1listers "github.com/kcp-dev/client-go/listers/storagemigration/v1alpha1" + logicalcluster "github.com/kcp-dev/logicalcluster/v3" + + apistoragemigrationv1alpha1 "k8s.io/api/storagemigration/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + storagemigrationv1alpha1 "k8s.io/client-go/informers/storagemigration/v1alpha1" + listersstoragemigrationv1alpha1 "k8s.io/client-go/listers/storagemigration/v1alpha1" + cache "k8s.io/client-go/tools/cache" + + kcpinternalinterfaces "github.com/kcp-dev/client-go/informers/internalinterfaces" + kcpkubernetes "github.com/kcp-dev/client-go/kubernetes" + kcpv1alpha1 "github.com/kcp-dev/client-go/listers/storagemigration/v1alpha1" ) // StorageVersionMigrationClusterInformer provides access to a shared informer and lister for // StorageVersionMigrations. type StorageVersionMigrationClusterInformer interface { - Cluster(logicalcluster.Name) upstreamstoragemigrationv1alpha1informers.StorageVersionMigrationInformer + Cluster(logicalcluster.Name) storagemigrationv1alpha1.StorageVersionMigrationInformer + ClusterWithContext(context.Context, logicalcluster.Name) storagemigrationv1alpha1.StorageVersionMigrationInformer Informer() kcpcache.ScopeableSharedIndexInformer - Lister() storagemigrationv1alpha1listers.StorageVersionMigrationClusterLister + Lister() kcpv1alpha1.StorageVersionMigrationClusterLister } type storageVersionMigrationClusterInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc + factory kcpinternalinterfaces.SharedInformerFactory + tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc } // NewStorageVersionMigrationClusterInformer constructs a new informer for StorageVersionMigration type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewStorageVersionMigrationClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { +func NewStorageVersionMigrationClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { return NewFilteredStorageVersionMigrationClusterInformer(client, resyncPeriod, indexers, nil) } // NewFilteredStorageVersionMigrationClusterInformer constructs a new informer for StorageVersionMigration type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredStorageVersionMigrationClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { +func NewFilteredStorageVersionMigrationClusterInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions kcpinternalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { return kcpinformers.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.StoragemigrationV1alpha1().StorageVersionMigrations().List(context.TODO(), options) + return client.StoragemigrationV1alpha1().StorageVersionMigrations().List(context.Background(), options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.StoragemigrationV1alpha1().StorageVersionMigrations().Watch(context.TODO(), options) + return client.StoragemigrationV1alpha1().StorageVersionMigrations().Watch(context.Background(), options) }, }, - &storagemigrationv1alpha1.StorageVersionMigration{}, + &apistoragemigrationv1alpha1.StorageVersionMigration{}, resyncPeriod, indexers, ) } -func (f *storageVersionMigrationClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { +func (i *storageVersionMigrationClusterInformer) defaultInformer(client kcpkubernetes.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredStorageVersionMigrationClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - }, - f.tweakListOptions, - ) + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + }, i.tweakListOptions) +} + +func (i *storageVersionMigrationClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return i.factory.InformerFor(&apistoragemigrationv1alpha1.StorageVersionMigration{}, i.defaultInformer) } -func (f *storageVersionMigrationClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { - return f.factory.InformerFor(&storagemigrationv1alpha1.StorageVersionMigration{}, f.defaultInformer) +func (i *storageVersionMigrationClusterInformer) Lister() kcpv1alpha1.StorageVersionMigrationClusterLister { + return kcpv1alpha1.NewStorageVersionMigrationClusterLister(i.Informer().GetIndexer()) } -func (f *storageVersionMigrationClusterInformer) Lister() storagemigrationv1alpha1listers.StorageVersionMigrationClusterLister { - return storagemigrationv1alpha1listers.NewStorageVersionMigrationClusterLister(f.Informer().GetIndexer()) +func (i *storageVersionMigrationClusterInformer) Cluster(clusterName logicalcluster.Name) storagemigrationv1alpha1.StorageVersionMigrationInformer { + return &storageVersionMigrationInformer{ + informer: i.Informer().Cluster(clusterName), + lister: i.Lister().Cluster(clusterName), + } } -func (f *storageVersionMigrationClusterInformer) Cluster(clusterName logicalcluster.Name) upstreamstoragemigrationv1alpha1informers.StorageVersionMigrationInformer { +func (i *storageVersionMigrationClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) storagemigrationv1alpha1.StorageVersionMigrationInformer { return &storageVersionMigrationInformer{ - informer: f.Informer().Cluster(clusterName), - lister: f.Lister().Cluster(clusterName), + informer: i.Informer().ClusterWithContext(ctx, clusterName), + lister: i.Lister().Cluster(clusterName), } } type storageVersionMigrationInformer struct { informer cache.SharedIndexInformer - lister upstreamstoragemigrationv1alpha1listers.StorageVersionMigrationLister + lister listersstoragemigrationv1alpha1.StorageVersionMigrationLister } -func (f *storageVersionMigrationInformer) Informer() cache.SharedIndexInformer { - return f.informer +func (i *storageVersionMigrationInformer) Informer() cache.SharedIndexInformer { + return i.informer } -func (f *storageVersionMigrationInformer) Lister() upstreamstoragemigrationv1alpha1listers.StorageVersionMigrationLister { - return f.lister +func (i *storageVersionMigrationInformer) Lister() listersstoragemigrationv1alpha1.StorageVersionMigrationLister { + return i.lister } diff --git a/kubernetes/clientset.go b/kubernetes/clientset.go index 8a4ff969a..2c38296ac 100644 --- a/kubernetes/clientset.go +++ b/kubernetes/clientset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,21 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package kubernetes import ( - "fmt" - "net/http" + fmt "fmt" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - "k8s.io/client-go/discovery" + discovery "k8s.io/client-go/discovery" client "k8s.io/client-go/kubernetes" - "k8s.io/client-go/rest" - "k8s.io/client-go/util/flowcontrol" + rest "k8s.io/client-go/rest" + flowcontrol "k8s.io/client-go/util/flowcontrol" admissionregistrationv1 "github.com/kcp-dev/client-go/kubernetes/typed/admissionregistration/v1" admissionregistrationv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/admissionregistration/v1alpha1" @@ -92,6 +92,7 @@ type ClusterInterface interface { AdmissionregistrationV1() admissionregistrationv1.AdmissionregistrationV1ClusterInterface AdmissionregistrationV1alpha1() admissionregistrationv1alpha1.AdmissionregistrationV1alpha1ClusterInterface AdmissionregistrationV1beta1() admissionregistrationv1beta1.AdmissionregistrationV1beta1ClusterInterface + InternalV1alpha1() internalv1alpha1.InternalV1alpha1ClusterInterface AppsV1() appsv1.AppsV1ClusterInterface AppsV1beta1() appsv1beta1.AppsV1beta1ClusterInterface AppsV1beta2() appsv1beta2.AppsV1beta2ClusterInterface @@ -122,7 +123,6 @@ type ClusterInterface interface { FlowcontrolV1beta1() flowcontrolv1beta1.FlowcontrolV1beta1ClusterInterface FlowcontrolV1beta2() flowcontrolv1beta2.FlowcontrolV1beta2ClusterInterface FlowcontrolV1beta3() flowcontrolv1beta3.FlowcontrolV1beta3ClusterInterface - InternalV1alpha1() internalv1alpha1.InternalV1alpha1ClusterInterface NetworkingV1() networkingv1.NetworkingV1ClusterInterface NetworkingV1alpha1() networkingv1alpha1.NetworkingV1alpha1ClusterInterface NetworkingV1beta1() networkingv1beta1.NetworkingV1beta1ClusterInterface @@ -139,19 +139,20 @@ type ClusterInterface interface { SchedulingV1() schedulingv1.SchedulingV1ClusterInterface SchedulingV1alpha1() schedulingv1alpha1.SchedulingV1alpha1ClusterInterface SchedulingV1beta1() schedulingv1beta1.SchedulingV1beta1ClusterInterface - StoragemigrationV1alpha1() storagemigrationv1alpha1.StoragemigrationV1alpha1ClusterInterface StorageV1() storagev1.StorageV1ClusterInterface StorageV1alpha1() storagev1alpha1.StorageV1alpha1ClusterInterface StorageV1beta1() storagev1beta1.StorageV1beta1ClusterInterface + StoragemigrationV1alpha1() storagemigrationv1alpha1.StoragemigrationV1alpha1ClusterInterface } -// ClusterClientset contains the clients for groups. +// ClusterClientset contains the cluster clients for groups. type ClusterClientset struct { *discovery.DiscoveryClient clientCache kcpclient.Cache[*client.Clientset] admissionregistrationV1 *admissionregistrationv1.AdmissionregistrationV1ClusterClient admissionregistrationV1alpha1 *admissionregistrationv1alpha1.AdmissionregistrationV1alpha1ClusterClient admissionregistrationV1beta1 *admissionregistrationv1beta1.AdmissionregistrationV1beta1ClusterClient + internalV1alpha1 *internalv1alpha1.InternalV1alpha1ClusterClient appsV1 *appsv1.AppsV1ClusterClient appsV1beta1 *appsv1beta1.AppsV1beta1ClusterClient appsV1beta2 *appsv1beta2.AppsV1beta2ClusterClient @@ -182,7 +183,6 @@ type ClusterClientset struct { flowcontrolV1beta1 *flowcontrolv1beta1.FlowcontrolV1beta1ClusterClient flowcontrolV1beta2 *flowcontrolv1beta2.FlowcontrolV1beta2ClusterClient flowcontrolV1beta3 *flowcontrolv1beta3.FlowcontrolV1beta3ClusterClient - internalV1alpha1 *internalv1alpha1.InternalV1alpha1ClusterClient networkingV1 *networkingv1.NetworkingV1ClusterClient networkingV1alpha1 *networkingv1alpha1.NetworkingV1alpha1ClusterClient networkingV1beta1 *networkingv1beta1.NetworkingV1beta1ClusterClient @@ -199,13 +199,13 @@ type ClusterClientset struct { schedulingV1 *schedulingv1.SchedulingV1ClusterClient schedulingV1alpha1 *schedulingv1alpha1.SchedulingV1alpha1ClusterClient schedulingV1beta1 *schedulingv1beta1.SchedulingV1beta1ClusterClient - storagemigrationV1alpha1 *storagemigrationv1alpha1.StoragemigrationV1alpha1ClusterClient storageV1 *storagev1.StorageV1ClusterClient storageV1alpha1 *storagev1alpha1.StorageV1alpha1ClusterClient storageV1beta1 *storagev1beta1.StorageV1beta1ClusterClient + storagemigrationV1alpha1 *storagemigrationv1alpha1.StoragemigrationV1alpha1ClusterClient } -// Discovery retrieves the DiscoveryClient +// Discovery retrieves the DiscoveryClient. func (c *ClusterClientset) Discovery() discovery.DiscoveryInterface { if c == nil { return nil @@ -228,6 +228,11 @@ func (c *ClusterClientset) AdmissionregistrationV1beta1() admissionregistrationv return c.admissionregistrationV1beta1 } +// InternalV1alpha1 retrieves the InternalV1alpha1ClusterClient. +func (c *ClusterClientset) InternalV1alpha1() internalv1alpha1.InternalV1alpha1ClusterInterface { + return c.internalV1alpha1 +} + // AppsV1 retrieves the AppsV1ClusterClient. func (c *ClusterClientset) AppsV1() appsv1.AppsV1ClusterInterface { return c.appsV1 @@ -378,11 +383,6 @@ func (c *ClusterClientset) FlowcontrolV1beta3() flowcontrolv1beta3.FlowcontrolV1 return c.flowcontrolV1beta3 } -// InternalV1alpha1 retrieves the InternalV1alpha1ClusterClient. -func (c *ClusterClientset) InternalV1alpha1() internalv1alpha1.InternalV1alpha1ClusterInterface { - return c.internalV1alpha1 -} - // NetworkingV1 retrieves the NetworkingV1ClusterClient. func (c *ClusterClientset) NetworkingV1() networkingv1.NetworkingV1ClusterInterface { return c.networkingV1 @@ -463,11 +463,6 @@ func (c *ClusterClientset) SchedulingV1beta1() schedulingv1beta1.SchedulingV1bet return c.schedulingV1beta1 } -// StoragemigrationV1alpha1 retrieves the StoragemigrationV1alpha1ClusterClient. -func (c *ClusterClientset) StoragemigrationV1alpha1() storagemigrationv1alpha1.StoragemigrationV1alpha1ClusterInterface { - return c.storagemigrationV1alpha1 -} - // StorageV1 retrieves the StorageV1ClusterClient. func (c *ClusterClientset) StorageV1() storagev1.StorageV1ClusterInterface { return c.storageV1 @@ -483,6 +478,11 @@ func (c *ClusterClientset) StorageV1beta1() storagev1beta1.StorageV1beta1Cluster return c.storageV1beta1 } +// StoragemigrationV1alpha1 retrieves the StoragemigrationV1alpha1ClusterClient. +func (c *ClusterClientset) StoragemigrationV1alpha1() storagemigrationv1alpha1.StoragemigrationV1alpha1ClusterInterface { + return c.storagemigrationV1alpha1 +} + // Cluster scopes this clientset to one cluster. func (c *ClusterClientset) Cluster(clusterPath logicalcluster.Path) client.Interface { if clusterPath == logicalcluster.Wildcard { @@ -547,6 +547,10 @@ func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*ClusterCli if err != nil { return nil, err } + cs.internalV1alpha1, err = internalv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } cs.appsV1, err = appsv1.NewForConfigAndClient(&configShallowCopy, httpClient) if err != nil { return nil, err @@ -667,10 +671,6 @@ func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*ClusterCli if err != nil { return nil, err } - cs.internalV1alpha1, err = internalv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) - if err != nil { - return nil, err - } cs.networkingV1, err = networkingv1.NewForConfigAndClient(&configShallowCopy, httpClient) if err != nil { return nil, err @@ -735,10 +735,6 @@ func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*ClusterCli if err != nil { return nil, err } - cs.storagemigrationV1alpha1, err = storagemigrationv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) - if err != nil { - return nil, err - } cs.storageV1, err = storagev1.NewForConfigAndClient(&configShallowCopy, httpClient) if err != nil { return nil, err @@ -751,6 +747,10 @@ func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*ClusterCli if err != nil { return nil, err } + cs.storagemigrationV1alpha1, err = storagemigrationv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient) if err != nil { @@ -768,3 +768,65 @@ func NewForConfigOrDie(c *rest.Config) *ClusterClientset { } return cs } + +// New creates a new ClusterClientset for the given RESTClient. +func New(c *rest.Config) *ClusterClientset { + var cs ClusterClientset + cs.admissionregistrationV1 = admissionregistrationv1.NewForConfigOrDie(c) + cs.admissionregistrationV1alpha1 = admissionregistrationv1alpha1.NewForConfigOrDie(c) + cs.admissionregistrationV1beta1 = admissionregistrationv1beta1.NewForConfigOrDie(c) + cs.internalV1alpha1 = internalv1alpha1.NewForConfigOrDie(c) + cs.appsV1 = appsv1.NewForConfigOrDie(c) + cs.appsV1beta1 = appsv1beta1.NewForConfigOrDie(c) + cs.appsV1beta2 = appsv1beta2.NewForConfigOrDie(c) + cs.authenticationV1 = authenticationv1.NewForConfigOrDie(c) + cs.authenticationV1alpha1 = authenticationv1alpha1.NewForConfigOrDie(c) + cs.authenticationV1beta1 = authenticationv1beta1.NewForConfigOrDie(c) + cs.authorizationV1 = authorizationv1.NewForConfigOrDie(c) + cs.authorizationV1beta1 = authorizationv1beta1.NewForConfigOrDie(c) + cs.autoscalingV1 = autoscalingv1.NewForConfigOrDie(c) + cs.autoscalingV2 = autoscalingv2.NewForConfigOrDie(c) + cs.autoscalingV2beta1 = autoscalingv2beta1.NewForConfigOrDie(c) + cs.autoscalingV2beta2 = autoscalingv2beta2.NewForConfigOrDie(c) + cs.batchV1 = batchv1.NewForConfigOrDie(c) + cs.batchV1beta1 = batchv1beta1.NewForConfigOrDie(c) + cs.certificatesV1 = certificatesv1.NewForConfigOrDie(c) + cs.certificatesV1alpha1 = certificatesv1alpha1.NewForConfigOrDie(c) + cs.certificatesV1beta1 = certificatesv1beta1.NewForConfigOrDie(c) + cs.coordinationV1 = coordinationv1.NewForConfigOrDie(c) + cs.coordinationV1alpha2 = coordinationv1alpha2.NewForConfigOrDie(c) + cs.coordinationV1beta1 = coordinationv1beta1.NewForConfigOrDie(c) + cs.coreV1 = corev1.NewForConfigOrDie(c) + cs.discoveryV1 = discoveryv1.NewForConfigOrDie(c) + cs.discoveryV1beta1 = discoveryv1beta1.NewForConfigOrDie(c) + cs.eventsV1 = eventsv1.NewForConfigOrDie(c) + cs.eventsV1beta1 = eventsv1beta1.NewForConfigOrDie(c) + cs.extensionsV1beta1 = extensionsv1beta1.NewForConfigOrDie(c) + cs.flowcontrolV1 = flowcontrolv1.NewForConfigOrDie(c) + cs.flowcontrolV1beta1 = flowcontrolv1beta1.NewForConfigOrDie(c) + cs.flowcontrolV1beta2 = flowcontrolv1beta2.NewForConfigOrDie(c) + cs.flowcontrolV1beta3 = flowcontrolv1beta3.NewForConfigOrDie(c) + cs.networkingV1 = networkingv1.NewForConfigOrDie(c) + cs.networkingV1alpha1 = networkingv1alpha1.NewForConfigOrDie(c) + cs.networkingV1beta1 = networkingv1beta1.NewForConfigOrDie(c) + cs.nodeV1 = nodev1.NewForConfigOrDie(c) + cs.nodeV1alpha1 = nodev1alpha1.NewForConfigOrDie(c) + cs.nodeV1beta1 = nodev1beta1.NewForConfigOrDie(c) + cs.policyV1 = policyv1.NewForConfigOrDie(c) + cs.policyV1beta1 = policyv1beta1.NewForConfigOrDie(c) + cs.rbacV1 = rbacv1.NewForConfigOrDie(c) + cs.rbacV1alpha1 = rbacv1alpha1.NewForConfigOrDie(c) + cs.rbacV1beta1 = rbacv1beta1.NewForConfigOrDie(c) + cs.resourceV1alpha3 = resourcev1alpha3.NewForConfigOrDie(c) + cs.resourceV1beta1 = resourcev1beta1.NewForConfigOrDie(c) + cs.schedulingV1 = schedulingv1.NewForConfigOrDie(c) + cs.schedulingV1alpha1 = schedulingv1alpha1.NewForConfigOrDie(c) + cs.schedulingV1beta1 = schedulingv1beta1.NewForConfigOrDie(c) + cs.storageV1 = storagev1.NewForConfigOrDie(c) + cs.storageV1alpha1 = storagev1alpha1.NewForConfigOrDie(c) + cs.storageV1beta1 = storagev1beta1.NewForConfigOrDie(c) + cs.storagemigrationV1alpha1 = storagemigrationv1alpha1.NewForConfigOrDie(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) + return &cs +} diff --git a/kubernetes/fake/clientset.go b/kubernetes/fake/clientset.go index a1cd48f9d..9efd348f1 100644 --- a/kubernetes/fake/clientset.go +++ b/kubernetes/fake/clientset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,9 +22,9 @@ import ( "github.com/kcp-dev/logicalcluster/v3" "k8s.io/apimachinery/pkg/runtime" + applyconfigurations "k8s.io/client-go/applyconfigurations" "k8s.io/client-go/discovery" - client "k8s.io/client-go/kubernetes" - clientscheme "k8s.io/client-go/kubernetes/scheme" + clientset "k8s.io/client-go/kubernetes" admissionregistrationv1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1" admissionregistrationv1alpha1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1" admissionregistrationv1beta1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1" @@ -80,144 +80,149 @@ import ( storagev1beta1 "k8s.io/client-go/kubernetes/typed/storage/v1beta1" storagemigrationv1alpha1 "k8s.io/client-go/kubernetes/typed/storagemigration/v1alpha1" - kcpclient "github.com/kcp-dev/client-go/kubernetes" + kcpclientset "github.com/kcp-dev/client-go/kubernetes" + kcpclientscheme "github.com/kcp-dev/client-go/kubernetes/scheme" kcpadmissionregistrationv1 "github.com/kcp-dev/client-go/kubernetes/typed/admissionregistration/v1" - fakeadmissionregistrationv1 "github.com/kcp-dev/client-go/kubernetes/typed/admissionregistration/v1/fake" + kcpfakeadmissionregistrationv1 "github.com/kcp-dev/client-go/kubernetes/typed/admissionregistration/v1/fake" kcpadmissionregistrationv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/admissionregistration/v1alpha1" - fakeadmissionregistrationv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/admissionregistration/v1alpha1/fake" + kcpfakeadmissionregistrationv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/admissionregistration/v1alpha1/fake" kcpadmissionregistrationv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/admissionregistration/v1beta1" - fakeadmissionregistrationv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/admissionregistration/v1beta1/fake" + kcpfakeadmissionregistrationv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/admissionregistration/v1beta1/fake" kcpinternalv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/apiserverinternal/v1alpha1" - fakeinternalv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/apiserverinternal/v1alpha1/fake" + kcpfakeinternalv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/apiserverinternal/v1alpha1/fake" kcpappsv1 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1" - fakeappsv1 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1/fake" + kcpfakeappsv1 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1/fake" kcpappsv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1beta1" - fakeappsv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1beta1/fake" + kcpfakeappsv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1beta1/fake" kcpappsv1beta2 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1beta2" - fakeappsv1beta2 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1beta2/fake" + kcpfakeappsv1beta2 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1beta2/fake" kcpauthenticationv1 "github.com/kcp-dev/client-go/kubernetes/typed/authentication/v1" - fakeauthenticationv1 "github.com/kcp-dev/client-go/kubernetes/typed/authentication/v1/fake" + kcpfakeauthenticationv1 "github.com/kcp-dev/client-go/kubernetes/typed/authentication/v1/fake" kcpauthenticationv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/authentication/v1alpha1" - fakeauthenticationv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/authentication/v1alpha1/fake" + kcpfakeauthenticationv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/authentication/v1alpha1/fake" kcpauthenticationv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/authentication/v1beta1" - fakeauthenticationv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/authentication/v1beta1/fake" + kcpfakeauthenticationv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/authentication/v1beta1/fake" kcpauthorizationv1 "github.com/kcp-dev/client-go/kubernetes/typed/authorization/v1" - fakeauthorizationv1 "github.com/kcp-dev/client-go/kubernetes/typed/authorization/v1/fake" + kcpfakeauthorizationv1 "github.com/kcp-dev/client-go/kubernetes/typed/authorization/v1/fake" kcpauthorizationv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/authorization/v1beta1" - fakeauthorizationv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/authorization/v1beta1/fake" + kcpfakeauthorizationv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/authorization/v1beta1/fake" kcpautoscalingv1 "github.com/kcp-dev/client-go/kubernetes/typed/autoscaling/v1" - fakeautoscalingv1 "github.com/kcp-dev/client-go/kubernetes/typed/autoscaling/v1/fake" + kcpfakeautoscalingv1 "github.com/kcp-dev/client-go/kubernetes/typed/autoscaling/v1/fake" kcpautoscalingv2 "github.com/kcp-dev/client-go/kubernetes/typed/autoscaling/v2" - fakeautoscalingv2 "github.com/kcp-dev/client-go/kubernetes/typed/autoscaling/v2/fake" + kcpfakeautoscalingv2 "github.com/kcp-dev/client-go/kubernetes/typed/autoscaling/v2/fake" kcpautoscalingv2beta1 "github.com/kcp-dev/client-go/kubernetes/typed/autoscaling/v2beta1" - fakeautoscalingv2beta1 "github.com/kcp-dev/client-go/kubernetes/typed/autoscaling/v2beta1/fake" + kcpfakeautoscalingv2beta1 "github.com/kcp-dev/client-go/kubernetes/typed/autoscaling/v2beta1/fake" kcpautoscalingv2beta2 "github.com/kcp-dev/client-go/kubernetes/typed/autoscaling/v2beta2" - fakeautoscalingv2beta2 "github.com/kcp-dev/client-go/kubernetes/typed/autoscaling/v2beta2/fake" + kcpfakeautoscalingv2beta2 "github.com/kcp-dev/client-go/kubernetes/typed/autoscaling/v2beta2/fake" kcpbatchv1 "github.com/kcp-dev/client-go/kubernetes/typed/batch/v1" - fakebatchv1 "github.com/kcp-dev/client-go/kubernetes/typed/batch/v1/fake" + kcpfakebatchv1 "github.com/kcp-dev/client-go/kubernetes/typed/batch/v1/fake" kcpbatchv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/batch/v1beta1" - fakebatchv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/batch/v1beta1/fake" + kcpfakebatchv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/batch/v1beta1/fake" kcpcertificatesv1 "github.com/kcp-dev/client-go/kubernetes/typed/certificates/v1" - fakecertificatesv1 "github.com/kcp-dev/client-go/kubernetes/typed/certificates/v1/fake" + kcpfakecertificatesv1 "github.com/kcp-dev/client-go/kubernetes/typed/certificates/v1/fake" kcpcertificatesv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/certificates/v1alpha1" - fakecertificatesv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/certificates/v1alpha1/fake" + kcpfakecertificatesv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/certificates/v1alpha1/fake" kcpcertificatesv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/certificates/v1beta1" - fakecertificatesv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/certificates/v1beta1/fake" + kcpfakecertificatesv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/certificates/v1beta1/fake" kcpcoordinationv1 "github.com/kcp-dev/client-go/kubernetes/typed/coordination/v1" - fakecoordinationv1 "github.com/kcp-dev/client-go/kubernetes/typed/coordination/v1/fake" + kcpfakecoordinationv1 "github.com/kcp-dev/client-go/kubernetes/typed/coordination/v1/fake" kcpcoordinationv1alpha2 "github.com/kcp-dev/client-go/kubernetes/typed/coordination/v1alpha2" - fakecoordinationv1alpha2 "github.com/kcp-dev/client-go/kubernetes/typed/coordination/v1alpha2/fake" + kcpfakecoordinationv1alpha2 "github.com/kcp-dev/client-go/kubernetes/typed/coordination/v1alpha2/fake" kcpcoordinationv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/coordination/v1beta1" - fakecoordinationv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/coordination/v1beta1/fake" + kcpfakecoordinationv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/coordination/v1beta1/fake" kcpcorev1 "github.com/kcp-dev/client-go/kubernetes/typed/core/v1" - fakecorev1 "github.com/kcp-dev/client-go/kubernetes/typed/core/v1/fake" + kcpfakecorev1 "github.com/kcp-dev/client-go/kubernetes/typed/core/v1/fake" kcpdiscoveryv1 "github.com/kcp-dev/client-go/kubernetes/typed/discovery/v1" - fakediscoveryv1 "github.com/kcp-dev/client-go/kubernetes/typed/discovery/v1/fake" + kcpfakediscoveryv1 "github.com/kcp-dev/client-go/kubernetes/typed/discovery/v1/fake" kcpdiscoveryv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/discovery/v1beta1" - fakediscoveryv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/discovery/v1beta1/fake" + kcpfakediscoveryv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/discovery/v1beta1/fake" kcpeventsv1 "github.com/kcp-dev/client-go/kubernetes/typed/events/v1" - fakeeventsv1 "github.com/kcp-dev/client-go/kubernetes/typed/events/v1/fake" + kcpfakeeventsv1 "github.com/kcp-dev/client-go/kubernetes/typed/events/v1/fake" kcpeventsv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/events/v1beta1" - fakeeventsv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/events/v1beta1/fake" + kcpfakeeventsv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/events/v1beta1/fake" kcpextensionsv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/extensions/v1beta1" - fakeextensionsv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/extensions/v1beta1/fake" + kcpfakeextensionsv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/extensions/v1beta1/fake" kcpflowcontrolv1 "github.com/kcp-dev/client-go/kubernetes/typed/flowcontrol/v1" - fakeflowcontrolv1 "github.com/kcp-dev/client-go/kubernetes/typed/flowcontrol/v1/fake" + kcpfakeflowcontrolv1 "github.com/kcp-dev/client-go/kubernetes/typed/flowcontrol/v1/fake" kcpflowcontrolv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/flowcontrol/v1beta1" - fakeflowcontrolv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/flowcontrol/v1beta1/fake" + kcpfakeflowcontrolv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/flowcontrol/v1beta1/fake" kcpflowcontrolv1beta2 "github.com/kcp-dev/client-go/kubernetes/typed/flowcontrol/v1beta2" - fakeflowcontrolv1beta2 "github.com/kcp-dev/client-go/kubernetes/typed/flowcontrol/v1beta2/fake" + kcpfakeflowcontrolv1beta2 "github.com/kcp-dev/client-go/kubernetes/typed/flowcontrol/v1beta2/fake" kcpflowcontrolv1beta3 "github.com/kcp-dev/client-go/kubernetes/typed/flowcontrol/v1beta3" - fakeflowcontrolv1beta3 "github.com/kcp-dev/client-go/kubernetes/typed/flowcontrol/v1beta3/fake" + kcpfakeflowcontrolv1beta3 "github.com/kcp-dev/client-go/kubernetes/typed/flowcontrol/v1beta3/fake" kcpnetworkingv1 "github.com/kcp-dev/client-go/kubernetes/typed/networking/v1" - fakenetworkingv1 "github.com/kcp-dev/client-go/kubernetes/typed/networking/v1/fake" + kcpfakenetworkingv1 "github.com/kcp-dev/client-go/kubernetes/typed/networking/v1/fake" kcpnetworkingv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/networking/v1alpha1" - fakenetworkingv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/networking/v1alpha1/fake" + kcpfakenetworkingv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/networking/v1alpha1/fake" kcpnetworkingv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/networking/v1beta1" - fakenetworkingv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/networking/v1beta1/fake" + kcpfakenetworkingv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/networking/v1beta1/fake" kcpnodev1 "github.com/kcp-dev/client-go/kubernetes/typed/node/v1" - fakenodev1 "github.com/kcp-dev/client-go/kubernetes/typed/node/v1/fake" + kcpfakenodev1 "github.com/kcp-dev/client-go/kubernetes/typed/node/v1/fake" kcpnodev1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/node/v1alpha1" - fakenodev1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/node/v1alpha1/fake" + kcpfakenodev1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/node/v1alpha1/fake" kcpnodev1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/node/v1beta1" - fakenodev1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/node/v1beta1/fake" + kcpfakenodev1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/node/v1beta1/fake" kcppolicyv1 "github.com/kcp-dev/client-go/kubernetes/typed/policy/v1" - fakepolicyv1 "github.com/kcp-dev/client-go/kubernetes/typed/policy/v1/fake" + kcpfakepolicyv1 "github.com/kcp-dev/client-go/kubernetes/typed/policy/v1/fake" kcppolicyv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/policy/v1beta1" - fakepolicyv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/policy/v1beta1/fake" + kcpfakepolicyv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/policy/v1beta1/fake" kcprbacv1 "github.com/kcp-dev/client-go/kubernetes/typed/rbac/v1" - fakerbacv1 "github.com/kcp-dev/client-go/kubernetes/typed/rbac/v1/fake" + kcpfakerbacv1 "github.com/kcp-dev/client-go/kubernetes/typed/rbac/v1/fake" kcprbacv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/rbac/v1alpha1" - fakerbacv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/rbac/v1alpha1/fake" + kcpfakerbacv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/rbac/v1alpha1/fake" kcprbacv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/rbac/v1beta1" - fakerbacv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/rbac/v1beta1/fake" + kcpfakerbacv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/rbac/v1beta1/fake" kcpresourcev1alpha3 "github.com/kcp-dev/client-go/kubernetes/typed/resource/v1alpha3" - fakeresourcev1alpha3 "github.com/kcp-dev/client-go/kubernetes/typed/resource/v1alpha3/fake" + kcpfakeresourcev1alpha3 "github.com/kcp-dev/client-go/kubernetes/typed/resource/v1alpha3/fake" kcpresourcev1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/resource/v1beta1" - fakeresourcev1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/resource/v1beta1/fake" + kcpfakeresourcev1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/resource/v1beta1/fake" kcpschedulingv1 "github.com/kcp-dev/client-go/kubernetes/typed/scheduling/v1" - fakeschedulingv1 "github.com/kcp-dev/client-go/kubernetes/typed/scheduling/v1/fake" + kcpfakeschedulingv1 "github.com/kcp-dev/client-go/kubernetes/typed/scheduling/v1/fake" kcpschedulingv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/scheduling/v1alpha1" - fakeschedulingv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/scheduling/v1alpha1/fake" + kcpfakeschedulingv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/scheduling/v1alpha1/fake" kcpschedulingv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/scheduling/v1beta1" - fakeschedulingv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/scheduling/v1beta1/fake" + kcpfakeschedulingv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/scheduling/v1beta1/fake" kcpstoragev1 "github.com/kcp-dev/client-go/kubernetes/typed/storage/v1" - fakestoragev1 "github.com/kcp-dev/client-go/kubernetes/typed/storage/v1/fake" + kcpfakestoragev1 "github.com/kcp-dev/client-go/kubernetes/typed/storage/v1/fake" kcpstoragev1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/storage/v1alpha1" - fakestoragev1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/storage/v1alpha1/fake" + kcpfakestoragev1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/storage/v1alpha1/fake" kcpstoragev1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/storage/v1beta1" - fakestoragev1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/storage/v1beta1/fake" + kcpfakestoragev1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/storage/v1beta1/fake" kcpstoragemigrationv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/storagemigration/v1alpha1" - fakestoragemigrationv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/storagemigration/v1alpha1/fake" + kcpfakestoragemigrationv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/storagemigration/v1alpha1/fake" kcpfakediscovery "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/discovery/fake" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) // NewSimpleClientset returns a clientset that will respond with the provided objects. // It's backed by a very simple object tracker that processes creates, updates and deletions as-is, -// without applying any validations and/or defaults. It shouldn't be considered a replacement +// without applying any field management, validations and/or defaults. It shouldn't be considered a replacement // for a real clientset and is mostly useful in simple unit tests. +// +// DEPRECATED: NewClientset replaces this with support for field management, which significantly improves +// server side apply testing. NewClientset is only available when apply configurations are generated (e.g. +// via --with-applyconfig). func NewSimpleClientset(objects ...runtime.Object) *ClusterClientset { - o := kcptesting.NewObjectTracker(clientscheme.Scheme, clientscheme.Codecs.UniversalDecoder()) + o := kcptesting.NewObjectTracker(kcpclientscheme.Scheme, kcpclientscheme.Codecs.UniversalDecoder()) o.AddAll(objects...) - cs := &ClusterClientset{Fake: &kcptesting.Fake{}, tracker: o} - cs.discovery = &kcpfakediscovery.FakeDiscovery{Fake: cs.Fake, ClusterPath: logicalcluster.Wildcard} + cs := &ClusterClientset{Fake: kcptesting.Fake{}, tracker: o} + cs.discovery = &kcpfakediscovery.FakeDiscovery{Fake: &cs.Fake, ClusterPath: logicalcluster.Wildcard} cs.AddReactor("*", "*", kcptesting.ObjectReaction(o)) cs.AddWatchReactor("*", kcptesting.WatchReaction(o)) return cs } -var _ kcpclient.ClusterInterface = (*ClusterClientset)(nil) - // ClusterClientset contains the clients for groups. type ClusterClientset struct { - *kcptesting.Fake + kcptesting.Fake discovery *kcpfakediscovery.FakeDiscovery tracker kcptesting.ObjectTracker } +var _ kcpclientset.ClusterInterface = (*ClusterClientset)(nil) + // Discovery retrieves the DiscoveryClient func (c *ClusterClientset) Discovery() discovery.DiscoveryInterface { return c.discovery @@ -227,292 +232,292 @@ func (c *ClusterClientset) Tracker() kcptesting.ObjectTracker { return c.tracker } -// AdmissionregistrationV1 retrieves the AdmissionregistrationV1ClusterClient. +// Cluster scopes this clientset to one cluster. +func (c *ClusterClientset) Cluster(clusterPath logicalcluster.Path) clientset.Interface { + if clusterPath == logicalcluster.Wildcard { + panic("A specific cluster must be provided when scoping, not the wildcard.") + } + return &Clientset{ + Fake: &c.Fake, + discovery: &kcpfakediscovery.FakeDiscovery{Fake: &c.Fake, ClusterPath: clusterPath}, + tracker: c.tracker.Cluster(clusterPath), + clusterPath: clusterPath, + } +} + +// AdmissionregistrationV1 retrieves the AdmissionregistrationV1ClusterClient func (c *ClusterClientset) AdmissionregistrationV1() kcpadmissionregistrationv1.AdmissionregistrationV1ClusterInterface { - return &fakeadmissionregistrationv1.AdmissionregistrationV1ClusterClient{Fake: c.Fake} + return &kcpfakeadmissionregistrationv1.AdmissionregistrationV1ClusterClient{Fake: &c.Fake} } -// AdmissionregistrationV1alpha1 retrieves the AdmissionregistrationV1alpha1ClusterClient. +// AdmissionregistrationV1alpha1 retrieves the AdmissionregistrationV1alpha1ClusterClient func (c *ClusterClientset) AdmissionregistrationV1alpha1() kcpadmissionregistrationv1alpha1.AdmissionregistrationV1alpha1ClusterInterface { - return &fakeadmissionregistrationv1alpha1.AdmissionregistrationV1alpha1ClusterClient{Fake: c.Fake} + return &kcpfakeadmissionregistrationv1alpha1.AdmissionregistrationV1alpha1ClusterClient{Fake: &c.Fake} } -// AdmissionregistrationV1beta1 retrieves the AdmissionregistrationV1beta1ClusterClient. +// AdmissionregistrationV1beta1 retrieves the AdmissionregistrationV1beta1ClusterClient func (c *ClusterClientset) AdmissionregistrationV1beta1() kcpadmissionregistrationv1beta1.AdmissionregistrationV1beta1ClusterInterface { - return &fakeadmissionregistrationv1beta1.AdmissionregistrationV1beta1ClusterClient{Fake: c.Fake} + return &kcpfakeadmissionregistrationv1beta1.AdmissionregistrationV1beta1ClusterClient{Fake: &c.Fake} +} + +// InternalV1alpha1 retrieves the InternalV1alpha1ClusterClient +func (c *ClusterClientset) InternalV1alpha1() kcpinternalv1alpha1.InternalV1alpha1ClusterInterface { + return &kcpfakeinternalv1alpha1.InternalV1alpha1ClusterClient{Fake: &c.Fake} } -// AppsV1 retrieves the AppsV1ClusterClient. +// AppsV1 retrieves the AppsV1ClusterClient func (c *ClusterClientset) AppsV1() kcpappsv1.AppsV1ClusterInterface { - return &fakeappsv1.AppsV1ClusterClient{Fake: c.Fake} + return &kcpfakeappsv1.AppsV1ClusterClient{Fake: &c.Fake} } -// AppsV1beta1 retrieves the AppsV1beta1ClusterClient. +// AppsV1beta1 retrieves the AppsV1beta1ClusterClient func (c *ClusterClientset) AppsV1beta1() kcpappsv1beta1.AppsV1beta1ClusterInterface { - return &fakeappsv1beta1.AppsV1beta1ClusterClient{Fake: c.Fake} + return &kcpfakeappsv1beta1.AppsV1beta1ClusterClient{Fake: &c.Fake} } -// AppsV1beta2 retrieves the AppsV1beta2ClusterClient. +// AppsV1beta2 retrieves the AppsV1beta2ClusterClient func (c *ClusterClientset) AppsV1beta2() kcpappsv1beta2.AppsV1beta2ClusterInterface { - return &fakeappsv1beta2.AppsV1beta2ClusterClient{Fake: c.Fake} + return &kcpfakeappsv1beta2.AppsV1beta2ClusterClient{Fake: &c.Fake} } -// AuthenticationV1 retrieves the AuthenticationV1ClusterClient. +// AuthenticationV1 retrieves the AuthenticationV1ClusterClient func (c *ClusterClientset) AuthenticationV1() kcpauthenticationv1.AuthenticationV1ClusterInterface { - return &fakeauthenticationv1.AuthenticationV1ClusterClient{Fake: c.Fake} + return &kcpfakeauthenticationv1.AuthenticationV1ClusterClient{Fake: &c.Fake} } -// AuthenticationV1alpha1 retrieves the AuthenticationV1alpha1ClusterClient. +// AuthenticationV1alpha1 retrieves the AuthenticationV1alpha1ClusterClient func (c *ClusterClientset) AuthenticationV1alpha1() kcpauthenticationv1alpha1.AuthenticationV1alpha1ClusterInterface { - return &fakeauthenticationv1alpha1.AuthenticationV1alpha1ClusterClient{Fake: c.Fake} + return &kcpfakeauthenticationv1alpha1.AuthenticationV1alpha1ClusterClient{Fake: &c.Fake} } -// AuthenticationV1beta1 retrieves the AuthenticationV1beta1ClusterClient. +// AuthenticationV1beta1 retrieves the AuthenticationV1beta1ClusterClient func (c *ClusterClientset) AuthenticationV1beta1() kcpauthenticationv1beta1.AuthenticationV1beta1ClusterInterface { - return &fakeauthenticationv1beta1.AuthenticationV1beta1ClusterClient{Fake: c.Fake} + return &kcpfakeauthenticationv1beta1.AuthenticationV1beta1ClusterClient{Fake: &c.Fake} } -// AuthorizationV1 retrieves the AuthorizationV1ClusterClient. +// AuthorizationV1 retrieves the AuthorizationV1ClusterClient func (c *ClusterClientset) AuthorizationV1() kcpauthorizationv1.AuthorizationV1ClusterInterface { - return &fakeauthorizationv1.AuthorizationV1ClusterClient{Fake: c.Fake} + return &kcpfakeauthorizationv1.AuthorizationV1ClusterClient{Fake: &c.Fake} } -// AuthorizationV1beta1 retrieves the AuthorizationV1beta1ClusterClient. +// AuthorizationV1beta1 retrieves the AuthorizationV1beta1ClusterClient func (c *ClusterClientset) AuthorizationV1beta1() kcpauthorizationv1beta1.AuthorizationV1beta1ClusterInterface { - return &fakeauthorizationv1beta1.AuthorizationV1beta1ClusterClient{Fake: c.Fake} + return &kcpfakeauthorizationv1beta1.AuthorizationV1beta1ClusterClient{Fake: &c.Fake} } -// AutoscalingV1 retrieves the AutoscalingV1ClusterClient. +// AutoscalingV1 retrieves the AutoscalingV1ClusterClient func (c *ClusterClientset) AutoscalingV1() kcpautoscalingv1.AutoscalingV1ClusterInterface { - return &fakeautoscalingv1.AutoscalingV1ClusterClient{Fake: c.Fake} + return &kcpfakeautoscalingv1.AutoscalingV1ClusterClient{Fake: &c.Fake} } -// AutoscalingV2 retrieves the AutoscalingV2ClusterClient. +// AutoscalingV2 retrieves the AutoscalingV2ClusterClient func (c *ClusterClientset) AutoscalingV2() kcpautoscalingv2.AutoscalingV2ClusterInterface { - return &fakeautoscalingv2.AutoscalingV2ClusterClient{Fake: c.Fake} + return &kcpfakeautoscalingv2.AutoscalingV2ClusterClient{Fake: &c.Fake} } -// AutoscalingV2beta1 retrieves the AutoscalingV2beta1ClusterClient. +// AutoscalingV2beta1 retrieves the AutoscalingV2beta1ClusterClient func (c *ClusterClientset) AutoscalingV2beta1() kcpautoscalingv2beta1.AutoscalingV2beta1ClusterInterface { - return &fakeautoscalingv2beta1.AutoscalingV2beta1ClusterClient{Fake: c.Fake} + return &kcpfakeautoscalingv2beta1.AutoscalingV2beta1ClusterClient{Fake: &c.Fake} } -// AutoscalingV2beta2 retrieves the AutoscalingV2beta2ClusterClient. +// AutoscalingV2beta2 retrieves the AutoscalingV2beta2ClusterClient func (c *ClusterClientset) AutoscalingV2beta2() kcpautoscalingv2beta2.AutoscalingV2beta2ClusterInterface { - return &fakeautoscalingv2beta2.AutoscalingV2beta2ClusterClient{Fake: c.Fake} + return &kcpfakeautoscalingv2beta2.AutoscalingV2beta2ClusterClient{Fake: &c.Fake} } -// BatchV1 retrieves the BatchV1ClusterClient. +// BatchV1 retrieves the BatchV1ClusterClient func (c *ClusterClientset) BatchV1() kcpbatchv1.BatchV1ClusterInterface { - return &fakebatchv1.BatchV1ClusterClient{Fake: c.Fake} + return &kcpfakebatchv1.BatchV1ClusterClient{Fake: &c.Fake} } -// BatchV1beta1 retrieves the BatchV1beta1ClusterClient. +// BatchV1beta1 retrieves the BatchV1beta1ClusterClient func (c *ClusterClientset) BatchV1beta1() kcpbatchv1beta1.BatchV1beta1ClusterInterface { - return &fakebatchv1beta1.BatchV1beta1ClusterClient{Fake: c.Fake} + return &kcpfakebatchv1beta1.BatchV1beta1ClusterClient{Fake: &c.Fake} } -// CertificatesV1 retrieves the CertificatesV1ClusterClient. +// CertificatesV1 retrieves the CertificatesV1ClusterClient func (c *ClusterClientset) CertificatesV1() kcpcertificatesv1.CertificatesV1ClusterInterface { - return &fakecertificatesv1.CertificatesV1ClusterClient{Fake: c.Fake} + return &kcpfakecertificatesv1.CertificatesV1ClusterClient{Fake: &c.Fake} } -// CertificatesV1alpha1 retrieves the CertificatesV1alpha1ClusterClient. +// CertificatesV1alpha1 retrieves the CertificatesV1alpha1ClusterClient func (c *ClusterClientset) CertificatesV1alpha1() kcpcertificatesv1alpha1.CertificatesV1alpha1ClusterInterface { - return &fakecertificatesv1alpha1.CertificatesV1alpha1ClusterClient{Fake: c.Fake} + return &kcpfakecertificatesv1alpha1.CertificatesV1alpha1ClusterClient{Fake: &c.Fake} } -// CertificatesV1beta1 retrieves the CertificatesV1beta1ClusterClient. +// CertificatesV1beta1 retrieves the CertificatesV1beta1ClusterClient func (c *ClusterClientset) CertificatesV1beta1() kcpcertificatesv1beta1.CertificatesV1beta1ClusterInterface { - return &fakecertificatesv1beta1.CertificatesV1beta1ClusterClient{Fake: c.Fake} + return &kcpfakecertificatesv1beta1.CertificatesV1beta1ClusterClient{Fake: &c.Fake} } -// CoordinationV1 retrieves the CoordinationV1ClusterClient. +// CoordinationV1 retrieves the CoordinationV1ClusterClient func (c *ClusterClientset) CoordinationV1() kcpcoordinationv1.CoordinationV1ClusterInterface { - return &fakecoordinationv1.CoordinationV1ClusterClient{Fake: c.Fake} + return &kcpfakecoordinationv1.CoordinationV1ClusterClient{Fake: &c.Fake} } -// CoordinationV1alpha2 retrieves the CoordinationV1alpha2ClusterClient. +// CoordinationV1alpha2 retrieves the CoordinationV1alpha2ClusterClient func (c *ClusterClientset) CoordinationV1alpha2() kcpcoordinationv1alpha2.CoordinationV1alpha2ClusterInterface { - return &fakecoordinationv1alpha2.CoordinationV1alpha2ClusterClient{Fake: c.Fake} + return &kcpfakecoordinationv1alpha2.CoordinationV1alpha2ClusterClient{Fake: &c.Fake} } -// CoordinationV1beta1 retrieves the CoordinationV1beta1ClusterClient. +// CoordinationV1beta1 retrieves the CoordinationV1beta1ClusterClient func (c *ClusterClientset) CoordinationV1beta1() kcpcoordinationv1beta1.CoordinationV1beta1ClusterInterface { - return &fakecoordinationv1beta1.CoordinationV1beta1ClusterClient{Fake: c.Fake} + return &kcpfakecoordinationv1beta1.CoordinationV1beta1ClusterClient{Fake: &c.Fake} } -// CoreV1 retrieves the CoreV1ClusterClient. +// CoreV1 retrieves the CoreV1ClusterClient func (c *ClusterClientset) CoreV1() kcpcorev1.CoreV1ClusterInterface { - return &fakecorev1.CoreV1ClusterClient{Fake: c.Fake} + return &kcpfakecorev1.CoreV1ClusterClient{Fake: &c.Fake} } -// DiscoveryV1 retrieves the DiscoveryV1ClusterClient. +// DiscoveryV1 retrieves the DiscoveryV1ClusterClient func (c *ClusterClientset) DiscoveryV1() kcpdiscoveryv1.DiscoveryV1ClusterInterface { - return &fakediscoveryv1.DiscoveryV1ClusterClient{Fake: c.Fake} + return &kcpfakediscoveryv1.DiscoveryV1ClusterClient{Fake: &c.Fake} } -// DiscoveryV1beta1 retrieves the DiscoveryV1beta1ClusterClient. +// DiscoveryV1beta1 retrieves the DiscoveryV1beta1ClusterClient func (c *ClusterClientset) DiscoveryV1beta1() kcpdiscoveryv1beta1.DiscoveryV1beta1ClusterInterface { - return &fakediscoveryv1beta1.DiscoveryV1beta1ClusterClient{Fake: c.Fake} + return &kcpfakediscoveryv1beta1.DiscoveryV1beta1ClusterClient{Fake: &c.Fake} } -// EventsV1 retrieves the EventsV1ClusterClient. +// EventsV1 retrieves the EventsV1ClusterClient func (c *ClusterClientset) EventsV1() kcpeventsv1.EventsV1ClusterInterface { - return &fakeeventsv1.EventsV1ClusterClient{Fake: c.Fake} + return &kcpfakeeventsv1.EventsV1ClusterClient{Fake: &c.Fake} } -// EventsV1beta1 retrieves the EventsV1beta1ClusterClient. +// EventsV1beta1 retrieves the EventsV1beta1ClusterClient func (c *ClusterClientset) EventsV1beta1() kcpeventsv1beta1.EventsV1beta1ClusterInterface { - return &fakeeventsv1beta1.EventsV1beta1ClusterClient{Fake: c.Fake} + return &kcpfakeeventsv1beta1.EventsV1beta1ClusterClient{Fake: &c.Fake} } -// ExtensionsV1beta1 retrieves the ExtensionsV1beta1ClusterClient. +// ExtensionsV1beta1 retrieves the ExtensionsV1beta1ClusterClient func (c *ClusterClientset) ExtensionsV1beta1() kcpextensionsv1beta1.ExtensionsV1beta1ClusterInterface { - return &fakeextensionsv1beta1.ExtensionsV1beta1ClusterClient{Fake: c.Fake} + return &kcpfakeextensionsv1beta1.ExtensionsV1beta1ClusterClient{Fake: &c.Fake} } -// FlowcontrolV1 retrieves the FlowcontrolV1ClusterClient. +// FlowcontrolV1 retrieves the FlowcontrolV1ClusterClient func (c *ClusterClientset) FlowcontrolV1() kcpflowcontrolv1.FlowcontrolV1ClusterInterface { - return &fakeflowcontrolv1.FlowcontrolV1ClusterClient{Fake: c.Fake} + return &kcpfakeflowcontrolv1.FlowcontrolV1ClusterClient{Fake: &c.Fake} } -// FlowcontrolV1beta1 retrieves the FlowcontrolV1beta1ClusterClient. +// FlowcontrolV1beta1 retrieves the FlowcontrolV1beta1ClusterClient func (c *ClusterClientset) FlowcontrolV1beta1() kcpflowcontrolv1beta1.FlowcontrolV1beta1ClusterInterface { - return &fakeflowcontrolv1beta1.FlowcontrolV1beta1ClusterClient{Fake: c.Fake} + return &kcpfakeflowcontrolv1beta1.FlowcontrolV1beta1ClusterClient{Fake: &c.Fake} } -// FlowcontrolV1beta2 retrieves the FlowcontrolV1beta2ClusterClient. +// FlowcontrolV1beta2 retrieves the FlowcontrolV1beta2ClusterClient func (c *ClusterClientset) FlowcontrolV1beta2() kcpflowcontrolv1beta2.FlowcontrolV1beta2ClusterInterface { - return &fakeflowcontrolv1beta2.FlowcontrolV1beta2ClusterClient{Fake: c.Fake} + return &kcpfakeflowcontrolv1beta2.FlowcontrolV1beta2ClusterClient{Fake: &c.Fake} } -// FlowcontrolV1beta3 retrieves the FlowcontrolV1beta3ClusterClient. +// FlowcontrolV1beta3 retrieves the FlowcontrolV1beta3ClusterClient func (c *ClusterClientset) FlowcontrolV1beta3() kcpflowcontrolv1beta3.FlowcontrolV1beta3ClusterInterface { - return &fakeflowcontrolv1beta3.FlowcontrolV1beta3ClusterClient{Fake: c.Fake} -} - -// InternalV1alpha1 retrieves the InternalV1alpha1ClusterClient. -func (c *ClusterClientset) InternalV1alpha1() kcpinternalv1alpha1.InternalV1alpha1ClusterInterface { - return &fakeinternalv1alpha1.InternalV1alpha1ClusterClient{Fake: c.Fake} + return &kcpfakeflowcontrolv1beta3.FlowcontrolV1beta3ClusterClient{Fake: &c.Fake} } -// NetworkingV1 retrieves the NetworkingV1ClusterClient. +// NetworkingV1 retrieves the NetworkingV1ClusterClient func (c *ClusterClientset) NetworkingV1() kcpnetworkingv1.NetworkingV1ClusterInterface { - return &fakenetworkingv1.NetworkingV1ClusterClient{Fake: c.Fake} + return &kcpfakenetworkingv1.NetworkingV1ClusterClient{Fake: &c.Fake} } -// NetworkingV1alpha1 retrieves the NetworkingV1alpha1ClusterClient. +// NetworkingV1alpha1 retrieves the NetworkingV1alpha1ClusterClient func (c *ClusterClientset) NetworkingV1alpha1() kcpnetworkingv1alpha1.NetworkingV1alpha1ClusterInterface { - return &fakenetworkingv1alpha1.NetworkingV1alpha1ClusterClient{Fake: c.Fake} + return &kcpfakenetworkingv1alpha1.NetworkingV1alpha1ClusterClient{Fake: &c.Fake} } -// NetworkingV1beta1 retrieves the NetworkingV1beta1ClusterClient. +// NetworkingV1beta1 retrieves the NetworkingV1beta1ClusterClient func (c *ClusterClientset) NetworkingV1beta1() kcpnetworkingv1beta1.NetworkingV1beta1ClusterInterface { - return &fakenetworkingv1beta1.NetworkingV1beta1ClusterClient{Fake: c.Fake} + return &kcpfakenetworkingv1beta1.NetworkingV1beta1ClusterClient{Fake: &c.Fake} } -// NodeV1 retrieves the NodeV1ClusterClient. +// NodeV1 retrieves the NodeV1ClusterClient func (c *ClusterClientset) NodeV1() kcpnodev1.NodeV1ClusterInterface { - return &fakenodev1.NodeV1ClusterClient{Fake: c.Fake} + return &kcpfakenodev1.NodeV1ClusterClient{Fake: &c.Fake} } -// NodeV1alpha1 retrieves the NodeV1alpha1ClusterClient. +// NodeV1alpha1 retrieves the NodeV1alpha1ClusterClient func (c *ClusterClientset) NodeV1alpha1() kcpnodev1alpha1.NodeV1alpha1ClusterInterface { - return &fakenodev1alpha1.NodeV1alpha1ClusterClient{Fake: c.Fake} + return &kcpfakenodev1alpha1.NodeV1alpha1ClusterClient{Fake: &c.Fake} } -// NodeV1beta1 retrieves the NodeV1beta1ClusterClient. +// NodeV1beta1 retrieves the NodeV1beta1ClusterClient func (c *ClusterClientset) NodeV1beta1() kcpnodev1beta1.NodeV1beta1ClusterInterface { - return &fakenodev1beta1.NodeV1beta1ClusterClient{Fake: c.Fake} + return &kcpfakenodev1beta1.NodeV1beta1ClusterClient{Fake: &c.Fake} } -// PolicyV1 retrieves the PolicyV1ClusterClient. +// PolicyV1 retrieves the PolicyV1ClusterClient func (c *ClusterClientset) PolicyV1() kcppolicyv1.PolicyV1ClusterInterface { - return &fakepolicyv1.PolicyV1ClusterClient{Fake: c.Fake} + return &kcpfakepolicyv1.PolicyV1ClusterClient{Fake: &c.Fake} } -// PolicyV1beta1 retrieves the PolicyV1beta1ClusterClient. +// PolicyV1beta1 retrieves the PolicyV1beta1ClusterClient func (c *ClusterClientset) PolicyV1beta1() kcppolicyv1beta1.PolicyV1beta1ClusterInterface { - return &fakepolicyv1beta1.PolicyV1beta1ClusterClient{Fake: c.Fake} + return &kcpfakepolicyv1beta1.PolicyV1beta1ClusterClient{Fake: &c.Fake} } -// RbacV1 retrieves the RbacV1ClusterClient. +// RbacV1 retrieves the RbacV1ClusterClient func (c *ClusterClientset) RbacV1() kcprbacv1.RbacV1ClusterInterface { - return &fakerbacv1.RbacV1ClusterClient{Fake: c.Fake} + return &kcpfakerbacv1.RbacV1ClusterClient{Fake: &c.Fake} } -// RbacV1alpha1 retrieves the RbacV1alpha1ClusterClient. +// RbacV1alpha1 retrieves the RbacV1alpha1ClusterClient func (c *ClusterClientset) RbacV1alpha1() kcprbacv1alpha1.RbacV1alpha1ClusterInterface { - return &fakerbacv1alpha1.RbacV1alpha1ClusterClient{Fake: c.Fake} + return &kcpfakerbacv1alpha1.RbacV1alpha1ClusterClient{Fake: &c.Fake} } -// RbacV1beta1 retrieves the RbacV1beta1ClusterClient. +// RbacV1beta1 retrieves the RbacV1beta1ClusterClient func (c *ClusterClientset) RbacV1beta1() kcprbacv1beta1.RbacV1beta1ClusterInterface { - return &fakerbacv1beta1.RbacV1beta1ClusterClient{Fake: c.Fake} + return &kcpfakerbacv1beta1.RbacV1beta1ClusterClient{Fake: &c.Fake} } -// ResourceV1alpha3 retrieves the ResourceV1alpha3ClusterClient. +// ResourceV1alpha3 retrieves the ResourceV1alpha3ClusterClient func (c *ClusterClientset) ResourceV1alpha3() kcpresourcev1alpha3.ResourceV1alpha3ClusterInterface { - return &fakeresourcev1alpha3.ResourceV1alpha3ClusterClient{Fake: c.Fake} + return &kcpfakeresourcev1alpha3.ResourceV1alpha3ClusterClient{Fake: &c.Fake} } -// ResourceV1beta1 retrieves the ResourceV1beta1ClusterClient. +// ResourceV1beta1 retrieves the ResourceV1beta1ClusterClient func (c *ClusterClientset) ResourceV1beta1() kcpresourcev1beta1.ResourceV1beta1ClusterInterface { - return &fakeresourcev1beta1.ResourceV1beta1ClusterClient{Fake: c.Fake} + return &kcpfakeresourcev1beta1.ResourceV1beta1ClusterClient{Fake: &c.Fake} } -// SchedulingV1 retrieves the SchedulingV1ClusterClient. +// SchedulingV1 retrieves the SchedulingV1ClusterClient func (c *ClusterClientset) SchedulingV1() kcpschedulingv1.SchedulingV1ClusterInterface { - return &fakeschedulingv1.SchedulingV1ClusterClient{Fake: c.Fake} + return &kcpfakeschedulingv1.SchedulingV1ClusterClient{Fake: &c.Fake} } -// SchedulingV1alpha1 retrieves the SchedulingV1alpha1ClusterClient. +// SchedulingV1alpha1 retrieves the SchedulingV1alpha1ClusterClient func (c *ClusterClientset) SchedulingV1alpha1() kcpschedulingv1alpha1.SchedulingV1alpha1ClusterInterface { - return &fakeschedulingv1alpha1.SchedulingV1alpha1ClusterClient{Fake: c.Fake} + return &kcpfakeschedulingv1alpha1.SchedulingV1alpha1ClusterClient{Fake: &c.Fake} } -// SchedulingV1beta1 retrieves the SchedulingV1beta1ClusterClient. +// SchedulingV1beta1 retrieves the SchedulingV1beta1ClusterClient func (c *ClusterClientset) SchedulingV1beta1() kcpschedulingv1beta1.SchedulingV1beta1ClusterInterface { - return &fakeschedulingv1beta1.SchedulingV1beta1ClusterClient{Fake: c.Fake} -} - -// StoragemigrationV1alpha1 retrieves the StoragemigrationV1alpha1ClusterClient. -func (c *ClusterClientset) StoragemigrationV1alpha1() kcpstoragemigrationv1alpha1.StoragemigrationV1alpha1ClusterInterface { - return &fakestoragemigrationv1alpha1.StoragemigrationV1alpha1ClusterClient{Fake: c.Fake} + return &kcpfakeschedulingv1beta1.SchedulingV1beta1ClusterClient{Fake: &c.Fake} } -// StorageV1 retrieves the StorageV1ClusterClient. +// StorageV1 retrieves the StorageV1ClusterClient func (c *ClusterClientset) StorageV1() kcpstoragev1.StorageV1ClusterInterface { - return &fakestoragev1.StorageV1ClusterClient{Fake: c.Fake} + return &kcpfakestoragev1.StorageV1ClusterClient{Fake: &c.Fake} } -// StorageV1alpha1 retrieves the StorageV1alpha1ClusterClient. +// StorageV1alpha1 retrieves the StorageV1alpha1ClusterClient func (c *ClusterClientset) StorageV1alpha1() kcpstoragev1alpha1.StorageV1alpha1ClusterInterface { - return &fakestoragev1alpha1.StorageV1alpha1ClusterClient{Fake: c.Fake} + return &kcpfakestoragev1alpha1.StorageV1alpha1ClusterClient{Fake: &c.Fake} } -// StorageV1beta1 retrieves the StorageV1beta1ClusterClient. +// StorageV1beta1 retrieves the StorageV1beta1ClusterClient func (c *ClusterClientset) StorageV1beta1() kcpstoragev1beta1.StorageV1beta1ClusterInterface { - return &fakestoragev1beta1.StorageV1beta1ClusterClient{Fake: c.Fake} + return &kcpfakestoragev1beta1.StorageV1beta1ClusterClient{Fake: &c.Fake} } -// Cluster scopes this clientset to one cluster. -func (c *ClusterClientset) Cluster(clusterPath logicalcluster.Path) client.Interface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - return &Clientset{ - Fake: c.Fake, - discovery: &kcpfakediscovery.FakeDiscovery{Fake: c.Fake, ClusterPath: clusterPath}, - tracker: c.tracker.Cluster(clusterPath), - clusterPath: clusterPath, - } +// StoragemigrationV1alpha1 retrieves the StoragemigrationV1alpha1ClusterClient +func (c *ClusterClientset) StoragemigrationV1alpha1() kcpstoragemigrationv1alpha1.StoragemigrationV1alpha1ClusterInterface { + return &kcpfakestoragemigrationv1alpha1.StoragemigrationV1alpha1ClusterClient{Fake: &c.Fake} } -var _ client.Interface = (*Clientset)(nil) - -// Clientset contains the clients for groups. +// Clientset implements clientset.Interface. Meant to be embedded into a +// struct to get a default implementation. This makes faking out just the method +// you want to test easier. type Clientset struct { *kcptesting.Fake discovery *kcpfakediscovery.FakeDiscovery @@ -520,7 +525,11 @@ type Clientset struct { clusterPath logicalcluster.Path } -// Discovery retrieves the DiscoveryClient +var ( + _ clientset.Interface = &Clientset{} + _ kcptesting.FakeScopedClient = &Clientset{} +) + func (c *Clientset) Discovery() discovery.DiscoveryInterface { return c.discovery } @@ -529,272 +538,292 @@ func (c *Clientset) Tracker() kcptesting.ScopedObjectTracker { return c.tracker } -// AdmissionregistrationV1 retrieves the AdmissionregistrationV1Client. +// NewClientset returns a clientset that will respond with the provided objects. +// It's backed by a very simple object tracker that processes creates, updates and deletions as-is, +// without applying any validations and/or defaults. It shouldn't be considered a replacement +// for a real clientset and is mostly useful in simple unit tests. +func NewClientset(objects ...runtime.Object) *ClusterClientset { + o := kcptesting.NewFieldManagedObjectTracker( + kcpclientscheme.Scheme, + kcpclientscheme.Codecs.UniversalDecoder(), + applyconfigurations.NewTypeConverter(kcpclientscheme.Scheme), + ) + o.AddAll(objects...) + + cs := &ClusterClientset{Fake: kcptesting.Fake{}, tracker: o} + cs.discovery = &kcpfakediscovery.FakeDiscovery{Fake: &cs.Fake, ClusterPath: logicalcluster.Wildcard} + cs.AddReactor("*", "*", kcptesting.ObjectReaction(o)) + cs.AddWatchReactor("*", kcptesting.WatchReaction(o)) + + return cs +} + +// AdmissionregistrationV1 retrieves the AdmissionregistrationV1Client func (c *Clientset) AdmissionregistrationV1() admissionregistrationv1.AdmissionregistrationV1Interface { - return &fakeadmissionregistrationv1.AdmissionregistrationV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakeadmissionregistrationv1.AdmissionregistrationV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// AdmissionregistrationV1alpha1 retrieves the AdmissionregistrationV1alpha1Client. +// AdmissionregistrationV1alpha1 retrieves the AdmissionregistrationV1alpha1Client func (c *Clientset) AdmissionregistrationV1alpha1() admissionregistrationv1alpha1.AdmissionregistrationV1alpha1Interface { - return &fakeadmissionregistrationv1alpha1.AdmissionregistrationV1alpha1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakeadmissionregistrationv1alpha1.AdmissionregistrationV1alpha1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// AdmissionregistrationV1beta1 retrieves the AdmissionregistrationV1beta1Client. +// AdmissionregistrationV1beta1 retrieves the AdmissionregistrationV1beta1Client func (c *Clientset) AdmissionregistrationV1beta1() admissionregistrationv1beta1.AdmissionregistrationV1beta1Interface { - return &fakeadmissionregistrationv1beta1.AdmissionregistrationV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakeadmissionregistrationv1beta1.AdmissionregistrationV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// AppsV1 retrieves the AppsV1Client. +// InternalV1alpha1 retrieves the InternalV1alpha1Client +func (c *Clientset) InternalV1alpha1() internalv1alpha1.InternalV1alpha1Interface { + return &kcpfakeinternalv1alpha1.InternalV1alpha1Client{Fake: c.Fake, ClusterPath: c.clusterPath} +} + +// AppsV1 retrieves the AppsV1Client func (c *Clientset) AppsV1() appsv1.AppsV1Interface { - return &fakeappsv1.AppsV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakeappsv1.AppsV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// AppsV1beta1 retrieves the AppsV1beta1Client. +// AppsV1beta1 retrieves the AppsV1beta1Client func (c *Clientset) AppsV1beta1() appsv1beta1.AppsV1beta1Interface { - return &fakeappsv1beta1.AppsV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakeappsv1beta1.AppsV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// AppsV1beta2 retrieves the AppsV1beta2Client. +// AppsV1beta2 retrieves the AppsV1beta2Client func (c *Clientset) AppsV1beta2() appsv1beta2.AppsV1beta2Interface { - return &fakeappsv1beta2.AppsV1beta2Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakeappsv1beta2.AppsV1beta2Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// AuthenticationV1 retrieves the AuthenticationV1Client. +// AuthenticationV1 retrieves the AuthenticationV1Client func (c *Clientset) AuthenticationV1() authenticationv1.AuthenticationV1Interface { - return &fakeauthenticationv1.AuthenticationV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakeauthenticationv1.AuthenticationV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// AuthenticationV1alpha1 retrieves the AuthenticationV1alpha1Client. +// AuthenticationV1alpha1 retrieves the AuthenticationV1alpha1Client func (c *Clientset) AuthenticationV1alpha1() authenticationv1alpha1.AuthenticationV1alpha1Interface { - return &fakeauthenticationv1alpha1.AuthenticationV1alpha1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakeauthenticationv1alpha1.AuthenticationV1alpha1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// AuthenticationV1beta1 retrieves the AuthenticationV1beta1Client. +// AuthenticationV1beta1 retrieves the AuthenticationV1beta1Client func (c *Clientset) AuthenticationV1beta1() authenticationv1beta1.AuthenticationV1beta1Interface { - return &fakeauthenticationv1beta1.AuthenticationV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakeauthenticationv1beta1.AuthenticationV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// AuthorizationV1 retrieves the AuthorizationV1Client. +// AuthorizationV1 retrieves the AuthorizationV1Client func (c *Clientset) AuthorizationV1() authorizationv1.AuthorizationV1Interface { - return &fakeauthorizationv1.AuthorizationV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakeauthorizationv1.AuthorizationV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// AuthorizationV1beta1 retrieves the AuthorizationV1beta1Client. +// AuthorizationV1beta1 retrieves the AuthorizationV1beta1Client func (c *Clientset) AuthorizationV1beta1() authorizationv1beta1.AuthorizationV1beta1Interface { - return &fakeauthorizationv1beta1.AuthorizationV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakeauthorizationv1beta1.AuthorizationV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// AutoscalingV1 retrieves the AutoscalingV1Client. +// AutoscalingV1 retrieves the AutoscalingV1Client func (c *Clientset) AutoscalingV1() autoscalingv1.AutoscalingV1Interface { - return &fakeautoscalingv1.AutoscalingV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakeautoscalingv1.AutoscalingV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// AutoscalingV2 retrieves the AutoscalingV2Client. +// AutoscalingV2 retrieves the AutoscalingV2Client func (c *Clientset) AutoscalingV2() autoscalingv2.AutoscalingV2Interface { - return &fakeautoscalingv2.AutoscalingV2Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakeautoscalingv2.AutoscalingV2Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// AutoscalingV2beta1 retrieves the AutoscalingV2beta1Client. +// AutoscalingV2beta1 retrieves the AutoscalingV2beta1Client func (c *Clientset) AutoscalingV2beta1() autoscalingv2beta1.AutoscalingV2beta1Interface { - return &fakeautoscalingv2beta1.AutoscalingV2beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakeautoscalingv2beta1.AutoscalingV2beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// AutoscalingV2beta2 retrieves the AutoscalingV2beta2Client. +// AutoscalingV2beta2 retrieves the AutoscalingV2beta2Client func (c *Clientset) AutoscalingV2beta2() autoscalingv2beta2.AutoscalingV2beta2Interface { - return &fakeautoscalingv2beta2.AutoscalingV2beta2Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakeautoscalingv2beta2.AutoscalingV2beta2Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// BatchV1 retrieves the BatchV1Client. +// BatchV1 retrieves the BatchV1Client func (c *Clientset) BatchV1() batchv1.BatchV1Interface { - return &fakebatchv1.BatchV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakebatchv1.BatchV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// BatchV1beta1 retrieves the BatchV1beta1Client. +// BatchV1beta1 retrieves the BatchV1beta1Client func (c *Clientset) BatchV1beta1() batchv1beta1.BatchV1beta1Interface { - return &fakebatchv1beta1.BatchV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakebatchv1beta1.BatchV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// CertificatesV1 retrieves the CertificatesV1Client. +// CertificatesV1 retrieves the CertificatesV1Client func (c *Clientset) CertificatesV1() certificatesv1.CertificatesV1Interface { - return &fakecertificatesv1.CertificatesV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakecertificatesv1.CertificatesV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// CertificatesV1alpha1 retrieves the CertificatesV1alpha1Client. +// CertificatesV1alpha1 retrieves the CertificatesV1alpha1Client func (c *Clientset) CertificatesV1alpha1() certificatesv1alpha1.CertificatesV1alpha1Interface { - return &fakecertificatesv1alpha1.CertificatesV1alpha1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakecertificatesv1alpha1.CertificatesV1alpha1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// CertificatesV1beta1 retrieves the CertificatesV1beta1Client. +// CertificatesV1beta1 retrieves the CertificatesV1beta1Client func (c *Clientset) CertificatesV1beta1() certificatesv1beta1.CertificatesV1beta1Interface { - return &fakecertificatesv1beta1.CertificatesV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakecertificatesv1beta1.CertificatesV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// CoordinationV1 retrieves the CoordinationV1Client. +// CoordinationV1 retrieves the CoordinationV1Client func (c *Clientset) CoordinationV1() coordinationv1.CoordinationV1Interface { - return &fakecoordinationv1.CoordinationV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakecoordinationv1.CoordinationV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// CoordinationV1alpha2 retrieves the CoordinationV1alpha2Client. +// CoordinationV1alpha2 retrieves the CoordinationV1alpha2Client func (c *Clientset) CoordinationV1alpha2() coordinationv1alpha2.CoordinationV1alpha2Interface { - return &fakecoordinationv1alpha2.CoordinationV1alpha2Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakecoordinationv1alpha2.CoordinationV1alpha2Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// CoordinationV1beta1 retrieves the CoordinationV1beta1Client. +// CoordinationV1beta1 retrieves the CoordinationV1beta1Client func (c *Clientset) CoordinationV1beta1() coordinationv1beta1.CoordinationV1beta1Interface { - return &fakecoordinationv1beta1.CoordinationV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakecoordinationv1beta1.CoordinationV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// CoreV1 retrieves the CoreV1Client. +// CoreV1 retrieves the CoreV1Client func (c *Clientset) CoreV1() corev1.CoreV1Interface { - return &fakecorev1.CoreV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakecorev1.CoreV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// DiscoveryV1 retrieves the DiscoveryV1Client. +// DiscoveryV1 retrieves the DiscoveryV1Client func (c *Clientset) DiscoveryV1() discoveryv1.DiscoveryV1Interface { - return &fakediscoveryv1.DiscoveryV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakediscoveryv1.DiscoveryV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// DiscoveryV1beta1 retrieves the DiscoveryV1beta1Client. +// DiscoveryV1beta1 retrieves the DiscoveryV1beta1Client func (c *Clientset) DiscoveryV1beta1() discoveryv1beta1.DiscoveryV1beta1Interface { - return &fakediscoveryv1beta1.DiscoveryV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakediscoveryv1beta1.DiscoveryV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// EventsV1 retrieves the EventsV1Client. +// EventsV1 retrieves the EventsV1Client func (c *Clientset) EventsV1() eventsv1.EventsV1Interface { - return &fakeeventsv1.EventsV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakeeventsv1.EventsV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// EventsV1beta1 retrieves the EventsV1beta1Client. +// EventsV1beta1 retrieves the EventsV1beta1Client func (c *Clientset) EventsV1beta1() eventsv1beta1.EventsV1beta1Interface { - return &fakeeventsv1beta1.EventsV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakeeventsv1beta1.EventsV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// ExtensionsV1beta1 retrieves the ExtensionsV1beta1Client. +// ExtensionsV1beta1 retrieves the ExtensionsV1beta1Client func (c *Clientset) ExtensionsV1beta1() extensionsv1beta1.ExtensionsV1beta1Interface { - return &fakeextensionsv1beta1.ExtensionsV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakeextensionsv1beta1.ExtensionsV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// FlowcontrolV1 retrieves the FlowcontrolV1Client. +// FlowcontrolV1 retrieves the FlowcontrolV1Client func (c *Clientset) FlowcontrolV1() flowcontrolv1.FlowcontrolV1Interface { - return &fakeflowcontrolv1.FlowcontrolV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakeflowcontrolv1.FlowcontrolV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// FlowcontrolV1beta1 retrieves the FlowcontrolV1beta1Client. +// FlowcontrolV1beta1 retrieves the FlowcontrolV1beta1Client func (c *Clientset) FlowcontrolV1beta1() flowcontrolv1beta1.FlowcontrolV1beta1Interface { - return &fakeflowcontrolv1beta1.FlowcontrolV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakeflowcontrolv1beta1.FlowcontrolV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// FlowcontrolV1beta2 retrieves the FlowcontrolV1beta2Client. +// FlowcontrolV1beta2 retrieves the FlowcontrolV1beta2Client func (c *Clientset) FlowcontrolV1beta2() flowcontrolv1beta2.FlowcontrolV1beta2Interface { - return &fakeflowcontrolv1beta2.FlowcontrolV1beta2Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakeflowcontrolv1beta2.FlowcontrolV1beta2Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// FlowcontrolV1beta3 retrieves the FlowcontrolV1beta3Client. +// FlowcontrolV1beta3 retrieves the FlowcontrolV1beta3Client func (c *Clientset) FlowcontrolV1beta3() flowcontrolv1beta3.FlowcontrolV1beta3Interface { - return &fakeflowcontrolv1beta3.FlowcontrolV1beta3Client{Fake: c.Fake, ClusterPath: c.clusterPath} -} - -// InternalV1alpha1 retrieves the InternalV1alpha1Client. -func (c *Clientset) InternalV1alpha1() internalv1alpha1.InternalV1alpha1Interface { - return &fakeinternalv1alpha1.InternalV1alpha1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakeflowcontrolv1beta3.FlowcontrolV1beta3Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// NetworkingV1 retrieves the NetworkingV1Client. +// NetworkingV1 retrieves the NetworkingV1Client func (c *Clientset) NetworkingV1() networkingv1.NetworkingV1Interface { - return &fakenetworkingv1.NetworkingV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakenetworkingv1.NetworkingV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// NetworkingV1alpha1 retrieves the NetworkingV1alpha1Client. +// NetworkingV1alpha1 retrieves the NetworkingV1alpha1Client func (c *Clientset) NetworkingV1alpha1() networkingv1alpha1.NetworkingV1alpha1Interface { - return &fakenetworkingv1alpha1.NetworkingV1alpha1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakenetworkingv1alpha1.NetworkingV1alpha1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// NetworkingV1beta1 retrieves the NetworkingV1beta1Client. +// NetworkingV1beta1 retrieves the NetworkingV1beta1Client func (c *Clientset) NetworkingV1beta1() networkingv1beta1.NetworkingV1beta1Interface { - return &fakenetworkingv1beta1.NetworkingV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakenetworkingv1beta1.NetworkingV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// NodeV1 retrieves the NodeV1Client. +// NodeV1 retrieves the NodeV1Client func (c *Clientset) NodeV1() nodev1.NodeV1Interface { - return &fakenodev1.NodeV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakenodev1.NodeV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// NodeV1alpha1 retrieves the NodeV1alpha1Client. +// NodeV1alpha1 retrieves the NodeV1alpha1Client func (c *Clientset) NodeV1alpha1() nodev1alpha1.NodeV1alpha1Interface { - return &fakenodev1alpha1.NodeV1alpha1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakenodev1alpha1.NodeV1alpha1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// NodeV1beta1 retrieves the NodeV1beta1Client. +// NodeV1beta1 retrieves the NodeV1beta1Client func (c *Clientset) NodeV1beta1() nodev1beta1.NodeV1beta1Interface { - return &fakenodev1beta1.NodeV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakenodev1beta1.NodeV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// PolicyV1 retrieves the PolicyV1Client. +// PolicyV1 retrieves the PolicyV1Client func (c *Clientset) PolicyV1() policyv1.PolicyV1Interface { - return &fakepolicyv1.PolicyV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakepolicyv1.PolicyV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// PolicyV1beta1 retrieves the PolicyV1beta1Client. +// PolicyV1beta1 retrieves the PolicyV1beta1Client func (c *Clientset) PolicyV1beta1() policyv1beta1.PolicyV1beta1Interface { - return &fakepolicyv1beta1.PolicyV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakepolicyv1beta1.PolicyV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// RbacV1 retrieves the RbacV1Client. +// RbacV1 retrieves the RbacV1Client func (c *Clientset) RbacV1() rbacv1.RbacV1Interface { - return &fakerbacv1.RbacV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakerbacv1.RbacV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// RbacV1alpha1 retrieves the RbacV1alpha1Client. +// RbacV1alpha1 retrieves the RbacV1alpha1Client func (c *Clientset) RbacV1alpha1() rbacv1alpha1.RbacV1alpha1Interface { - return &fakerbacv1alpha1.RbacV1alpha1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakerbacv1alpha1.RbacV1alpha1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// RbacV1beta1 retrieves the RbacV1beta1Client. +// RbacV1beta1 retrieves the RbacV1beta1Client func (c *Clientset) RbacV1beta1() rbacv1beta1.RbacV1beta1Interface { - return &fakerbacv1beta1.RbacV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakerbacv1beta1.RbacV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// ResourceV1alpha3 retrieves the ResourceV1alpha3Client. +// ResourceV1alpha3 retrieves the ResourceV1alpha3Client func (c *Clientset) ResourceV1alpha3() resourcev1alpha3.ResourceV1alpha3Interface { - return &fakeresourcev1alpha3.ResourceV1alpha3Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakeresourcev1alpha3.ResourceV1alpha3Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// ResourceV1beta1 retrieves the ResourceV1beta1Client. +// ResourceV1beta1 retrieves the ResourceV1beta1Client func (c *Clientset) ResourceV1beta1() resourcev1beta1.ResourceV1beta1Interface { - return &fakeresourcev1beta1.ResourceV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakeresourcev1beta1.ResourceV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// SchedulingV1 retrieves the SchedulingV1Client. +// SchedulingV1 retrieves the SchedulingV1Client func (c *Clientset) SchedulingV1() schedulingv1.SchedulingV1Interface { - return &fakeschedulingv1.SchedulingV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakeschedulingv1.SchedulingV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// SchedulingV1alpha1 retrieves the SchedulingV1alpha1Client. +// SchedulingV1alpha1 retrieves the SchedulingV1alpha1Client func (c *Clientset) SchedulingV1alpha1() schedulingv1alpha1.SchedulingV1alpha1Interface { - return &fakeschedulingv1alpha1.SchedulingV1alpha1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakeschedulingv1alpha1.SchedulingV1alpha1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// SchedulingV1beta1 retrieves the SchedulingV1beta1Client. +// SchedulingV1beta1 retrieves the SchedulingV1beta1Client func (c *Clientset) SchedulingV1beta1() schedulingv1beta1.SchedulingV1beta1Interface { - return &fakeschedulingv1beta1.SchedulingV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} -} - -// StoragemigrationV1alpha1 retrieves the StoragemigrationV1alpha1Client. -func (c *Clientset) StoragemigrationV1alpha1() storagemigrationv1alpha1.StoragemigrationV1alpha1Interface { - return &fakestoragemigrationv1alpha1.StoragemigrationV1alpha1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakeschedulingv1beta1.SchedulingV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// StorageV1 retrieves the StorageV1Client. +// StorageV1 retrieves the StorageV1Client func (c *Clientset) StorageV1() storagev1.StorageV1Interface { - return &fakestoragev1.StorageV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakestoragev1.StorageV1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// StorageV1alpha1 retrieves the StorageV1alpha1Client. +// StorageV1alpha1 retrieves the StorageV1alpha1Client func (c *Clientset) StorageV1alpha1() storagev1alpha1.StorageV1alpha1Interface { - return &fakestoragev1alpha1.StorageV1alpha1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakestoragev1alpha1.StorageV1alpha1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } -// StorageV1beta1 retrieves the StorageV1beta1Client. +// StorageV1beta1 retrieves the StorageV1beta1Client func (c *Clientset) StorageV1beta1() storagev1beta1.StorageV1beta1Interface { - return &fakestoragev1beta1.StorageV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} + return &kcpfakestoragev1beta1.StorageV1beta1Client{Fake: c.Fake, ClusterPath: c.clusterPath} +} + +// StoragemigrationV1alpha1 retrieves the StoragemigrationV1alpha1Client +func (c *Clientset) StoragemigrationV1alpha1() storagemigrationv1alpha1.StoragemigrationV1alpha1Interface { + return &kcpfakestoragemigrationv1alpha1.StoragemigrationV1alpha1Client{Fake: c.Fake, ClusterPath: c.clusterPath} } diff --git a/kubernetes/fake/doc.go b/kubernetes/fake/doc.go new file mode 100644 index 000000000..05690c918 --- /dev/null +++ b/kubernetes/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated fake clientset. +package fake diff --git a/kubernetes/fake/register.go b/kubernetes/fake/register.go new file mode 100644 index 000000000..b13baf7e3 --- /dev/null +++ b/kubernetes/fake/register.go @@ -0,0 +1,162 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package fake + +import ( + admissionregistrationv1 "k8s.io/api/admissionregistration/v1" + admissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1" + admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" + internalv1alpha1 "k8s.io/api/apiserverinternal/v1alpha1" + appsv1 "k8s.io/api/apps/v1" + appsv1beta1 "k8s.io/api/apps/v1beta1" + appsv1beta2 "k8s.io/api/apps/v1beta2" + authenticationv1 "k8s.io/api/authentication/v1" + authenticationv1alpha1 "k8s.io/api/authentication/v1alpha1" + authenticationv1beta1 "k8s.io/api/authentication/v1beta1" + authorizationv1 "k8s.io/api/authorization/v1" + authorizationv1beta1 "k8s.io/api/authorization/v1beta1" + autoscalingv1 "k8s.io/api/autoscaling/v1" + autoscalingv2 "k8s.io/api/autoscaling/v2" + autoscalingv2beta1 "k8s.io/api/autoscaling/v2beta1" + autoscalingv2beta2 "k8s.io/api/autoscaling/v2beta2" + batchv1 "k8s.io/api/batch/v1" + batchv1beta1 "k8s.io/api/batch/v1beta1" + certificatesv1 "k8s.io/api/certificates/v1" + certificatesv1alpha1 "k8s.io/api/certificates/v1alpha1" + certificatesv1beta1 "k8s.io/api/certificates/v1beta1" + coordinationv1 "k8s.io/api/coordination/v1" + coordinationv1alpha2 "k8s.io/api/coordination/v1alpha2" + coordinationv1beta1 "k8s.io/api/coordination/v1beta1" + corev1 "k8s.io/api/core/v1" + discoveryv1 "k8s.io/api/discovery/v1" + discoveryv1beta1 "k8s.io/api/discovery/v1beta1" + eventsv1 "k8s.io/api/events/v1" + eventsv1beta1 "k8s.io/api/events/v1beta1" + extensionsv1beta1 "k8s.io/api/extensions/v1beta1" + flowcontrolv1 "k8s.io/api/flowcontrol/v1" + flowcontrolv1beta1 "k8s.io/api/flowcontrol/v1beta1" + flowcontrolv1beta2 "k8s.io/api/flowcontrol/v1beta2" + flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3" + networkingv1 "k8s.io/api/networking/v1" + networkingv1alpha1 "k8s.io/api/networking/v1alpha1" + networkingv1beta1 "k8s.io/api/networking/v1beta1" + nodev1 "k8s.io/api/node/v1" + nodev1alpha1 "k8s.io/api/node/v1alpha1" + nodev1beta1 "k8s.io/api/node/v1beta1" + policyv1 "k8s.io/api/policy/v1" + policyv1beta1 "k8s.io/api/policy/v1beta1" + rbacv1 "k8s.io/api/rbac/v1" + rbacv1alpha1 "k8s.io/api/rbac/v1alpha1" + rbacv1beta1 "k8s.io/api/rbac/v1beta1" + resourcev1alpha3 "k8s.io/api/resource/v1alpha3" + resourcev1beta1 "k8s.io/api/resource/v1beta1" + schedulingv1 "k8s.io/api/scheduling/v1" + schedulingv1alpha1 "k8s.io/api/scheduling/v1alpha1" + schedulingv1beta1 "k8s.io/api/scheduling/v1beta1" + storagev1 "k8s.io/api/storage/v1" + storagev1alpha1 "k8s.io/api/storage/v1alpha1" + storagev1beta1 "k8s.io/api/storage/v1beta1" + storagemigrationv1alpha1 "k8s.io/api/storagemigration/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" +) + +var scheme = runtime.NewScheme() +var codecs = serializer.NewCodecFactory(scheme) + +var localSchemeBuilder = runtime.SchemeBuilder{ + admissionregistrationv1.AddToScheme, + admissionregistrationv1alpha1.AddToScheme, + admissionregistrationv1beta1.AddToScheme, + internalv1alpha1.AddToScheme, + appsv1.AddToScheme, + appsv1beta1.AddToScheme, + appsv1beta2.AddToScheme, + authenticationv1.AddToScheme, + authenticationv1alpha1.AddToScheme, + authenticationv1beta1.AddToScheme, + authorizationv1.AddToScheme, + authorizationv1beta1.AddToScheme, + autoscalingv1.AddToScheme, + autoscalingv2.AddToScheme, + autoscalingv2beta1.AddToScheme, + autoscalingv2beta2.AddToScheme, + batchv1.AddToScheme, + batchv1beta1.AddToScheme, + certificatesv1.AddToScheme, + certificatesv1alpha1.AddToScheme, + certificatesv1beta1.AddToScheme, + coordinationv1.AddToScheme, + coordinationv1alpha2.AddToScheme, + coordinationv1beta1.AddToScheme, + corev1.AddToScheme, + discoveryv1.AddToScheme, + discoveryv1beta1.AddToScheme, + eventsv1.AddToScheme, + eventsv1beta1.AddToScheme, + extensionsv1beta1.AddToScheme, + flowcontrolv1.AddToScheme, + flowcontrolv1beta1.AddToScheme, + flowcontrolv1beta2.AddToScheme, + flowcontrolv1beta3.AddToScheme, + networkingv1.AddToScheme, + networkingv1alpha1.AddToScheme, + networkingv1beta1.AddToScheme, + nodev1.AddToScheme, + nodev1alpha1.AddToScheme, + nodev1beta1.AddToScheme, + policyv1.AddToScheme, + policyv1beta1.AddToScheme, + rbacv1.AddToScheme, + rbacv1alpha1.AddToScheme, + rbacv1beta1.AddToScheme, + resourcev1alpha3.AddToScheme, + resourcev1beta1.AddToScheme, + schedulingv1.AddToScheme, + schedulingv1alpha1.AddToScheme, + schedulingv1beta1.AddToScheme, + storagev1.AddToScheme, + storagev1alpha1.AddToScheme, + storagev1beta1.AddToScheme, + storagemigrationv1alpha1.AddToScheme, +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(AddToScheme(scheme)) +} diff --git a/kubernetes/scheme/doc.go b/kubernetes/scheme/doc.go new file mode 100644 index 000000000..65ba12554 --- /dev/null +++ b/kubernetes/scheme/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package contains the scheme of the automatically generated clientset. +package scheme diff --git a/kubernetes/scheme/register.go b/kubernetes/scheme/register.go index c5a45e766..8a4f3a85b 100644 --- a/kubernetes/scheme/register.go +++ b/kubernetes/scheme/register.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package scheme @@ -73,10 +73,10 @@ import ( storagev1alpha1 "k8s.io/api/storage/v1alpha1" storagev1beta1 "k8s.io/api/storage/v1beta1" storagemigrationv1alpha1 "k8s.io/api/storagemigration/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/runtime/serializer" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" utilruntime "k8s.io/apimachinery/pkg/util/runtime" ) @@ -87,6 +87,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{ admissionregistrationv1.AddToScheme, admissionregistrationv1alpha1.AddToScheme, admissionregistrationv1beta1.AddToScheme, + internalv1alpha1.AddToScheme, appsv1.AddToScheme, appsv1beta1.AddToScheme, appsv1beta2.AddToScheme, @@ -117,7 +118,6 @@ var localSchemeBuilder = runtime.SchemeBuilder{ flowcontrolv1beta1.AddToScheme, flowcontrolv1beta2.AddToScheme, flowcontrolv1beta3.AddToScheme, - internalv1alpha1.AddToScheme, networkingv1.AddToScheme, networkingv1alpha1.AddToScheme, networkingv1beta1.AddToScheme, @@ -134,10 +134,10 @@ var localSchemeBuilder = runtime.SchemeBuilder{ schedulingv1.AddToScheme, schedulingv1alpha1.AddToScheme, schedulingv1beta1.AddToScheme, - storagemigrationv1alpha1.AddToScheme, storagev1.AddToScheme, storagev1alpha1.AddToScheme, storagev1beta1.AddToScheme, + storagemigrationv1alpha1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition @@ -157,6 +157,6 @@ var localSchemeBuilder = runtime.SchemeBuilder{ var AddToScheme = localSchemeBuilder.AddToScheme func init() { - metav1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) + v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) utilruntime.Must(AddToScheme(Scheme)) } diff --git a/kubernetes/typed/admissionregistration/v1/admissionregistration_client.go b/kubernetes/typed/admissionregistration/v1/admissionregistration_client.go index 02e790d3a..04a671daa 100644 --- a/kubernetes/typed/admissionregistration/v1/admissionregistration_client.go +++ b/kubernetes/typed/admissionregistration/v1/admissionregistration_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,32 +14,36 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apiadmissionregistrationv1 "k8s.io/api/admissionregistration/v1" admissionregistrationv1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type AdmissionregistrationV1ClusterInterface interface { AdmissionregistrationV1ClusterScoper + MutatingWebhookConfigurationsClusterGetter ValidatingAdmissionPoliciesClusterGetter ValidatingAdmissionPolicyBindingsClusterGetter ValidatingWebhookConfigurationsClusterGetter - MutatingWebhookConfigurationsClusterGetter } type AdmissionregistrationV1ClusterScoper interface { Cluster(logicalcluster.Path) admissionregistrationv1.AdmissionregistrationV1Interface } +// AdmissionregistrationV1ClusterClient is used to interact with features provided by the admissionregistration.k8s.io group. type AdmissionregistrationV1ClusterClient struct { clientCache kcpclient.Cache[*admissionregistrationv1.AdmissionregistrationV1Client] } @@ -51,6 +55,10 @@ func (c *AdmissionregistrationV1ClusterClient) Cluster(clusterPath logicalcluste return c.clientCache.ClusterOrDie(clusterPath) } +func (c *AdmissionregistrationV1ClusterClient) MutatingWebhookConfigurations() MutatingWebhookConfigurationClusterInterface { + return &mutatingWebhookConfigurationsClusterInterface{clientCache: c.clientCache} +} + func (c *AdmissionregistrationV1ClusterClient) ValidatingAdmissionPolicies() ValidatingAdmissionPolicyClusterInterface { return &validatingAdmissionPoliciesClusterInterface{clientCache: c.clientCache} } @@ -63,19 +71,17 @@ func (c *AdmissionregistrationV1ClusterClient) ValidatingWebhookConfigurations() return &validatingWebhookConfigurationsClusterInterface{clientCache: c.clientCache} } -func (c *AdmissionregistrationV1ClusterClient) MutatingWebhookConfigurations() MutatingWebhookConfigurationClusterInterface { - return &mutatingWebhookConfigurationsClusterInterface{clientCache: c.clientCache} -} - // NewForConfig creates a new AdmissionregistrationV1ClusterClient for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*AdmissionregistrationV1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new AdmissionregistrationV1ClusterClient for the given config and http client. @@ -87,6 +93,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*Admissionregistrati if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &AdmissionregistrationV1ClusterClient{clientCache: cache}, nil } @@ -99,3 +106,14 @@ func NewForConfigOrDie(c *rest.Config) *AdmissionregistrationV1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apiadmissionregistrationv1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/admissionregistration/v1/doc.go b/kubernetes/typed/admissionregistration/v1/doc.go new file mode 100644 index 000000000..d2f3412ab --- /dev/null +++ b/kubernetes/typed/admissionregistration/v1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1 diff --git a/kubernetes/typed/admissionregistration/v1/fake/admissionregistration_client.go b/kubernetes/typed/admissionregistration/v1/fake/admissionregistration_client.go index b304d7cb9..f6e70f1b5 100644 --- a/kubernetes/typed/admissionregistration/v1/fake/admissionregistration_client.go +++ b/kubernetes/typed/admissionregistration/v1/fake/admissionregistration_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" admissionregistrationv1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpadmissionregistrationv1 "github.com/kcp-dev/client-go/kubernetes/typed/admissionregistration/v1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -41,46 +41,46 @@ func (c *AdmissionregistrationV1ClusterClient) Cluster(clusterPath logicalcluste return &AdmissionregistrationV1Client{Fake: c.Fake, ClusterPath: clusterPath} } +func (c *AdmissionregistrationV1ClusterClient) MutatingWebhookConfigurations() kcpadmissionregistrationv1.MutatingWebhookConfigurationClusterInterface { + return newFakeMutatingWebhookConfigurationClusterClient(c) +} + func (c *AdmissionregistrationV1ClusterClient) ValidatingAdmissionPolicies() kcpadmissionregistrationv1.ValidatingAdmissionPolicyClusterInterface { - return &validatingAdmissionPoliciesClusterClient{Fake: c.Fake} + return newFakeValidatingAdmissionPolicyClusterClient(c) } func (c *AdmissionregistrationV1ClusterClient) ValidatingAdmissionPolicyBindings() kcpadmissionregistrationv1.ValidatingAdmissionPolicyBindingClusterInterface { - return &validatingAdmissionPolicyBindingsClusterClient{Fake: c.Fake} + return newFakeValidatingAdmissionPolicyBindingClusterClient(c) } func (c *AdmissionregistrationV1ClusterClient) ValidatingWebhookConfigurations() kcpadmissionregistrationv1.ValidatingWebhookConfigurationClusterInterface { - return &validatingWebhookConfigurationsClusterClient{Fake: c.Fake} -} - -func (c *AdmissionregistrationV1ClusterClient) MutatingWebhookConfigurations() kcpadmissionregistrationv1.MutatingWebhookConfigurationClusterInterface { - return &mutatingWebhookConfigurationsClusterClient{Fake: c.Fake} + return newFakeValidatingWebhookConfigurationClusterClient(c) } -var _ admissionregistrationv1.AdmissionregistrationV1Interface = (*AdmissionregistrationV1Client)(nil) - type AdmissionregistrationV1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *AdmissionregistrationV1Client) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret +func (c *AdmissionregistrationV1Client) MutatingWebhookConfigurations() admissionregistrationv1.MutatingWebhookConfigurationInterface { + return newFakeMutatingWebhookConfigurationClient(c.Fake, c.ClusterPath) } func (c *AdmissionregistrationV1Client) ValidatingAdmissionPolicies() admissionregistrationv1.ValidatingAdmissionPolicyInterface { - return &validatingAdmissionPoliciesClient{Fake: c.Fake, ClusterPath: c.ClusterPath} + return newFakeValidatingAdmissionPolicyClient(c.Fake, c.ClusterPath) } func (c *AdmissionregistrationV1Client) ValidatingAdmissionPolicyBindings() admissionregistrationv1.ValidatingAdmissionPolicyBindingInterface { - return &validatingAdmissionPolicyBindingsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} + return newFakeValidatingAdmissionPolicyBindingClient(c.Fake, c.ClusterPath) } func (c *AdmissionregistrationV1Client) ValidatingWebhookConfigurations() admissionregistrationv1.ValidatingWebhookConfigurationInterface { - return &validatingWebhookConfigurationsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} + return newFakeValidatingWebhookConfigurationClient(c.Fake, c.ClusterPath) } -func (c *AdmissionregistrationV1Client) MutatingWebhookConfigurations() admissionregistrationv1.MutatingWebhookConfigurationInterface { - return &mutatingWebhookConfigurationsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *AdmissionregistrationV1Client) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret } diff --git a/kubernetes/typed/admissionregistration/v1/fake/doc.go b/kubernetes/typed/admissionregistration/v1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/admissionregistration/v1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/admissionregistration/v1/fake/mutatingwebhookconfiguration.go b/kubernetes/typed/admissionregistration/v1/fake/mutatingwebhookconfiguration.go index 00bccba5c..969153b19 100644 --- a/kubernetes/typed/admissionregistration/v1/fake/mutatingwebhookconfiguration.go +++ b/kubernetes/typed/admissionregistration/v1/fake/mutatingwebhookconfiguration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,86 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" admissionregistrationv1 "k8s.io/api/admissionregistration/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsadmissionregistrationv1 "k8s.io/client-go/applyconfigurations/admissionregistration/v1" - admissionregistrationv1client "k8s.io/client-go/kubernetes/typed/admissionregistration/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/admissionregistration/v1" + typedadmissionregistrationv1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1" + typedkcpadmissionregistrationv1 "github.com/kcp-dev/client-go/kubernetes/typed/admissionregistration/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var mutatingWebhookConfigurationsResource = schema.GroupVersionResource{Group: "admissionregistration.k8s.io", Version: "v1", Resource: "mutatingwebhookconfigurations"} -var mutatingWebhookConfigurationsKind = schema.GroupVersionKind{Group: "admissionregistration.k8s.io", Version: "v1", Kind: "MutatingWebhookConfiguration"} - -type mutatingWebhookConfigurationsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *mutatingWebhookConfigurationsClusterClient) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1client.MutatingWebhookConfigurationInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &mutatingWebhookConfigurationsClient{Fake: c.Fake, ClusterPath: clusterPath} -} - -// List takes label and field selectors, and returns the list of MutatingWebhookConfigurations that match those selectors across all clusters. -func (c *mutatingWebhookConfigurationsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1.MutatingWebhookConfigurationList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(mutatingWebhookConfigurationsResource, mutatingWebhookConfigurationsKind, logicalcluster.Wildcard, opts), &admissionregistrationv1.MutatingWebhookConfigurationList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &admissionregistrationv1.MutatingWebhookConfigurationList{ListMeta: obj.(*admissionregistrationv1.MutatingWebhookConfigurationList).ListMeta} - for _, item := range obj.(*admissionregistrationv1.MutatingWebhookConfigurationList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested MutatingWebhookConfigurations across all clusters. -func (c *mutatingWebhookConfigurationsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(mutatingWebhookConfigurationsResource, logicalcluster.Wildcard, opts)) -} - -type mutatingWebhookConfigurationsClient struct { - *kcptesting.Fake +// mutatingWebhookConfigurationClusterClient implements MutatingWebhookConfigurationClusterInterface +type mutatingWebhookConfigurationClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*admissionregistrationv1.MutatingWebhookConfiguration, *admissionregistrationv1.MutatingWebhookConfigurationList] + Fake *kcptesting.Fake +} + +func newFakeMutatingWebhookConfigurationClusterClient(fake *AdmissionregistrationV1ClusterClient) typedkcpadmissionregistrationv1.MutatingWebhookConfigurationClusterInterface { + return &mutatingWebhookConfigurationClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*admissionregistrationv1.MutatingWebhookConfiguration, *admissionregistrationv1.MutatingWebhookConfigurationList]( + fake.Fake, + admissionregistrationv1.SchemeGroupVersion.WithResource("mutatingwebhookconfigurations"), + admissionregistrationv1.SchemeGroupVersion.WithKind("MutatingWebhookConfiguration"), + func() *admissionregistrationv1.MutatingWebhookConfiguration { + return &admissionregistrationv1.MutatingWebhookConfiguration{} + }, + func() *admissionregistrationv1.MutatingWebhookConfigurationList { + return &admissionregistrationv1.MutatingWebhookConfigurationList{} + }, + func(dst, src *admissionregistrationv1.MutatingWebhookConfigurationList) { dst.ListMeta = src.ListMeta }, + func(list *admissionregistrationv1.MutatingWebhookConfigurationList) []*admissionregistrationv1.MutatingWebhookConfiguration { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *admissionregistrationv1.MutatingWebhookConfigurationList, items []*admissionregistrationv1.MutatingWebhookConfiguration) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, + } +} + +func (c *mutatingWebhookConfigurationClusterClient) Cluster(cluster logicalcluster.Path) typedadmissionregistrationv1.MutatingWebhookConfigurationInterface { + return newFakeMutatingWebhookConfigurationClient(c.Fake, cluster) +} + +// mutatingWebhookConfigurationScopedClient implements MutatingWebhookConfigurationInterface +type mutatingWebhookConfigurationScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*admissionregistrationv1.MutatingWebhookConfiguration, *admissionregistrationv1.MutatingWebhookConfigurationList, *v1.MutatingWebhookConfigurationApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *mutatingWebhookConfigurationsClient) Create(ctx context.Context, mutatingWebhookConfiguration *admissionregistrationv1.MutatingWebhookConfiguration, opts metav1.CreateOptions) (*admissionregistrationv1.MutatingWebhookConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(mutatingWebhookConfigurationsResource, c.ClusterPath, mutatingWebhookConfiguration), &admissionregistrationv1.MutatingWebhookConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1.MutatingWebhookConfiguration), err -} - -func (c *mutatingWebhookConfigurationsClient) Update(ctx context.Context, mutatingWebhookConfiguration *admissionregistrationv1.MutatingWebhookConfiguration, opts metav1.UpdateOptions) (*admissionregistrationv1.MutatingWebhookConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(mutatingWebhookConfigurationsResource, c.ClusterPath, mutatingWebhookConfiguration), &admissionregistrationv1.MutatingWebhookConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1.MutatingWebhookConfiguration), err -} - -func (c *mutatingWebhookConfigurationsClient) UpdateStatus(ctx context.Context, mutatingWebhookConfiguration *admissionregistrationv1.MutatingWebhookConfiguration, opts metav1.UpdateOptions) (*admissionregistrationv1.MutatingWebhookConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(mutatingWebhookConfigurationsResource, c.ClusterPath, "status", mutatingWebhookConfiguration), &admissionregistrationv1.MutatingWebhookConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1.MutatingWebhookConfiguration), err -} - -func (c *mutatingWebhookConfigurationsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(mutatingWebhookConfigurationsResource, c.ClusterPath, name, opts), &admissionregistrationv1.MutatingWebhookConfiguration{}) - return err -} - -func (c *mutatingWebhookConfigurationsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(mutatingWebhookConfigurationsResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &admissionregistrationv1.MutatingWebhookConfigurationList{}) - return err -} - -func (c *mutatingWebhookConfigurationsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*admissionregistrationv1.MutatingWebhookConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(mutatingWebhookConfigurationsResource, c.ClusterPath, name), &admissionregistrationv1.MutatingWebhookConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1.MutatingWebhookConfiguration), err -} - -// List takes label and field selectors, and returns the list of MutatingWebhookConfigurations that match those selectors. -func (c *mutatingWebhookConfigurationsClient) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1.MutatingWebhookConfigurationList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(mutatingWebhookConfigurationsResource, mutatingWebhookConfigurationsKind, c.ClusterPath, opts), &admissionregistrationv1.MutatingWebhookConfigurationList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &admissionregistrationv1.MutatingWebhookConfigurationList{ListMeta: obj.(*admissionregistrationv1.MutatingWebhookConfigurationList).ListMeta} - for _, item := range obj.(*admissionregistrationv1.MutatingWebhookConfigurationList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *mutatingWebhookConfigurationsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(mutatingWebhookConfigurationsResource, c.ClusterPath, opts)) -} - -func (c *mutatingWebhookConfigurationsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*admissionregistrationv1.MutatingWebhookConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(mutatingWebhookConfigurationsResource, c.ClusterPath, name, pt, data, subresources...), &admissionregistrationv1.MutatingWebhookConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1.MutatingWebhookConfiguration), err -} - -func (c *mutatingWebhookConfigurationsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsadmissionregistrationv1.MutatingWebhookConfigurationApplyConfiguration, opts metav1.ApplyOptions) (*admissionregistrationv1.MutatingWebhookConfiguration, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(mutatingWebhookConfigurationsResource, c.ClusterPath, *name, types.ApplyPatchType, data), &admissionregistrationv1.MutatingWebhookConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1.MutatingWebhookConfiguration), err -} - -func (c *mutatingWebhookConfigurationsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsadmissionregistrationv1.MutatingWebhookConfigurationApplyConfiguration, opts metav1.ApplyOptions) (*admissionregistrationv1.MutatingWebhookConfiguration, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(mutatingWebhookConfigurationsResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &admissionregistrationv1.MutatingWebhookConfiguration{}) - if obj == nil { - return nil, err +func newFakeMutatingWebhookConfigurationClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedadmissionregistrationv1.MutatingWebhookConfigurationInterface { + return &mutatingWebhookConfigurationScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*admissionregistrationv1.MutatingWebhookConfiguration, *admissionregistrationv1.MutatingWebhookConfigurationList, *v1.MutatingWebhookConfigurationApplyConfiguration]( + fake, + clusterPath, + "", + admissionregistrationv1.SchemeGroupVersion.WithResource("mutatingwebhookconfigurations"), + admissionregistrationv1.SchemeGroupVersion.WithKind("MutatingWebhookConfiguration"), + func() *admissionregistrationv1.MutatingWebhookConfiguration { + return &admissionregistrationv1.MutatingWebhookConfiguration{} + }, + func() *admissionregistrationv1.MutatingWebhookConfigurationList { + return &admissionregistrationv1.MutatingWebhookConfigurationList{} + }, + func(dst, src *admissionregistrationv1.MutatingWebhookConfigurationList) { dst.ListMeta = src.ListMeta }, + func(list *admissionregistrationv1.MutatingWebhookConfigurationList) []*admissionregistrationv1.MutatingWebhookConfiguration { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *admissionregistrationv1.MutatingWebhookConfigurationList, items []*admissionregistrationv1.MutatingWebhookConfiguration) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*admissionregistrationv1.MutatingWebhookConfiguration), err } diff --git a/kubernetes/typed/admissionregistration/v1/fake/validatingadmissionpolicy.go b/kubernetes/typed/admissionregistration/v1/fake/validatingadmissionpolicy.go index 5c400acdd..d57de3901 100644 --- a/kubernetes/typed/admissionregistration/v1/fake/validatingadmissionpolicy.go +++ b/kubernetes/typed/admissionregistration/v1/fake/validatingadmissionpolicy.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,86 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" admissionregistrationv1 "k8s.io/api/admissionregistration/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsadmissionregistrationv1 "k8s.io/client-go/applyconfigurations/admissionregistration/v1" - admissionregistrationv1client "k8s.io/client-go/kubernetes/typed/admissionregistration/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/admissionregistration/v1" + typedadmissionregistrationv1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1" + typedkcpadmissionregistrationv1 "github.com/kcp-dev/client-go/kubernetes/typed/admissionregistration/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var validatingAdmissionPoliciesResource = schema.GroupVersionResource{Group: "admissionregistration.k8s.io", Version: "v1", Resource: "validatingadmissionpolicies"} -var validatingAdmissionPoliciesKind = schema.GroupVersionKind{Group: "admissionregistration.k8s.io", Version: "v1", Kind: "ValidatingAdmissionPolicy"} - -type validatingAdmissionPoliciesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *validatingAdmissionPoliciesClusterClient) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1client.ValidatingAdmissionPolicyInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &validatingAdmissionPoliciesClient{Fake: c.Fake, ClusterPath: clusterPath} -} - -// List takes label and field selectors, and returns the list of ValidatingAdmissionPolicies that match those selectors across all clusters. -func (c *validatingAdmissionPoliciesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1.ValidatingAdmissionPolicyList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(validatingAdmissionPoliciesResource, validatingAdmissionPoliciesKind, logicalcluster.Wildcard, opts), &admissionregistrationv1.ValidatingAdmissionPolicyList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &admissionregistrationv1.ValidatingAdmissionPolicyList{ListMeta: obj.(*admissionregistrationv1.ValidatingAdmissionPolicyList).ListMeta} - for _, item := range obj.(*admissionregistrationv1.ValidatingAdmissionPolicyList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested ValidatingAdmissionPolicies across all clusters. -func (c *validatingAdmissionPoliciesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(validatingAdmissionPoliciesResource, logicalcluster.Wildcard, opts)) -} - -type validatingAdmissionPoliciesClient struct { - *kcptesting.Fake +// validatingAdmissionPolicyClusterClient implements ValidatingAdmissionPolicyClusterInterface +type validatingAdmissionPolicyClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*admissionregistrationv1.ValidatingAdmissionPolicy, *admissionregistrationv1.ValidatingAdmissionPolicyList] + Fake *kcptesting.Fake +} + +func newFakeValidatingAdmissionPolicyClusterClient(fake *AdmissionregistrationV1ClusterClient) typedkcpadmissionregistrationv1.ValidatingAdmissionPolicyClusterInterface { + return &validatingAdmissionPolicyClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*admissionregistrationv1.ValidatingAdmissionPolicy, *admissionregistrationv1.ValidatingAdmissionPolicyList]( + fake.Fake, + admissionregistrationv1.SchemeGroupVersion.WithResource("validatingadmissionpolicies"), + admissionregistrationv1.SchemeGroupVersion.WithKind("ValidatingAdmissionPolicy"), + func() *admissionregistrationv1.ValidatingAdmissionPolicy { + return &admissionregistrationv1.ValidatingAdmissionPolicy{} + }, + func() *admissionregistrationv1.ValidatingAdmissionPolicyList { + return &admissionregistrationv1.ValidatingAdmissionPolicyList{} + }, + func(dst, src *admissionregistrationv1.ValidatingAdmissionPolicyList) { dst.ListMeta = src.ListMeta }, + func(list *admissionregistrationv1.ValidatingAdmissionPolicyList) []*admissionregistrationv1.ValidatingAdmissionPolicy { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *admissionregistrationv1.ValidatingAdmissionPolicyList, items []*admissionregistrationv1.ValidatingAdmissionPolicy) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, + } +} + +func (c *validatingAdmissionPolicyClusterClient) Cluster(cluster logicalcluster.Path) typedadmissionregistrationv1.ValidatingAdmissionPolicyInterface { + return newFakeValidatingAdmissionPolicyClient(c.Fake, cluster) +} + +// validatingAdmissionPolicyScopedClient implements ValidatingAdmissionPolicyInterface +type validatingAdmissionPolicyScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*admissionregistrationv1.ValidatingAdmissionPolicy, *admissionregistrationv1.ValidatingAdmissionPolicyList, *v1.ValidatingAdmissionPolicyApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *validatingAdmissionPoliciesClient) Create(ctx context.Context, validatingAdmissionPolicy *admissionregistrationv1.ValidatingAdmissionPolicy, opts metav1.CreateOptions) (*admissionregistrationv1.ValidatingAdmissionPolicy, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(validatingAdmissionPoliciesResource, c.ClusterPath, validatingAdmissionPolicy), &admissionregistrationv1.ValidatingAdmissionPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1.ValidatingAdmissionPolicy), err -} - -func (c *validatingAdmissionPoliciesClient) Update(ctx context.Context, validatingAdmissionPolicy *admissionregistrationv1.ValidatingAdmissionPolicy, opts metav1.UpdateOptions) (*admissionregistrationv1.ValidatingAdmissionPolicy, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(validatingAdmissionPoliciesResource, c.ClusterPath, validatingAdmissionPolicy), &admissionregistrationv1.ValidatingAdmissionPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1.ValidatingAdmissionPolicy), err -} - -func (c *validatingAdmissionPoliciesClient) UpdateStatus(ctx context.Context, validatingAdmissionPolicy *admissionregistrationv1.ValidatingAdmissionPolicy, opts metav1.UpdateOptions) (*admissionregistrationv1.ValidatingAdmissionPolicy, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(validatingAdmissionPoliciesResource, c.ClusterPath, "status", validatingAdmissionPolicy), &admissionregistrationv1.ValidatingAdmissionPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1.ValidatingAdmissionPolicy), err -} - -func (c *validatingAdmissionPoliciesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(validatingAdmissionPoliciesResource, c.ClusterPath, name, opts), &admissionregistrationv1.ValidatingAdmissionPolicy{}) - return err -} - -func (c *validatingAdmissionPoliciesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(validatingAdmissionPoliciesResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &admissionregistrationv1.ValidatingAdmissionPolicyList{}) - return err -} - -func (c *validatingAdmissionPoliciesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*admissionregistrationv1.ValidatingAdmissionPolicy, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(validatingAdmissionPoliciesResource, c.ClusterPath, name), &admissionregistrationv1.ValidatingAdmissionPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1.ValidatingAdmissionPolicy), err -} - -// List takes label and field selectors, and returns the list of ValidatingAdmissionPolicies that match those selectors. -func (c *validatingAdmissionPoliciesClient) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1.ValidatingAdmissionPolicyList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(validatingAdmissionPoliciesResource, validatingAdmissionPoliciesKind, c.ClusterPath, opts), &admissionregistrationv1.ValidatingAdmissionPolicyList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &admissionregistrationv1.ValidatingAdmissionPolicyList{ListMeta: obj.(*admissionregistrationv1.ValidatingAdmissionPolicyList).ListMeta} - for _, item := range obj.(*admissionregistrationv1.ValidatingAdmissionPolicyList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *validatingAdmissionPoliciesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(validatingAdmissionPoliciesResource, c.ClusterPath, opts)) -} - -func (c *validatingAdmissionPoliciesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*admissionregistrationv1.ValidatingAdmissionPolicy, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(validatingAdmissionPoliciesResource, c.ClusterPath, name, pt, data, subresources...), &admissionregistrationv1.ValidatingAdmissionPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1.ValidatingAdmissionPolicy), err -} - -func (c *validatingAdmissionPoliciesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsadmissionregistrationv1.ValidatingAdmissionPolicyApplyConfiguration, opts metav1.ApplyOptions) (*admissionregistrationv1.ValidatingAdmissionPolicy, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(validatingAdmissionPoliciesResource, c.ClusterPath, *name, types.ApplyPatchType, data), &admissionregistrationv1.ValidatingAdmissionPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1.ValidatingAdmissionPolicy), err -} - -func (c *validatingAdmissionPoliciesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsadmissionregistrationv1.ValidatingAdmissionPolicyApplyConfiguration, opts metav1.ApplyOptions) (*admissionregistrationv1.ValidatingAdmissionPolicy, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(validatingAdmissionPoliciesResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &admissionregistrationv1.ValidatingAdmissionPolicy{}) - if obj == nil { - return nil, err +func newFakeValidatingAdmissionPolicyClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedadmissionregistrationv1.ValidatingAdmissionPolicyInterface { + return &validatingAdmissionPolicyScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*admissionregistrationv1.ValidatingAdmissionPolicy, *admissionregistrationv1.ValidatingAdmissionPolicyList, *v1.ValidatingAdmissionPolicyApplyConfiguration]( + fake, + clusterPath, + "", + admissionregistrationv1.SchemeGroupVersion.WithResource("validatingadmissionpolicies"), + admissionregistrationv1.SchemeGroupVersion.WithKind("ValidatingAdmissionPolicy"), + func() *admissionregistrationv1.ValidatingAdmissionPolicy { + return &admissionregistrationv1.ValidatingAdmissionPolicy{} + }, + func() *admissionregistrationv1.ValidatingAdmissionPolicyList { + return &admissionregistrationv1.ValidatingAdmissionPolicyList{} + }, + func(dst, src *admissionregistrationv1.ValidatingAdmissionPolicyList) { dst.ListMeta = src.ListMeta }, + func(list *admissionregistrationv1.ValidatingAdmissionPolicyList) []*admissionregistrationv1.ValidatingAdmissionPolicy { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *admissionregistrationv1.ValidatingAdmissionPolicyList, items []*admissionregistrationv1.ValidatingAdmissionPolicy) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*admissionregistrationv1.ValidatingAdmissionPolicy), err } diff --git a/kubernetes/typed/admissionregistration/v1/fake/validatingadmissionpolicybinding.go b/kubernetes/typed/admissionregistration/v1/fake/validatingadmissionpolicybinding.go index 4eec36741..17093ae75 100644 --- a/kubernetes/typed/admissionregistration/v1/fake/validatingadmissionpolicybinding.go +++ b/kubernetes/typed/admissionregistration/v1/fake/validatingadmissionpolicybinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,90 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" admissionregistrationv1 "k8s.io/api/admissionregistration/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsadmissionregistrationv1 "k8s.io/client-go/applyconfigurations/admissionregistration/v1" - admissionregistrationv1client "k8s.io/client-go/kubernetes/typed/admissionregistration/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/admissionregistration/v1" + typedadmissionregistrationv1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1" + typedkcpadmissionregistrationv1 "github.com/kcp-dev/client-go/kubernetes/typed/admissionregistration/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var validatingAdmissionPolicyBindingsResource = schema.GroupVersionResource{Group: "admissionregistration.k8s.io", Version: "v1", Resource: "validatingadmissionpolicybindings"} -var validatingAdmissionPolicyBindingsKind = schema.GroupVersionKind{Group: "admissionregistration.k8s.io", Version: "v1", Kind: "ValidatingAdmissionPolicyBinding"} - -type validatingAdmissionPolicyBindingsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *validatingAdmissionPolicyBindingsClusterClient) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1client.ValidatingAdmissionPolicyBindingInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &validatingAdmissionPolicyBindingsClient{Fake: c.Fake, ClusterPath: clusterPath} -} - -// List takes label and field selectors, and returns the list of ValidatingAdmissionPolicyBindings that match those selectors across all clusters. -func (c *validatingAdmissionPolicyBindingsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1.ValidatingAdmissionPolicyBindingList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(validatingAdmissionPolicyBindingsResource, validatingAdmissionPolicyBindingsKind, logicalcluster.Wildcard, opts), &admissionregistrationv1.ValidatingAdmissionPolicyBindingList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &admissionregistrationv1.ValidatingAdmissionPolicyBindingList{ListMeta: obj.(*admissionregistrationv1.ValidatingAdmissionPolicyBindingList).ListMeta} - for _, item := range obj.(*admissionregistrationv1.ValidatingAdmissionPolicyBindingList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested ValidatingAdmissionPolicyBindings across all clusters. -func (c *validatingAdmissionPolicyBindingsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(validatingAdmissionPolicyBindingsResource, logicalcluster.Wildcard, opts)) -} - -type validatingAdmissionPolicyBindingsClient struct { - *kcptesting.Fake +// validatingAdmissionPolicyBindingClusterClient implements ValidatingAdmissionPolicyBindingClusterInterface +type validatingAdmissionPolicyBindingClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*admissionregistrationv1.ValidatingAdmissionPolicyBinding, *admissionregistrationv1.ValidatingAdmissionPolicyBindingList] + Fake *kcptesting.Fake +} + +func newFakeValidatingAdmissionPolicyBindingClusterClient(fake *AdmissionregistrationV1ClusterClient) typedkcpadmissionregistrationv1.ValidatingAdmissionPolicyBindingClusterInterface { + return &validatingAdmissionPolicyBindingClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*admissionregistrationv1.ValidatingAdmissionPolicyBinding, *admissionregistrationv1.ValidatingAdmissionPolicyBindingList]( + fake.Fake, + admissionregistrationv1.SchemeGroupVersion.WithResource("validatingadmissionpolicybindings"), + admissionregistrationv1.SchemeGroupVersion.WithKind("ValidatingAdmissionPolicyBinding"), + func() *admissionregistrationv1.ValidatingAdmissionPolicyBinding { + return &admissionregistrationv1.ValidatingAdmissionPolicyBinding{} + }, + func() *admissionregistrationv1.ValidatingAdmissionPolicyBindingList { + return &admissionregistrationv1.ValidatingAdmissionPolicyBindingList{} + }, + func(dst, src *admissionregistrationv1.ValidatingAdmissionPolicyBindingList) { + dst.ListMeta = src.ListMeta + }, + func(list *admissionregistrationv1.ValidatingAdmissionPolicyBindingList) []*admissionregistrationv1.ValidatingAdmissionPolicyBinding { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *admissionregistrationv1.ValidatingAdmissionPolicyBindingList, items []*admissionregistrationv1.ValidatingAdmissionPolicyBinding) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, + } +} + +func (c *validatingAdmissionPolicyBindingClusterClient) Cluster(cluster logicalcluster.Path) typedadmissionregistrationv1.ValidatingAdmissionPolicyBindingInterface { + return newFakeValidatingAdmissionPolicyBindingClient(c.Fake, cluster) +} + +// validatingAdmissionPolicyBindingScopedClient implements ValidatingAdmissionPolicyBindingInterface +type validatingAdmissionPolicyBindingScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*admissionregistrationv1.ValidatingAdmissionPolicyBinding, *admissionregistrationv1.ValidatingAdmissionPolicyBindingList, *v1.ValidatingAdmissionPolicyBindingApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *validatingAdmissionPolicyBindingsClient) Create(ctx context.Context, validatingAdmissionPolicyBinding *admissionregistrationv1.ValidatingAdmissionPolicyBinding, opts metav1.CreateOptions) (*admissionregistrationv1.ValidatingAdmissionPolicyBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(validatingAdmissionPolicyBindingsResource, c.ClusterPath, validatingAdmissionPolicyBinding), &admissionregistrationv1.ValidatingAdmissionPolicyBinding{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1.ValidatingAdmissionPolicyBinding), err -} - -func (c *validatingAdmissionPolicyBindingsClient) Update(ctx context.Context, validatingAdmissionPolicyBinding *admissionregistrationv1.ValidatingAdmissionPolicyBinding, opts metav1.UpdateOptions) (*admissionregistrationv1.ValidatingAdmissionPolicyBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(validatingAdmissionPolicyBindingsResource, c.ClusterPath, validatingAdmissionPolicyBinding), &admissionregistrationv1.ValidatingAdmissionPolicyBinding{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1.ValidatingAdmissionPolicyBinding), err -} - -func (c *validatingAdmissionPolicyBindingsClient) UpdateStatus(ctx context.Context, validatingAdmissionPolicyBinding *admissionregistrationv1.ValidatingAdmissionPolicyBinding, opts metav1.UpdateOptions) (*admissionregistrationv1.ValidatingAdmissionPolicyBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(validatingAdmissionPolicyBindingsResource, c.ClusterPath, "status", validatingAdmissionPolicyBinding), &admissionregistrationv1.ValidatingAdmissionPolicyBinding{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1.ValidatingAdmissionPolicyBinding), err -} - -func (c *validatingAdmissionPolicyBindingsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(validatingAdmissionPolicyBindingsResource, c.ClusterPath, name, opts), &admissionregistrationv1.ValidatingAdmissionPolicyBinding{}) - return err -} - -func (c *validatingAdmissionPolicyBindingsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(validatingAdmissionPolicyBindingsResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &admissionregistrationv1.ValidatingAdmissionPolicyBindingList{}) - return err -} - -func (c *validatingAdmissionPolicyBindingsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*admissionregistrationv1.ValidatingAdmissionPolicyBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(validatingAdmissionPolicyBindingsResource, c.ClusterPath, name), &admissionregistrationv1.ValidatingAdmissionPolicyBinding{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1.ValidatingAdmissionPolicyBinding), err -} - -// List takes label and field selectors, and returns the list of ValidatingAdmissionPolicyBindings that match those selectors. -func (c *validatingAdmissionPolicyBindingsClient) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1.ValidatingAdmissionPolicyBindingList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(validatingAdmissionPolicyBindingsResource, validatingAdmissionPolicyBindingsKind, c.ClusterPath, opts), &admissionregistrationv1.ValidatingAdmissionPolicyBindingList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &admissionregistrationv1.ValidatingAdmissionPolicyBindingList{ListMeta: obj.(*admissionregistrationv1.ValidatingAdmissionPolicyBindingList).ListMeta} - for _, item := range obj.(*admissionregistrationv1.ValidatingAdmissionPolicyBindingList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *validatingAdmissionPolicyBindingsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(validatingAdmissionPolicyBindingsResource, c.ClusterPath, opts)) -} - -func (c *validatingAdmissionPolicyBindingsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*admissionregistrationv1.ValidatingAdmissionPolicyBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(validatingAdmissionPolicyBindingsResource, c.ClusterPath, name, pt, data, subresources...), &admissionregistrationv1.ValidatingAdmissionPolicyBinding{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1.ValidatingAdmissionPolicyBinding), err -} - -func (c *validatingAdmissionPolicyBindingsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsadmissionregistrationv1.ValidatingAdmissionPolicyBindingApplyConfiguration, opts metav1.ApplyOptions) (*admissionregistrationv1.ValidatingAdmissionPolicyBinding, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(validatingAdmissionPolicyBindingsResource, c.ClusterPath, *name, types.ApplyPatchType, data), &admissionregistrationv1.ValidatingAdmissionPolicyBinding{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1.ValidatingAdmissionPolicyBinding), err -} - -func (c *validatingAdmissionPolicyBindingsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsadmissionregistrationv1.ValidatingAdmissionPolicyBindingApplyConfiguration, opts metav1.ApplyOptions) (*admissionregistrationv1.ValidatingAdmissionPolicyBinding, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(validatingAdmissionPolicyBindingsResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &admissionregistrationv1.ValidatingAdmissionPolicyBinding{}) - if obj == nil { - return nil, err +func newFakeValidatingAdmissionPolicyBindingClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedadmissionregistrationv1.ValidatingAdmissionPolicyBindingInterface { + return &validatingAdmissionPolicyBindingScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*admissionregistrationv1.ValidatingAdmissionPolicyBinding, *admissionregistrationv1.ValidatingAdmissionPolicyBindingList, *v1.ValidatingAdmissionPolicyBindingApplyConfiguration]( + fake, + clusterPath, + "", + admissionregistrationv1.SchemeGroupVersion.WithResource("validatingadmissionpolicybindings"), + admissionregistrationv1.SchemeGroupVersion.WithKind("ValidatingAdmissionPolicyBinding"), + func() *admissionregistrationv1.ValidatingAdmissionPolicyBinding { + return &admissionregistrationv1.ValidatingAdmissionPolicyBinding{} + }, + func() *admissionregistrationv1.ValidatingAdmissionPolicyBindingList { + return &admissionregistrationv1.ValidatingAdmissionPolicyBindingList{} + }, + func(dst, src *admissionregistrationv1.ValidatingAdmissionPolicyBindingList) { + dst.ListMeta = src.ListMeta + }, + func(list *admissionregistrationv1.ValidatingAdmissionPolicyBindingList) []*admissionregistrationv1.ValidatingAdmissionPolicyBinding { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *admissionregistrationv1.ValidatingAdmissionPolicyBindingList, items []*admissionregistrationv1.ValidatingAdmissionPolicyBinding) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*admissionregistrationv1.ValidatingAdmissionPolicyBinding), err } diff --git a/kubernetes/typed/admissionregistration/v1/fake/validatingwebhookconfiguration.go b/kubernetes/typed/admissionregistration/v1/fake/validatingwebhookconfiguration.go index 2981f813f..ac30be3ca 100644 --- a/kubernetes/typed/admissionregistration/v1/fake/validatingwebhookconfiguration.go +++ b/kubernetes/typed/admissionregistration/v1/fake/validatingwebhookconfiguration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,90 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" admissionregistrationv1 "k8s.io/api/admissionregistration/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsadmissionregistrationv1 "k8s.io/client-go/applyconfigurations/admissionregistration/v1" - admissionregistrationv1client "k8s.io/client-go/kubernetes/typed/admissionregistration/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/admissionregistration/v1" + typedadmissionregistrationv1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1" + typedkcpadmissionregistrationv1 "github.com/kcp-dev/client-go/kubernetes/typed/admissionregistration/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var validatingWebhookConfigurationsResource = schema.GroupVersionResource{Group: "admissionregistration.k8s.io", Version: "v1", Resource: "validatingwebhookconfigurations"} -var validatingWebhookConfigurationsKind = schema.GroupVersionKind{Group: "admissionregistration.k8s.io", Version: "v1", Kind: "ValidatingWebhookConfiguration"} - -type validatingWebhookConfigurationsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *validatingWebhookConfigurationsClusterClient) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1client.ValidatingWebhookConfigurationInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &validatingWebhookConfigurationsClient{Fake: c.Fake, ClusterPath: clusterPath} -} - -// List takes label and field selectors, and returns the list of ValidatingWebhookConfigurations that match those selectors across all clusters. -func (c *validatingWebhookConfigurationsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1.ValidatingWebhookConfigurationList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(validatingWebhookConfigurationsResource, validatingWebhookConfigurationsKind, logicalcluster.Wildcard, opts), &admissionregistrationv1.ValidatingWebhookConfigurationList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &admissionregistrationv1.ValidatingWebhookConfigurationList{ListMeta: obj.(*admissionregistrationv1.ValidatingWebhookConfigurationList).ListMeta} - for _, item := range obj.(*admissionregistrationv1.ValidatingWebhookConfigurationList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested ValidatingWebhookConfigurations across all clusters. -func (c *validatingWebhookConfigurationsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(validatingWebhookConfigurationsResource, logicalcluster.Wildcard, opts)) -} - -type validatingWebhookConfigurationsClient struct { - *kcptesting.Fake +// validatingWebhookConfigurationClusterClient implements ValidatingWebhookConfigurationClusterInterface +type validatingWebhookConfigurationClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*admissionregistrationv1.ValidatingWebhookConfiguration, *admissionregistrationv1.ValidatingWebhookConfigurationList] + Fake *kcptesting.Fake +} + +func newFakeValidatingWebhookConfigurationClusterClient(fake *AdmissionregistrationV1ClusterClient) typedkcpadmissionregistrationv1.ValidatingWebhookConfigurationClusterInterface { + return &validatingWebhookConfigurationClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*admissionregistrationv1.ValidatingWebhookConfiguration, *admissionregistrationv1.ValidatingWebhookConfigurationList]( + fake.Fake, + admissionregistrationv1.SchemeGroupVersion.WithResource("validatingwebhookconfigurations"), + admissionregistrationv1.SchemeGroupVersion.WithKind("ValidatingWebhookConfiguration"), + func() *admissionregistrationv1.ValidatingWebhookConfiguration { + return &admissionregistrationv1.ValidatingWebhookConfiguration{} + }, + func() *admissionregistrationv1.ValidatingWebhookConfigurationList { + return &admissionregistrationv1.ValidatingWebhookConfigurationList{} + }, + func(dst, src *admissionregistrationv1.ValidatingWebhookConfigurationList) { + dst.ListMeta = src.ListMeta + }, + func(list *admissionregistrationv1.ValidatingWebhookConfigurationList) []*admissionregistrationv1.ValidatingWebhookConfiguration { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *admissionregistrationv1.ValidatingWebhookConfigurationList, items []*admissionregistrationv1.ValidatingWebhookConfiguration) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, + } +} + +func (c *validatingWebhookConfigurationClusterClient) Cluster(cluster logicalcluster.Path) typedadmissionregistrationv1.ValidatingWebhookConfigurationInterface { + return newFakeValidatingWebhookConfigurationClient(c.Fake, cluster) +} + +// validatingWebhookConfigurationScopedClient implements ValidatingWebhookConfigurationInterface +type validatingWebhookConfigurationScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*admissionregistrationv1.ValidatingWebhookConfiguration, *admissionregistrationv1.ValidatingWebhookConfigurationList, *v1.ValidatingWebhookConfigurationApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *validatingWebhookConfigurationsClient) Create(ctx context.Context, validatingWebhookConfiguration *admissionregistrationv1.ValidatingWebhookConfiguration, opts metav1.CreateOptions) (*admissionregistrationv1.ValidatingWebhookConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(validatingWebhookConfigurationsResource, c.ClusterPath, validatingWebhookConfiguration), &admissionregistrationv1.ValidatingWebhookConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1.ValidatingWebhookConfiguration), err -} - -func (c *validatingWebhookConfigurationsClient) Update(ctx context.Context, validatingWebhookConfiguration *admissionregistrationv1.ValidatingWebhookConfiguration, opts metav1.UpdateOptions) (*admissionregistrationv1.ValidatingWebhookConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(validatingWebhookConfigurationsResource, c.ClusterPath, validatingWebhookConfiguration), &admissionregistrationv1.ValidatingWebhookConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1.ValidatingWebhookConfiguration), err -} - -func (c *validatingWebhookConfigurationsClient) UpdateStatus(ctx context.Context, validatingWebhookConfiguration *admissionregistrationv1.ValidatingWebhookConfiguration, opts metav1.UpdateOptions) (*admissionregistrationv1.ValidatingWebhookConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(validatingWebhookConfigurationsResource, c.ClusterPath, "status", validatingWebhookConfiguration), &admissionregistrationv1.ValidatingWebhookConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1.ValidatingWebhookConfiguration), err -} - -func (c *validatingWebhookConfigurationsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(validatingWebhookConfigurationsResource, c.ClusterPath, name, opts), &admissionregistrationv1.ValidatingWebhookConfiguration{}) - return err -} - -func (c *validatingWebhookConfigurationsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(validatingWebhookConfigurationsResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &admissionregistrationv1.ValidatingWebhookConfigurationList{}) - return err -} - -func (c *validatingWebhookConfigurationsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*admissionregistrationv1.ValidatingWebhookConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(validatingWebhookConfigurationsResource, c.ClusterPath, name), &admissionregistrationv1.ValidatingWebhookConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1.ValidatingWebhookConfiguration), err -} - -// List takes label and field selectors, and returns the list of ValidatingWebhookConfigurations that match those selectors. -func (c *validatingWebhookConfigurationsClient) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1.ValidatingWebhookConfigurationList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(validatingWebhookConfigurationsResource, validatingWebhookConfigurationsKind, c.ClusterPath, opts), &admissionregistrationv1.ValidatingWebhookConfigurationList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &admissionregistrationv1.ValidatingWebhookConfigurationList{ListMeta: obj.(*admissionregistrationv1.ValidatingWebhookConfigurationList).ListMeta} - for _, item := range obj.(*admissionregistrationv1.ValidatingWebhookConfigurationList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *validatingWebhookConfigurationsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(validatingWebhookConfigurationsResource, c.ClusterPath, opts)) -} - -func (c *validatingWebhookConfigurationsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*admissionregistrationv1.ValidatingWebhookConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(validatingWebhookConfigurationsResource, c.ClusterPath, name, pt, data, subresources...), &admissionregistrationv1.ValidatingWebhookConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1.ValidatingWebhookConfiguration), err -} - -func (c *validatingWebhookConfigurationsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsadmissionregistrationv1.ValidatingWebhookConfigurationApplyConfiguration, opts metav1.ApplyOptions) (*admissionregistrationv1.ValidatingWebhookConfiguration, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(validatingWebhookConfigurationsResource, c.ClusterPath, *name, types.ApplyPatchType, data), &admissionregistrationv1.ValidatingWebhookConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1.ValidatingWebhookConfiguration), err -} - -func (c *validatingWebhookConfigurationsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsadmissionregistrationv1.ValidatingWebhookConfigurationApplyConfiguration, opts metav1.ApplyOptions) (*admissionregistrationv1.ValidatingWebhookConfiguration, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(validatingWebhookConfigurationsResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &admissionregistrationv1.ValidatingWebhookConfiguration{}) - if obj == nil { - return nil, err +func newFakeValidatingWebhookConfigurationClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedadmissionregistrationv1.ValidatingWebhookConfigurationInterface { + return &validatingWebhookConfigurationScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*admissionregistrationv1.ValidatingWebhookConfiguration, *admissionregistrationv1.ValidatingWebhookConfigurationList, *v1.ValidatingWebhookConfigurationApplyConfiguration]( + fake, + clusterPath, + "", + admissionregistrationv1.SchemeGroupVersion.WithResource("validatingwebhookconfigurations"), + admissionregistrationv1.SchemeGroupVersion.WithKind("ValidatingWebhookConfiguration"), + func() *admissionregistrationv1.ValidatingWebhookConfiguration { + return &admissionregistrationv1.ValidatingWebhookConfiguration{} + }, + func() *admissionregistrationv1.ValidatingWebhookConfigurationList { + return &admissionregistrationv1.ValidatingWebhookConfigurationList{} + }, + func(dst, src *admissionregistrationv1.ValidatingWebhookConfigurationList) { + dst.ListMeta = src.ListMeta + }, + func(list *admissionregistrationv1.ValidatingWebhookConfigurationList) []*admissionregistrationv1.ValidatingWebhookConfiguration { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *admissionregistrationv1.ValidatingWebhookConfigurationList, items []*admissionregistrationv1.ValidatingWebhookConfiguration) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*admissionregistrationv1.ValidatingWebhookConfiguration), err } diff --git a/kubernetes/typed/admissionregistration/v1/generated_expansion.go b/kubernetes/typed/admissionregistration/v1/generated_expansion.go new file mode 100644 index 000000000..f00116bd8 --- /dev/null +++ b/kubernetes/typed/admissionregistration/v1/generated_expansion.go @@ -0,0 +1,27 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1 + +type MutatingWebhookConfigurationClusterExpansion interface{} + +type ValidatingAdmissionPolicyClusterExpansion interface{} + +type ValidatingAdmissionPolicyBindingClusterExpansion interface{} + +type ValidatingWebhookConfigurationClusterExpansion interface{} diff --git a/kubernetes/typed/admissionregistration/v1/mutatingwebhookconfiguration.go b/kubernetes/typed/admissionregistration/v1/mutatingwebhookconfiguration.go index c07b8a3dc..44bbc575b 100644 --- a/kubernetes/typed/admissionregistration/v1/mutatingwebhookconfiguration.go +++ b/kubernetes/typed/admissionregistration/v1/mutatingwebhookconfiguration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - admissionregistrationv1 "k8s.io/api/admissionregistration/v1" + apiadmissionregistrationv1 "k8s.io/api/admissionregistration/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - admissionregistrationv1client "k8s.io/client-go/kubernetes/typed/admissionregistration/v1" + watch "k8s.io/apimachinery/pkg/watch" + admissionregistrationv1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1" ) // MutatingWebhookConfigurationsClusterGetter has a method to return a MutatingWebhookConfigurationClusterInterface. @@ -37,19 +37,20 @@ type MutatingWebhookConfigurationsClusterGetter interface { } // MutatingWebhookConfigurationClusterInterface can operate on MutatingWebhookConfigurations across all clusters, -// or scope down to one cluster and return a admissionregistrationv1client.MutatingWebhookConfigurationInterface. +// or scope down to one cluster and return a admissionregistrationv1.MutatingWebhookConfigurationInterface. type MutatingWebhookConfigurationClusterInterface interface { - Cluster(logicalcluster.Path) admissionregistrationv1client.MutatingWebhookConfigurationInterface - List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1.MutatingWebhookConfigurationList, error) + Cluster(logicalcluster.Path) admissionregistrationv1.MutatingWebhookConfigurationInterface + List(ctx context.Context, opts metav1.ListOptions) (*apiadmissionregistrationv1.MutatingWebhookConfigurationList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + MutatingWebhookConfigurationClusterExpansion } type mutatingWebhookConfigurationsClusterInterface struct { - clientCache kcpclient.Cache[*admissionregistrationv1client.AdmissionregistrationV1Client] + clientCache kcpclient.Cache[*admissionregistrationv1.AdmissionregistrationV1Client] } // Cluster scopes the client down to a particular cluster. -func (c *mutatingWebhookConfigurationsClusterInterface) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1client.MutatingWebhookConfigurationInterface { +func (c *mutatingWebhookConfigurationsClusterInterface) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1.MutatingWebhookConfigurationInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,7 +59,7 @@ func (c *mutatingWebhookConfigurationsClusterInterface) Cluster(clusterPath logi } // List returns the entire collection of all MutatingWebhookConfigurations across all clusters. -func (c *mutatingWebhookConfigurationsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1.MutatingWebhookConfigurationList, error) { +func (c *mutatingWebhookConfigurationsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*apiadmissionregistrationv1.MutatingWebhookConfigurationList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).MutatingWebhookConfigurations().List(ctx, opts) } diff --git a/kubernetes/typed/admissionregistration/v1/validatingadmissionpolicy.go b/kubernetes/typed/admissionregistration/v1/validatingadmissionpolicy.go index ca49f2fde..01bdaa9ae 100644 --- a/kubernetes/typed/admissionregistration/v1/validatingadmissionpolicy.go +++ b/kubernetes/typed/admissionregistration/v1/validatingadmissionpolicy.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - admissionregistrationv1 "k8s.io/api/admissionregistration/v1" + apiadmissionregistrationv1 "k8s.io/api/admissionregistration/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - admissionregistrationv1client "k8s.io/client-go/kubernetes/typed/admissionregistration/v1" + watch "k8s.io/apimachinery/pkg/watch" + admissionregistrationv1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1" ) // ValidatingAdmissionPoliciesClusterGetter has a method to return a ValidatingAdmissionPolicyClusterInterface. @@ -37,19 +37,20 @@ type ValidatingAdmissionPoliciesClusterGetter interface { } // ValidatingAdmissionPolicyClusterInterface can operate on ValidatingAdmissionPolicies across all clusters, -// or scope down to one cluster and return a admissionregistrationv1client.ValidatingAdmissionPolicyInterface. +// or scope down to one cluster and return a admissionregistrationv1.ValidatingAdmissionPolicyInterface. type ValidatingAdmissionPolicyClusterInterface interface { - Cluster(logicalcluster.Path) admissionregistrationv1client.ValidatingAdmissionPolicyInterface - List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1.ValidatingAdmissionPolicyList, error) + Cluster(logicalcluster.Path) admissionregistrationv1.ValidatingAdmissionPolicyInterface + List(ctx context.Context, opts metav1.ListOptions) (*apiadmissionregistrationv1.ValidatingAdmissionPolicyList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + ValidatingAdmissionPolicyClusterExpansion } type validatingAdmissionPoliciesClusterInterface struct { - clientCache kcpclient.Cache[*admissionregistrationv1client.AdmissionregistrationV1Client] + clientCache kcpclient.Cache[*admissionregistrationv1.AdmissionregistrationV1Client] } // Cluster scopes the client down to a particular cluster. -func (c *validatingAdmissionPoliciesClusterInterface) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1client.ValidatingAdmissionPolicyInterface { +func (c *validatingAdmissionPoliciesClusterInterface) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1.ValidatingAdmissionPolicyInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,7 +59,7 @@ func (c *validatingAdmissionPoliciesClusterInterface) Cluster(clusterPath logica } // List returns the entire collection of all ValidatingAdmissionPolicies across all clusters. -func (c *validatingAdmissionPoliciesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1.ValidatingAdmissionPolicyList, error) { +func (c *validatingAdmissionPoliciesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*apiadmissionregistrationv1.ValidatingAdmissionPolicyList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ValidatingAdmissionPolicies().List(ctx, opts) } diff --git a/kubernetes/typed/admissionregistration/v1/validatingadmissionpolicybinding.go b/kubernetes/typed/admissionregistration/v1/validatingadmissionpolicybinding.go index 8416b2797..a7938face 100644 --- a/kubernetes/typed/admissionregistration/v1/validatingadmissionpolicybinding.go +++ b/kubernetes/typed/admissionregistration/v1/validatingadmissionpolicybinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - admissionregistrationv1 "k8s.io/api/admissionregistration/v1" + apiadmissionregistrationv1 "k8s.io/api/admissionregistration/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - admissionregistrationv1client "k8s.io/client-go/kubernetes/typed/admissionregistration/v1" + watch "k8s.io/apimachinery/pkg/watch" + admissionregistrationv1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1" ) // ValidatingAdmissionPolicyBindingsClusterGetter has a method to return a ValidatingAdmissionPolicyBindingClusterInterface. @@ -37,19 +37,20 @@ type ValidatingAdmissionPolicyBindingsClusterGetter interface { } // ValidatingAdmissionPolicyBindingClusterInterface can operate on ValidatingAdmissionPolicyBindings across all clusters, -// or scope down to one cluster and return a admissionregistrationv1client.ValidatingAdmissionPolicyBindingInterface. +// or scope down to one cluster and return a admissionregistrationv1.ValidatingAdmissionPolicyBindingInterface. type ValidatingAdmissionPolicyBindingClusterInterface interface { - Cluster(logicalcluster.Path) admissionregistrationv1client.ValidatingAdmissionPolicyBindingInterface - List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1.ValidatingAdmissionPolicyBindingList, error) + Cluster(logicalcluster.Path) admissionregistrationv1.ValidatingAdmissionPolicyBindingInterface + List(ctx context.Context, opts metav1.ListOptions) (*apiadmissionregistrationv1.ValidatingAdmissionPolicyBindingList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + ValidatingAdmissionPolicyBindingClusterExpansion } type validatingAdmissionPolicyBindingsClusterInterface struct { - clientCache kcpclient.Cache[*admissionregistrationv1client.AdmissionregistrationV1Client] + clientCache kcpclient.Cache[*admissionregistrationv1.AdmissionregistrationV1Client] } // Cluster scopes the client down to a particular cluster. -func (c *validatingAdmissionPolicyBindingsClusterInterface) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1client.ValidatingAdmissionPolicyBindingInterface { +func (c *validatingAdmissionPolicyBindingsClusterInterface) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1.ValidatingAdmissionPolicyBindingInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,7 +59,7 @@ func (c *validatingAdmissionPolicyBindingsClusterInterface) Cluster(clusterPath } // List returns the entire collection of all ValidatingAdmissionPolicyBindings across all clusters. -func (c *validatingAdmissionPolicyBindingsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1.ValidatingAdmissionPolicyBindingList, error) { +func (c *validatingAdmissionPolicyBindingsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*apiadmissionregistrationv1.ValidatingAdmissionPolicyBindingList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ValidatingAdmissionPolicyBindings().List(ctx, opts) } diff --git a/kubernetes/typed/admissionregistration/v1/validatingwebhookconfiguration.go b/kubernetes/typed/admissionregistration/v1/validatingwebhookconfiguration.go index 13035c862..7d6cfa755 100644 --- a/kubernetes/typed/admissionregistration/v1/validatingwebhookconfiguration.go +++ b/kubernetes/typed/admissionregistration/v1/validatingwebhookconfiguration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - admissionregistrationv1 "k8s.io/api/admissionregistration/v1" + apiadmissionregistrationv1 "k8s.io/api/admissionregistration/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - admissionregistrationv1client "k8s.io/client-go/kubernetes/typed/admissionregistration/v1" + watch "k8s.io/apimachinery/pkg/watch" + admissionregistrationv1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1" ) // ValidatingWebhookConfigurationsClusterGetter has a method to return a ValidatingWebhookConfigurationClusterInterface. @@ -37,19 +37,20 @@ type ValidatingWebhookConfigurationsClusterGetter interface { } // ValidatingWebhookConfigurationClusterInterface can operate on ValidatingWebhookConfigurations across all clusters, -// or scope down to one cluster and return a admissionregistrationv1client.ValidatingWebhookConfigurationInterface. +// or scope down to one cluster and return a admissionregistrationv1.ValidatingWebhookConfigurationInterface. type ValidatingWebhookConfigurationClusterInterface interface { - Cluster(logicalcluster.Path) admissionregistrationv1client.ValidatingWebhookConfigurationInterface - List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1.ValidatingWebhookConfigurationList, error) + Cluster(logicalcluster.Path) admissionregistrationv1.ValidatingWebhookConfigurationInterface + List(ctx context.Context, opts metav1.ListOptions) (*apiadmissionregistrationv1.ValidatingWebhookConfigurationList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + ValidatingWebhookConfigurationClusterExpansion } type validatingWebhookConfigurationsClusterInterface struct { - clientCache kcpclient.Cache[*admissionregistrationv1client.AdmissionregistrationV1Client] + clientCache kcpclient.Cache[*admissionregistrationv1.AdmissionregistrationV1Client] } // Cluster scopes the client down to a particular cluster. -func (c *validatingWebhookConfigurationsClusterInterface) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1client.ValidatingWebhookConfigurationInterface { +func (c *validatingWebhookConfigurationsClusterInterface) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1.ValidatingWebhookConfigurationInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,7 +59,7 @@ func (c *validatingWebhookConfigurationsClusterInterface) Cluster(clusterPath lo } // List returns the entire collection of all ValidatingWebhookConfigurations across all clusters. -func (c *validatingWebhookConfigurationsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1.ValidatingWebhookConfigurationList, error) { +func (c *validatingWebhookConfigurationsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*apiadmissionregistrationv1.ValidatingWebhookConfigurationList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ValidatingWebhookConfigurations().List(ctx, opts) } diff --git a/kubernetes/typed/admissionregistration/v1alpha1/admissionregistration_client.go b/kubernetes/typed/admissionregistration/v1alpha1/admissionregistration_client.go index 7ce577d36..63bb4fe28 100644 --- a/kubernetes/typed/admissionregistration/v1alpha1/admissionregistration_client.go +++ b/kubernetes/typed/admissionregistration/v1alpha1/admissionregistration_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,32 +14,36 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apiadmissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1" admissionregistrationv1alpha1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type AdmissionregistrationV1alpha1ClusterInterface interface { AdmissionregistrationV1alpha1ClusterScoper - ValidatingAdmissionPoliciesClusterGetter - ValidatingAdmissionPolicyBindingsClusterGetter MutatingAdmissionPoliciesClusterGetter MutatingAdmissionPolicyBindingsClusterGetter + ValidatingAdmissionPoliciesClusterGetter + ValidatingAdmissionPolicyBindingsClusterGetter } type AdmissionregistrationV1alpha1ClusterScoper interface { Cluster(logicalcluster.Path) admissionregistrationv1alpha1.AdmissionregistrationV1alpha1Interface } +// AdmissionregistrationV1alpha1ClusterClient is used to interact with features provided by the admissionregistration.k8s.io group. type AdmissionregistrationV1alpha1ClusterClient struct { clientCache kcpclient.Cache[*admissionregistrationv1alpha1.AdmissionregistrationV1alpha1Client] } @@ -51,14 +55,6 @@ func (c *AdmissionregistrationV1alpha1ClusterClient) Cluster(clusterPath logical return c.clientCache.ClusterOrDie(clusterPath) } -func (c *AdmissionregistrationV1alpha1ClusterClient) ValidatingAdmissionPolicies() ValidatingAdmissionPolicyClusterInterface { - return &validatingAdmissionPoliciesClusterInterface{clientCache: c.clientCache} -} - -func (c *AdmissionregistrationV1alpha1ClusterClient) ValidatingAdmissionPolicyBindings() ValidatingAdmissionPolicyBindingClusterInterface { - return &validatingAdmissionPolicyBindingsClusterInterface{clientCache: c.clientCache} -} - func (c *AdmissionregistrationV1alpha1ClusterClient) MutatingAdmissionPolicies() MutatingAdmissionPolicyClusterInterface { return &mutatingAdmissionPoliciesClusterInterface{clientCache: c.clientCache} } @@ -67,15 +63,25 @@ func (c *AdmissionregistrationV1alpha1ClusterClient) MutatingAdmissionPolicyBind return &mutatingAdmissionPolicyBindingsClusterInterface{clientCache: c.clientCache} } +func (c *AdmissionregistrationV1alpha1ClusterClient) ValidatingAdmissionPolicies() ValidatingAdmissionPolicyClusterInterface { + return &validatingAdmissionPoliciesClusterInterface{clientCache: c.clientCache} +} + +func (c *AdmissionregistrationV1alpha1ClusterClient) ValidatingAdmissionPolicyBindings() ValidatingAdmissionPolicyBindingClusterInterface { + return &validatingAdmissionPolicyBindingsClusterInterface{clientCache: c.clientCache} +} + // NewForConfig creates a new AdmissionregistrationV1alpha1ClusterClient for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*AdmissionregistrationV1alpha1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new AdmissionregistrationV1alpha1ClusterClient for the given config and http client. @@ -87,6 +93,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*Admissionregistrati if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &AdmissionregistrationV1alpha1ClusterClient{clientCache: cache}, nil } @@ -99,3 +106,14 @@ func NewForConfigOrDie(c *rest.Config) *AdmissionregistrationV1alpha1ClusterClie } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apiadmissionregistrationv1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/admissionregistration/v1alpha1/doc.go b/kubernetes/typed/admissionregistration/v1alpha1/doc.go new file mode 100644 index 000000000..08b80237c --- /dev/null +++ b/kubernetes/typed/admissionregistration/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/kubernetes/typed/admissionregistration/v1alpha1/fake/admissionregistration_client.go b/kubernetes/typed/admissionregistration/v1alpha1/fake/admissionregistration_client.go index 2c9919fe1..c3e70d7bb 100644 --- a/kubernetes/typed/admissionregistration/v1alpha1/fake/admissionregistration_client.go +++ b/kubernetes/typed/admissionregistration/v1alpha1/fake/admissionregistration_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" admissionregistrationv1alpha1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpadmissionregistrationv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/admissionregistration/v1alpha1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -41,46 +41,46 @@ func (c *AdmissionregistrationV1alpha1ClusterClient) Cluster(clusterPath logical return &AdmissionregistrationV1alpha1Client{Fake: c.Fake, ClusterPath: clusterPath} } -func (c *AdmissionregistrationV1alpha1ClusterClient) ValidatingAdmissionPolicies() kcpadmissionregistrationv1alpha1.ValidatingAdmissionPolicyClusterInterface { - return &validatingAdmissionPoliciesClusterClient{Fake: c.Fake} +func (c *AdmissionregistrationV1alpha1ClusterClient) MutatingAdmissionPolicies() kcpadmissionregistrationv1alpha1.MutatingAdmissionPolicyClusterInterface { + return newFakeMutatingAdmissionPolicyClusterClient(c) } -func (c *AdmissionregistrationV1alpha1ClusterClient) ValidatingAdmissionPolicyBindings() kcpadmissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingClusterInterface { - return &validatingAdmissionPolicyBindingsClusterClient{Fake: c.Fake} +func (c *AdmissionregistrationV1alpha1ClusterClient) MutatingAdmissionPolicyBindings() kcpadmissionregistrationv1alpha1.MutatingAdmissionPolicyBindingClusterInterface { + return newFakeMutatingAdmissionPolicyBindingClusterClient(c) } -func (c *AdmissionregistrationV1alpha1ClusterClient) MutatingAdmissionPolicies() kcpadmissionregistrationv1alpha1.MutatingAdmissionPolicyClusterInterface { - return &mutatingAdmissionPoliciesClusterClient{Fake: c.Fake} +func (c *AdmissionregistrationV1alpha1ClusterClient) ValidatingAdmissionPolicies() kcpadmissionregistrationv1alpha1.ValidatingAdmissionPolicyClusterInterface { + return newFakeValidatingAdmissionPolicyClusterClient(c) } -func (c *AdmissionregistrationV1alpha1ClusterClient) MutatingAdmissionPolicyBindings() kcpadmissionregistrationv1alpha1.MutatingAdmissionPolicyBindingClusterInterface { - return &mutatingAdmissionPolicyBindingsClusterClient{Fake: c.Fake} +func (c *AdmissionregistrationV1alpha1ClusterClient) ValidatingAdmissionPolicyBindings() kcpadmissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingClusterInterface { + return newFakeValidatingAdmissionPolicyBindingClusterClient(c) } -var _ admissionregistrationv1alpha1.AdmissionregistrationV1alpha1Interface = (*AdmissionregistrationV1alpha1Client)(nil) - type AdmissionregistrationV1alpha1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *AdmissionregistrationV1alpha1Client) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret +func (c *AdmissionregistrationV1alpha1Client) MutatingAdmissionPolicies() admissionregistrationv1alpha1.MutatingAdmissionPolicyInterface { + return newFakeMutatingAdmissionPolicyClient(c.Fake, c.ClusterPath) } -func (c *AdmissionregistrationV1alpha1Client) ValidatingAdmissionPolicies() admissionregistrationv1alpha1.ValidatingAdmissionPolicyInterface { - return &validatingAdmissionPoliciesClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +func (c *AdmissionregistrationV1alpha1Client) MutatingAdmissionPolicyBindings() admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingInterface { + return newFakeMutatingAdmissionPolicyBindingClient(c.Fake, c.ClusterPath) } -func (c *AdmissionregistrationV1alpha1Client) ValidatingAdmissionPolicyBindings() admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingInterface { - return &validatingAdmissionPolicyBindingsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +func (c *AdmissionregistrationV1alpha1Client) ValidatingAdmissionPolicies() admissionregistrationv1alpha1.ValidatingAdmissionPolicyInterface { + return newFakeValidatingAdmissionPolicyClient(c.Fake, c.ClusterPath) } -func (c *AdmissionregistrationV1alpha1Client) MutatingAdmissionPolicies() admissionregistrationv1alpha1.MutatingAdmissionPolicyInterface { - return &mutatingAdmissionPoliciesClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +func (c *AdmissionregistrationV1alpha1Client) ValidatingAdmissionPolicyBindings() admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingInterface { + return newFakeValidatingAdmissionPolicyBindingClient(c.Fake, c.ClusterPath) } -func (c *AdmissionregistrationV1alpha1Client) MutatingAdmissionPolicyBindings() admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingInterface { - return &mutatingAdmissionPolicyBindingsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *AdmissionregistrationV1alpha1Client) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret } diff --git a/kubernetes/typed/admissionregistration/v1alpha1/fake/doc.go b/kubernetes/typed/admissionregistration/v1alpha1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/admissionregistration/v1alpha1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/admissionregistration/v1alpha1/fake/mutatingadmissionpolicy.go b/kubernetes/typed/admissionregistration/v1alpha1/fake/mutatingadmissionpolicy.go index 97546e9f4..bee49420d 100644 --- a/kubernetes/typed/admissionregistration/v1alpha1/fake/mutatingadmissionpolicy.go +++ b/kubernetes/typed/admissionregistration/v1alpha1/fake/mutatingadmissionpolicy.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,86 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" admissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsadmissionregistrationv1alpha1 "k8s.io/client-go/applyconfigurations/admissionregistration/v1alpha1" - admissionregistrationv1alpha1client "k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1" - "k8s.io/client-go/testing" + v1alpha1 "k8s.io/client-go/applyconfigurations/admissionregistration/v1alpha1" + typedadmissionregistrationv1alpha1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1" + typedkcpadmissionregistrationv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/admissionregistration/v1alpha1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var mutatingAdmissionPoliciesResource = schema.GroupVersionResource{Group: "admissionregistration.k8s.io", Version: "v1alpha1", Resource: "mutatingadmissionpolicies"} -var mutatingAdmissionPoliciesKind = schema.GroupVersionKind{Group: "admissionregistration.k8s.io", Version: "v1alpha1", Kind: "MutatingAdmissionPolicy"} - -type mutatingAdmissionPoliciesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *mutatingAdmissionPoliciesClusterClient) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1alpha1client.MutatingAdmissionPolicyInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &mutatingAdmissionPoliciesClient{Fake: c.Fake, ClusterPath: clusterPath} -} - -// List takes label and field selectors, and returns the list of MutatingAdmissionPolicies that match those selectors across all clusters. -func (c *mutatingAdmissionPoliciesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1alpha1.MutatingAdmissionPolicyList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(mutatingAdmissionPoliciesResource, mutatingAdmissionPoliciesKind, logicalcluster.Wildcard, opts), &admissionregistrationv1alpha1.MutatingAdmissionPolicyList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &admissionregistrationv1alpha1.MutatingAdmissionPolicyList{ListMeta: obj.(*admissionregistrationv1alpha1.MutatingAdmissionPolicyList).ListMeta} - for _, item := range obj.(*admissionregistrationv1alpha1.MutatingAdmissionPolicyList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested MutatingAdmissionPolicies across all clusters. -func (c *mutatingAdmissionPoliciesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(mutatingAdmissionPoliciesResource, logicalcluster.Wildcard, opts)) -} - -type mutatingAdmissionPoliciesClient struct { - *kcptesting.Fake +// mutatingAdmissionPolicyClusterClient implements MutatingAdmissionPolicyClusterInterface +type mutatingAdmissionPolicyClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*admissionregistrationv1alpha1.MutatingAdmissionPolicy, *admissionregistrationv1alpha1.MutatingAdmissionPolicyList] + Fake *kcptesting.Fake +} + +func newFakeMutatingAdmissionPolicyClusterClient(fake *AdmissionregistrationV1alpha1ClusterClient) typedkcpadmissionregistrationv1alpha1.MutatingAdmissionPolicyClusterInterface { + return &mutatingAdmissionPolicyClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*admissionregistrationv1alpha1.MutatingAdmissionPolicy, *admissionregistrationv1alpha1.MutatingAdmissionPolicyList]( + fake.Fake, + admissionregistrationv1alpha1.SchemeGroupVersion.WithResource("mutatingadmissionpolicies"), + admissionregistrationv1alpha1.SchemeGroupVersion.WithKind("MutatingAdmissionPolicy"), + func() *admissionregistrationv1alpha1.MutatingAdmissionPolicy { + return &admissionregistrationv1alpha1.MutatingAdmissionPolicy{} + }, + func() *admissionregistrationv1alpha1.MutatingAdmissionPolicyList { + return &admissionregistrationv1alpha1.MutatingAdmissionPolicyList{} + }, + func(dst, src *admissionregistrationv1alpha1.MutatingAdmissionPolicyList) { dst.ListMeta = src.ListMeta }, + func(list *admissionregistrationv1alpha1.MutatingAdmissionPolicyList) []*admissionregistrationv1alpha1.MutatingAdmissionPolicy { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *admissionregistrationv1alpha1.MutatingAdmissionPolicyList, items []*admissionregistrationv1alpha1.MutatingAdmissionPolicy) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, + } +} + +func (c *mutatingAdmissionPolicyClusterClient) Cluster(cluster logicalcluster.Path) typedadmissionregistrationv1alpha1.MutatingAdmissionPolicyInterface { + return newFakeMutatingAdmissionPolicyClient(c.Fake, cluster) +} + +// mutatingAdmissionPolicyScopedClient implements MutatingAdmissionPolicyInterface +type mutatingAdmissionPolicyScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*admissionregistrationv1alpha1.MutatingAdmissionPolicy, *admissionregistrationv1alpha1.MutatingAdmissionPolicyList, *v1alpha1.MutatingAdmissionPolicyApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *mutatingAdmissionPoliciesClient) Create(ctx context.Context, mutatingAdmissionPolicy *admissionregistrationv1alpha1.MutatingAdmissionPolicy, opts metav1.CreateOptions) (*admissionregistrationv1alpha1.MutatingAdmissionPolicy, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(mutatingAdmissionPoliciesResource, c.ClusterPath, mutatingAdmissionPolicy), &admissionregistrationv1alpha1.MutatingAdmissionPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1alpha1.MutatingAdmissionPolicy), err -} - -func (c *mutatingAdmissionPoliciesClient) Update(ctx context.Context, mutatingAdmissionPolicy *admissionregistrationv1alpha1.MutatingAdmissionPolicy, opts metav1.UpdateOptions) (*admissionregistrationv1alpha1.MutatingAdmissionPolicy, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(mutatingAdmissionPoliciesResource, c.ClusterPath, mutatingAdmissionPolicy), &admissionregistrationv1alpha1.MutatingAdmissionPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1alpha1.MutatingAdmissionPolicy), err -} - -func (c *mutatingAdmissionPoliciesClient) UpdateStatus(ctx context.Context, mutatingAdmissionPolicy *admissionregistrationv1alpha1.MutatingAdmissionPolicy, opts metav1.UpdateOptions) (*admissionregistrationv1alpha1.MutatingAdmissionPolicy, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(mutatingAdmissionPoliciesResource, c.ClusterPath, "status", mutatingAdmissionPolicy), &admissionregistrationv1alpha1.MutatingAdmissionPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1alpha1.MutatingAdmissionPolicy), err -} - -func (c *mutatingAdmissionPoliciesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(mutatingAdmissionPoliciesResource, c.ClusterPath, name, opts), &admissionregistrationv1alpha1.MutatingAdmissionPolicy{}) - return err -} - -func (c *mutatingAdmissionPoliciesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(mutatingAdmissionPoliciesResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &admissionregistrationv1alpha1.MutatingAdmissionPolicyList{}) - return err -} - -func (c *mutatingAdmissionPoliciesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*admissionregistrationv1alpha1.MutatingAdmissionPolicy, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(mutatingAdmissionPoliciesResource, c.ClusterPath, name), &admissionregistrationv1alpha1.MutatingAdmissionPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1alpha1.MutatingAdmissionPolicy), err -} - -// List takes label and field selectors, and returns the list of MutatingAdmissionPolicies that match those selectors. -func (c *mutatingAdmissionPoliciesClient) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1alpha1.MutatingAdmissionPolicyList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(mutatingAdmissionPoliciesResource, mutatingAdmissionPoliciesKind, c.ClusterPath, opts), &admissionregistrationv1alpha1.MutatingAdmissionPolicyList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &admissionregistrationv1alpha1.MutatingAdmissionPolicyList{ListMeta: obj.(*admissionregistrationv1alpha1.MutatingAdmissionPolicyList).ListMeta} - for _, item := range obj.(*admissionregistrationv1alpha1.MutatingAdmissionPolicyList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *mutatingAdmissionPoliciesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(mutatingAdmissionPoliciesResource, c.ClusterPath, opts)) -} - -func (c *mutatingAdmissionPoliciesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*admissionregistrationv1alpha1.MutatingAdmissionPolicy, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(mutatingAdmissionPoliciesResource, c.ClusterPath, name, pt, data, subresources...), &admissionregistrationv1alpha1.MutatingAdmissionPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1alpha1.MutatingAdmissionPolicy), err -} - -func (c *mutatingAdmissionPoliciesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsadmissionregistrationv1alpha1.MutatingAdmissionPolicyApplyConfiguration, opts metav1.ApplyOptions) (*admissionregistrationv1alpha1.MutatingAdmissionPolicy, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(mutatingAdmissionPoliciesResource, c.ClusterPath, *name, types.ApplyPatchType, data), &admissionregistrationv1alpha1.MutatingAdmissionPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1alpha1.MutatingAdmissionPolicy), err -} - -func (c *mutatingAdmissionPoliciesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsadmissionregistrationv1alpha1.MutatingAdmissionPolicyApplyConfiguration, opts metav1.ApplyOptions) (*admissionregistrationv1alpha1.MutatingAdmissionPolicy, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(mutatingAdmissionPoliciesResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &admissionregistrationv1alpha1.MutatingAdmissionPolicy{}) - if obj == nil { - return nil, err +func newFakeMutatingAdmissionPolicyClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedadmissionregistrationv1alpha1.MutatingAdmissionPolicyInterface { + return &mutatingAdmissionPolicyScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*admissionregistrationv1alpha1.MutatingAdmissionPolicy, *admissionregistrationv1alpha1.MutatingAdmissionPolicyList, *v1alpha1.MutatingAdmissionPolicyApplyConfiguration]( + fake, + clusterPath, + "", + admissionregistrationv1alpha1.SchemeGroupVersion.WithResource("mutatingadmissionpolicies"), + admissionregistrationv1alpha1.SchemeGroupVersion.WithKind("MutatingAdmissionPolicy"), + func() *admissionregistrationv1alpha1.MutatingAdmissionPolicy { + return &admissionregistrationv1alpha1.MutatingAdmissionPolicy{} + }, + func() *admissionregistrationv1alpha1.MutatingAdmissionPolicyList { + return &admissionregistrationv1alpha1.MutatingAdmissionPolicyList{} + }, + func(dst, src *admissionregistrationv1alpha1.MutatingAdmissionPolicyList) { dst.ListMeta = src.ListMeta }, + func(list *admissionregistrationv1alpha1.MutatingAdmissionPolicyList) []*admissionregistrationv1alpha1.MutatingAdmissionPolicy { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *admissionregistrationv1alpha1.MutatingAdmissionPolicyList, items []*admissionregistrationv1alpha1.MutatingAdmissionPolicy) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*admissionregistrationv1alpha1.MutatingAdmissionPolicy), err } diff --git a/kubernetes/typed/admissionregistration/v1alpha1/fake/mutatingadmissionpolicybinding.go b/kubernetes/typed/admissionregistration/v1alpha1/fake/mutatingadmissionpolicybinding.go index 06a51b03b..e8dcd9fdc 100644 --- a/kubernetes/typed/admissionregistration/v1alpha1/fake/mutatingadmissionpolicybinding.go +++ b/kubernetes/typed/admissionregistration/v1alpha1/fake/mutatingadmissionpolicybinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,90 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" admissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsadmissionregistrationv1alpha1 "k8s.io/client-go/applyconfigurations/admissionregistration/v1alpha1" - admissionregistrationv1alpha1client "k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1" - "k8s.io/client-go/testing" + v1alpha1 "k8s.io/client-go/applyconfigurations/admissionregistration/v1alpha1" + typedadmissionregistrationv1alpha1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1" + typedkcpadmissionregistrationv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/admissionregistration/v1alpha1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var mutatingAdmissionPolicyBindingsResource = schema.GroupVersionResource{Group: "admissionregistration.k8s.io", Version: "v1alpha1", Resource: "mutatingadmissionpolicybindings"} -var mutatingAdmissionPolicyBindingsKind = schema.GroupVersionKind{Group: "admissionregistration.k8s.io", Version: "v1alpha1", Kind: "MutatingAdmissionPolicyBinding"} - -type mutatingAdmissionPolicyBindingsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *mutatingAdmissionPolicyBindingsClusterClient) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1alpha1client.MutatingAdmissionPolicyBindingInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &mutatingAdmissionPolicyBindingsClient{Fake: c.Fake, ClusterPath: clusterPath} -} - -// List takes label and field selectors, and returns the list of MutatingAdmissionPolicyBindings that match those selectors across all clusters. -func (c *mutatingAdmissionPolicyBindingsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(mutatingAdmissionPolicyBindingsResource, mutatingAdmissionPolicyBindingsKind, logicalcluster.Wildcard, opts), &admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingList{ListMeta: obj.(*admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingList).ListMeta} - for _, item := range obj.(*admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested MutatingAdmissionPolicyBindings across all clusters. -func (c *mutatingAdmissionPolicyBindingsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(mutatingAdmissionPolicyBindingsResource, logicalcluster.Wildcard, opts)) -} - -type mutatingAdmissionPolicyBindingsClient struct { - *kcptesting.Fake +// mutatingAdmissionPolicyBindingClusterClient implements MutatingAdmissionPolicyBindingClusterInterface +type mutatingAdmissionPolicyBindingClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding, *admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingList] + Fake *kcptesting.Fake +} + +func newFakeMutatingAdmissionPolicyBindingClusterClient(fake *AdmissionregistrationV1alpha1ClusterClient) typedkcpadmissionregistrationv1alpha1.MutatingAdmissionPolicyBindingClusterInterface { + return &mutatingAdmissionPolicyBindingClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding, *admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingList]( + fake.Fake, + admissionregistrationv1alpha1.SchemeGroupVersion.WithResource("mutatingadmissionpolicybindings"), + admissionregistrationv1alpha1.SchemeGroupVersion.WithKind("MutatingAdmissionPolicyBinding"), + func() *admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding { + return &admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding{} + }, + func() *admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingList { + return &admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingList{} + }, + func(dst, src *admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingList) { + dst.ListMeta = src.ListMeta + }, + func(list *admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingList) []*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingList, items []*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, + } +} + +func (c *mutatingAdmissionPolicyBindingClusterClient) Cluster(cluster logicalcluster.Path) typedadmissionregistrationv1alpha1.MutatingAdmissionPolicyBindingInterface { + return newFakeMutatingAdmissionPolicyBindingClient(c.Fake, cluster) +} + +// mutatingAdmissionPolicyBindingScopedClient implements MutatingAdmissionPolicyBindingInterface +type mutatingAdmissionPolicyBindingScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding, *admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingList, *v1alpha1.MutatingAdmissionPolicyBindingApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *mutatingAdmissionPolicyBindingsClient) Create(ctx context.Context, mutatingAdmissionPolicyBinding *admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding, opts metav1.CreateOptions) (*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(mutatingAdmissionPolicyBindingsResource, c.ClusterPath, mutatingAdmissionPolicyBinding), &admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding), err -} - -func (c *mutatingAdmissionPolicyBindingsClient) Update(ctx context.Context, mutatingAdmissionPolicyBinding *admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding, opts metav1.UpdateOptions) (*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(mutatingAdmissionPolicyBindingsResource, c.ClusterPath, mutatingAdmissionPolicyBinding), &admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding), err -} - -func (c *mutatingAdmissionPolicyBindingsClient) UpdateStatus(ctx context.Context, mutatingAdmissionPolicyBinding *admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding, opts metav1.UpdateOptions) (*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(mutatingAdmissionPolicyBindingsResource, c.ClusterPath, "status", mutatingAdmissionPolicyBinding), &admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding), err -} - -func (c *mutatingAdmissionPolicyBindingsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(mutatingAdmissionPolicyBindingsResource, c.ClusterPath, name, opts), &admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding{}) - return err -} - -func (c *mutatingAdmissionPolicyBindingsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(mutatingAdmissionPolicyBindingsResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingList{}) - return err -} - -func (c *mutatingAdmissionPolicyBindingsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(mutatingAdmissionPolicyBindingsResource, c.ClusterPath, name), &admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding), err -} - -// List takes label and field selectors, and returns the list of MutatingAdmissionPolicyBindings that match those selectors. -func (c *mutatingAdmissionPolicyBindingsClient) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(mutatingAdmissionPolicyBindingsResource, mutatingAdmissionPolicyBindingsKind, c.ClusterPath, opts), &admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingList{ListMeta: obj.(*admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingList).ListMeta} - for _, item := range obj.(*admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *mutatingAdmissionPolicyBindingsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(mutatingAdmissionPolicyBindingsResource, c.ClusterPath, opts)) -} - -func (c *mutatingAdmissionPolicyBindingsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(mutatingAdmissionPolicyBindingsResource, c.ClusterPath, name, pt, data, subresources...), &admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding), err -} - -func (c *mutatingAdmissionPolicyBindingsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsadmissionregistrationv1alpha1.MutatingAdmissionPolicyBindingApplyConfiguration, opts metav1.ApplyOptions) (*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(mutatingAdmissionPolicyBindingsResource, c.ClusterPath, *name, types.ApplyPatchType, data), &admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding), err -} - -func (c *mutatingAdmissionPolicyBindingsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsadmissionregistrationv1alpha1.MutatingAdmissionPolicyBindingApplyConfiguration, opts metav1.ApplyOptions) (*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(mutatingAdmissionPolicyBindingsResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding{}) - if obj == nil { - return nil, err +func newFakeMutatingAdmissionPolicyBindingClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedadmissionregistrationv1alpha1.MutatingAdmissionPolicyBindingInterface { + return &mutatingAdmissionPolicyBindingScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding, *admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingList, *v1alpha1.MutatingAdmissionPolicyBindingApplyConfiguration]( + fake, + clusterPath, + "", + admissionregistrationv1alpha1.SchemeGroupVersion.WithResource("mutatingadmissionpolicybindings"), + admissionregistrationv1alpha1.SchemeGroupVersion.WithKind("MutatingAdmissionPolicyBinding"), + func() *admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding { + return &admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding{} + }, + func() *admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingList { + return &admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingList{} + }, + func(dst, src *admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingList) { + dst.ListMeta = src.ListMeta + }, + func(list *admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingList) []*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingList, items []*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding), err } diff --git a/kubernetes/typed/admissionregistration/v1alpha1/fake/validatingadmissionpolicy.go b/kubernetes/typed/admissionregistration/v1alpha1/fake/validatingadmissionpolicy.go index 05b45ad11..2d9bac103 100644 --- a/kubernetes/typed/admissionregistration/v1alpha1/fake/validatingadmissionpolicy.go +++ b/kubernetes/typed/admissionregistration/v1alpha1/fake/validatingadmissionpolicy.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,90 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" admissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsadmissionregistrationv1alpha1 "k8s.io/client-go/applyconfigurations/admissionregistration/v1alpha1" - admissionregistrationv1alpha1client "k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1" - "k8s.io/client-go/testing" + v1alpha1 "k8s.io/client-go/applyconfigurations/admissionregistration/v1alpha1" + typedadmissionregistrationv1alpha1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1" + typedkcpadmissionregistrationv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/admissionregistration/v1alpha1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var validatingAdmissionPoliciesResource = schema.GroupVersionResource{Group: "admissionregistration.k8s.io", Version: "v1alpha1", Resource: "validatingadmissionpolicies"} -var validatingAdmissionPoliciesKind = schema.GroupVersionKind{Group: "admissionregistration.k8s.io", Version: "v1alpha1", Kind: "ValidatingAdmissionPolicy"} - -type validatingAdmissionPoliciesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *validatingAdmissionPoliciesClusterClient) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1alpha1client.ValidatingAdmissionPolicyInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &validatingAdmissionPoliciesClient{Fake: c.Fake, ClusterPath: clusterPath} -} - -// List takes label and field selectors, and returns the list of ValidatingAdmissionPolicies that match those selectors across all clusters. -func (c *validatingAdmissionPoliciesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1alpha1.ValidatingAdmissionPolicyList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(validatingAdmissionPoliciesResource, validatingAdmissionPoliciesKind, logicalcluster.Wildcard, opts), &admissionregistrationv1alpha1.ValidatingAdmissionPolicyList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &admissionregistrationv1alpha1.ValidatingAdmissionPolicyList{ListMeta: obj.(*admissionregistrationv1alpha1.ValidatingAdmissionPolicyList).ListMeta} - for _, item := range obj.(*admissionregistrationv1alpha1.ValidatingAdmissionPolicyList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested ValidatingAdmissionPolicies across all clusters. -func (c *validatingAdmissionPoliciesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(validatingAdmissionPoliciesResource, logicalcluster.Wildcard, opts)) -} - -type validatingAdmissionPoliciesClient struct { - *kcptesting.Fake +// validatingAdmissionPolicyClusterClient implements ValidatingAdmissionPolicyClusterInterface +type validatingAdmissionPolicyClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*admissionregistrationv1alpha1.ValidatingAdmissionPolicy, *admissionregistrationv1alpha1.ValidatingAdmissionPolicyList] + Fake *kcptesting.Fake +} + +func newFakeValidatingAdmissionPolicyClusterClient(fake *AdmissionregistrationV1alpha1ClusterClient) typedkcpadmissionregistrationv1alpha1.ValidatingAdmissionPolicyClusterInterface { + return &validatingAdmissionPolicyClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*admissionregistrationv1alpha1.ValidatingAdmissionPolicy, *admissionregistrationv1alpha1.ValidatingAdmissionPolicyList]( + fake.Fake, + admissionregistrationv1alpha1.SchemeGroupVersion.WithResource("validatingadmissionpolicies"), + admissionregistrationv1alpha1.SchemeGroupVersion.WithKind("ValidatingAdmissionPolicy"), + func() *admissionregistrationv1alpha1.ValidatingAdmissionPolicy { + return &admissionregistrationv1alpha1.ValidatingAdmissionPolicy{} + }, + func() *admissionregistrationv1alpha1.ValidatingAdmissionPolicyList { + return &admissionregistrationv1alpha1.ValidatingAdmissionPolicyList{} + }, + func(dst, src *admissionregistrationv1alpha1.ValidatingAdmissionPolicyList) { + dst.ListMeta = src.ListMeta + }, + func(list *admissionregistrationv1alpha1.ValidatingAdmissionPolicyList) []*admissionregistrationv1alpha1.ValidatingAdmissionPolicy { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *admissionregistrationv1alpha1.ValidatingAdmissionPolicyList, items []*admissionregistrationv1alpha1.ValidatingAdmissionPolicy) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, + } +} + +func (c *validatingAdmissionPolicyClusterClient) Cluster(cluster logicalcluster.Path) typedadmissionregistrationv1alpha1.ValidatingAdmissionPolicyInterface { + return newFakeValidatingAdmissionPolicyClient(c.Fake, cluster) +} + +// validatingAdmissionPolicyScopedClient implements ValidatingAdmissionPolicyInterface +type validatingAdmissionPolicyScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*admissionregistrationv1alpha1.ValidatingAdmissionPolicy, *admissionregistrationv1alpha1.ValidatingAdmissionPolicyList, *v1alpha1.ValidatingAdmissionPolicyApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *validatingAdmissionPoliciesClient) Create(ctx context.Context, validatingAdmissionPolicy *admissionregistrationv1alpha1.ValidatingAdmissionPolicy, opts metav1.CreateOptions) (*admissionregistrationv1alpha1.ValidatingAdmissionPolicy, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(validatingAdmissionPoliciesResource, c.ClusterPath, validatingAdmissionPolicy), &admissionregistrationv1alpha1.ValidatingAdmissionPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1alpha1.ValidatingAdmissionPolicy), err -} - -func (c *validatingAdmissionPoliciesClient) Update(ctx context.Context, validatingAdmissionPolicy *admissionregistrationv1alpha1.ValidatingAdmissionPolicy, opts metav1.UpdateOptions) (*admissionregistrationv1alpha1.ValidatingAdmissionPolicy, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(validatingAdmissionPoliciesResource, c.ClusterPath, validatingAdmissionPolicy), &admissionregistrationv1alpha1.ValidatingAdmissionPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1alpha1.ValidatingAdmissionPolicy), err -} - -func (c *validatingAdmissionPoliciesClient) UpdateStatus(ctx context.Context, validatingAdmissionPolicy *admissionregistrationv1alpha1.ValidatingAdmissionPolicy, opts metav1.UpdateOptions) (*admissionregistrationv1alpha1.ValidatingAdmissionPolicy, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(validatingAdmissionPoliciesResource, c.ClusterPath, "status", validatingAdmissionPolicy), &admissionregistrationv1alpha1.ValidatingAdmissionPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1alpha1.ValidatingAdmissionPolicy), err -} - -func (c *validatingAdmissionPoliciesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(validatingAdmissionPoliciesResource, c.ClusterPath, name, opts), &admissionregistrationv1alpha1.ValidatingAdmissionPolicy{}) - return err -} - -func (c *validatingAdmissionPoliciesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(validatingAdmissionPoliciesResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &admissionregistrationv1alpha1.ValidatingAdmissionPolicyList{}) - return err -} - -func (c *validatingAdmissionPoliciesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*admissionregistrationv1alpha1.ValidatingAdmissionPolicy, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(validatingAdmissionPoliciesResource, c.ClusterPath, name), &admissionregistrationv1alpha1.ValidatingAdmissionPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1alpha1.ValidatingAdmissionPolicy), err -} - -// List takes label and field selectors, and returns the list of ValidatingAdmissionPolicies that match those selectors. -func (c *validatingAdmissionPoliciesClient) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1alpha1.ValidatingAdmissionPolicyList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(validatingAdmissionPoliciesResource, validatingAdmissionPoliciesKind, c.ClusterPath, opts), &admissionregistrationv1alpha1.ValidatingAdmissionPolicyList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &admissionregistrationv1alpha1.ValidatingAdmissionPolicyList{ListMeta: obj.(*admissionregistrationv1alpha1.ValidatingAdmissionPolicyList).ListMeta} - for _, item := range obj.(*admissionregistrationv1alpha1.ValidatingAdmissionPolicyList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *validatingAdmissionPoliciesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(validatingAdmissionPoliciesResource, c.ClusterPath, opts)) -} - -func (c *validatingAdmissionPoliciesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*admissionregistrationv1alpha1.ValidatingAdmissionPolicy, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(validatingAdmissionPoliciesResource, c.ClusterPath, name, pt, data, subresources...), &admissionregistrationv1alpha1.ValidatingAdmissionPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1alpha1.ValidatingAdmissionPolicy), err -} - -func (c *validatingAdmissionPoliciesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsadmissionregistrationv1alpha1.ValidatingAdmissionPolicyApplyConfiguration, opts metav1.ApplyOptions) (*admissionregistrationv1alpha1.ValidatingAdmissionPolicy, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(validatingAdmissionPoliciesResource, c.ClusterPath, *name, types.ApplyPatchType, data), &admissionregistrationv1alpha1.ValidatingAdmissionPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1alpha1.ValidatingAdmissionPolicy), err -} - -func (c *validatingAdmissionPoliciesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsadmissionregistrationv1alpha1.ValidatingAdmissionPolicyApplyConfiguration, opts metav1.ApplyOptions) (*admissionregistrationv1alpha1.ValidatingAdmissionPolicy, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(validatingAdmissionPoliciesResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &admissionregistrationv1alpha1.ValidatingAdmissionPolicy{}) - if obj == nil { - return nil, err +func newFakeValidatingAdmissionPolicyClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedadmissionregistrationv1alpha1.ValidatingAdmissionPolicyInterface { + return &validatingAdmissionPolicyScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*admissionregistrationv1alpha1.ValidatingAdmissionPolicy, *admissionregistrationv1alpha1.ValidatingAdmissionPolicyList, *v1alpha1.ValidatingAdmissionPolicyApplyConfiguration]( + fake, + clusterPath, + "", + admissionregistrationv1alpha1.SchemeGroupVersion.WithResource("validatingadmissionpolicies"), + admissionregistrationv1alpha1.SchemeGroupVersion.WithKind("ValidatingAdmissionPolicy"), + func() *admissionregistrationv1alpha1.ValidatingAdmissionPolicy { + return &admissionregistrationv1alpha1.ValidatingAdmissionPolicy{} + }, + func() *admissionregistrationv1alpha1.ValidatingAdmissionPolicyList { + return &admissionregistrationv1alpha1.ValidatingAdmissionPolicyList{} + }, + func(dst, src *admissionregistrationv1alpha1.ValidatingAdmissionPolicyList) { + dst.ListMeta = src.ListMeta + }, + func(list *admissionregistrationv1alpha1.ValidatingAdmissionPolicyList) []*admissionregistrationv1alpha1.ValidatingAdmissionPolicy { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *admissionregistrationv1alpha1.ValidatingAdmissionPolicyList, items []*admissionregistrationv1alpha1.ValidatingAdmissionPolicy) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*admissionregistrationv1alpha1.ValidatingAdmissionPolicy), err } diff --git a/kubernetes/typed/admissionregistration/v1alpha1/fake/validatingadmissionpolicybinding.go b/kubernetes/typed/admissionregistration/v1alpha1/fake/validatingadmissionpolicybinding.go index 2689dff30..2e2ff3fb7 100644 --- a/kubernetes/typed/admissionregistration/v1alpha1/fake/validatingadmissionpolicybinding.go +++ b/kubernetes/typed/admissionregistration/v1alpha1/fake/validatingadmissionpolicybinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,90 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" admissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsadmissionregistrationv1alpha1 "k8s.io/client-go/applyconfigurations/admissionregistration/v1alpha1" - admissionregistrationv1alpha1client "k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1" - "k8s.io/client-go/testing" + v1alpha1 "k8s.io/client-go/applyconfigurations/admissionregistration/v1alpha1" + typedadmissionregistrationv1alpha1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1" + typedkcpadmissionregistrationv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/admissionregistration/v1alpha1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var validatingAdmissionPolicyBindingsResource = schema.GroupVersionResource{Group: "admissionregistration.k8s.io", Version: "v1alpha1", Resource: "validatingadmissionpolicybindings"} -var validatingAdmissionPolicyBindingsKind = schema.GroupVersionKind{Group: "admissionregistration.k8s.io", Version: "v1alpha1", Kind: "ValidatingAdmissionPolicyBinding"} - -type validatingAdmissionPolicyBindingsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *validatingAdmissionPolicyBindingsClusterClient) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1alpha1client.ValidatingAdmissionPolicyBindingInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &validatingAdmissionPolicyBindingsClient{Fake: c.Fake, ClusterPath: clusterPath} -} - -// List takes label and field selectors, and returns the list of ValidatingAdmissionPolicyBindings that match those selectors across all clusters. -func (c *validatingAdmissionPolicyBindingsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(validatingAdmissionPolicyBindingsResource, validatingAdmissionPolicyBindingsKind, logicalcluster.Wildcard, opts), &admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingList{ListMeta: obj.(*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingList).ListMeta} - for _, item := range obj.(*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested ValidatingAdmissionPolicyBindings across all clusters. -func (c *validatingAdmissionPolicyBindingsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(validatingAdmissionPolicyBindingsResource, logicalcluster.Wildcard, opts)) -} - -type validatingAdmissionPolicyBindingsClient struct { - *kcptesting.Fake +// validatingAdmissionPolicyBindingClusterClient implements ValidatingAdmissionPolicyBindingClusterInterface +type validatingAdmissionPolicyBindingClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding, *admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingList] + Fake *kcptesting.Fake +} + +func newFakeValidatingAdmissionPolicyBindingClusterClient(fake *AdmissionregistrationV1alpha1ClusterClient) typedkcpadmissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingClusterInterface { + return &validatingAdmissionPolicyBindingClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding, *admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingList]( + fake.Fake, + admissionregistrationv1alpha1.SchemeGroupVersion.WithResource("validatingadmissionpolicybindings"), + admissionregistrationv1alpha1.SchemeGroupVersion.WithKind("ValidatingAdmissionPolicyBinding"), + func() *admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding { + return &admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding{} + }, + func() *admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingList { + return &admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingList{} + }, + func(dst, src *admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingList) { + dst.ListMeta = src.ListMeta + }, + func(list *admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingList) []*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingList, items []*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, + } +} + +func (c *validatingAdmissionPolicyBindingClusterClient) Cluster(cluster logicalcluster.Path) typedadmissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingInterface { + return newFakeValidatingAdmissionPolicyBindingClient(c.Fake, cluster) +} + +// validatingAdmissionPolicyBindingScopedClient implements ValidatingAdmissionPolicyBindingInterface +type validatingAdmissionPolicyBindingScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding, *admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingList, *v1alpha1.ValidatingAdmissionPolicyBindingApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *validatingAdmissionPolicyBindingsClient) Create(ctx context.Context, validatingAdmissionPolicyBinding *admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding, opts metav1.CreateOptions) (*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(validatingAdmissionPolicyBindingsResource, c.ClusterPath, validatingAdmissionPolicyBinding), &admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding), err -} - -func (c *validatingAdmissionPolicyBindingsClient) Update(ctx context.Context, validatingAdmissionPolicyBinding *admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding, opts metav1.UpdateOptions) (*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(validatingAdmissionPolicyBindingsResource, c.ClusterPath, validatingAdmissionPolicyBinding), &admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding), err -} - -func (c *validatingAdmissionPolicyBindingsClient) UpdateStatus(ctx context.Context, validatingAdmissionPolicyBinding *admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding, opts metav1.UpdateOptions) (*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(validatingAdmissionPolicyBindingsResource, c.ClusterPath, "status", validatingAdmissionPolicyBinding), &admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding), err -} - -func (c *validatingAdmissionPolicyBindingsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(validatingAdmissionPolicyBindingsResource, c.ClusterPath, name, opts), &admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding{}) - return err -} - -func (c *validatingAdmissionPolicyBindingsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(validatingAdmissionPolicyBindingsResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingList{}) - return err -} - -func (c *validatingAdmissionPolicyBindingsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(validatingAdmissionPolicyBindingsResource, c.ClusterPath, name), &admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding), err -} - -// List takes label and field selectors, and returns the list of ValidatingAdmissionPolicyBindings that match those selectors. -func (c *validatingAdmissionPolicyBindingsClient) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(validatingAdmissionPolicyBindingsResource, validatingAdmissionPolicyBindingsKind, c.ClusterPath, opts), &admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingList{ListMeta: obj.(*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingList).ListMeta} - for _, item := range obj.(*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *validatingAdmissionPolicyBindingsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(validatingAdmissionPolicyBindingsResource, c.ClusterPath, opts)) -} - -func (c *validatingAdmissionPolicyBindingsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(validatingAdmissionPolicyBindingsResource, c.ClusterPath, name, pt, data, subresources...), &admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding), err -} - -func (c *validatingAdmissionPolicyBindingsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsadmissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingApplyConfiguration, opts metav1.ApplyOptions) (*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(validatingAdmissionPolicyBindingsResource, c.ClusterPath, *name, types.ApplyPatchType, data), &admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding), err -} - -func (c *validatingAdmissionPolicyBindingsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsadmissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingApplyConfiguration, opts metav1.ApplyOptions) (*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(validatingAdmissionPolicyBindingsResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding{}) - if obj == nil { - return nil, err +func newFakeValidatingAdmissionPolicyBindingClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedadmissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingInterface { + return &validatingAdmissionPolicyBindingScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding, *admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingList, *v1alpha1.ValidatingAdmissionPolicyBindingApplyConfiguration]( + fake, + clusterPath, + "", + admissionregistrationv1alpha1.SchemeGroupVersion.WithResource("validatingadmissionpolicybindings"), + admissionregistrationv1alpha1.SchemeGroupVersion.WithKind("ValidatingAdmissionPolicyBinding"), + func() *admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding { + return &admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding{} + }, + func() *admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingList { + return &admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingList{} + }, + func(dst, src *admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingList) { + dst.ListMeta = src.ListMeta + }, + func(list *admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingList) []*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingList, items []*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding), err } diff --git a/kubernetes/typed/admissionregistration/v1alpha1/generated_expansion.go b/kubernetes/typed/admissionregistration/v1alpha1/generated_expansion.go new file mode 100644 index 000000000..4bab38212 --- /dev/null +++ b/kubernetes/typed/admissionregistration/v1alpha1/generated_expansion.go @@ -0,0 +1,27 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1alpha1 + +type MutatingAdmissionPolicyClusterExpansion interface{} + +type MutatingAdmissionPolicyBindingClusterExpansion interface{} + +type ValidatingAdmissionPolicyClusterExpansion interface{} + +type ValidatingAdmissionPolicyBindingClusterExpansion interface{} diff --git a/kubernetes/typed/admissionregistration/v1alpha1/mutatingadmissionpolicy.go b/kubernetes/typed/admissionregistration/v1alpha1/mutatingadmissionpolicy.go index e1a3144c4..4128254d5 100644 --- a/kubernetes/typed/admissionregistration/v1alpha1/mutatingadmissionpolicy.go +++ b/kubernetes/typed/admissionregistration/v1alpha1/mutatingadmissionpolicy.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - admissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - admissionregistrationv1alpha1client "k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1" + apiadmissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + admissionregistrationv1alpha1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1" ) // MutatingAdmissionPoliciesClusterGetter has a method to return a MutatingAdmissionPolicyClusterInterface. @@ -37,19 +37,20 @@ type MutatingAdmissionPoliciesClusterGetter interface { } // MutatingAdmissionPolicyClusterInterface can operate on MutatingAdmissionPolicies across all clusters, -// or scope down to one cluster and return a admissionregistrationv1alpha1client.MutatingAdmissionPolicyInterface. +// or scope down to one cluster and return a admissionregistrationv1alpha1.MutatingAdmissionPolicyInterface. type MutatingAdmissionPolicyClusterInterface interface { - Cluster(logicalcluster.Path) admissionregistrationv1alpha1client.MutatingAdmissionPolicyInterface - List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1alpha1.MutatingAdmissionPolicyList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) admissionregistrationv1alpha1.MutatingAdmissionPolicyInterface + List(ctx context.Context, opts v1.ListOptions) (*apiadmissionregistrationv1alpha1.MutatingAdmissionPolicyList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + MutatingAdmissionPolicyClusterExpansion } type mutatingAdmissionPoliciesClusterInterface struct { - clientCache kcpclient.Cache[*admissionregistrationv1alpha1client.AdmissionregistrationV1alpha1Client] + clientCache kcpclient.Cache[*admissionregistrationv1alpha1.AdmissionregistrationV1alpha1Client] } // Cluster scopes the client down to a particular cluster. -func (c *mutatingAdmissionPoliciesClusterInterface) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1alpha1client.MutatingAdmissionPolicyInterface { +func (c *mutatingAdmissionPoliciesClusterInterface) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1alpha1.MutatingAdmissionPolicyInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *mutatingAdmissionPoliciesClusterInterface) Cluster(clusterPath logicalc } // List returns the entire collection of all MutatingAdmissionPolicies across all clusters. -func (c *mutatingAdmissionPoliciesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1alpha1.MutatingAdmissionPolicyList, error) { +func (c *mutatingAdmissionPoliciesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apiadmissionregistrationv1alpha1.MutatingAdmissionPolicyList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).MutatingAdmissionPolicies().List(ctx, opts) } // Watch begins to watch all MutatingAdmissionPolicies across all clusters. -func (c *mutatingAdmissionPoliciesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *mutatingAdmissionPoliciesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).MutatingAdmissionPolicies().Watch(ctx, opts) } diff --git a/kubernetes/typed/admissionregistration/v1alpha1/mutatingadmissionpolicybinding.go b/kubernetes/typed/admissionregistration/v1alpha1/mutatingadmissionpolicybinding.go index 407551647..4eb45f3ea 100644 --- a/kubernetes/typed/admissionregistration/v1alpha1/mutatingadmissionpolicybinding.go +++ b/kubernetes/typed/admissionregistration/v1alpha1/mutatingadmissionpolicybinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - admissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - admissionregistrationv1alpha1client "k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1" + apiadmissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + admissionregistrationv1alpha1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1" ) // MutatingAdmissionPolicyBindingsClusterGetter has a method to return a MutatingAdmissionPolicyBindingClusterInterface. @@ -37,19 +37,20 @@ type MutatingAdmissionPolicyBindingsClusterGetter interface { } // MutatingAdmissionPolicyBindingClusterInterface can operate on MutatingAdmissionPolicyBindings across all clusters, -// or scope down to one cluster and return a admissionregistrationv1alpha1client.MutatingAdmissionPolicyBindingInterface. +// or scope down to one cluster and return a admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingInterface. type MutatingAdmissionPolicyBindingClusterInterface interface { - Cluster(logicalcluster.Path) admissionregistrationv1alpha1client.MutatingAdmissionPolicyBindingInterface - List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingInterface + List(ctx context.Context, opts v1.ListOptions) (*apiadmissionregistrationv1alpha1.MutatingAdmissionPolicyBindingList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + MutatingAdmissionPolicyBindingClusterExpansion } type mutatingAdmissionPolicyBindingsClusterInterface struct { - clientCache kcpclient.Cache[*admissionregistrationv1alpha1client.AdmissionregistrationV1alpha1Client] + clientCache kcpclient.Cache[*admissionregistrationv1alpha1.AdmissionregistrationV1alpha1Client] } // Cluster scopes the client down to a particular cluster. -func (c *mutatingAdmissionPolicyBindingsClusterInterface) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1alpha1client.MutatingAdmissionPolicyBindingInterface { +func (c *mutatingAdmissionPolicyBindingsClusterInterface) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *mutatingAdmissionPolicyBindingsClusterInterface) Cluster(clusterPath lo } // List returns the entire collection of all MutatingAdmissionPolicyBindings across all clusters. -func (c *mutatingAdmissionPolicyBindingsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1alpha1.MutatingAdmissionPolicyBindingList, error) { +func (c *mutatingAdmissionPolicyBindingsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apiadmissionregistrationv1alpha1.MutatingAdmissionPolicyBindingList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).MutatingAdmissionPolicyBindings().List(ctx, opts) } // Watch begins to watch all MutatingAdmissionPolicyBindings across all clusters. -func (c *mutatingAdmissionPolicyBindingsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *mutatingAdmissionPolicyBindingsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).MutatingAdmissionPolicyBindings().Watch(ctx, opts) } diff --git a/kubernetes/typed/admissionregistration/v1alpha1/validatingadmissionpolicy.go b/kubernetes/typed/admissionregistration/v1alpha1/validatingadmissionpolicy.go index 5fbd7cd3c..1d71dee8c 100644 --- a/kubernetes/typed/admissionregistration/v1alpha1/validatingadmissionpolicy.go +++ b/kubernetes/typed/admissionregistration/v1alpha1/validatingadmissionpolicy.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - admissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - admissionregistrationv1alpha1client "k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1" + apiadmissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + admissionregistrationv1alpha1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1" ) // ValidatingAdmissionPoliciesClusterGetter has a method to return a ValidatingAdmissionPolicyClusterInterface. @@ -37,19 +37,20 @@ type ValidatingAdmissionPoliciesClusterGetter interface { } // ValidatingAdmissionPolicyClusterInterface can operate on ValidatingAdmissionPolicies across all clusters, -// or scope down to one cluster and return a admissionregistrationv1alpha1client.ValidatingAdmissionPolicyInterface. +// or scope down to one cluster and return a admissionregistrationv1alpha1.ValidatingAdmissionPolicyInterface. type ValidatingAdmissionPolicyClusterInterface interface { - Cluster(logicalcluster.Path) admissionregistrationv1alpha1client.ValidatingAdmissionPolicyInterface - List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1alpha1.ValidatingAdmissionPolicyList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) admissionregistrationv1alpha1.ValidatingAdmissionPolicyInterface + List(ctx context.Context, opts v1.ListOptions) (*apiadmissionregistrationv1alpha1.ValidatingAdmissionPolicyList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + ValidatingAdmissionPolicyClusterExpansion } type validatingAdmissionPoliciesClusterInterface struct { - clientCache kcpclient.Cache[*admissionregistrationv1alpha1client.AdmissionregistrationV1alpha1Client] + clientCache kcpclient.Cache[*admissionregistrationv1alpha1.AdmissionregistrationV1alpha1Client] } // Cluster scopes the client down to a particular cluster. -func (c *validatingAdmissionPoliciesClusterInterface) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1alpha1client.ValidatingAdmissionPolicyInterface { +func (c *validatingAdmissionPoliciesClusterInterface) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1alpha1.ValidatingAdmissionPolicyInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *validatingAdmissionPoliciesClusterInterface) Cluster(clusterPath logica } // List returns the entire collection of all ValidatingAdmissionPolicies across all clusters. -func (c *validatingAdmissionPoliciesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1alpha1.ValidatingAdmissionPolicyList, error) { +func (c *validatingAdmissionPoliciesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apiadmissionregistrationv1alpha1.ValidatingAdmissionPolicyList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ValidatingAdmissionPolicies().List(ctx, opts) } // Watch begins to watch all ValidatingAdmissionPolicies across all clusters. -func (c *validatingAdmissionPoliciesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *validatingAdmissionPoliciesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ValidatingAdmissionPolicies().Watch(ctx, opts) } diff --git a/kubernetes/typed/admissionregistration/v1alpha1/validatingadmissionpolicybinding.go b/kubernetes/typed/admissionregistration/v1alpha1/validatingadmissionpolicybinding.go index 567165ce5..d316cd5e7 100644 --- a/kubernetes/typed/admissionregistration/v1alpha1/validatingadmissionpolicybinding.go +++ b/kubernetes/typed/admissionregistration/v1alpha1/validatingadmissionpolicybinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - admissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - admissionregistrationv1alpha1client "k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1" + apiadmissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + admissionregistrationv1alpha1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1" ) // ValidatingAdmissionPolicyBindingsClusterGetter has a method to return a ValidatingAdmissionPolicyBindingClusterInterface. @@ -37,19 +37,20 @@ type ValidatingAdmissionPolicyBindingsClusterGetter interface { } // ValidatingAdmissionPolicyBindingClusterInterface can operate on ValidatingAdmissionPolicyBindings across all clusters, -// or scope down to one cluster and return a admissionregistrationv1alpha1client.ValidatingAdmissionPolicyBindingInterface. +// or scope down to one cluster and return a admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingInterface. type ValidatingAdmissionPolicyBindingClusterInterface interface { - Cluster(logicalcluster.Path) admissionregistrationv1alpha1client.ValidatingAdmissionPolicyBindingInterface - List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingInterface + List(ctx context.Context, opts v1.ListOptions) (*apiadmissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + ValidatingAdmissionPolicyBindingClusterExpansion } type validatingAdmissionPolicyBindingsClusterInterface struct { - clientCache kcpclient.Cache[*admissionregistrationv1alpha1client.AdmissionregistrationV1alpha1Client] + clientCache kcpclient.Cache[*admissionregistrationv1alpha1.AdmissionregistrationV1alpha1Client] } // Cluster scopes the client down to a particular cluster. -func (c *validatingAdmissionPolicyBindingsClusterInterface) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1alpha1client.ValidatingAdmissionPolicyBindingInterface { +func (c *validatingAdmissionPolicyBindingsClusterInterface) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *validatingAdmissionPolicyBindingsClusterInterface) Cluster(clusterPath } // List returns the entire collection of all ValidatingAdmissionPolicyBindings across all clusters. -func (c *validatingAdmissionPolicyBindingsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingList, error) { +func (c *validatingAdmissionPolicyBindingsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apiadmissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ValidatingAdmissionPolicyBindings().List(ctx, opts) } // Watch begins to watch all ValidatingAdmissionPolicyBindings across all clusters. -func (c *validatingAdmissionPolicyBindingsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *validatingAdmissionPolicyBindingsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ValidatingAdmissionPolicyBindings().Watch(ctx, opts) } diff --git a/kubernetes/typed/admissionregistration/v1beta1/admissionregistration_client.go b/kubernetes/typed/admissionregistration/v1beta1/admissionregistration_client.go index 43e67380c..93c86c402 100644 --- a/kubernetes/typed/admissionregistration/v1beta1/admissionregistration_client.go +++ b/kubernetes/typed/admissionregistration/v1beta1/admissionregistration_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,32 +14,36 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apiadmissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" admissionregistrationv1beta1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type AdmissionregistrationV1beta1ClusterInterface interface { AdmissionregistrationV1beta1ClusterScoper + MutatingWebhookConfigurationsClusterGetter ValidatingAdmissionPoliciesClusterGetter ValidatingAdmissionPolicyBindingsClusterGetter ValidatingWebhookConfigurationsClusterGetter - MutatingWebhookConfigurationsClusterGetter } type AdmissionregistrationV1beta1ClusterScoper interface { Cluster(logicalcluster.Path) admissionregistrationv1beta1.AdmissionregistrationV1beta1Interface } +// AdmissionregistrationV1beta1ClusterClient is used to interact with features provided by the admissionregistration.k8s.io group. type AdmissionregistrationV1beta1ClusterClient struct { clientCache kcpclient.Cache[*admissionregistrationv1beta1.AdmissionregistrationV1beta1Client] } @@ -51,6 +55,10 @@ func (c *AdmissionregistrationV1beta1ClusterClient) Cluster(clusterPath logicalc return c.clientCache.ClusterOrDie(clusterPath) } +func (c *AdmissionregistrationV1beta1ClusterClient) MutatingWebhookConfigurations() MutatingWebhookConfigurationClusterInterface { + return &mutatingWebhookConfigurationsClusterInterface{clientCache: c.clientCache} +} + func (c *AdmissionregistrationV1beta1ClusterClient) ValidatingAdmissionPolicies() ValidatingAdmissionPolicyClusterInterface { return &validatingAdmissionPoliciesClusterInterface{clientCache: c.clientCache} } @@ -63,19 +71,17 @@ func (c *AdmissionregistrationV1beta1ClusterClient) ValidatingWebhookConfigurati return &validatingWebhookConfigurationsClusterInterface{clientCache: c.clientCache} } -func (c *AdmissionregistrationV1beta1ClusterClient) MutatingWebhookConfigurations() MutatingWebhookConfigurationClusterInterface { - return &mutatingWebhookConfigurationsClusterInterface{clientCache: c.clientCache} -} - // NewForConfig creates a new AdmissionregistrationV1beta1ClusterClient for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*AdmissionregistrationV1beta1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new AdmissionregistrationV1beta1ClusterClient for the given config and http client. @@ -87,6 +93,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*Admissionregistrati if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &AdmissionregistrationV1beta1ClusterClient{clientCache: cache}, nil } @@ -99,3 +106,14 @@ func NewForConfigOrDie(c *rest.Config) *AdmissionregistrationV1beta1ClusterClien } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apiadmissionregistrationv1beta1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/admissionregistration/v1beta1/doc.go b/kubernetes/typed/admissionregistration/v1beta1/doc.go new file mode 100644 index 000000000..541e9d258 --- /dev/null +++ b/kubernetes/typed/admissionregistration/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1beta1 diff --git a/kubernetes/typed/admissionregistration/v1beta1/fake/admissionregistration_client.go b/kubernetes/typed/admissionregistration/v1beta1/fake/admissionregistration_client.go index 6357d65ac..4da8aa8e0 100644 --- a/kubernetes/typed/admissionregistration/v1beta1/fake/admissionregistration_client.go +++ b/kubernetes/typed/admissionregistration/v1beta1/fake/admissionregistration_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" admissionregistrationv1beta1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpadmissionregistrationv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/admissionregistration/v1beta1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -41,46 +41,46 @@ func (c *AdmissionregistrationV1beta1ClusterClient) Cluster(clusterPath logicalc return &AdmissionregistrationV1beta1Client{Fake: c.Fake, ClusterPath: clusterPath} } +func (c *AdmissionregistrationV1beta1ClusterClient) MutatingWebhookConfigurations() kcpadmissionregistrationv1beta1.MutatingWebhookConfigurationClusterInterface { + return newFakeMutatingWebhookConfigurationClusterClient(c) +} + func (c *AdmissionregistrationV1beta1ClusterClient) ValidatingAdmissionPolicies() kcpadmissionregistrationv1beta1.ValidatingAdmissionPolicyClusterInterface { - return &validatingAdmissionPoliciesClusterClient{Fake: c.Fake} + return newFakeValidatingAdmissionPolicyClusterClient(c) } func (c *AdmissionregistrationV1beta1ClusterClient) ValidatingAdmissionPolicyBindings() kcpadmissionregistrationv1beta1.ValidatingAdmissionPolicyBindingClusterInterface { - return &validatingAdmissionPolicyBindingsClusterClient{Fake: c.Fake} + return newFakeValidatingAdmissionPolicyBindingClusterClient(c) } func (c *AdmissionregistrationV1beta1ClusterClient) ValidatingWebhookConfigurations() kcpadmissionregistrationv1beta1.ValidatingWebhookConfigurationClusterInterface { - return &validatingWebhookConfigurationsClusterClient{Fake: c.Fake} -} - -func (c *AdmissionregistrationV1beta1ClusterClient) MutatingWebhookConfigurations() kcpadmissionregistrationv1beta1.MutatingWebhookConfigurationClusterInterface { - return &mutatingWebhookConfigurationsClusterClient{Fake: c.Fake} + return newFakeValidatingWebhookConfigurationClusterClient(c) } -var _ admissionregistrationv1beta1.AdmissionregistrationV1beta1Interface = (*AdmissionregistrationV1beta1Client)(nil) - type AdmissionregistrationV1beta1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *AdmissionregistrationV1beta1Client) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret +func (c *AdmissionregistrationV1beta1Client) MutatingWebhookConfigurations() admissionregistrationv1beta1.MutatingWebhookConfigurationInterface { + return newFakeMutatingWebhookConfigurationClient(c.Fake, c.ClusterPath) } func (c *AdmissionregistrationV1beta1Client) ValidatingAdmissionPolicies() admissionregistrationv1beta1.ValidatingAdmissionPolicyInterface { - return &validatingAdmissionPoliciesClient{Fake: c.Fake, ClusterPath: c.ClusterPath} + return newFakeValidatingAdmissionPolicyClient(c.Fake, c.ClusterPath) } func (c *AdmissionregistrationV1beta1Client) ValidatingAdmissionPolicyBindings() admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingInterface { - return &validatingAdmissionPolicyBindingsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} + return newFakeValidatingAdmissionPolicyBindingClient(c.Fake, c.ClusterPath) } func (c *AdmissionregistrationV1beta1Client) ValidatingWebhookConfigurations() admissionregistrationv1beta1.ValidatingWebhookConfigurationInterface { - return &validatingWebhookConfigurationsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} + return newFakeValidatingWebhookConfigurationClient(c.Fake, c.ClusterPath) } -func (c *AdmissionregistrationV1beta1Client) MutatingWebhookConfigurations() admissionregistrationv1beta1.MutatingWebhookConfigurationInterface { - return &mutatingWebhookConfigurationsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *AdmissionregistrationV1beta1Client) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret } diff --git a/kubernetes/typed/admissionregistration/v1beta1/fake/doc.go b/kubernetes/typed/admissionregistration/v1beta1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/admissionregistration/v1beta1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/admissionregistration/v1beta1/fake/mutatingwebhookconfiguration.go b/kubernetes/typed/admissionregistration/v1beta1/fake/mutatingwebhookconfiguration.go index 1fc431776..82d9c5f09 100644 --- a/kubernetes/typed/admissionregistration/v1beta1/fake/mutatingwebhookconfiguration.go +++ b/kubernetes/typed/admissionregistration/v1beta1/fake/mutatingwebhookconfiguration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,90 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsadmissionregistrationv1beta1 "k8s.io/client-go/applyconfigurations/admissionregistration/v1beta1" - admissionregistrationv1beta1client "k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/admissionregistration/v1beta1" + typedadmissionregistrationv1beta1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1" + typedkcpadmissionregistrationv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/admissionregistration/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var mutatingWebhookConfigurationsResource = schema.GroupVersionResource{Group: "admissionregistration.k8s.io", Version: "v1beta1", Resource: "mutatingwebhookconfigurations"} -var mutatingWebhookConfigurationsKind = schema.GroupVersionKind{Group: "admissionregistration.k8s.io", Version: "v1beta1", Kind: "MutatingWebhookConfiguration"} - -type mutatingWebhookConfigurationsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *mutatingWebhookConfigurationsClusterClient) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1beta1client.MutatingWebhookConfigurationInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &mutatingWebhookConfigurationsClient{Fake: c.Fake, ClusterPath: clusterPath} -} - -// List takes label and field selectors, and returns the list of MutatingWebhookConfigurations that match those selectors across all clusters. -func (c *mutatingWebhookConfigurationsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1beta1.MutatingWebhookConfigurationList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(mutatingWebhookConfigurationsResource, mutatingWebhookConfigurationsKind, logicalcluster.Wildcard, opts), &admissionregistrationv1beta1.MutatingWebhookConfigurationList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &admissionregistrationv1beta1.MutatingWebhookConfigurationList{ListMeta: obj.(*admissionregistrationv1beta1.MutatingWebhookConfigurationList).ListMeta} - for _, item := range obj.(*admissionregistrationv1beta1.MutatingWebhookConfigurationList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested MutatingWebhookConfigurations across all clusters. -func (c *mutatingWebhookConfigurationsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(mutatingWebhookConfigurationsResource, logicalcluster.Wildcard, opts)) -} - -type mutatingWebhookConfigurationsClient struct { - *kcptesting.Fake +// mutatingWebhookConfigurationClusterClient implements MutatingWebhookConfigurationClusterInterface +type mutatingWebhookConfigurationClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*admissionregistrationv1beta1.MutatingWebhookConfiguration, *admissionregistrationv1beta1.MutatingWebhookConfigurationList] + Fake *kcptesting.Fake +} + +func newFakeMutatingWebhookConfigurationClusterClient(fake *AdmissionregistrationV1beta1ClusterClient) typedkcpadmissionregistrationv1beta1.MutatingWebhookConfigurationClusterInterface { + return &mutatingWebhookConfigurationClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*admissionregistrationv1beta1.MutatingWebhookConfiguration, *admissionregistrationv1beta1.MutatingWebhookConfigurationList]( + fake.Fake, + admissionregistrationv1beta1.SchemeGroupVersion.WithResource("mutatingwebhookconfigurations"), + admissionregistrationv1beta1.SchemeGroupVersion.WithKind("MutatingWebhookConfiguration"), + func() *admissionregistrationv1beta1.MutatingWebhookConfiguration { + return &admissionregistrationv1beta1.MutatingWebhookConfiguration{} + }, + func() *admissionregistrationv1beta1.MutatingWebhookConfigurationList { + return &admissionregistrationv1beta1.MutatingWebhookConfigurationList{} + }, + func(dst, src *admissionregistrationv1beta1.MutatingWebhookConfigurationList) { + dst.ListMeta = src.ListMeta + }, + func(list *admissionregistrationv1beta1.MutatingWebhookConfigurationList) []*admissionregistrationv1beta1.MutatingWebhookConfiguration { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *admissionregistrationv1beta1.MutatingWebhookConfigurationList, items []*admissionregistrationv1beta1.MutatingWebhookConfiguration) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, + } +} + +func (c *mutatingWebhookConfigurationClusterClient) Cluster(cluster logicalcluster.Path) typedadmissionregistrationv1beta1.MutatingWebhookConfigurationInterface { + return newFakeMutatingWebhookConfigurationClient(c.Fake, cluster) +} + +// mutatingWebhookConfigurationScopedClient implements MutatingWebhookConfigurationInterface +type mutatingWebhookConfigurationScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*admissionregistrationv1beta1.MutatingWebhookConfiguration, *admissionregistrationv1beta1.MutatingWebhookConfigurationList, *v1beta1.MutatingWebhookConfigurationApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *mutatingWebhookConfigurationsClient) Create(ctx context.Context, mutatingWebhookConfiguration *admissionregistrationv1beta1.MutatingWebhookConfiguration, opts metav1.CreateOptions) (*admissionregistrationv1beta1.MutatingWebhookConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(mutatingWebhookConfigurationsResource, c.ClusterPath, mutatingWebhookConfiguration), &admissionregistrationv1beta1.MutatingWebhookConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1beta1.MutatingWebhookConfiguration), err -} - -func (c *mutatingWebhookConfigurationsClient) Update(ctx context.Context, mutatingWebhookConfiguration *admissionregistrationv1beta1.MutatingWebhookConfiguration, opts metav1.UpdateOptions) (*admissionregistrationv1beta1.MutatingWebhookConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(mutatingWebhookConfigurationsResource, c.ClusterPath, mutatingWebhookConfiguration), &admissionregistrationv1beta1.MutatingWebhookConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1beta1.MutatingWebhookConfiguration), err -} - -func (c *mutatingWebhookConfigurationsClient) UpdateStatus(ctx context.Context, mutatingWebhookConfiguration *admissionregistrationv1beta1.MutatingWebhookConfiguration, opts metav1.UpdateOptions) (*admissionregistrationv1beta1.MutatingWebhookConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(mutatingWebhookConfigurationsResource, c.ClusterPath, "status", mutatingWebhookConfiguration), &admissionregistrationv1beta1.MutatingWebhookConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1beta1.MutatingWebhookConfiguration), err -} - -func (c *mutatingWebhookConfigurationsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(mutatingWebhookConfigurationsResource, c.ClusterPath, name, opts), &admissionregistrationv1beta1.MutatingWebhookConfiguration{}) - return err -} - -func (c *mutatingWebhookConfigurationsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(mutatingWebhookConfigurationsResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &admissionregistrationv1beta1.MutatingWebhookConfigurationList{}) - return err -} - -func (c *mutatingWebhookConfigurationsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*admissionregistrationv1beta1.MutatingWebhookConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(mutatingWebhookConfigurationsResource, c.ClusterPath, name), &admissionregistrationv1beta1.MutatingWebhookConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1beta1.MutatingWebhookConfiguration), err -} - -// List takes label and field selectors, and returns the list of MutatingWebhookConfigurations that match those selectors. -func (c *mutatingWebhookConfigurationsClient) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1beta1.MutatingWebhookConfigurationList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(mutatingWebhookConfigurationsResource, mutatingWebhookConfigurationsKind, c.ClusterPath, opts), &admissionregistrationv1beta1.MutatingWebhookConfigurationList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &admissionregistrationv1beta1.MutatingWebhookConfigurationList{ListMeta: obj.(*admissionregistrationv1beta1.MutatingWebhookConfigurationList).ListMeta} - for _, item := range obj.(*admissionregistrationv1beta1.MutatingWebhookConfigurationList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *mutatingWebhookConfigurationsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(mutatingWebhookConfigurationsResource, c.ClusterPath, opts)) -} - -func (c *mutatingWebhookConfigurationsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*admissionregistrationv1beta1.MutatingWebhookConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(mutatingWebhookConfigurationsResource, c.ClusterPath, name, pt, data, subresources...), &admissionregistrationv1beta1.MutatingWebhookConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1beta1.MutatingWebhookConfiguration), err -} - -func (c *mutatingWebhookConfigurationsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsadmissionregistrationv1beta1.MutatingWebhookConfigurationApplyConfiguration, opts metav1.ApplyOptions) (*admissionregistrationv1beta1.MutatingWebhookConfiguration, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(mutatingWebhookConfigurationsResource, c.ClusterPath, *name, types.ApplyPatchType, data), &admissionregistrationv1beta1.MutatingWebhookConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1beta1.MutatingWebhookConfiguration), err -} - -func (c *mutatingWebhookConfigurationsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsadmissionregistrationv1beta1.MutatingWebhookConfigurationApplyConfiguration, opts metav1.ApplyOptions) (*admissionregistrationv1beta1.MutatingWebhookConfiguration, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(mutatingWebhookConfigurationsResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &admissionregistrationv1beta1.MutatingWebhookConfiguration{}) - if obj == nil { - return nil, err +func newFakeMutatingWebhookConfigurationClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedadmissionregistrationv1beta1.MutatingWebhookConfigurationInterface { + return &mutatingWebhookConfigurationScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*admissionregistrationv1beta1.MutatingWebhookConfiguration, *admissionregistrationv1beta1.MutatingWebhookConfigurationList, *v1beta1.MutatingWebhookConfigurationApplyConfiguration]( + fake, + clusterPath, + "", + admissionregistrationv1beta1.SchemeGroupVersion.WithResource("mutatingwebhookconfigurations"), + admissionregistrationv1beta1.SchemeGroupVersion.WithKind("MutatingWebhookConfiguration"), + func() *admissionregistrationv1beta1.MutatingWebhookConfiguration { + return &admissionregistrationv1beta1.MutatingWebhookConfiguration{} + }, + func() *admissionregistrationv1beta1.MutatingWebhookConfigurationList { + return &admissionregistrationv1beta1.MutatingWebhookConfigurationList{} + }, + func(dst, src *admissionregistrationv1beta1.MutatingWebhookConfigurationList) { + dst.ListMeta = src.ListMeta + }, + func(list *admissionregistrationv1beta1.MutatingWebhookConfigurationList) []*admissionregistrationv1beta1.MutatingWebhookConfiguration { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *admissionregistrationv1beta1.MutatingWebhookConfigurationList, items []*admissionregistrationv1beta1.MutatingWebhookConfiguration) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*admissionregistrationv1beta1.MutatingWebhookConfiguration), err } diff --git a/kubernetes/typed/admissionregistration/v1beta1/fake/validatingadmissionpolicy.go b/kubernetes/typed/admissionregistration/v1beta1/fake/validatingadmissionpolicy.go index bfdbaf5d7..9ae6caf72 100644 --- a/kubernetes/typed/admissionregistration/v1beta1/fake/validatingadmissionpolicy.go +++ b/kubernetes/typed/admissionregistration/v1beta1/fake/validatingadmissionpolicy.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,90 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsadmissionregistrationv1beta1 "k8s.io/client-go/applyconfigurations/admissionregistration/v1beta1" - admissionregistrationv1beta1client "k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/admissionregistration/v1beta1" + typedadmissionregistrationv1beta1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1" + typedkcpadmissionregistrationv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/admissionregistration/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var validatingAdmissionPoliciesResource = schema.GroupVersionResource{Group: "admissionregistration.k8s.io", Version: "v1beta1", Resource: "validatingadmissionpolicies"} -var validatingAdmissionPoliciesKind = schema.GroupVersionKind{Group: "admissionregistration.k8s.io", Version: "v1beta1", Kind: "ValidatingAdmissionPolicy"} - -type validatingAdmissionPoliciesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *validatingAdmissionPoliciesClusterClient) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1beta1client.ValidatingAdmissionPolicyInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &validatingAdmissionPoliciesClient{Fake: c.Fake, ClusterPath: clusterPath} -} - -// List takes label and field selectors, and returns the list of ValidatingAdmissionPolicies that match those selectors across all clusters. -func (c *validatingAdmissionPoliciesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1beta1.ValidatingAdmissionPolicyList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(validatingAdmissionPoliciesResource, validatingAdmissionPoliciesKind, logicalcluster.Wildcard, opts), &admissionregistrationv1beta1.ValidatingAdmissionPolicyList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &admissionregistrationv1beta1.ValidatingAdmissionPolicyList{ListMeta: obj.(*admissionregistrationv1beta1.ValidatingAdmissionPolicyList).ListMeta} - for _, item := range obj.(*admissionregistrationv1beta1.ValidatingAdmissionPolicyList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested ValidatingAdmissionPolicies across all clusters. -func (c *validatingAdmissionPoliciesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(validatingAdmissionPoliciesResource, logicalcluster.Wildcard, opts)) -} - -type validatingAdmissionPoliciesClient struct { - *kcptesting.Fake +// validatingAdmissionPolicyClusterClient implements ValidatingAdmissionPolicyClusterInterface +type validatingAdmissionPolicyClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*admissionregistrationv1beta1.ValidatingAdmissionPolicy, *admissionregistrationv1beta1.ValidatingAdmissionPolicyList] + Fake *kcptesting.Fake +} + +func newFakeValidatingAdmissionPolicyClusterClient(fake *AdmissionregistrationV1beta1ClusterClient) typedkcpadmissionregistrationv1beta1.ValidatingAdmissionPolicyClusterInterface { + return &validatingAdmissionPolicyClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*admissionregistrationv1beta1.ValidatingAdmissionPolicy, *admissionregistrationv1beta1.ValidatingAdmissionPolicyList]( + fake.Fake, + admissionregistrationv1beta1.SchemeGroupVersion.WithResource("validatingadmissionpolicies"), + admissionregistrationv1beta1.SchemeGroupVersion.WithKind("ValidatingAdmissionPolicy"), + func() *admissionregistrationv1beta1.ValidatingAdmissionPolicy { + return &admissionregistrationv1beta1.ValidatingAdmissionPolicy{} + }, + func() *admissionregistrationv1beta1.ValidatingAdmissionPolicyList { + return &admissionregistrationv1beta1.ValidatingAdmissionPolicyList{} + }, + func(dst, src *admissionregistrationv1beta1.ValidatingAdmissionPolicyList) { + dst.ListMeta = src.ListMeta + }, + func(list *admissionregistrationv1beta1.ValidatingAdmissionPolicyList) []*admissionregistrationv1beta1.ValidatingAdmissionPolicy { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *admissionregistrationv1beta1.ValidatingAdmissionPolicyList, items []*admissionregistrationv1beta1.ValidatingAdmissionPolicy) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, + } +} + +func (c *validatingAdmissionPolicyClusterClient) Cluster(cluster logicalcluster.Path) typedadmissionregistrationv1beta1.ValidatingAdmissionPolicyInterface { + return newFakeValidatingAdmissionPolicyClient(c.Fake, cluster) +} + +// validatingAdmissionPolicyScopedClient implements ValidatingAdmissionPolicyInterface +type validatingAdmissionPolicyScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*admissionregistrationv1beta1.ValidatingAdmissionPolicy, *admissionregistrationv1beta1.ValidatingAdmissionPolicyList, *v1beta1.ValidatingAdmissionPolicyApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *validatingAdmissionPoliciesClient) Create(ctx context.Context, validatingAdmissionPolicy *admissionregistrationv1beta1.ValidatingAdmissionPolicy, opts metav1.CreateOptions) (*admissionregistrationv1beta1.ValidatingAdmissionPolicy, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(validatingAdmissionPoliciesResource, c.ClusterPath, validatingAdmissionPolicy), &admissionregistrationv1beta1.ValidatingAdmissionPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1beta1.ValidatingAdmissionPolicy), err -} - -func (c *validatingAdmissionPoliciesClient) Update(ctx context.Context, validatingAdmissionPolicy *admissionregistrationv1beta1.ValidatingAdmissionPolicy, opts metav1.UpdateOptions) (*admissionregistrationv1beta1.ValidatingAdmissionPolicy, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(validatingAdmissionPoliciesResource, c.ClusterPath, validatingAdmissionPolicy), &admissionregistrationv1beta1.ValidatingAdmissionPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1beta1.ValidatingAdmissionPolicy), err -} - -func (c *validatingAdmissionPoliciesClient) UpdateStatus(ctx context.Context, validatingAdmissionPolicy *admissionregistrationv1beta1.ValidatingAdmissionPolicy, opts metav1.UpdateOptions) (*admissionregistrationv1beta1.ValidatingAdmissionPolicy, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(validatingAdmissionPoliciesResource, c.ClusterPath, "status", validatingAdmissionPolicy), &admissionregistrationv1beta1.ValidatingAdmissionPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1beta1.ValidatingAdmissionPolicy), err -} - -func (c *validatingAdmissionPoliciesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(validatingAdmissionPoliciesResource, c.ClusterPath, name, opts), &admissionregistrationv1beta1.ValidatingAdmissionPolicy{}) - return err -} - -func (c *validatingAdmissionPoliciesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(validatingAdmissionPoliciesResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &admissionregistrationv1beta1.ValidatingAdmissionPolicyList{}) - return err -} - -func (c *validatingAdmissionPoliciesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*admissionregistrationv1beta1.ValidatingAdmissionPolicy, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(validatingAdmissionPoliciesResource, c.ClusterPath, name), &admissionregistrationv1beta1.ValidatingAdmissionPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1beta1.ValidatingAdmissionPolicy), err -} - -// List takes label and field selectors, and returns the list of ValidatingAdmissionPolicies that match those selectors. -func (c *validatingAdmissionPoliciesClient) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1beta1.ValidatingAdmissionPolicyList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(validatingAdmissionPoliciesResource, validatingAdmissionPoliciesKind, c.ClusterPath, opts), &admissionregistrationv1beta1.ValidatingAdmissionPolicyList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &admissionregistrationv1beta1.ValidatingAdmissionPolicyList{ListMeta: obj.(*admissionregistrationv1beta1.ValidatingAdmissionPolicyList).ListMeta} - for _, item := range obj.(*admissionregistrationv1beta1.ValidatingAdmissionPolicyList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *validatingAdmissionPoliciesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(validatingAdmissionPoliciesResource, c.ClusterPath, opts)) -} - -func (c *validatingAdmissionPoliciesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*admissionregistrationv1beta1.ValidatingAdmissionPolicy, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(validatingAdmissionPoliciesResource, c.ClusterPath, name, pt, data, subresources...), &admissionregistrationv1beta1.ValidatingAdmissionPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1beta1.ValidatingAdmissionPolicy), err -} - -func (c *validatingAdmissionPoliciesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsadmissionregistrationv1beta1.ValidatingAdmissionPolicyApplyConfiguration, opts metav1.ApplyOptions) (*admissionregistrationv1beta1.ValidatingAdmissionPolicy, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(validatingAdmissionPoliciesResource, c.ClusterPath, *name, types.ApplyPatchType, data), &admissionregistrationv1beta1.ValidatingAdmissionPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1beta1.ValidatingAdmissionPolicy), err -} - -func (c *validatingAdmissionPoliciesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsadmissionregistrationv1beta1.ValidatingAdmissionPolicyApplyConfiguration, opts metav1.ApplyOptions) (*admissionregistrationv1beta1.ValidatingAdmissionPolicy, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(validatingAdmissionPoliciesResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &admissionregistrationv1beta1.ValidatingAdmissionPolicy{}) - if obj == nil { - return nil, err +func newFakeValidatingAdmissionPolicyClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedadmissionregistrationv1beta1.ValidatingAdmissionPolicyInterface { + return &validatingAdmissionPolicyScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*admissionregistrationv1beta1.ValidatingAdmissionPolicy, *admissionregistrationv1beta1.ValidatingAdmissionPolicyList, *v1beta1.ValidatingAdmissionPolicyApplyConfiguration]( + fake, + clusterPath, + "", + admissionregistrationv1beta1.SchemeGroupVersion.WithResource("validatingadmissionpolicies"), + admissionregistrationv1beta1.SchemeGroupVersion.WithKind("ValidatingAdmissionPolicy"), + func() *admissionregistrationv1beta1.ValidatingAdmissionPolicy { + return &admissionregistrationv1beta1.ValidatingAdmissionPolicy{} + }, + func() *admissionregistrationv1beta1.ValidatingAdmissionPolicyList { + return &admissionregistrationv1beta1.ValidatingAdmissionPolicyList{} + }, + func(dst, src *admissionregistrationv1beta1.ValidatingAdmissionPolicyList) { + dst.ListMeta = src.ListMeta + }, + func(list *admissionregistrationv1beta1.ValidatingAdmissionPolicyList) []*admissionregistrationv1beta1.ValidatingAdmissionPolicy { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *admissionregistrationv1beta1.ValidatingAdmissionPolicyList, items []*admissionregistrationv1beta1.ValidatingAdmissionPolicy) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*admissionregistrationv1beta1.ValidatingAdmissionPolicy), err } diff --git a/kubernetes/typed/admissionregistration/v1beta1/fake/validatingadmissionpolicybinding.go b/kubernetes/typed/admissionregistration/v1beta1/fake/validatingadmissionpolicybinding.go index 58361f393..879b281c0 100644 --- a/kubernetes/typed/admissionregistration/v1beta1/fake/validatingadmissionpolicybinding.go +++ b/kubernetes/typed/admissionregistration/v1beta1/fake/validatingadmissionpolicybinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,90 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsadmissionregistrationv1beta1 "k8s.io/client-go/applyconfigurations/admissionregistration/v1beta1" - admissionregistrationv1beta1client "k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/admissionregistration/v1beta1" + typedadmissionregistrationv1beta1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1" + typedkcpadmissionregistrationv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/admissionregistration/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var validatingAdmissionPolicyBindingsResource = schema.GroupVersionResource{Group: "admissionregistration.k8s.io", Version: "v1beta1", Resource: "validatingadmissionpolicybindings"} -var validatingAdmissionPolicyBindingsKind = schema.GroupVersionKind{Group: "admissionregistration.k8s.io", Version: "v1beta1", Kind: "ValidatingAdmissionPolicyBinding"} - -type validatingAdmissionPolicyBindingsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *validatingAdmissionPolicyBindingsClusterClient) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1beta1client.ValidatingAdmissionPolicyBindingInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &validatingAdmissionPolicyBindingsClient{Fake: c.Fake, ClusterPath: clusterPath} -} - -// List takes label and field selectors, and returns the list of ValidatingAdmissionPolicyBindings that match those selectors across all clusters. -func (c *validatingAdmissionPolicyBindingsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(validatingAdmissionPolicyBindingsResource, validatingAdmissionPolicyBindingsKind, logicalcluster.Wildcard, opts), &admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingList{ListMeta: obj.(*admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingList).ListMeta} - for _, item := range obj.(*admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested ValidatingAdmissionPolicyBindings across all clusters. -func (c *validatingAdmissionPolicyBindingsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(validatingAdmissionPolicyBindingsResource, logicalcluster.Wildcard, opts)) -} - -type validatingAdmissionPolicyBindingsClient struct { - *kcptesting.Fake +// validatingAdmissionPolicyBindingClusterClient implements ValidatingAdmissionPolicyBindingClusterInterface +type validatingAdmissionPolicyBindingClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding, *admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingList] + Fake *kcptesting.Fake +} + +func newFakeValidatingAdmissionPolicyBindingClusterClient(fake *AdmissionregistrationV1beta1ClusterClient) typedkcpadmissionregistrationv1beta1.ValidatingAdmissionPolicyBindingClusterInterface { + return &validatingAdmissionPolicyBindingClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding, *admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingList]( + fake.Fake, + admissionregistrationv1beta1.SchemeGroupVersion.WithResource("validatingadmissionpolicybindings"), + admissionregistrationv1beta1.SchemeGroupVersion.WithKind("ValidatingAdmissionPolicyBinding"), + func() *admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding { + return &admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding{} + }, + func() *admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingList { + return &admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingList{} + }, + func(dst, src *admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingList) { + dst.ListMeta = src.ListMeta + }, + func(list *admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingList) []*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingList, items []*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, + } +} + +func (c *validatingAdmissionPolicyBindingClusterClient) Cluster(cluster logicalcluster.Path) typedadmissionregistrationv1beta1.ValidatingAdmissionPolicyBindingInterface { + return newFakeValidatingAdmissionPolicyBindingClient(c.Fake, cluster) +} + +// validatingAdmissionPolicyBindingScopedClient implements ValidatingAdmissionPolicyBindingInterface +type validatingAdmissionPolicyBindingScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding, *admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingList, *v1beta1.ValidatingAdmissionPolicyBindingApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *validatingAdmissionPolicyBindingsClient) Create(ctx context.Context, validatingAdmissionPolicyBinding *admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding, opts metav1.CreateOptions) (*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(validatingAdmissionPolicyBindingsResource, c.ClusterPath, validatingAdmissionPolicyBinding), &admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding), err -} - -func (c *validatingAdmissionPolicyBindingsClient) Update(ctx context.Context, validatingAdmissionPolicyBinding *admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding, opts metav1.UpdateOptions) (*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(validatingAdmissionPolicyBindingsResource, c.ClusterPath, validatingAdmissionPolicyBinding), &admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding), err -} - -func (c *validatingAdmissionPolicyBindingsClient) UpdateStatus(ctx context.Context, validatingAdmissionPolicyBinding *admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding, opts metav1.UpdateOptions) (*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(validatingAdmissionPolicyBindingsResource, c.ClusterPath, "status", validatingAdmissionPolicyBinding), &admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding), err -} - -func (c *validatingAdmissionPolicyBindingsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(validatingAdmissionPolicyBindingsResource, c.ClusterPath, name, opts), &admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding{}) - return err -} - -func (c *validatingAdmissionPolicyBindingsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(validatingAdmissionPolicyBindingsResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingList{}) - return err -} - -func (c *validatingAdmissionPolicyBindingsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(validatingAdmissionPolicyBindingsResource, c.ClusterPath, name), &admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding), err -} - -// List takes label and field selectors, and returns the list of ValidatingAdmissionPolicyBindings that match those selectors. -func (c *validatingAdmissionPolicyBindingsClient) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(validatingAdmissionPolicyBindingsResource, validatingAdmissionPolicyBindingsKind, c.ClusterPath, opts), &admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingList{ListMeta: obj.(*admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingList).ListMeta} - for _, item := range obj.(*admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *validatingAdmissionPolicyBindingsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(validatingAdmissionPolicyBindingsResource, c.ClusterPath, opts)) -} - -func (c *validatingAdmissionPolicyBindingsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(validatingAdmissionPolicyBindingsResource, c.ClusterPath, name, pt, data, subresources...), &admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding), err -} - -func (c *validatingAdmissionPolicyBindingsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsadmissionregistrationv1beta1.ValidatingAdmissionPolicyBindingApplyConfiguration, opts metav1.ApplyOptions) (*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(validatingAdmissionPolicyBindingsResource, c.ClusterPath, *name, types.ApplyPatchType, data), &admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding), err -} - -func (c *validatingAdmissionPolicyBindingsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsadmissionregistrationv1beta1.ValidatingAdmissionPolicyBindingApplyConfiguration, opts metav1.ApplyOptions) (*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(validatingAdmissionPolicyBindingsResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding{}) - if obj == nil { - return nil, err +func newFakeValidatingAdmissionPolicyBindingClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedadmissionregistrationv1beta1.ValidatingAdmissionPolicyBindingInterface { + return &validatingAdmissionPolicyBindingScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding, *admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingList, *v1beta1.ValidatingAdmissionPolicyBindingApplyConfiguration]( + fake, + clusterPath, + "", + admissionregistrationv1beta1.SchemeGroupVersion.WithResource("validatingadmissionpolicybindings"), + admissionregistrationv1beta1.SchemeGroupVersion.WithKind("ValidatingAdmissionPolicyBinding"), + func() *admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding { + return &admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding{} + }, + func() *admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingList { + return &admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingList{} + }, + func(dst, src *admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingList) { + dst.ListMeta = src.ListMeta + }, + func(list *admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingList) []*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingList, items []*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding), err } diff --git a/kubernetes/typed/admissionregistration/v1beta1/fake/validatingwebhookconfiguration.go b/kubernetes/typed/admissionregistration/v1beta1/fake/validatingwebhookconfiguration.go index d00a07878..ed1f8ffa6 100644 --- a/kubernetes/typed/admissionregistration/v1beta1/fake/validatingwebhookconfiguration.go +++ b/kubernetes/typed/admissionregistration/v1beta1/fake/validatingwebhookconfiguration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,90 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsadmissionregistrationv1beta1 "k8s.io/client-go/applyconfigurations/admissionregistration/v1beta1" - admissionregistrationv1beta1client "k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/admissionregistration/v1beta1" + typedadmissionregistrationv1beta1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1" + typedkcpadmissionregistrationv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/admissionregistration/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var validatingWebhookConfigurationsResource = schema.GroupVersionResource{Group: "admissionregistration.k8s.io", Version: "v1beta1", Resource: "validatingwebhookconfigurations"} -var validatingWebhookConfigurationsKind = schema.GroupVersionKind{Group: "admissionregistration.k8s.io", Version: "v1beta1", Kind: "ValidatingWebhookConfiguration"} - -type validatingWebhookConfigurationsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *validatingWebhookConfigurationsClusterClient) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1beta1client.ValidatingWebhookConfigurationInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &validatingWebhookConfigurationsClient{Fake: c.Fake, ClusterPath: clusterPath} -} - -// List takes label and field selectors, and returns the list of ValidatingWebhookConfigurations that match those selectors across all clusters. -func (c *validatingWebhookConfigurationsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1beta1.ValidatingWebhookConfigurationList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(validatingWebhookConfigurationsResource, validatingWebhookConfigurationsKind, logicalcluster.Wildcard, opts), &admissionregistrationv1beta1.ValidatingWebhookConfigurationList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &admissionregistrationv1beta1.ValidatingWebhookConfigurationList{ListMeta: obj.(*admissionregistrationv1beta1.ValidatingWebhookConfigurationList).ListMeta} - for _, item := range obj.(*admissionregistrationv1beta1.ValidatingWebhookConfigurationList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested ValidatingWebhookConfigurations across all clusters. -func (c *validatingWebhookConfigurationsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(validatingWebhookConfigurationsResource, logicalcluster.Wildcard, opts)) -} - -type validatingWebhookConfigurationsClient struct { - *kcptesting.Fake +// validatingWebhookConfigurationClusterClient implements ValidatingWebhookConfigurationClusterInterface +type validatingWebhookConfigurationClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*admissionregistrationv1beta1.ValidatingWebhookConfiguration, *admissionregistrationv1beta1.ValidatingWebhookConfigurationList] + Fake *kcptesting.Fake +} + +func newFakeValidatingWebhookConfigurationClusterClient(fake *AdmissionregistrationV1beta1ClusterClient) typedkcpadmissionregistrationv1beta1.ValidatingWebhookConfigurationClusterInterface { + return &validatingWebhookConfigurationClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*admissionregistrationv1beta1.ValidatingWebhookConfiguration, *admissionregistrationv1beta1.ValidatingWebhookConfigurationList]( + fake.Fake, + admissionregistrationv1beta1.SchemeGroupVersion.WithResource("validatingwebhookconfigurations"), + admissionregistrationv1beta1.SchemeGroupVersion.WithKind("ValidatingWebhookConfiguration"), + func() *admissionregistrationv1beta1.ValidatingWebhookConfiguration { + return &admissionregistrationv1beta1.ValidatingWebhookConfiguration{} + }, + func() *admissionregistrationv1beta1.ValidatingWebhookConfigurationList { + return &admissionregistrationv1beta1.ValidatingWebhookConfigurationList{} + }, + func(dst, src *admissionregistrationv1beta1.ValidatingWebhookConfigurationList) { + dst.ListMeta = src.ListMeta + }, + func(list *admissionregistrationv1beta1.ValidatingWebhookConfigurationList) []*admissionregistrationv1beta1.ValidatingWebhookConfiguration { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *admissionregistrationv1beta1.ValidatingWebhookConfigurationList, items []*admissionregistrationv1beta1.ValidatingWebhookConfiguration) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, + } +} + +func (c *validatingWebhookConfigurationClusterClient) Cluster(cluster logicalcluster.Path) typedadmissionregistrationv1beta1.ValidatingWebhookConfigurationInterface { + return newFakeValidatingWebhookConfigurationClient(c.Fake, cluster) +} + +// validatingWebhookConfigurationScopedClient implements ValidatingWebhookConfigurationInterface +type validatingWebhookConfigurationScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*admissionregistrationv1beta1.ValidatingWebhookConfiguration, *admissionregistrationv1beta1.ValidatingWebhookConfigurationList, *v1beta1.ValidatingWebhookConfigurationApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *validatingWebhookConfigurationsClient) Create(ctx context.Context, validatingWebhookConfiguration *admissionregistrationv1beta1.ValidatingWebhookConfiguration, opts metav1.CreateOptions) (*admissionregistrationv1beta1.ValidatingWebhookConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(validatingWebhookConfigurationsResource, c.ClusterPath, validatingWebhookConfiguration), &admissionregistrationv1beta1.ValidatingWebhookConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1beta1.ValidatingWebhookConfiguration), err -} - -func (c *validatingWebhookConfigurationsClient) Update(ctx context.Context, validatingWebhookConfiguration *admissionregistrationv1beta1.ValidatingWebhookConfiguration, opts metav1.UpdateOptions) (*admissionregistrationv1beta1.ValidatingWebhookConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(validatingWebhookConfigurationsResource, c.ClusterPath, validatingWebhookConfiguration), &admissionregistrationv1beta1.ValidatingWebhookConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1beta1.ValidatingWebhookConfiguration), err -} - -func (c *validatingWebhookConfigurationsClient) UpdateStatus(ctx context.Context, validatingWebhookConfiguration *admissionregistrationv1beta1.ValidatingWebhookConfiguration, opts metav1.UpdateOptions) (*admissionregistrationv1beta1.ValidatingWebhookConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(validatingWebhookConfigurationsResource, c.ClusterPath, "status", validatingWebhookConfiguration), &admissionregistrationv1beta1.ValidatingWebhookConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1beta1.ValidatingWebhookConfiguration), err -} - -func (c *validatingWebhookConfigurationsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(validatingWebhookConfigurationsResource, c.ClusterPath, name, opts), &admissionregistrationv1beta1.ValidatingWebhookConfiguration{}) - return err -} - -func (c *validatingWebhookConfigurationsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(validatingWebhookConfigurationsResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &admissionregistrationv1beta1.ValidatingWebhookConfigurationList{}) - return err -} - -func (c *validatingWebhookConfigurationsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*admissionregistrationv1beta1.ValidatingWebhookConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(validatingWebhookConfigurationsResource, c.ClusterPath, name), &admissionregistrationv1beta1.ValidatingWebhookConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1beta1.ValidatingWebhookConfiguration), err -} - -// List takes label and field selectors, and returns the list of ValidatingWebhookConfigurations that match those selectors. -func (c *validatingWebhookConfigurationsClient) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1beta1.ValidatingWebhookConfigurationList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(validatingWebhookConfigurationsResource, validatingWebhookConfigurationsKind, c.ClusterPath, opts), &admissionregistrationv1beta1.ValidatingWebhookConfigurationList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &admissionregistrationv1beta1.ValidatingWebhookConfigurationList{ListMeta: obj.(*admissionregistrationv1beta1.ValidatingWebhookConfigurationList).ListMeta} - for _, item := range obj.(*admissionregistrationv1beta1.ValidatingWebhookConfigurationList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *validatingWebhookConfigurationsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(validatingWebhookConfigurationsResource, c.ClusterPath, opts)) -} - -func (c *validatingWebhookConfigurationsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*admissionregistrationv1beta1.ValidatingWebhookConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(validatingWebhookConfigurationsResource, c.ClusterPath, name, pt, data, subresources...), &admissionregistrationv1beta1.ValidatingWebhookConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1beta1.ValidatingWebhookConfiguration), err -} - -func (c *validatingWebhookConfigurationsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsadmissionregistrationv1beta1.ValidatingWebhookConfigurationApplyConfiguration, opts metav1.ApplyOptions) (*admissionregistrationv1beta1.ValidatingWebhookConfiguration, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(validatingWebhookConfigurationsResource, c.ClusterPath, *name, types.ApplyPatchType, data), &admissionregistrationv1beta1.ValidatingWebhookConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*admissionregistrationv1beta1.ValidatingWebhookConfiguration), err -} - -func (c *validatingWebhookConfigurationsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsadmissionregistrationv1beta1.ValidatingWebhookConfigurationApplyConfiguration, opts metav1.ApplyOptions) (*admissionregistrationv1beta1.ValidatingWebhookConfiguration, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(validatingWebhookConfigurationsResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &admissionregistrationv1beta1.ValidatingWebhookConfiguration{}) - if obj == nil { - return nil, err +func newFakeValidatingWebhookConfigurationClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedadmissionregistrationv1beta1.ValidatingWebhookConfigurationInterface { + return &validatingWebhookConfigurationScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*admissionregistrationv1beta1.ValidatingWebhookConfiguration, *admissionregistrationv1beta1.ValidatingWebhookConfigurationList, *v1beta1.ValidatingWebhookConfigurationApplyConfiguration]( + fake, + clusterPath, + "", + admissionregistrationv1beta1.SchemeGroupVersion.WithResource("validatingwebhookconfigurations"), + admissionregistrationv1beta1.SchemeGroupVersion.WithKind("ValidatingWebhookConfiguration"), + func() *admissionregistrationv1beta1.ValidatingWebhookConfiguration { + return &admissionregistrationv1beta1.ValidatingWebhookConfiguration{} + }, + func() *admissionregistrationv1beta1.ValidatingWebhookConfigurationList { + return &admissionregistrationv1beta1.ValidatingWebhookConfigurationList{} + }, + func(dst, src *admissionregistrationv1beta1.ValidatingWebhookConfigurationList) { + dst.ListMeta = src.ListMeta + }, + func(list *admissionregistrationv1beta1.ValidatingWebhookConfigurationList) []*admissionregistrationv1beta1.ValidatingWebhookConfiguration { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *admissionregistrationv1beta1.ValidatingWebhookConfigurationList, items []*admissionregistrationv1beta1.ValidatingWebhookConfiguration) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*admissionregistrationv1beta1.ValidatingWebhookConfiguration), err } diff --git a/kubernetes/typed/admissionregistration/v1beta1/generated_expansion.go b/kubernetes/typed/admissionregistration/v1beta1/generated_expansion.go new file mode 100644 index 000000000..b5348cea7 --- /dev/null +++ b/kubernetes/typed/admissionregistration/v1beta1/generated_expansion.go @@ -0,0 +1,27 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1beta1 + +type MutatingWebhookConfigurationClusterExpansion interface{} + +type ValidatingAdmissionPolicyClusterExpansion interface{} + +type ValidatingAdmissionPolicyBindingClusterExpansion interface{} + +type ValidatingWebhookConfigurationClusterExpansion interface{} diff --git a/kubernetes/typed/admissionregistration/v1beta1/mutatingwebhookconfiguration.go b/kubernetes/typed/admissionregistration/v1beta1/mutatingwebhookconfiguration.go index 06443db1b..3fd893d28 100644 --- a/kubernetes/typed/admissionregistration/v1beta1/mutatingwebhookconfiguration.go +++ b/kubernetes/typed/admissionregistration/v1beta1/mutatingwebhookconfiguration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - admissionregistrationv1beta1client "k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1" + apiadmissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + admissionregistrationv1beta1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1" ) // MutatingWebhookConfigurationsClusterGetter has a method to return a MutatingWebhookConfigurationClusterInterface. @@ -37,19 +37,20 @@ type MutatingWebhookConfigurationsClusterGetter interface { } // MutatingWebhookConfigurationClusterInterface can operate on MutatingWebhookConfigurations across all clusters, -// or scope down to one cluster and return a admissionregistrationv1beta1client.MutatingWebhookConfigurationInterface. +// or scope down to one cluster and return a admissionregistrationv1beta1.MutatingWebhookConfigurationInterface. type MutatingWebhookConfigurationClusterInterface interface { - Cluster(logicalcluster.Path) admissionregistrationv1beta1client.MutatingWebhookConfigurationInterface - List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1beta1.MutatingWebhookConfigurationList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) admissionregistrationv1beta1.MutatingWebhookConfigurationInterface + List(ctx context.Context, opts v1.ListOptions) (*apiadmissionregistrationv1beta1.MutatingWebhookConfigurationList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + MutatingWebhookConfigurationClusterExpansion } type mutatingWebhookConfigurationsClusterInterface struct { - clientCache kcpclient.Cache[*admissionregistrationv1beta1client.AdmissionregistrationV1beta1Client] + clientCache kcpclient.Cache[*admissionregistrationv1beta1.AdmissionregistrationV1beta1Client] } // Cluster scopes the client down to a particular cluster. -func (c *mutatingWebhookConfigurationsClusterInterface) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1beta1client.MutatingWebhookConfigurationInterface { +func (c *mutatingWebhookConfigurationsClusterInterface) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1beta1.MutatingWebhookConfigurationInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *mutatingWebhookConfigurationsClusterInterface) Cluster(clusterPath logi } // List returns the entire collection of all MutatingWebhookConfigurations across all clusters. -func (c *mutatingWebhookConfigurationsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1beta1.MutatingWebhookConfigurationList, error) { +func (c *mutatingWebhookConfigurationsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apiadmissionregistrationv1beta1.MutatingWebhookConfigurationList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).MutatingWebhookConfigurations().List(ctx, opts) } // Watch begins to watch all MutatingWebhookConfigurations across all clusters. -func (c *mutatingWebhookConfigurationsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *mutatingWebhookConfigurationsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).MutatingWebhookConfigurations().Watch(ctx, opts) } diff --git a/kubernetes/typed/admissionregistration/v1beta1/validatingadmissionpolicy.go b/kubernetes/typed/admissionregistration/v1beta1/validatingadmissionpolicy.go index 33200017f..51027efd3 100644 --- a/kubernetes/typed/admissionregistration/v1beta1/validatingadmissionpolicy.go +++ b/kubernetes/typed/admissionregistration/v1beta1/validatingadmissionpolicy.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - admissionregistrationv1beta1client "k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1" + apiadmissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + admissionregistrationv1beta1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1" ) // ValidatingAdmissionPoliciesClusterGetter has a method to return a ValidatingAdmissionPolicyClusterInterface. @@ -37,19 +37,20 @@ type ValidatingAdmissionPoliciesClusterGetter interface { } // ValidatingAdmissionPolicyClusterInterface can operate on ValidatingAdmissionPolicies across all clusters, -// or scope down to one cluster and return a admissionregistrationv1beta1client.ValidatingAdmissionPolicyInterface. +// or scope down to one cluster and return a admissionregistrationv1beta1.ValidatingAdmissionPolicyInterface. type ValidatingAdmissionPolicyClusterInterface interface { - Cluster(logicalcluster.Path) admissionregistrationv1beta1client.ValidatingAdmissionPolicyInterface - List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1beta1.ValidatingAdmissionPolicyList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) admissionregistrationv1beta1.ValidatingAdmissionPolicyInterface + List(ctx context.Context, opts v1.ListOptions) (*apiadmissionregistrationv1beta1.ValidatingAdmissionPolicyList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + ValidatingAdmissionPolicyClusterExpansion } type validatingAdmissionPoliciesClusterInterface struct { - clientCache kcpclient.Cache[*admissionregistrationv1beta1client.AdmissionregistrationV1beta1Client] + clientCache kcpclient.Cache[*admissionregistrationv1beta1.AdmissionregistrationV1beta1Client] } // Cluster scopes the client down to a particular cluster. -func (c *validatingAdmissionPoliciesClusterInterface) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1beta1client.ValidatingAdmissionPolicyInterface { +func (c *validatingAdmissionPoliciesClusterInterface) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1beta1.ValidatingAdmissionPolicyInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *validatingAdmissionPoliciesClusterInterface) Cluster(clusterPath logica } // List returns the entire collection of all ValidatingAdmissionPolicies across all clusters. -func (c *validatingAdmissionPoliciesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1beta1.ValidatingAdmissionPolicyList, error) { +func (c *validatingAdmissionPoliciesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apiadmissionregistrationv1beta1.ValidatingAdmissionPolicyList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ValidatingAdmissionPolicies().List(ctx, opts) } // Watch begins to watch all ValidatingAdmissionPolicies across all clusters. -func (c *validatingAdmissionPoliciesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *validatingAdmissionPoliciesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ValidatingAdmissionPolicies().Watch(ctx, opts) } diff --git a/kubernetes/typed/admissionregistration/v1beta1/validatingadmissionpolicybinding.go b/kubernetes/typed/admissionregistration/v1beta1/validatingadmissionpolicybinding.go index 38337427c..14b8f2109 100644 --- a/kubernetes/typed/admissionregistration/v1beta1/validatingadmissionpolicybinding.go +++ b/kubernetes/typed/admissionregistration/v1beta1/validatingadmissionpolicybinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - admissionregistrationv1beta1client "k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1" + apiadmissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + admissionregistrationv1beta1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1" ) // ValidatingAdmissionPolicyBindingsClusterGetter has a method to return a ValidatingAdmissionPolicyBindingClusterInterface. @@ -37,19 +37,20 @@ type ValidatingAdmissionPolicyBindingsClusterGetter interface { } // ValidatingAdmissionPolicyBindingClusterInterface can operate on ValidatingAdmissionPolicyBindings across all clusters, -// or scope down to one cluster and return a admissionregistrationv1beta1client.ValidatingAdmissionPolicyBindingInterface. +// or scope down to one cluster and return a admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingInterface. type ValidatingAdmissionPolicyBindingClusterInterface interface { - Cluster(logicalcluster.Path) admissionregistrationv1beta1client.ValidatingAdmissionPolicyBindingInterface - List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingInterface + List(ctx context.Context, opts v1.ListOptions) (*apiadmissionregistrationv1beta1.ValidatingAdmissionPolicyBindingList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + ValidatingAdmissionPolicyBindingClusterExpansion } type validatingAdmissionPolicyBindingsClusterInterface struct { - clientCache kcpclient.Cache[*admissionregistrationv1beta1client.AdmissionregistrationV1beta1Client] + clientCache kcpclient.Cache[*admissionregistrationv1beta1.AdmissionregistrationV1beta1Client] } // Cluster scopes the client down to a particular cluster. -func (c *validatingAdmissionPolicyBindingsClusterInterface) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1beta1client.ValidatingAdmissionPolicyBindingInterface { +func (c *validatingAdmissionPolicyBindingsClusterInterface) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *validatingAdmissionPolicyBindingsClusterInterface) Cluster(clusterPath } // List returns the entire collection of all ValidatingAdmissionPolicyBindings across all clusters. -func (c *validatingAdmissionPolicyBindingsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1beta1.ValidatingAdmissionPolicyBindingList, error) { +func (c *validatingAdmissionPolicyBindingsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apiadmissionregistrationv1beta1.ValidatingAdmissionPolicyBindingList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ValidatingAdmissionPolicyBindings().List(ctx, opts) } // Watch begins to watch all ValidatingAdmissionPolicyBindings across all clusters. -func (c *validatingAdmissionPolicyBindingsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *validatingAdmissionPolicyBindingsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ValidatingAdmissionPolicyBindings().Watch(ctx, opts) } diff --git a/kubernetes/typed/admissionregistration/v1beta1/validatingwebhookconfiguration.go b/kubernetes/typed/admissionregistration/v1beta1/validatingwebhookconfiguration.go index 1ed799457..143e86ba6 100644 --- a/kubernetes/typed/admissionregistration/v1beta1/validatingwebhookconfiguration.go +++ b/kubernetes/typed/admissionregistration/v1beta1/validatingwebhookconfiguration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - admissionregistrationv1beta1client "k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1" + apiadmissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + admissionregistrationv1beta1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1" ) // ValidatingWebhookConfigurationsClusterGetter has a method to return a ValidatingWebhookConfigurationClusterInterface. @@ -37,19 +37,20 @@ type ValidatingWebhookConfigurationsClusterGetter interface { } // ValidatingWebhookConfigurationClusterInterface can operate on ValidatingWebhookConfigurations across all clusters, -// or scope down to one cluster and return a admissionregistrationv1beta1client.ValidatingWebhookConfigurationInterface. +// or scope down to one cluster and return a admissionregistrationv1beta1.ValidatingWebhookConfigurationInterface. type ValidatingWebhookConfigurationClusterInterface interface { - Cluster(logicalcluster.Path) admissionregistrationv1beta1client.ValidatingWebhookConfigurationInterface - List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1beta1.ValidatingWebhookConfigurationList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) admissionregistrationv1beta1.ValidatingWebhookConfigurationInterface + List(ctx context.Context, opts v1.ListOptions) (*apiadmissionregistrationv1beta1.ValidatingWebhookConfigurationList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + ValidatingWebhookConfigurationClusterExpansion } type validatingWebhookConfigurationsClusterInterface struct { - clientCache kcpclient.Cache[*admissionregistrationv1beta1client.AdmissionregistrationV1beta1Client] + clientCache kcpclient.Cache[*admissionregistrationv1beta1.AdmissionregistrationV1beta1Client] } // Cluster scopes the client down to a particular cluster. -func (c *validatingWebhookConfigurationsClusterInterface) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1beta1client.ValidatingWebhookConfigurationInterface { +func (c *validatingWebhookConfigurationsClusterInterface) Cluster(clusterPath logicalcluster.Path) admissionregistrationv1beta1.ValidatingWebhookConfigurationInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *validatingWebhookConfigurationsClusterInterface) Cluster(clusterPath lo } // List returns the entire collection of all ValidatingWebhookConfigurations across all clusters. -func (c *validatingWebhookConfigurationsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*admissionregistrationv1beta1.ValidatingWebhookConfigurationList, error) { +func (c *validatingWebhookConfigurationsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apiadmissionregistrationv1beta1.ValidatingWebhookConfigurationList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ValidatingWebhookConfigurations().List(ctx, opts) } // Watch begins to watch all ValidatingWebhookConfigurations across all clusters. -func (c *validatingWebhookConfigurationsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *validatingWebhookConfigurationsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ValidatingWebhookConfigurations().Watch(ctx, opts) } diff --git a/kubernetes/typed/apiserverinternal/v1alpha1/apiserverinternal_client.go b/kubernetes/typed/apiserverinternal/v1alpha1/apiserverinternal_client.go index 260163269..6ebc99e68 100644 --- a/kubernetes/typed/apiserverinternal/v1alpha1/apiserverinternal_client.go +++ b/kubernetes/typed/apiserverinternal/v1alpha1/apiserverinternal_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - internalv1alpha1 "k8s.io/client-go/kubernetes/typed/apiserverinternal/v1alpha1" - "k8s.io/client-go/rest" + apiapiserverinternalv1alpha1 "k8s.io/api/apiserverinternal/v1alpha1" + apiserverinternalv1alpha1 "k8s.io/client-go/kubernetes/typed/apiserverinternal/v1alpha1" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type InternalV1alpha1ClusterInterface interface { @@ -34,14 +37,15 @@ type InternalV1alpha1ClusterInterface interface { } type InternalV1alpha1ClusterScoper interface { - Cluster(logicalcluster.Path) internalv1alpha1.InternalV1alpha1Interface + Cluster(logicalcluster.Path) apiserverinternalv1alpha1.InternalV1alpha1Interface } +// InternalV1alpha1ClusterClient is used to interact with features provided by the internal.apiserver.k8s.io group. type InternalV1alpha1ClusterClient struct { - clientCache kcpclient.Cache[*internalv1alpha1.InternalV1alpha1Client] + clientCache kcpclient.Cache[*apiserverinternalv1alpha1.InternalV1alpha1Client] } -func (c *InternalV1alpha1ClusterClient) Cluster(clusterPath logicalcluster.Path) internalv1alpha1.InternalV1alpha1Interface { +func (c *InternalV1alpha1ClusterClient) Cluster(clusterPath logicalcluster.Path) apiserverinternalv1alpha1.InternalV1alpha1Interface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -56,22 +60,25 @@ func (c *InternalV1alpha1ClusterClient) StorageVersions() StorageVersionClusterI // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*InternalV1alpha1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new InternalV1alpha1ClusterClient for the given config and http client. // Note the http client provided takes precedence over the configured transport values. func NewForConfigAndClient(c *rest.Config, h *http.Client) (*InternalV1alpha1ClusterClient, error) { - cache := kcpclient.NewCache(c, h, &kcpclient.Constructor[*internalv1alpha1.InternalV1alpha1Client]{ - NewForConfigAndClient: internalv1alpha1.NewForConfigAndClient, + cache := kcpclient.NewCache(c, h, &kcpclient.Constructor[*apiserverinternalv1alpha1.InternalV1alpha1Client]{ + NewForConfigAndClient: apiserverinternalv1alpha1.NewForConfigAndClient, }) if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &InternalV1alpha1ClusterClient{clientCache: cache}, nil } @@ -84,3 +91,14 @@ func NewForConfigOrDie(c *rest.Config) *InternalV1alpha1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apiapiserverinternalv1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/apiserverinternal/v1alpha1/doc.go b/kubernetes/typed/apiserverinternal/v1alpha1/doc.go new file mode 100644 index 000000000..08b80237c --- /dev/null +++ b/kubernetes/typed/apiserverinternal/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/kubernetes/typed/apiserverinternal/v1alpha1/fake/apiserverinternal_client.go b/kubernetes/typed/apiserverinternal/v1alpha1/fake/apiserverinternal_client.go index 8d060f92c..d60f47601 100644 --- a/kubernetes/typed/apiserverinternal/v1alpha1/fake/apiserverinternal_client.go +++ b/kubernetes/typed/apiserverinternal/v1alpha1/fake/apiserverinternal_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,49 +14,49 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( "github.com/kcp-dev/logicalcluster/v3" - internalv1alpha1 "k8s.io/client-go/kubernetes/typed/apiserverinternal/v1alpha1" - "k8s.io/client-go/rest" + apiserverinternalv1alpha1 "k8s.io/client-go/kubernetes/typed/apiserverinternal/v1alpha1" + rest "k8s.io/client-go/rest" - kcpinternalv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/apiserverinternal/v1alpha1" + kcpapiserverinternalv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/apiserverinternal/v1alpha1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var _ kcpinternalv1alpha1.InternalV1alpha1ClusterInterface = (*InternalV1alpha1ClusterClient)(nil) +var _ kcpapiserverinternalv1alpha1.InternalV1alpha1ClusterInterface = (*InternalV1alpha1ClusterClient)(nil) type InternalV1alpha1ClusterClient struct { *kcptesting.Fake } -func (c *InternalV1alpha1ClusterClient) Cluster(clusterPath logicalcluster.Path) internalv1alpha1.InternalV1alpha1Interface { +func (c *InternalV1alpha1ClusterClient) Cluster(clusterPath logicalcluster.Path) apiserverinternalv1alpha1.InternalV1alpha1Interface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } return &InternalV1alpha1Client{Fake: c.Fake, ClusterPath: clusterPath} } -func (c *InternalV1alpha1ClusterClient) StorageVersions() kcpinternalv1alpha1.StorageVersionClusterInterface { - return &storageVersionsClusterClient{Fake: c.Fake} +func (c *InternalV1alpha1ClusterClient) StorageVersions() kcpapiserverinternalv1alpha1.StorageVersionClusterInterface { + return newFakeStorageVersionClusterClient(c) } -var _ internalv1alpha1.InternalV1alpha1Interface = (*InternalV1alpha1Client)(nil) - type InternalV1alpha1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } +func (c *InternalV1alpha1Client) StorageVersions() apiserverinternalv1alpha1.StorageVersionInterface { + return newFakeStorageVersionClient(c.Fake, c.ClusterPath) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. func (c *InternalV1alpha1Client) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } - -func (c *InternalV1alpha1Client) StorageVersions() internalv1alpha1.StorageVersionInterface { - return &storageVersionsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} -} diff --git a/kubernetes/typed/apiserverinternal/v1alpha1/fake/doc.go b/kubernetes/typed/apiserverinternal/v1alpha1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/apiserverinternal/v1alpha1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/apiserverinternal/v1alpha1/fake/storageversion.go b/kubernetes/typed/apiserverinternal/v1alpha1/fake/storageversion.go index b3305e491..ce79c3005 100644 --- a/kubernetes/typed/apiserverinternal/v1alpha1/fake/storageversion.go +++ b/kubernetes/typed/apiserverinternal/v1alpha1/fake/storageversion.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,82 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" - internalv1alpha1 "k8s.io/api/apiserverinternal/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsinternalv1alpha1 "k8s.io/client-go/applyconfigurations/apiserverinternal/v1alpha1" - internalv1alpha1client "k8s.io/client-go/kubernetes/typed/apiserverinternal/v1alpha1" - "k8s.io/client-go/testing" + apiserverinternalv1alpha1 "k8s.io/api/apiserverinternal/v1alpha1" + v1alpha1 "k8s.io/client-go/applyconfigurations/apiserverinternal/v1alpha1" + typedapiserverinternalv1alpha1 "k8s.io/client-go/kubernetes/typed/apiserverinternal/v1alpha1" + typedkcpapiserverinternalv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/apiserverinternal/v1alpha1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var storageVersionsResource = schema.GroupVersionResource{Group: "internal.apiserver.k8s.io", Version: "v1alpha1", Resource: "storageversions"} -var storageVersionsKind = schema.GroupVersionKind{Group: "internal.apiserver.k8s.io", Version: "v1alpha1", Kind: "StorageVersion"} - -type storageVersionsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *storageVersionsClusterClient) Cluster(clusterPath logicalcluster.Path) internalv1alpha1client.StorageVersionInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &storageVersionsClient{Fake: c.Fake, ClusterPath: clusterPath} -} - -// List takes label and field selectors, and returns the list of StorageVersions that match those selectors across all clusters. -func (c *storageVersionsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*internalv1alpha1.StorageVersionList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(storageVersionsResource, storageVersionsKind, logicalcluster.Wildcard, opts), &internalv1alpha1.StorageVersionList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &internalv1alpha1.StorageVersionList{ListMeta: obj.(*internalv1alpha1.StorageVersionList).ListMeta} - for _, item := range obj.(*internalv1alpha1.StorageVersionList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested StorageVersions across all clusters. -func (c *storageVersionsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(storageVersionsResource, logicalcluster.Wildcard, opts)) -} - -type storageVersionsClient struct { - *kcptesting.Fake +// storageVersionClusterClient implements StorageVersionClusterInterface +type storageVersionClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*apiserverinternalv1alpha1.StorageVersion, *apiserverinternalv1alpha1.StorageVersionList] + Fake *kcptesting.Fake +} + +func newFakeStorageVersionClusterClient(fake *InternalV1alpha1ClusterClient) typedkcpapiserverinternalv1alpha1.StorageVersionClusterInterface { + return &storageVersionClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*apiserverinternalv1alpha1.StorageVersion, *apiserverinternalv1alpha1.StorageVersionList]( + fake.Fake, + apiserverinternalv1alpha1.SchemeGroupVersion.WithResource("storageversions"), + apiserverinternalv1alpha1.SchemeGroupVersion.WithKind("StorageVersion"), + func() *apiserverinternalv1alpha1.StorageVersion { return &apiserverinternalv1alpha1.StorageVersion{} }, + func() *apiserverinternalv1alpha1.StorageVersionList { + return &apiserverinternalv1alpha1.StorageVersionList{} + }, + func(dst, src *apiserverinternalv1alpha1.StorageVersionList) { dst.ListMeta = src.ListMeta }, + func(list *apiserverinternalv1alpha1.StorageVersionList) []*apiserverinternalv1alpha1.StorageVersion { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *apiserverinternalv1alpha1.StorageVersionList, items []*apiserverinternalv1alpha1.StorageVersion) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, + } +} + +func (c *storageVersionClusterClient) Cluster(cluster logicalcluster.Path) typedapiserverinternalv1alpha1.StorageVersionInterface { + return newFakeStorageVersionClient(c.Fake, cluster) +} + +// storageVersionScopedClient implements StorageVersionInterface +type storageVersionScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*apiserverinternalv1alpha1.StorageVersion, *apiserverinternalv1alpha1.StorageVersionList, *v1alpha1.StorageVersionApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *storageVersionsClient) Create(ctx context.Context, storageVersion *internalv1alpha1.StorageVersion, opts metav1.CreateOptions) (*internalv1alpha1.StorageVersion, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(storageVersionsResource, c.ClusterPath, storageVersion), &internalv1alpha1.StorageVersion{}) - if obj == nil { - return nil, err - } - return obj.(*internalv1alpha1.StorageVersion), err -} - -func (c *storageVersionsClient) Update(ctx context.Context, storageVersion *internalv1alpha1.StorageVersion, opts metav1.UpdateOptions) (*internalv1alpha1.StorageVersion, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(storageVersionsResource, c.ClusterPath, storageVersion), &internalv1alpha1.StorageVersion{}) - if obj == nil { - return nil, err - } - return obj.(*internalv1alpha1.StorageVersion), err -} - -func (c *storageVersionsClient) UpdateStatus(ctx context.Context, storageVersion *internalv1alpha1.StorageVersion, opts metav1.UpdateOptions) (*internalv1alpha1.StorageVersion, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(storageVersionsResource, c.ClusterPath, "status", storageVersion), &internalv1alpha1.StorageVersion{}) - if obj == nil { - return nil, err - } - return obj.(*internalv1alpha1.StorageVersion), err -} - -func (c *storageVersionsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(storageVersionsResource, c.ClusterPath, name, opts), &internalv1alpha1.StorageVersion{}) - return err -} - -func (c *storageVersionsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(storageVersionsResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &internalv1alpha1.StorageVersionList{}) - return err -} - -func (c *storageVersionsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*internalv1alpha1.StorageVersion, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(storageVersionsResource, c.ClusterPath, name), &internalv1alpha1.StorageVersion{}) - if obj == nil { - return nil, err - } - return obj.(*internalv1alpha1.StorageVersion), err -} - -// List takes label and field selectors, and returns the list of StorageVersions that match those selectors. -func (c *storageVersionsClient) List(ctx context.Context, opts metav1.ListOptions) (*internalv1alpha1.StorageVersionList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(storageVersionsResource, storageVersionsKind, c.ClusterPath, opts), &internalv1alpha1.StorageVersionList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &internalv1alpha1.StorageVersionList{ListMeta: obj.(*internalv1alpha1.StorageVersionList).ListMeta} - for _, item := range obj.(*internalv1alpha1.StorageVersionList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *storageVersionsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(storageVersionsResource, c.ClusterPath, opts)) -} - -func (c *storageVersionsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*internalv1alpha1.StorageVersion, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(storageVersionsResource, c.ClusterPath, name, pt, data, subresources...), &internalv1alpha1.StorageVersion{}) - if obj == nil { - return nil, err - } - return obj.(*internalv1alpha1.StorageVersion), err -} - -func (c *storageVersionsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsinternalv1alpha1.StorageVersionApplyConfiguration, opts metav1.ApplyOptions) (*internalv1alpha1.StorageVersion, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(storageVersionsResource, c.ClusterPath, *name, types.ApplyPatchType, data), &internalv1alpha1.StorageVersion{}) - if obj == nil { - return nil, err - } - return obj.(*internalv1alpha1.StorageVersion), err -} - -func (c *storageVersionsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsinternalv1alpha1.StorageVersionApplyConfiguration, opts metav1.ApplyOptions) (*internalv1alpha1.StorageVersion, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(storageVersionsResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &internalv1alpha1.StorageVersion{}) - if obj == nil { - return nil, err +func newFakeStorageVersionClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedapiserverinternalv1alpha1.StorageVersionInterface { + return &storageVersionScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*apiserverinternalv1alpha1.StorageVersion, *apiserverinternalv1alpha1.StorageVersionList, *v1alpha1.StorageVersionApplyConfiguration]( + fake, + clusterPath, + "", + apiserverinternalv1alpha1.SchemeGroupVersion.WithResource("storageversions"), + apiserverinternalv1alpha1.SchemeGroupVersion.WithKind("StorageVersion"), + func() *apiserverinternalv1alpha1.StorageVersion { return &apiserverinternalv1alpha1.StorageVersion{} }, + func() *apiserverinternalv1alpha1.StorageVersionList { + return &apiserverinternalv1alpha1.StorageVersionList{} + }, + func(dst, src *apiserverinternalv1alpha1.StorageVersionList) { dst.ListMeta = src.ListMeta }, + func(list *apiserverinternalv1alpha1.StorageVersionList) []*apiserverinternalv1alpha1.StorageVersion { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *apiserverinternalv1alpha1.StorageVersionList, items []*apiserverinternalv1alpha1.StorageVersion) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*internalv1alpha1.StorageVersion), err } diff --git a/kubernetes/typed/apiserverinternal/v1alpha1/generated_expansion.go b/kubernetes/typed/apiserverinternal/v1alpha1/generated_expansion.go new file mode 100644 index 000000000..8537e859c --- /dev/null +++ b/kubernetes/typed/apiserverinternal/v1alpha1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1alpha1 + +type StorageVersionClusterExpansion interface{} diff --git a/kubernetes/typed/apiserverinternal/v1alpha1/storageversion.go b/kubernetes/typed/apiserverinternal/v1alpha1/storageversion.go index 1838fba2f..02aee0bc7 100644 --- a/kubernetes/typed/apiserverinternal/v1alpha1/storageversion.go +++ b/kubernetes/typed/apiserverinternal/v1alpha1/storageversion.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - internalv1alpha1 "k8s.io/api/apiserverinternal/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - internalv1alpha1client "k8s.io/client-go/kubernetes/typed/apiserverinternal/v1alpha1" + apiapiserverinternalv1alpha1 "k8s.io/api/apiserverinternal/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + apiserverinternalv1alpha1 "k8s.io/client-go/kubernetes/typed/apiserverinternal/v1alpha1" ) // StorageVersionsClusterGetter has a method to return a StorageVersionClusterInterface. @@ -37,19 +37,20 @@ type StorageVersionsClusterGetter interface { } // StorageVersionClusterInterface can operate on StorageVersions across all clusters, -// or scope down to one cluster and return a internalv1alpha1client.StorageVersionInterface. +// or scope down to one cluster and return a apiserverinternalv1alpha1.StorageVersionInterface. type StorageVersionClusterInterface interface { - Cluster(logicalcluster.Path) internalv1alpha1client.StorageVersionInterface - List(ctx context.Context, opts metav1.ListOptions) (*internalv1alpha1.StorageVersionList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) apiserverinternalv1alpha1.StorageVersionInterface + List(ctx context.Context, opts v1.ListOptions) (*apiapiserverinternalv1alpha1.StorageVersionList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + StorageVersionClusterExpansion } type storageVersionsClusterInterface struct { - clientCache kcpclient.Cache[*internalv1alpha1client.InternalV1alpha1Client] + clientCache kcpclient.Cache[*apiserverinternalv1alpha1.InternalV1alpha1Client] } // Cluster scopes the client down to a particular cluster. -func (c *storageVersionsClusterInterface) Cluster(clusterPath logicalcluster.Path) internalv1alpha1client.StorageVersionInterface { +func (c *storageVersionsClusterInterface) Cluster(clusterPath logicalcluster.Path) apiserverinternalv1alpha1.StorageVersionInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *storageVersionsClusterInterface) Cluster(clusterPath logicalcluster.Pat } // List returns the entire collection of all StorageVersions across all clusters. -func (c *storageVersionsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*internalv1alpha1.StorageVersionList, error) { +func (c *storageVersionsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apiapiserverinternalv1alpha1.StorageVersionList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).StorageVersions().List(ctx, opts) } // Watch begins to watch all StorageVersions across all clusters. -func (c *storageVersionsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *storageVersionsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).StorageVersions().Watch(ctx, opts) } diff --git a/kubernetes/typed/apps/v1/apps_client.go b/kubernetes/typed/apps/v1/apps_client.go index e6449aadd..49b887bff 100644 --- a/kubernetes/typed/apps/v1/apps_client.go +++ b/kubernetes/typed/apps/v1/apps_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,33 +14,37 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apiappsv1 "k8s.io/api/apps/v1" appsv1 "k8s.io/client-go/kubernetes/typed/apps/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type AppsV1ClusterInterface interface { AppsV1ClusterScoper - StatefulSetsClusterGetter - DeploymentsClusterGetter + ControllerRevisionsClusterGetter DaemonSetsClusterGetter + DeploymentsClusterGetter ReplicaSetsClusterGetter - ControllerRevisionsClusterGetter + StatefulSetsClusterGetter } type AppsV1ClusterScoper interface { Cluster(logicalcluster.Path) appsv1.AppsV1Interface } +// AppsV1ClusterClient is used to interact with features provided by the apps group. type AppsV1ClusterClient struct { clientCache kcpclient.Cache[*appsv1.AppsV1Client] } @@ -52,35 +56,37 @@ func (c *AppsV1ClusterClient) Cluster(clusterPath logicalcluster.Path) appsv1.Ap return c.clientCache.ClusterOrDie(clusterPath) } -func (c *AppsV1ClusterClient) StatefulSets() StatefulSetClusterInterface { - return &statefulSetsClusterInterface{clientCache: c.clientCache} -} - -func (c *AppsV1ClusterClient) Deployments() DeploymentClusterInterface { - return &deploymentsClusterInterface{clientCache: c.clientCache} +func (c *AppsV1ClusterClient) ControllerRevisions() ControllerRevisionClusterInterface { + return &controllerRevisionsClusterInterface{clientCache: c.clientCache} } func (c *AppsV1ClusterClient) DaemonSets() DaemonSetClusterInterface { return &daemonSetsClusterInterface{clientCache: c.clientCache} } +func (c *AppsV1ClusterClient) Deployments() DeploymentClusterInterface { + return &deploymentsClusterInterface{clientCache: c.clientCache} +} + func (c *AppsV1ClusterClient) ReplicaSets() ReplicaSetClusterInterface { return &replicaSetsClusterInterface{clientCache: c.clientCache} } -func (c *AppsV1ClusterClient) ControllerRevisions() ControllerRevisionClusterInterface { - return &controllerRevisionsClusterInterface{clientCache: c.clientCache} +func (c *AppsV1ClusterClient) StatefulSets() StatefulSetClusterInterface { + return &statefulSetsClusterInterface{clientCache: c.clientCache} } // NewForConfig creates a new AppsV1ClusterClient for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*AppsV1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new AppsV1ClusterClient for the given config and http client. @@ -92,6 +98,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*AppsV1ClusterClient if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &AppsV1ClusterClient{clientCache: cache}, nil } @@ -104,3 +111,14 @@ func NewForConfigOrDie(c *rest.Config) *AppsV1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apiappsv1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/apps/v1/controllerrevision.go b/kubernetes/typed/apps/v1/controllerrevision.go index 9ddb3d353..7fb4a21fd 100644 --- a/kubernetes/typed/apps/v1/controllerrevision.go +++ b/kubernetes/typed/apps/v1/controllerrevision.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" appsv1 "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - appsv1client "k8s.io/client-go/kubernetes/typed/apps/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedappsv1 "k8s.io/client-go/kubernetes/typed/apps/v1" ) // ControllerRevisionsClusterGetter has a method to return a ControllerRevisionClusterInterface. @@ -42,10 +42,11 @@ type ControllerRevisionClusterInterface interface { Cluster(logicalcluster.Path) ControllerRevisionsNamespacer List(ctx context.Context, opts metav1.ListOptions) (*appsv1.ControllerRevisionList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + ControllerRevisionClusterExpansion } type controllerRevisionsClusterInterface struct { - clientCache kcpclient.Cache[*appsv1client.AppsV1Client] + clientCache kcpclient.Cache[*typedappsv1.AppsV1Client] } // Cluster scopes the client down to a particular cluster. @@ -67,16 +68,16 @@ func (c *controllerRevisionsClusterInterface) Watch(ctx context.Context, opts me return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ControllerRevisions(metav1.NamespaceAll).Watch(ctx, opts) } -// ControllerRevisionsNamespacer can scope to objects within a namespace, returning a appsv1client.ControllerRevisionInterface. +// ControllerRevisionsNamespacer can scope to objects within a namespace, returning a typedappsv1.ControllerRevisionInterface. type ControllerRevisionsNamespacer interface { - Namespace(string) appsv1client.ControllerRevisionInterface + Namespace(string) typedappsv1.ControllerRevisionInterface } type controllerRevisionsNamespacer struct { - clientCache kcpclient.Cache[*appsv1client.AppsV1Client] + clientCache kcpclient.Cache[*typedappsv1.AppsV1Client] clusterPath logicalcluster.Path } -func (n *controllerRevisionsNamespacer) Namespace(namespace string) appsv1client.ControllerRevisionInterface { +func (n *controllerRevisionsNamespacer) Namespace(namespace string) typedappsv1.ControllerRevisionInterface { return n.clientCache.ClusterOrDie(n.clusterPath).ControllerRevisions(namespace) } diff --git a/kubernetes/typed/apps/v1/daemonset.go b/kubernetes/typed/apps/v1/daemonset.go index ad002b2f7..6a651eb93 100644 --- a/kubernetes/typed/apps/v1/daemonset.go +++ b/kubernetes/typed/apps/v1/daemonset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" appsv1 "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - appsv1client "k8s.io/client-go/kubernetes/typed/apps/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedappsv1 "k8s.io/client-go/kubernetes/typed/apps/v1" ) // DaemonSetsClusterGetter has a method to return a DaemonSetClusterInterface. @@ -42,10 +42,11 @@ type DaemonSetClusterInterface interface { Cluster(logicalcluster.Path) DaemonSetsNamespacer List(ctx context.Context, opts metav1.ListOptions) (*appsv1.DaemonSetList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + DaemonSetClusterExpansion } type daemonSetsClusterInterface struct { - clientCache kcpclient.Cache[*appsv1client.AppsV1Client] + clientCache kcpclient.Cache[*typedappsv1.AppsV1Client] } // Cluster scopes the client down to a particular cluster. @@ -67,16 +68,16 @@ func (c *daemonSetsClusterInterface) Watch(ctx context.Context, opts metav1.List return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).DaemonSets(metav1.NamespaceAll).Watch(ctx, opts) } -// DaemonSetsNamespacer can scope to objects within a namespace, returning a appsv1client.DaemonSetInterface. +// DaemonSetsNamespacer can scope to objects within a namespace, returning a typedappsv1.DaemonSetInterface. type DaemonSetsNamespacer interface { - Namespace(string) appsv1client.DaemonSetInterface + Namespace(string) typedappsv1.DaemonSetInterface } type daemonSetsNamespacer struct { - clientCache kcpclient.Cache[*appsv1client.AppsV1Client] + clientCache kcpclient.Cache[*typedappsv1.AppsV1Client] clusterPath logicalcluster.Path } -func (n *daemonSetsNamespacer) Namespace(namespace string) appsv1client.DaemonSetInterface { +func (n *daemonSetsNamespacer) Namespace(namespace string) typedappsv1.DaemonSetInterface { return n.clientCache.ClusterOrDie(n.clusterPath).DaemonSets(namespace) } diff --git a/kubernetes/typed/apps/v1/deployment.go b/kubernetes/typed/apps/v1/deployment.go index b4957d817..4b299d8b2 100644 --- a/kubernetes/typed/apps/v1/deployment.go +++ b/kubernetes/typed/apps/v1/deployment.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" appsv1 "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - appsv1client "k8s.io/client-go/kubernetes/typed/apps/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedappsv1 "k8s.io/client-go/kubernetes/typed/apps/v1" ) // DeploymentsClusterGetter has a method to return a DeploymentClusterInterface. @@ -42,10 +42,11 @@ type DeploymentClusterInterface interface { Cluster(logicalcluster.Path) DeploymentsNamespacer List(ctx context.Context, opts metav1.ListOptions) (*appsv1.DeploymentList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + DeploymentClusterExpansion } type deploymentsClusterInterface struct { - clientCache kcpclient.Cache[*appsv1client.AppsV1Client] + clientCache kcpclient.Cache[*typedappsv1.AppsV1Client] } // Cluster scopes the client down to a particular cluster. @@ -67,16 +68,16 @@ func (c *deploymentsClusterInterface) Watch(ctx context.Context, opts metav1.Lis return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Deployments(metav1.NamespaceAll).Watch(ctx, opts) } -// DeploymentsNamespacer can scope to objects within a namespace, returning a appsv1client.DeploymentInterface. +// DeploymentsNamespacer can scope to objects within a namespace, returning a typedappsv1.DeploymentInterface. type DeploymentsNamespacer interface { - Namespace(string) appsv1client.DeploymentInterface + Namespace(string) typedappsv1.DeploymentInterface } type deploymentsNamespacer struct { - clientCache kcpclient.Cache[*appsv1client.AppsV1Client] + clientCache kcpclient.Cache[*typedappsv1.AppsV1Client] clusterPath logicalcluster.Path } -func (n *deploymentsNamespacer) Namespace(namespace string) appsv1client.DeploymentInterface { +func (n *deploymentsNamespacer) Namespace(namespace string) typedappsv1.DeploymentInterface { return n.clientCache.ClusterOrDie(n.clusterPath).Deployments(namespace) } diff --git a/kubernetes/typed/apps/v1/doc.go b/kubernetes/typed/apps/v1/doc.go new file mode 100644 index 000000000..d2f3412ab --- /dev/null +++ b/kubernetes/typed/apps/v1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1 diff --git a/kubernetes/typed/apps/v1/fake/apps_client.go b/kubernetes/typed/apps/v1/fake/apps_client.go index 2c1ae042d..12ed1d64e 100644 --- a/kubernetes/typed/apps/v1/fake/apps_client.go +++ b/kubernetes/typed/apps/v1/fake/apps_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" appsv1 "k8s.io/client-go/kubernetes/typed/apps/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpappsv1 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -41,54 +41,54 @@ func (c *AppsV1ClusterClient) Cluster(clusterPath logicalcluster.Path) appsv1.Ap return &AppsV1Client{Fake: c.Fake, ClusterPath: clusterPath} } -func (c *AppsV1ClusterClient) StatefulSets() kcpappsv1.StatefulSetClusterInterface { - return &statefulSetsClusterClient{Fake: c.Fake} +func (c *AppsV1ClusterClient) ControllerRevisions() kcpappsv1.ControllerRevisionClusterInterface { + return newFakeControllerRevisionClusterClient(c) } -func (c *AppsV1ClusterClient) Deployments() kcpappsv1.DeploymentClusterInterface { - return &deploymentsClusterClient{Fake: c.Fake} +func (c *AppsV1ClusterClient) DaemonSets() kcpappsv1.DaemonSetClusterInterface { + return newFakeDaemonSetClusterClient(c) } -func (c *AppsV1ClusterClient) DaemonSets() kcpappsv1.DaemonSetClusterInterface { - return &daemonSetsClusterClient{Fake: c.Fake} +func (c *AppsV1ClusterClient) Deployments() kcpappsv1.DeploymentClusterInterface { + return newFakeDeploymentClusterClient(c) } func (c *AppsV1ClusterClient) ReplicaSets() kcpappsv1.ReplicaSetClusterInterface { - return &replicaSetsClusterClient{Fake: c.Fake} + return newFakeReplicaSetClusterClient(c) } -func (c *AppsV1ClusterClient) ControllerRevisions() kcpappsv1.ControllerRevisionClusterInterface { - return &controllerRevisionsClusterClient{Fake: c.Fake} +func (c *AppsV1ClusterClient) StatefulSets() kcpappsv1.StatefulSetClusterInterface { + return newFakeStatefulSetClusterClient(c) } -var _ appsv1.AppsV1Interface = (*AppsV1Client)(nil) - type AppsV1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *AppsV1Client) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret +func (c *AppsV1Client) ControllerRevisions(namespace string) appsv1.ControllerRevisionInterface { + return newFakeControllerRevisionClient(c.Fake, namespace, c.ClusterPath) } -func (c *AppsV1Client) StatefulSets(namespace string) appsv1.StatefulSetInterface { - return &statefulSetsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *AppsV1Client) DaemonSets(namespace string) appsv1.DaemonSetInterface { + return newFakeDaemonSetClient(c.Fake, namespace, c.ClusterPath) } func (c *AppsV1Client) Deployments(namespace string) appsv1.DeploymentInterface { - return &deploymentsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} + return newFakeDeploymentClient(c.Fake, namespace, c.ClusterPath) } -func (c *AppsV1Client) DaemonSets(namespace string) appsv1.DaemonSetInterface { - return &daemonSetsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *AppsV1Client) ReplicaSets(namespace string) appsv1.ReplicaSetInterface { + return newFakeReplicaSetClient(c.Fake, namespace, c.ClusterPath) } -func (c *AppsV1Client) ReplicaSets(namespace string) appsv1.ReplicaSetInterface { - return &replicaSetsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *AppsV1Client) StatefulSets(namespace string) appsv1.StatefulSetInterface { + return newFakeStatefulSetClient(c.Fake, namespace, c.ClusterPath) } -func (c *AppsV1Client) ControllerRevisions(namespace string) appsv1.ControllerRevisionInterface { - return &controllerRevisionsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *AppsV1Client) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret } diff --git a/kubernetes/typed/apps/v1/fake/controllerrevision.go b/kubernetes/typed/apps/v1/fake/controllerrevision.go index 50a4f467d..dc4c095a3 100644 --- a/kubernetes/typed/apps/v1/fake/controllerrevision.go +++ b/kubernetes/typed/apps/v1/fake/controllerrevision.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" appsv1 "k8s.io/api/apps/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsappsv1 "k8s.io/client-go/applyconfigurations/apps/v1" - appsv1client "k8s.io/client-go/kubernetes/typed/apps/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/apps/v1" + typedappsv1 "k8s.io/client-go/kubernetes/typed/apps/v1" - kcpappsv1 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1" + typedkcpappsv1 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var controllerRevisionsResource = schema.GroupVersionResource{Group: "apps", Version: "v1", Resource: "controllerrevisions"} -var controllerRevisionsKind = schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "ControllerRevision"} - -type controllerRevisionsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *controllerRevisionsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpappsv1.ControllerRevisionsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &controllerRevisionsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// controllerRevisionClusterClient implements ControllerRevisionClusterInterface +type controllerRevisionClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*appsv1.ControllerRevision, *appsv1.ControllerRevisionList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of ControllerRevisions that match those selectors across all clusters. -func (c *controllerRevisionsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*appsv1.ControllerRevisionList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(controllerRevisionsResource, controllerRevisionsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &appsv1.ControllerRevisionList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeControllerRevisionClusterClient(fake *AppsV1ClusterClient) typedkcpappsv1.ControllerRevisionClusterInterface { + return &controllerRevisionClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*appsv1.ControllerRevision, *appsv1.ControllerRevisionList]( + fake.Fake, + appsv1.SchemeGroupVersion.WithResource("controllerrevisions"), + appsv1.SchemeGroupVersion.WithKind("ControllerRevision"), + func() *appsv1.ControllerRevision { return &appsv1.ControllerRevision{} }, + func() *appsv1.ControllerRevisionList { return &appsv1.ControllerRevisionList{} }, + func(dst, src *appsv1.ControllerRevisionList) { dst.ListMeta = src.ListMeta }, + func(list *appsv1.ControllerRevisionList) []*appsv1.ControllerRevision { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *appsv1.ControllerRevisionList, items []*appsv1.ControllerRevision) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &appsv1.ControllerRevisionList{ListMeta: obj.(*appsv1.ControllerRevisionList).ListMeta} - for _, item := range obj.(*appsv1.ControllerRevisionList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested ControllerRevisions across all clusters. -func (c *controllerRevisionsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(controllerRevisionsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *controllerRevisionClusterClient) Cluster(cluster logicalcluster.Path) typedkcpappsv1.ControllerRevisionsNamespacer { + return &controllerRevisionNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type controllerRevisionsNamespacer struct { +type controllerRevisionNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *controllerRevisionsNamespacer) Namespace(namespace string) appsv1client.ControllerRevisionInterface { - return &controllerRevisionsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *controllerRevisionNamespacer) Namespace(namespace string) typedappsv1.ControllerRevisionInterface { + return newFakeControllerRevisionClient(n.Fake, namespace, n.ClusterPath) } -type controllerRevisionsClient struct { - *kcptesting.Fake +// controllerRevisionScopedClient implements ControllerRevisionInterface +type controllerRevisionScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*appsv1.ControllerRevision, *appsv1.ControllerRevisionList, *v1.ControllerRevisionApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *controllerRevisionsClient) Create(ctx context.Context, controllerRevision *appsv1.ControllerRevision, opts metav1.CreateOptions) (*appsv1.ControllerRevision, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(controllerRevisionsResource, c.ClusterPath, c.Namespace, controllerRevision), &appsv1.ControllerRevision{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1.ControllerRevision), err -} - -func (c *controllerRevisionsClient) Update(ctx context.Context, controllerRevision *appsv1.ControllerRevision, opts metav1.UpdateOptions) (*appsv1.ControllerRevision, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(controllerRevisionsResource, c.ClusterPath, c.Namespace, controllerRevision), &appsv1.ControllerRevision{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1.ControllerRevision), err -} - -func (c *controllerRevisionsClient) UpdateStatus(ctx context.Context, controllerRevision *appsv1.ControllerRevision, opts metav1.UpdateOptions) (*appsv1.ControllerRevision, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(controllerRevisionsResource, c.ClusterPath, "status", c.Namespace, controllerRevision), &appsv1.ControllerRevision{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1.ControllerRevision), err -} - -func (c *controllerRevisionsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(controllerRevisionsResource, c.ClusterPath, c.Namespace, name, opts), &appsv1.ControllerRevision{}) - return err -} - -func (c *controllerRevisionsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(controllerRevisionsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &appsv1.ControllerRevisionList{}) - return err -} - -func (c *controllerRevisionsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*appsv1.ControllerRevision, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(controllerRevisionsResource, c.ClusterPath, c.Namespace, name), &appsv1.ControllerRevision{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1.ControllerRevision), err -} - -// List takes label and field selectors, and returns the list of ControllerRevisions that match those selectors. -func (c *controllerRevisionsClient) List(ctx context.Context, opts metav1.ListOptions) (*appsv1.ControllerRevisionList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(controllerRevisionsResource, controllerRevisionsKind, c.ClusterPath, c.Namespace, opts), &appsv1.ControllerRevisionList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &appsv1.ControllerRevisionList{ListMeta: obj.(*appsv1.ControllerRevisionList).ListMeta} - for _, item := range obj.(*appsv1.ControllerRevisionList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *controllerRevisionsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(controllerRevisionsResource, c.ClusterPath, c.Namespace, opts)) } -func (c *controllerRevisionsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*appsv1.ControllerRevision, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(controllerRevisionsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &appsv1.ControllerRevision{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1.ControllerRevision), err -} - -func (c *controllerRevisionsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsappsv1.ControllerRevisionApplyConfiguration, opts metav1.ApplyOptions) (*appsv1.ControllerRevision, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(controllerRevisionsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &appsv1.ControllerRevision{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1.ControllerRevision), err -} - -func (c *controllerRevisionsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsappsv1.ControllerRevisionApplyConfiguration, opts metav1.ApplyOptions) (*appsv1.ControllerRevision, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(controllerRevisionsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &appsv1.ControllerRevision{}) - if obj == nil { - return nil, err +func newFakeControllerRevisionClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedappsv1.ControllerRevisionInterface { + return &controllerRevisionScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*appsv1.ControllerRevision, *appsv1.ControllerRevisionList, *v1.ControllerRevisionApplyConfiguration]( + fake, + clusterPath, + namespace, + appsv1.SchemeGroupVersion.WithResource("controllerrevisions"), + appsv1.SchemeGroupVersion.WithKind("ControllerRevision"), + func() *appsv1.ControllerRevision { return &appsv1.ControllerRevision{} }, + func() *appsv1.ControllerRevisionList { return &appsv1.ControllerRevisionList{} }, + func(dst, src *appsv1.ControllerRevisionList) { dst.ListMeta = src.ListMeta }, + func(list *appsv1.ControllerRevisionList) []*appsv1.ControllerRevision { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *appsv1.ControllerRevisionList, items []*appsv1.ControllerRevision) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*appsv1.ControllerRevision), err } diff --git a/kubernetes/typed/apps/v1/fake/daemonset.go b/kubernetes/typed/apps/v1/fake/daemonset.go index 0308958d8..715527bb4 100644 --- a/kubernetes/typed/apps/v1/fake/daemonset.go +++ b/kubernetes/typed/apps/v1/fake/daemonset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,83 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" appsv1 "k8s.io/api/apps/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsappsv1 "k8s.io/client-go/applyconfigurations/apps/v1" - appsv1client "k8s.io/client-go/kubernetes/typed/apps/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/apps/v1" + typedappsv1 "k8s.io/client-go/kubernetes/typed/apps/v1" - kcpappsv1 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1" + typedkcpappsv1 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var daemonSetsResource = schema.GroupVersionResource{Group: "apps", Version: "v1", Resource: "daemonsets"} -var daemonSetsKind = schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "DaemonSet"} - -type daemonSetsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *daemonSetsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpappsv1.DaemonSetsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &daemonSetsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// daemonSetClusterClient implements DaemonSetClusterInterface +type daemonSetClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*appsv1.DaemonSet, *appsv1.DaemonSetList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of DaemonSets that match those selectors across all clusters. -func (c *daemonSetsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*appsv1.DaemonSetList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(daemonSetsResource, daemonSetsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &appsv1.DaemonSetList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeDaemonSetClusterClient(fake *AppsV1ClusterClient) typedkcpappsv1.DaemonSetClusterInterface { + return &daemonSetClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*appsv1.DaemonSet, *appsv1.DaemonSetList]( + fake.Fake, + appsv1.SchemeGroupVersion.WithResource("daemonsets"), + appsv1.SchemeGroupVersion.WithKind("DaemonSet"), + func() *appsv1.DaemonSet { return &appsv1.DaemonSet{} }, + func() *appsv1.DaemonSetList { return &appsv1.DaemonSetList{} }, + func(dst, src *appsv1.DaemonSetList) { dst.ListMeta = src.ListMeta }, + func(list *appsv1.DaemonSetList) []*appsv1.DaemonSet { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *appsv1.DaemonSetList, items []*appsv1.DaemonSet) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &appsv1.DaemonSetList{ListMeta: obj.(*appsv1.DaemonSetList).ListMeta} - for _, item := range obj.(*appsv1.DaemonSetList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested DaemonSets across all clusters. -func (c *daemonSetsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(daemonSetsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *daemonSetClusterClient) Cluster(cluster logicalcluster.Path) typedkcpappsv1.DaemonSetsNamespacer { + return &daemonSetNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type daemonSetsNamespacer struct { +type daemonSetNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *daemonSetsNamespacer) Namespace(namespace string) appsv1client.DaemonSetInterface { - return &daemonSetsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *daemonSetNamespacer) Namespace(namespace string) typedappsv1.DaemonSetInterface { + return newFakeDaemonSetClient(n.Fake, namespace, n.ClusterPath) } -type daemonSetsClient struct { - *kcptesting.Fake +// daemonSetScopedClient implements DaemonSetInterface +type daemonSetScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*appsv1.DaemonSet, *appsv1.DaemonSetList, *v1.DaemonSetApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *daemonSetsClient) Create(ctx context.Context, daemonSet *appsv1.DaemonSet, opts metav1.CreateOptions) (*appsv1.DaemonSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(daemonSetsResource, c.ClusterPath, c.Namespace, daemonSet), &appsv1.DaemonSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1.DaemonSet), err -} - -func (c *daemonSetsClient) Update(ctx context.Context, daemonSet *appsv1.DaemonSet, opts metav1.UpdateOptions) (*appsv1.DaemonSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(daemonSetsResource, c.ClusterPath, c.Namespace, daemonSet), &appsv1.DaemonSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1.DaemonSet), err -} - -func (c *daemonSetsClient) UpdateStatus(ctx context.Context, daemonSet *appsv1.DaemonSet, opts metav1.UpdateOptions) (*appsv1.DaemonSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(daemonSetsResource, c.ClusterPath, "status", c.Namespace, daemonSet), &appsv1.DaemonSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1.DaemonSet), err -} - -func (c *daemonSetsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(daemonSetsResource, c.ClusterPath, c.Namespace, name, opts), &appsv1.DaemonSet{}) - return err -} - -func (c *daemonSetsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(daemonSetsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &appsv1.DaemonSetList{}) - return err -} - -func (c *daemonSetsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*appsv1.DaemonSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(daemonSetsResource, c.ClusterPath, c.Namespace, name), &appsv1.DaemonSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1.DaemonSet), err -} - -// List takes label and field selectors, and returns the list of DaemonSets that match those selectors. -func (c *daemonSetsClient) List(ctx context.Context, opts metav1.ListOptions) (*appsv1.DaemonSetList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(daemonSetsResource, daemonSetsKind, c.ClusterPath, c.Namespace, opts), &appsv1.DaemonSetList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &appsv1.DaemonSetList{ListMeta: obj.(*appsv1.DaemonSetList).ListMeta} - for _, item := range obj.(*appsv1.DaemonSetList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *daemonSetsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(daemonSetsResource, c.ClusterPath, c.Namespace, opts)) } -func (c *daemonSetsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*appsv1.DaemonSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(daemonSetsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &appsv1.DaemonSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1.DaemonSet), err -} - -func (c *daemonSetsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsappsv1.DaemonSetApplyConfiguration, opts metav1.ApplyOptions) (*appsv1.DaemonSet, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(daemonSetsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &appsv1.DaemonSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1.DaemonSet), err -} - -func (c *daemonSetsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsappsv1.DaemonSetApplyConfiguration, opts metav1.ApplyOptions) (*appsv1.DaemonSet, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(daemonSetsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &appsv1.DaemonSet{}) - if obj == nil { - return nil, err +func newFakeDaemonSetClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedappsv1.DaemonSetInterface { + return &daemonSetScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*appsv1.DaemonSet, *appsv1.DaemonSetList, *v1.DaemonSetApplyConfiguration]( + fake, + clusterPath, + namespace, + appsv1.SchemeGroupVersion.WithResource("daemonsets"), + appsv1.SchemeGroupVersion.WithKind("DaemonSet"), + func() *appsv1.DaemonSet { return &appsv1.DaemonSet{} }, + func() *appsv1.DaemonSetList { return &appsv1.DaemonSetList{} }, + func(dst, src *appsv1.DaemonSetList) { dst.ListMeta = src.ListMeta }, + func(list *appsv1.DaemonSetList) []*appsv1.DaemonSet { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *appsv1.DaemonSetList, items []*appsv1.DaemonSet) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*appsv1.DaemonSet), err } diff --git a/kubernetes/typed/apps/v1/fake/deployment.go b/kubernetes/typed/apps/v1/fake/deployment.go index 714a1acf7..71c013214 100644 --- a/kubernetes/typed/apps/v1/fake/deployment.go +++ b/kubernetes/typed/apps/v1/fake/deployment.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,234 +14,129 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" + context "context" + json "encoding/json" + fmt "fmt" "github.com/kcp-dev/logicalcluster/v3" appsv1 "k8s.io/api/apps/v1" autoscalingv1 "k8s.io/api/autoscaling/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsappsv1 "k8s.io/client-go/applyconfigurations/apps/v1" + types "k8s.io/apimachinery/pkg/types" + v1 "k8s.io/client-go/applyconfigurations/apps/v1" applyconfigurationsautoscalingv1 "k8s.io/client-go/applyconfigurations/autoscaling/v1" - appsv1client "k8s.io/client-go/kubernetes/typed/apps/v1" - "k8s.io/client-go/testing" + typedappsv1 "k8s.io/client-go/kubernetes/typed/apps/v1" - kcpappsv1 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1" + typedkcpappsv1 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var deploymentsResource = schema.GroupVersionResource{Group: "apps", Version: "v1", Resource: "deployments"} -var deploymentsKind = schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "Deployment"} - -type deploymentsClusterClient struct { - *kcptesting.Fake +// deploymentClusterClient implements DeploymentClusterInterface +type deploymentClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*appsv1.Deployment, *appsv1.DeploymentList] + Fake *kcptesting.Fake } -// Cluster scopes the client down to a particular cluster. -func (c *deploymentsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpappsv1.DeploymentsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") +func newFakeDeploymentClusterClient(fake *AppsV1ClusterClient) typedkcpappsv1.DeploymentClusterInterface { + return &deploymentClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*appsv1.Deployment, *appsv1.DeploymentList]( + fake.Fake, + appsv1.SchemeGroupVersion.WithResource("deployments"), + appsv1.SchemeGroupVersion.WithKind("Deployment"), + func() *appsv1.Deployment { return &appsv1.Deployment{} }, + func() *appsv1.DeploymentList { return &appsv1.DeploymentList{} }, + func(dst, src *appsv1.DeploymentList) { dst.ListMeta = src.ListMeta }, + func(list *appsv1.DeploymentList) []*appsv1.Deployment { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *appsv1.DeploymentList, items []*appsv1.Deployment) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - return &deploymentsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} } -// List takes label and field selectors, and returns the list of Deployments that match those selectors across all clusters. -func (c *deploymentsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*appsv1.DeploymentList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(deploymentsResource, deploymentsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &appsv1.DeploymentList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &appsv1.DeploymentList{ListMeta: obj.(*appsv1.DeploymentList).ListMeta} - for _, item := range obj.(*appsv1.DeploymentList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err +func (c *deploymentClusterClient) Cluster(cluster logicalcluster.Path) typedkcpappsv1.DeploymentsNamespacer { + return &deploymentNamespacer{Fake: c.Fake, ClusterPath: cluster} } -// Watch returns a watch.Interface that watches the requested Deployments across all clusters. -func (c *deploymentsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(deploymentsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) -} - -type deploymentsNamespacer struct { +type deploymentNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *deploymentsNamespacer) Namespace(namespace string) appsv1client.DeploymentInterface { - return &deploymentsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *deploymentNamespacer) Namespace(namespace string) typedappsv1.DeploymentInterface { + return newFakeDeploymentClient(n.Fake, namespace, n.ClusterPath) } -type deploymentsClient struct { - *kcptesting.Fake +// deploymentScopedClient implements DeploymentInterface +type deploymentScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*appsv1.Deployment, *appsv1.DeploymentList, *v1.DeploymentApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *deploymentsClient) Create(ctx context.Context, deployment *appsv1.Deployment, opts metav1.CreateOptions) (*appsv1.Deployment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(deploymentsResource, c.ClusterPath, c.Namespace, deployment), &appsv1.Deployment{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1.Deployment), err -} - -func (c *deploymentsClient) Update(ctx context.Context, deployment *appsv1.Deployment, opts metav1.UpdateOptions) (*appsv1.Deployment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(deploymentsResource, c.ClusterPath, c.Namespace, deployment), &appsv1.Deployment{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1.Deployment), err -} - -func (c *deploymentsClient) UpdateStatus(ctx context.Context, deployment *appsv1.Deployment, opts metav1.UpdateOptions) (*appsv1.Deployment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(deploymentsResource, c.ClusterPath, "status", c.Namespace, deployment), &appsv1.Deployment{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1.Deployment), err -} - -func (c *deploymentsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(deploymentsResource, c.ClusterPath, c.Namespace, name, opts), &appsv1.Deployment{}) - return err -} - -func (c *deploymentsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(deploymentsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &appsv1.DeploymentList{}) - return err -} - -func (c *deploymentsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*appsv1.Deployment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(deploymentsResource, c.ClusterPath, c.Namespace, name), &appsv1.Deployment{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1.Deployment), err -} - -// List takes label and field selectors, and returns the list of Deployments that match those selectors. -func (c *deploymentsClient) List(ctx context.Context, opts metav1.ListOptions) (*appsv1.DeploymentList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(deploymentsResource, deploymentsKind, c.ClusterPath, c.Namespace, opts), &appsv1.DeploymentList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &appsv1.DeploymentList{ListMeta: obj.(*appsv1.DeploymentList).ListMeta} - for _, item := range obj.(*appsv1.DeploymentList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *deploymentsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(deploymentsResource, c.ClusterPath, c.Namespace, opts)) -} - -func (c *deploymentsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*appsv1.Deployment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(deploymentsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &appsv1.Deployment{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1.Deployment), err -} - -func (c *deploymentsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsappsv1.DeploymentApplyConfiguration, opts metav1.ApplyOptions) (*appsv1.Deployment, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(deploymentsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &appsv1.Deployment{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1.Deployment), err } -func (c *deploymentsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsappsv1.DeploymentApplyConfiguration, opts metav1.ApplyOptions) (*appsv1.Deployment, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(deploymentsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &appsv1.Deployment{}) +func newFakeDeploymentClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedappsv1.DeploymentInterface { + return &deploymentScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*appsv1.Deployment, *appsv1.DeploymentList, *v1.DeploymentApplyConfiguration]( + fake, + clusterPath, + namespace, + appsv1.SchemeGroupVersion.WithResource("deployments"), + appsv1.SchemeGroupVersion.WithKind("Deployment"), + func() *appsv1.Deployment { return &appsv1.Deployment{} }, + func() *appsv1.DeploymentList { return &appsv1.DeploymentList{} }, + func(dst, src *appsv1.DeploymentList) { dst.ListMeta = src.ListMeta }, + func(list *appsv1.DeploymentList) []*appsv1.Deployment { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *appsv1.DeploymentList, items []*appsv1.Deployment) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, + } +} + +// GetScale takes name of the deployment, and returns the corresponding scale object, and an error if there is any. +func (c *deploymentScopedClient) GetScale(ctx context.Context, deploymentName string, _ metav1.GetOptions) (result *autoscalingv1.Scale, err error) { + emptyResult := &autoscalingv1.Scale{} + obj, err := c.Fake.Invokes(kcptesting.NewGetSubresourceAction(c.Resource(), c.ClusterPath, c.Namespace(), "scale", deploymentName), emptyResult) if obj == nil { - return nil, err - } - return obj.(*appsv1.Deployment), err -} - -func (c *deploymentsClient) GetScale(ctx context.Context, deploymentName string, options metav1.GetOptions) (*autoscalingv1.Scale, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetSubresourceAction(deploymentsResource, c.ClusterPath, "scale", c.Namespace, deploymentName), &autoscalingv1.Scale{}) - if obj == nil { - return nil, err + return emptyResult, err } return obj.(*autoscalingv1.Scale), err } -func (c *deploymentsClient) UpdateScale(ctx context.Context, deploymentName string, scale *autoscalingv1.Scale, opts metav1.UpdateOptions) (*autoscalingv1.Scale, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(deploymentsResource, c.ClusterPath, "scale", c.Namespace, scale), &autoscalingv1.Scale{}) +// UpdateScale takes the representation of a scale and updates it. Returns the server's representation of the scale, and an error, if there is any. +func (c *deploymentScopedClient) UpdateScale(ctx context.Context, deploymentName string, scale *autoscalingv1.Scale, _ metav1.UpdateOptions) (result *autoscalingv1.Scale, err error) { + emptyResult := &autoscalingv1.Scale{} + obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(c.Resource(), c.ClusterPath, "scale", c.Namespace(), scale), &autoscalingv1.Scale{}) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*autoscalingv1.Scale), err } -func (c *deploymentsClient) ApplyScale(ctx context.Context, deploymentName string, applyConfiguration *applyconfigurationsautoscalingv1.ScaleApplyConfiguration, opts metav1.ApplyOptions) (*autoscalingv1.Scale, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") +// ApplyScale takes top resource name and the apply declarative configuration for scale, +// applies it and returns the applied scale, and an error, if there is any. +func (c *deploymentScopedClient) ApplyScale(ctx context.Context, deploymentName string, scale *applyconfigurationsautoscalingv1.ScaleApplyConfiguration, _ metav1.ApplyOptions) (result *autoscalingv1.Scale, err error) { + if scale == nil { + return nil, fmt.Errorf("scale provided to ApplyScale must not be nil") } - data, err := json.Marshal(applyConfiguration) + data, err := json.Marshal(scale) if err != nil { return nil, err } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(deploymentsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &autoscalingv1.Scale{}) + emptyResult := &autoscalingv1.Scale{} + obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(c.Resource(), c.ClusterPath, c.Namespace(), deploymentName, types.ApplyPatchType, data, "scale"), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*autoscalingv1.Scale), err } diff --git a/kubernetes/typed/apps/v1/fake/doc.go b/kubernetes/typed/apps/v1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/apps/v1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/apps/v1/fake/replicaset.go b/kubernetes/typed/apps/v1/fake/replicaset.go index 7526bbf95..191583dcc 100644 --- a/kubernetes/typed/apps/v1/fake/replicaset.go +++ b/kubernetes/typed/apps/v1/fake/replicaset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,234 +14,129 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" + context "context" + json "encoding/json" + fmt "fmt" "github.com/kcp-dev/logicalcluster/v3" appsv1 "k8s.io/api/apps/v1" autoscalingv1 "k8s.io/api/autoscaling/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsappsv1 "k8s.io/client-go/applyconfigurations/apps/v1" + types "k8s.io/apimachinery/pkg/types" + v1 "k8s.io/client-go/applyconfigurations/apps/v1" applyconfigurationsautoscalingv1 "k8s.io/client-go/applyconfigurations/autoscaling/v1" - appsv1client "k8s.io/client-go/kubernetes/typed/apps/v1" - "k8s.io/client-go/testing" + typedappsv1 "k8s.io/client-go/kubernetes/typed/apps/v1" - kcpappsv1 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1" + typedkcpappsv1 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var replicaSetsResource = schema.GroupVersionResource{Group: "apps", Version: "v1", Resource: "replicasets"} -var replicaSetsKind = schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "ReplicaSet"} - -type replicaSetsClusterClient struct { - *kcptesting.Fake +// replicaSetClusterClient implements ReplicaSetClusterInterface +type replicaSetClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*appsv1.ReplicaSet, *appsv1.ReplicaSetList] + Fake *kcptesting.Fake } -// Cluster scopes the client down to a particular cluster. -func (c *replicaSetsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpappsv1.ReplicaSetsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") +func newFakeReplicaSetClusterClient(fake *AppsV1ClusterClient) typedkcpappsv1.ReplicaSetClusterInterface { + return &replicaSetClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*appsv1.ReplicaSet, *appsv1.ReplicaSetList]( + fake.Fake, + appsv1.SchemeGroupVersion.WithResource("replicasets"), + appsv1.SchemeGroupVersion.WithKind("ReplicaSet"), + func() *appsv1.ReplicaSet { return &appsv1.ReplicaSet{} }, + func() *appsv1.ReplicaSetList { return &appsv1.ReplicaSetList{} }, + func(dst, src *appsv1.ReplicaSetList) { dst.ListMeta = src.ListMeta }, + func(list *appsv1.ReplicaSetList) []*appsv1.ReplicaSet { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *appsv1.ReplicaSetList, items []*appsv1.ReplicaSet) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - return &replicaSetsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} } -// List takes label and field selectors, and returns the list of ReplicaSets that match those selectors across all clusters. -func (c *replicaSetsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*appsv1.ReplicaSetList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(replicaSetsResource, replicaSetsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &appsv1.ReplicaSetList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &appsv1.ReplicaSetList{ListMeta: obj.(*appsv1.ReplicaSetList).ListMeta} - for _, item := range obj.(*appsv1.ReplicaSetList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err +func (c *replicaSetClusterClient) Cluster(cluster logicalcluster.Path) typedkcpappsv1.ReplicaSetsNamespacer { + return &replicaSetNamespacer{Fake: c.Fake, ClusterPath: cluster} } -// Watch returns a watch.Interface that watches the requested ReplicaSets across all clusters. -func (c *replicaSetsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(replicaSetsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) -} - -type replicaSetsNamespacer struct { +type replicaSetNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *replicaSetsNamespacer) Namespace(namespace string) appsv1client.ReplicaSetInterface { - return &replicaSetsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *replicaSetNamespacer) Namespace(namespace string) typedappsv1.ReplicaSetInterface { + return newFakeReplicaSetClient(n.Fake, namespace, n.ClusterPath) } -type replicaSetsClient struct { - *kcptesting.Fake +// replicaSetScopedClient implements ReplicaSetInterface +type replicaSetScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*appsv1.ReplicaSet, *appsv1.ReplicaSetList, *v1.ReplicaSetApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *replicaSetsClient) Create(ctx context.Context, replicaSet *appsv1.ReplicaSet, opts metav1.CreateOptions) (*appsv1.ReplicaSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(replicaSetsResource, c.ClusterPath, c.Namespace, replicaSet), &appsv1.ReplicaSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1.ReplicaSet), err -} - -func (c *replicaSetsClient) Update(ctx context.Context, replicaSet *appsv1.ReplicaSet, opts metav1.UpdateOptions) (*appsv1.ReplicaSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(replicaSetsResource, c.ClusterPath, c.Namespace, replicaSet), &appsv1.ReplicaSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1.ReplicaSet), err -} - -func (c *replicaSetsClient) UpdateStatus(ctx context.Context, replicaSet *appsv1.ReplicaSet, opts metav1.UpdateOptions) (*appsv1.ReplicaSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(replicaSetsResource, c.ClusterPath, "status", c.Namespace, replicaSet), &appsv1.ReplicaSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1.ReplicaSet), err -} - -func (c *replicaSetsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(replicaSetsResource, c.ClusterPath, c.Namespace, name, opts), &appsv1.ReplicaSet{}) - return err -} - -func (c *replicaSetsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(replicaSetsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &appsv1.ReplicaSetList{}) - return err -} - -func (c *replicaSetsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*appsv1.ReplicaSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(replicaSetsResource, c.ClusterPath, c.Namespace, name), &appsv1.ReplicaSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1.ReplicaSet), err -} - -// List takes label and field selectors, and returns the list of ReplicaSets that match those selectors. -func (c *replicaSetsClient) List(ctx context.Context, opts metav1.ListOptions) (*appsv1.ReplicaSetList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(replicaSetsResource, replicaSetsKind, c.ClusterPath, c.Namespace, opts), &appsv1.ReplicaSetList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &appsv1.ReplicaSetList{ListMeta: obj.(*appsv1.ReplicaSetList).ListMeta} - for _, item := range obj.(*appsv1.ReplicaSetList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *replicaSetsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(replicaSetsResource, c.ClusterPath, c.Namespace, opts)) -} - -func (c *replicaSetsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*appsv1.ReplicaSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(replicaSetsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &appsv1.ReplicaSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1.ReplicaSet), err -} - -func (c *replicaSetsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsappsv1.ReplicaSetApplyConfiguration, opts metav1.ApplyOptions) (*appsv1.ReplicaSet, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(replicaSetsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &appsv1.ReplicaSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1.ReplicaSet), err } -func (c *replicaSetsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsappsv1.ReplicaSetApplyConfiguration, opts metav1.ApplyOptions) (*appsv1.ReplicaSet, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(replicaSetsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &appsv1.ReplicaSet{}) +func newFakeReplicaSetClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedappsv1.ReplicaSetInterface { + return &replicaSetScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*appsv1.ReplicaSet, *appsv1.ReplicaSetList, *v1.ReplicaSetApplyConfiguration]( + fake, + clusterPath, + namespace, + appsv1.SchemeGroupVersion.WithResource("replicasets"), + appsv1.SchemeGroupVersion.WithKind("ReplicaSet"), + func() *appsv1.ReplicaSet { return &appsv1.ReplicaSet{} }, + func() *appsv1.ReplicaSetList { return &appsv1.ReplicaSetList{} }, + func(dst, src *appsv1.ReplicaSetList) { dst.ListMeta = src.ListMeta }, + func(list *appsv1.ReplicaSetList) []*appsv1.ReplicaSet { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *appsv1.ReplicaSetList, items []*appsv1.ReplicaSet) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, + } +} + +// GetScale takes name of the replicaSet, and returns the corresponding scale object, and an error if there is any. +func (c *replicaSetScopedClient) GetScale(ctx context.Context, replicaSetName string, _ metav1.GetOptions) (result *autoscalingv1.Scale, err error) { + emptyResult := &autoscalingv1.Scale{} + obj, err := c.Fake.Invokes(kcptesting.NewGetSubresourceAction(c.Resource(), c.ClusterPath, c.Namespace(), "scale", replicaSetName), emptyResult) if obj == nil { - return nil, err - } - return obj.(*appsv1.ReplicaSet), err -} - -func (c *replicaSetsClient) GetScale(ctx context.Context, replicaSetName string, options metav1.GetOptions) (*autoscalingv1.Scale, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetSubresourceAction(replicaSetsResource, c.ClusterPath, "scale", c.Namespace, replicaSetName), &autoscalingv1.Scale{}) - if obj == nil { - return nil, err + return emptyResult, err } return obj.(*autoscalingv1.Scale), err } -func (c *replicaSetsClient) UpdateScale(ctx context.Context, replicaSetName string, scale *autoscalingv1.Scale, opts metav1.UpdateOptions) (*autoscalingv1.Scale, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(replicaSetsResource, c.ClusterPath, "scale", c.Namespace, scale), &autoscalingv1.Scale{}) +// UpdateScale takes the representation of a scale and updates it. Returns the server's representation of the scale, and an error, if there is any. +func (c *replicaSetScopedClient) UpdateScale(ctx context.Context, replicaSetName string, scale *autoscalingv1.Scale, _ metav1.UpdateOptions) (result *autoscalingv1.Scale, err error) { + emptyResult := &autoscalingv1.Scale{} + obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(c.Resource(), c.ClusterPath, "scale", c.Namespace(), scale), &autoscalingv1.Scale{}) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*autoscalingv1.Scale), err } -func (c *replicaSetsClient) ApplyScale(ctx context.Context, replicaSetName string, applyConfiguration *applyconfigurationsautoscalingv1.ScaleApplyConfiguration, opts metav1.ApplyOptions) (*autoscalingv1.Scale, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") +// ApplyScale takes top resource name and the apply declarative configuration for scale, +// applies it and returns the applied scale, and an error, if there is any. +func (c *replicaSetScopedClient) ApplyScale(ctx context.Context, replicaSetName string, scale *applyconfigurationsautoscalingv1.ScaleApplyConfiguration, _ metav1.ApplyOptions) (result *autoscalingv1.Scale, err error) { + if scale == nil { + return nil, fmt.Errorf("scale provided to ApplyScale must not be nil") } - data, err := json.Marshal(applyConfiguration) + data, err := json.Marshal(scale) if err != nil { return nil, err } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(replicaSetsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &autoscalingv1.Scale{}) + emptyResult := &autoscalingv1.Scale{} + obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(c.Resource(), c.ClusterPath, c.Namespace(), replicaSetName, types.ApplyPatchType, data, "scale"), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*autoscalingv1.Scale), err } diff --git a/kubernetes/typed/apps/v1/fake/statefulset.go b/kubernetes/typed/apps/v1/fake/statefulset.go index 00ac02909..9a68141b9 100644 --- a/kubernetes/typed/apps/v1/fake/statefulset.go +++ b/kubernetes/typed/apps/v1/fake/statefulset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,234 +14,129 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" + context "context" + json "encoding/json" + fmt "fmt" "github.com/kcp-dev/logicalcluster/v3" appsv1 "k8s.io/api/apps/v1" autoscalingv1 "k8s.io/api/autoscaling/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsappsv1 "k8s.io/client-go/applyconfigurations/apps/v1" + types "k8s.io/apimachinery/pkg/types" + v1 "k8s.io/client-go/applyconfigurations/apps/v1" applyconfigurationsautoscalingv1 "k8s.io/client-go/applyconfigurations/autoscaling/v1" - appsv1client "k8s.io/client-go/kubernetes/typed/apps/v1" - "k8s.io/client-go/testing" + typedappsv1 "k8s.io/client-go/kubernetes/typed/apps/v1" - kcpappsv1 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1" + typedkcpappsv1 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var statefulSetsResource = schema.GroupVersionResource{Group: "apps", Version: "v1", Resource: "statefulsets"} -var statefulSetsKind = schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "StatefulSet"} - -type statefulSetsClusterClient struct { - *kcptesting.Fake +// statefulSetClusterClient implements StatefulSetClusterInterface +type statefulSetClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*appsv1.StatefulSet, *appsv1.StatefulSetList] + Fake *kcptesting.Fake } -// Cluster scopes the client down to a particular cluster. -func (c *statefulSetsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpappsv1.StatefulSetsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") +func newFakeStatefulSetClusterClient(fake *AppsV1ClusterClient) typedkcpappsv1.StatefulSetClusterInterface { + return &statefulSetClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*appsv1.StatefulSet, *appsv1.StatefulSetList]( + fake.Fake, + appsv1.SchemeGroupVersion.WithResource("statefulsets"), + appsv1.SchemeGroupVersion.WithKind("StatefulSet"), + func() *appsv1.StatefulSet { return &appsv1.StatefulSet{} }, + func() *appsv1.StatefulSetList { return &appsv1.StatefulSetList{} }, + func(dst, src *appsv1.StatefulSetList) { dst.ListMeta = src.ListMeta }, + func(list *appsv1.StatefulSetList) []*appsv1.StatefulSet { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *appsv1.StatefulSetList, items []*appsv1.StatefulSet) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - return &statefulSetsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} } -// List takes label and field selectors, and returns the list of StatefulSets that match those selectors across all clusters. -func (c *statefulSetsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*appsv1.StatefulSetList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(statefulSetsResource, statefulSetsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &appsv1.StatefulSetList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &appsv1.StatefulSetList{ListMeta: obj.(*appsv1.StatefulSetList).ListMeta} - for _, item := range obj.(*appsv1.StatefulSetList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err +func (c *statefulSetClusterClient) Cluster(cluster logicalcluster.Path) typedkcpappsv1.StatefulSetsNamespacer { + return &statefulSetNamespacer{Fake: c.Fake, ClusterPath: cluster} } -// Watch returns a watch.Interface that watches the requested StatefulSets across all clusters. -func (c *statefulSetsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(statefulSetsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) -} - -type statefulSetsNamespacer struct { +type statefulSetNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *statefulSetsNamespacer) Namespace(namespace string) appsv1client.StatefulSetInterface { - return &statefulSetsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *statefulSetNamespacer) Namespace(namespace string) typedappsv1.StatefulSetInterface { + return newFakeStatefulSetClient(n.Fake, namespace, n.ClusterPath) } -type statefulSetsClient struct { - *kcptesting.Fake +// statefulSetScopedClient implements StatefulSetInterface +type statefulSetScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*appsv1.StatefulSet, *appsv1.StatefulSetList, *v1.StatefulSetApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *statefulSetsClient) Create(ctx context.Context, statefulSet *appsv1.StatefulSet, opts metav1.CreateOptions) (*appsv1.StatefulSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(statefulSetsResource, c.ClusterPath, c.Namespace, statefulSet), &appsv1.StatefulSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1.StatefulSet), err -} - -func (c *statefulSetsClient) Update(ctx context.Context, statefulSet *appsv1.StatefulSet, opts metav1.UpdateOptions) (*appsv1.StatefulSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(statefulSetsResource, c.ClusterPath, c.Namespace, statefulSet), &appsv1.StatefulSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1.StatefulSet), err -} - -func (c *statefulSetsClient) UpdateStatus(ctx context.Context, statefulSet *appsv1.StatefulSet, opts metav1.UpdateOptions) (*appsv1.StatefulSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(statefulSetsResource, c.ClusterPath, "status", c.Namespace, statefulSet), &appsv1.StatefulSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1.StatefulSet), err -} - -func (c *statefulSetsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(statefulSetsResource, c.ClusterPath, c.Namespace, name, opts), &appsv1.StatefulSet{}) - return err -} - -func (c *statefulSetsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(statefulSetsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &appsv1.StatefulSetList{}) - return err -} - -func (c *statefulSetsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*appsv1.StatefulSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(statefulSetsResource, c.ClusterPath, c.Namespace, name), &appsv1.StatefulSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1.StatefulSet), err -} - -// List takes label and field selectors, and returns the list of StatefulSets that match those selectors. -func (c *statefulSetsClient) List(ctx context.Context, opts metav1.ListOptions) (*appsv1.StatefulSetList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(statefulSetsResource, statefulSetsKind, c.ClusterPath, c.Namespace, opts), &appsv1.StatefulSetList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &appsv1.StatefulSetList{ListMeta: obj.(*appsv1.StatefulSetList).ListMeta} - for _, item := range obj.(*appsv1.StatefulSetList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *statefulSetsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(statefulSetsResource, c.ClusterPath, c.Namespace, opts)) -} - -func (c *statefulSetsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*appsv1.StatefulSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(statefulSetsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &appsv1.StatefulSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1.StatefulSet), err -} - -func (c *statefulSetsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsappsv1.StatefulSetApplyConfiguration, opts metav1.ApplyOptions) (*appsv1.StatefulSet, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(statefulSetsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &appsv1.StatefulSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1.StatefulSet), err } -func (c *statefulSetsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsappsv1.StatefulSetApplyConfiguration, opts metav1.ApplyOptions) (*appsv1.StatefulSet, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(statefulSetsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &appsv1.StatefulSet{}) +func newFakeStatefulSetClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedappsv1.StatefulSetInterface { + return &statefulSetScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*appsv1.StatefulSet, *appsv1.StatefulSetList, *v1.StatefulSetApplyConfiguration]( + fake, + clusterPath, + namespace, + appsv1.SchemeGroupVersion.WithResource("statefulsets"), + appsv1.SchemeGroupVersion.WithKind("StatefulSet"), + func() *appsv1.StatefulSet { return &appsv1.StatefulSet{} }, + func() *appsv1.StatefulSetList { return &appsv1.StatefulSetList{} }, + func(dst, src *appsv1.StatefulSetList) { dst.ListMeta = src.ListMeta }, + func(list *appsv1.StatefulSetList) []*appsv1.StatefulSet { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *appsv1.StatefulSetList, items []*appsv1.StatefulSet) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, + } +} + +// GetScale takes name of the statefulSet, and returns the corresponding scale object, and an error if there is any. +func (c *statefulSetScopedClient) GetScale(ctx context.Context, statefulSetName string, _ metav1.GetOptions) (result *autoscalingv1.Scale, err error) { + emptyResult := &autoscalingv1.Scale{} + obj, err := c.Fake.Invokes(kcptesting.NewGetSubresourceAction(c.Resource(), c.ClusterPath, c.Namespace(), "scale", statefulSetName), emptyResult) if obj == nil { - return nil, err - } - return obj.(*appsv1.StatefulSet), err -} - -func (c *statefulSetsClient) GetScale(ctx context.Context, statefulSetName string, options metav1.GetOptions) (*autoscalingv1.Scale, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetSubresourceAction(statefulSetsResource, c.ClusterPath, "scale", c.Namespace, statefulSetName), &autoscalingv1.Scale{}) - if obj == nil { - return nil, err + return emptyResult, err } return obj.(*autoscalingv1.Scale), err } -func (c *statefulSetsClient) UpdateScale(ctx context.Context, statefulSetName string, scale *autoscalingv1.Scale, opts metav1.UpdateOptions) (*autoscalingv1.Scale, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(statefulSetsResource, c.ClusterPath, "scale", c.Namespace, scale), &autoscalingv1.Scale{}) +// UpdateScale takes the representation of a scale and updates it. Returns the server's representation of the scale, and an error, if there is any. +func (c *statefulSetScopedClient) UpdateScale(ctx context.Context, statefulSetName string, scale *autoscalingv1.Scale, _ metav1.UpdateOptions) (result *autoscalingv1.Scale, err error) { + emptyResult := &autoscalingv1.Scale{} + obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(c.Resource(), c.ClusterPath, "scale", c.Namespace(), scale), &autoscalingv1.Scale{}) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*autoscalingv1.Scale), err } -func (c *statefulSetsClient) ApplyScale(ctx context.Context, statefulSetName string, applyConfiguration *applyconfigurationsautoscalingv1.ScaleApplyConfiguration, opts metav1.ApplyOptions) (*autoscalingv1.Scale, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") +// ApplyScale takes top resource name and the apply declarative configuration for scale, +// applies it and returns the applied scale, and an error, if there is any. +func (c *statefulSetScopedClient) ApplyScale(ctx context.Context, statefulSetName string, scale *applyconfigurationsautoscalingv1.ScaleApplyConfiguration, _ metav1.ApplyOptions) (result *autoscalingv1.Scale, err error) { + if scale == nil { + return nil, fmt.Errorf("scale provided to ApplyScale must not be nil") } - data, err := json.Marshal(applyConfiguration) + data, err := json.Marshal(scale) if err != nil { return nil, err } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(statefulSetsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &autoscalingv1.Scale{}) + emptyResult := &autoscalingv1.Scale{} + obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(c.Resource(), c.ClusterPath, c.Namespace(), statefulSetName, types.ApplyPatchType, data, "scale"), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*autoscalingv1.Scale), err } diff --git a/kubernetes/typed/apps/v1/generated_expansion.go b/kubernetes/typed/apps/v1/generated_expansion.go new file mode 100644 index 000000000..69ab8c915 --- /dev/null +++ b/kubernetes/typed/apps/v1/generated_expansion.go @@ -0,0 +1,29 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1 + +type ControllerRevisionClusterExpansion interface{} + +type DaemonSetClusterExpansion interface{} + +type DeploymentClusterExpansion interface{} + +type ReplicaSetClusterExpansion interface{} + +type StatefulSetClusterExpansion interface{} diff --git a/kubernetes/typed/apps/v1/replicaset.go b/kubernetes/typed/apps/v1/replicaset.go index 0ca6cbc86..37a1401f0 100644 --- a/kubernetes/typed/apps/v1/replicaset.go +++ b/kubernetes/typed/apps/v1/replicaset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" appsv1 "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - appsv1client "k8s.io/client-go/kubernetes/typed/apps/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedappsv1 "k8s.io/client-go/kubernetes/typed/apps/v1" ) // ReplicaSetsClusterGetter has a method to return a ReplicaSetClusterInterface. @@ -42,10 +42,11 @@ type ReplicaSetClusterInterface interface { Cluster(logicalcluster.Path) ReplicaSetsNamespacer List(ctx context.Context, opts metav1.ListOptions) (*appsv1.ReplicaSetList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + ReplicaSetClusterExpansion } type replicaSetsClusterInterface struct { - clientCache kcpclient.Cache[*appsv1client.AppsV1Client] + clientCache kcpclient.Cache[*typedappsv1.AppsV1Client] } // Cluster scopes the client down to a particular cluster. @@ -67,16 +68,16 @@ func (c *replicaSetsClusterInterface) Watch(ctx context.Context, opts metav1.Lis return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ReplicaSets(metav1.NamespaceAll).Watch(ctx, opts) } -// ReplicaSetsNamespacer can scope to objects within a namespace, returning a appsv1client.ReplicaSetInterface. +// ReplicaSetsNamespacer can scope to objects within a namespace, returning a typedappsv1.ReplicaSetInterface. type ReplicaSetsNamespacer interface { - Namespace(string) appsv1client.ReplicaSetInterface + Namespace(string) typedappsv1.ReplicaSetInterface } type replicaSetsNamespacer struct { - clientCache kcpclient.Cache[*appsv1client.AppsV1Client] + clientCache kcpclient.Cache[*typedappsv1.AppsV1Client] clusterPath logicalcluster.Path } -func (n *replicaSetsNamespacer) Namespace(namespace string) appsv1client.ReplicaSetInterface { +func (n *replicaSetsNamespacer) Namespace(namespace string) typedappsv1.ReplicaSetInterface { return n.clientCache.ClusterOrDie(n.clusterPath).ReplicaSets(namespace) } diff --git a/kubernetes/typed/apps/v1/statefulset.go b/kubernetes/typed/apps/v1/statefulset.go index c08f944e1..9ebf5392d 100644 --- a/kubernetes/typed/apps/v1/statefulset.go +++ b/kubernetes/typed/apps/v1/statefulset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" appsv1 "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - appsv1client "k8s.io/client-go/kubernetes/typed/apps/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedappsv1 "k8s.io/client-go/kubernetes/typed/apps/v1" ) // StatefulSetsClusterGetter has a method to return a StatefulSetClusterInterface. @@ -42,10 +42,11 @@ type StatefulSetClusterInterface interface { Cluster(logicalcluster.Path) StatefulSetsNamespacer List(ctx context.Context, opts metav1.ListOptions) (*appsv1.StatefulSetList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + StatefulSetClusterExpansion } type statefulSetsClusterInterface struct { - clientCache kcpclient.Cache[*appsv1client.AppsV1Client] + clientCache kcpclient.Cache[*typedappsv1.AppsV1Client] } // Cluster scopes the client down to a particular cluster. @@ -67,16 +68,16 @@ func (c *statefulSetsClusterInterface) Watch(ctx context.Context, opts metav1.Li return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).StatefulSets(metav1.NamespaceAll).Watch(ctx, opts) } -// StatefulSetsNamespacer can scope to objects within a namespace, returning a appsv1client.StatefulSetInterface. +// StatefulSetsNamespacer can scope to objects within a namespace, returning a typedappsv1.StatefulSetInterface. type StatefulSetsNamespacer interface { - Namespace(string) appsv1client.StatefulSetInterface + Namespace(string) typedappsv1.StatefulSetInterface } type statefulSetsNamespacer struct { - clientCache kcpclient.Cache[*appsv1client.AppsV1Client] + clientCache kcpclient.Cache[*typedappsv1.AppsV1Client] clusterPath logicalcluster.Path } -func (n *statefulSetsNamespacer) Namespace(namespace string) appsv1client.StatefulSetInterface { +func (n *statefulSetsNamespacer) Namespace(namespace string) typedappsv1.StatefulSetInterface { return n.clientCache.ClusterOrDie(n.clusterPath).StatefulSets(namespace) } diff --git a/kubernetes/typed/apps/v1beta1/apps_client.go b/kubernetes/typed/apps/v1beta1/apps_client.go index 6d16cd61c..d438bb89f 100644 --- a/kubernetes/typed/apps/v1beta1/apps_client.go +++ b/kubernetes/typed/apps/v1beta1/apps_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,31 +14,35 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apiappsv1beta1 "k8s.io/api/apps/v1beta1" appsv1beta1 "k8s.io/client-go/kubernetes/typed/apps/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type AppsV1beta1ClusterInterface interface { AppsV1beta1ClusterScoper - StatefulSetsClusterGetter - DeploymentsClusterGetter ControllerRevisionsClusterGetter + DeploymentsClusterGetter + StatefulSetsClusterGetter } type AppsV1beta1ClusterScoper interface { Cluster(logicalcluster.Path) appsv1beta1.AppsV1beta1Interface } +// AppsV1beta1ClusterClient is used to interact with features provided by the apps group. type AppsV1beta1ClusterClient struct { clientCache kcpclient.Cache[*appsv1beta1.AppsV1beta1Client] } @@ -50,27 +54,29 @@ func (c *AppsV1beta1ClusterClient) Cluster(clusterPath logicalcluster.Path) apps return c.clientCache.ClusterOrDie(clusterPath) } -func (c *AppsV1beta1ClusterClient) StatefulSets() StatefulSetClusterInterface { - return &statefulSetsClusterInterface{clientCache: c.clientCache} +func (c *AppsV1beta1ClusterClient) ControllerRevisions() ControllerRevisionClusterInterface { + return &controllerRevisionsClusterInterface{clientCache: c.clientCache} } func (c *AppsV1beta1ClusterClient) Deployments() DeploymentClusterInterface { return &deploymentsClusterInterface{clientCache: c.clientCache} } -func (c *AppsV1beta1ClusterClient) ControllerRevisions() ControllerRevisionClusterInterface { - return &controllerRevisionsClusterInterface{clientCache: c.clientCache} +func (c *AppsV1beta1ClusterClient) StatefulSets() StatefulSetClusterInterface { + return &statefulSetsClusterInterface{clientCache: c.clientCache} } // NewForConfig creates a new AppsV1beta1ClusterClient for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*AppsV1beta1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new AppsV1beta1ClusterClient for the given config and http client. @@ -82,6 +88,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*AppsV1beta1ClusterC if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &AppsV1beta1ClusterClient{clientCache: cache}, nil } @@ -94,3 +101,14 @@ func NewForConfigOrDie(c *rest.Config) *AppsV1beta1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apiappsv1beta1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/apps/v1beta1/controllerrevision.go b/kubernetes/typed/apps/v1beta1/controllerrevision.go index d96506985..d6e0a2933 100644 --- a/kubernetes/typed/apps/v1beta1/controllerrevision.go +++ b/kubernetes/typed/apps/v1beta1/controllerrevision.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" appsv1beta1 "k8s.io/api/apps/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - appsv1beta1client "k8s.io/client-go/kubernetes/typed/apps/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedappsv1beta1 "k8s.io/client-go/kubernetes/typed/apps/v1beta1" ) // ControllerRevisionsClusterGetter has a method to return a ControllerRevisionClusterInterface. @@ -40,12 +40,13 @@ type ControllerRevisionsClusterGetter interface { // or scope down to one cluster and return a ControllerRevisionsNamespacer. type ControllerRevisionClusterInterface interface { Cluster(logicalcluster.Path) ControllerRevisionsNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta1.ControllerRevisionList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*appsv1beta1.ControllerRevisionList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + ControllerRevisionClusterExpansion } type controllerRevisionsClusterInterface struct { - clientCache kcpclient.Cache[*appsv1beta1client.AppsV1beta1Client] + clientCache kcpclient.Cache[*typedappsv1beta1.AppsV1beta1Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *controllerRevisionsClusterInterface) Cluster(clusterPath logicalcluster } // List returns the entire collection of all ControllerRevisions across all clusters. -func (c *controllerRevisionsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta1.ControllerRevisionList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ControllerRevisions(metav1.NamespaceAll).List(ctx, opts) +func (c *controllerRevisionsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*appsv1beta1.ControllerRevisionList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ControllerRevisions(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all ControllerRevisions across all clusters. -func (c *controllerRevisionsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ControllerRevisions(metav1.NamespaceAll).Watch(ctx, opts) +func (c *controllerRevisionsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ControllerRevisions(v1.NamespaceAll).Watch(ctx, opts) } -// ControllerRevisionsNamespacer can scope to objects within a namespace, returning a appsv1beta1client.ControllerRevisionInterface. +// ControllerRevisionsNamespacer can scope to objects within a namespace, returning a typedappsv1beta1.ControllerRevisionInterface. type ControllerRevisionsNamespacer interface { - Namespace(string) appsv1beta1client.ControllerRevisionInterface + Namespace(string) typedappsv1beta1.ControllerRevisionInterface } type controllerRevisionsNamespacer struct { - clientCache kcpclient.Cache[*appsv1beta1client.AppsV1beta1Client] + clientCache kcpclient.Cache[*typedappsv1beta1.AppsV1beta1Client] clusterPath logicalcluster.Path } -func (n *controllerRevisionsNamespacer) Namespace(namespace string) appsv1beta1client.ControllerRevisionInterface { +func (n *controllerRevisionsNamespacer) Namespace(namespace string) typedappsv1beta1.ControllerRevisionInterface { return n.clientCache.ClusterOrDie(n.clusterPath).ControllerRevisions(namespace) } diff --git a/kubernetes/typed/apps/v1beta1/deployment.go b/kubernetes/typed/apps/v1beta1/deployment.go index c24669eb2..9bbf40ed0 100644 --- a/kubernetes/typed/apps/v1beta1/deployment.go +++ b/kubernetes/typed/apps/v1beta1/deployment.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" appsv1beta1 "k8s.io/api/apps/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - appsv1beta1client "k8s.io/client-go/kubernetes/typed/apps/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedappsv1beta1 "k8s.io/client-go/kubernetes/typed/apps/v1beta1" ) // DeploymentsClusterGetter has a method to return a DeploymentClusterInterface. @@ -40,12 +40,13 @@ type DeploymentsClusterGetter interface { // or scope down to one cluster and return a DeploymentsNamespacer. type DeploymentClusterInterface interface { Cluster(logicalcluster.Path) DeploymentsNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta1.DeploymentList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*appsv1beta1.DeploymentList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + DeploymentClusterExpansion } type deploymentsClusterInterface struct { - clientCache kcpclient.Cache[*appsv1beta1client.AppsV1beta1Client] + clientCache kcpclient.Cache[*typedappsv1beta1.AppsV1beta1Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *deploymentsClusterInterface) Cluster(clusterPath logicalcluster.Path) D } // List returns the entire collection of all Deployments across all clusters. -func (c *deploymentsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta1.DeploymentList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Deployments(metav1.NamespaceAll).List(ctx, opts) +func (c *deploymentsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*appsv1beta1.DeploymentList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Deployments(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all Deployments across all clusters. -func (c *deploymentsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Deployments(metav1.NamespaceAll).Watch(ctx, opts) +func (c *deploymentsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Deployments(v1.NamespaceAll).Watch(ctx, opts) } -// DeploymentsNamespacer can scope to objects within a namespace, returning a appsv1beta1client.DeploymentInterface. +// DeploymentsNamespacer can scope to objects within a namespace, returning a typedappsv1beta1.DeploymentInterface. type DeploymentsNamespacer interface { - Namespace(string) appsv1beta1client.DeploymentInterface + Namespace(string) typedappsv1beta1.DeploymentInterface } type deploymentsNamespacer struct { - clientCache kcpclient.Cache[*appsv1beta1client.AppsV1beta1Client] + clientCache kcpclient.Cache[*typedappsv1beta1.AppsV1beta1Client] clusterPath logicalcluster.Path } -func (n *deploymentsNamespacer) Namespace(namespace string) appsv1beta1client.DeploymentInterface { +func (n *deploymentsNamespacer) Namespace(namespace string) typedappsv1beta1.DeploymentInterface { return n.clientCache.ClusterOrDie(n.clusterPath).Deployments(namespace) } diff --git a/kubernetes/typed/apps/v1beta1/doc.go b/kubernetes/typed/apps/v1beta1/doc.go new file mode 100644 index 000000000..541e9d258 --- /dev/null +++ b/kubernetes/typed/apps/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1beta1 diff --git a/kubernetes/typed/apps/v1beta1/fake/apps_client.go b/kubernetes/typed/apps/v1beta1/fake/apps_client.go index b60c4858e..f94125843 100644 --- a/kubernetes/typed/apps/v1beta1/fake/apps_client.go +++ b/kubernetes/typed/apps/v1beta1/fake/apps_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" appsv1beta1 "k8s.io/client-go/kubernetes/typed/apps/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpappsv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1beta1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -41,38 +41,38 @@ func (c *AppsV1beta1ClusterClient) Cluster(clusterPath logicalcluster.Path) apps return &AppsV1beta1Client{Fake: c.Fake, ClusterPath: clusterPath} } -func (c *AppsV1beta1ClusterClient) StatefulSets() kcpappsv1beta1.StatefulSetClusterInterface { - return &statefulSetsClusterClient{Fake: c.Fake} +func (c *AppsV1beta1ClusterClient) ControllerRevisions() kcpappsv1beta1.ControllerRevisionClusterInterface { + return newFakeControllerRevisionClusterClient(c) } func (c *AppsV1beta1ClusterClient) Deployments() kcpappsv1beta1.DeploymentClusterInterface { - return &deploymentsClusterClient{Fake: c.Fake} + return newFakeDeploymentClusterClient(c) } -func (c *AppsV1beta1ClusterClient) ControllerRevisions() kcpappsv1beta1.ControllerRevisionClusterInterface { - return &controllerRevisionsClusterClient{Fake: c.Fake} +func (c *AppsV1beta1ClusterClient) StatefulSets() kcpappsv1beta1.StatefulSetClusterInterface { + return newFakeStatefulSetClusterClient(c) } -var _ appsv1beta1.AppsV1beta1Interface = (*AppsV1beta1Client)(nil) - type AppsV1beta1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *AppsV1beta1Client) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret +func (c *AppsV1beta1Client) ControllerRevisions(namespace string) appsv1beta1.ControllerRevisionInterface { + return newFakeControllerRevisionClient(c.Fake, namespace, c.ClusterPath) } -func (c *AppsV1beta1Client) StatefulSets(namespace string) appsv1beta1.StatefulSetInterface { - return &statefulSetsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *AppsV1beta1Client) Deployments(namespace string) appsv1beta1.DeploymentInterface { + return newFakeDeploymentClient(c.Fake, namespace, c.ClusterPath) } -func (c *AppsV1beta1Client) Deployments(namespace string) appsv1beta1.DeploymentInterface { - return &deploymentsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *AppsV1beta1Client) StatefulSets(namespace string) appsv1beta1.StatefulSetInterface { + return newFakeStatefulSetClient(c.Fake, namespace, c.ClusterPath) } -func (c *AppsV1beta1Client) ControllerRevisions(namespace string) appsv1beta1.ControllerRevisionInterface { - return &controllerRevisionsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *AppsV1beta1Client) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret } diff --git a/kubernetes/typed/apps/v1beta1/fake/controllerrevision.go b/kubernetes/typed/apps/v1beta1/fake/controllerrevision.go index f1d1b693f..116c57b36 100644 --- a/kubernetes/typed/apps/v1beta1/fake/controllerrevision.go +++ b/kubernetes/typed/apps/v1beta1/fake/controllerrevision.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" appsv1beta1 "k8s.io/api/apps/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsappsv1beta1 "k8s.io/client-go/applyconfigurations/apps/v1beta1" - appsv1beta1client "k8s.io/client-go/kubernetes/typed/apps/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/apps/v1beta1" + typedappsv1beta1 "k8s.io/client-go/kubernetes/typed/apps/v1beta1" - kcpappsv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1beta1" + typedkcpappsv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var controllerRevisionsResource = schema.GroupVersionResource{Group: "apps", Version: "v1beta1", Resource: "controllerrevisions"} -var controllerRevisionsKind = schema.GroupVersionKind{Group: "apps", Version: "v1beta1", Kind: "ControllerRevision"} - -type controllerRevisionsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *controllerRevisionsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpappsv1beta1.ControllerRevisionsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &controllerRevisionsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// controllerRevisionClusterClient implements ControllerRevisionClusterInterface +type controllerRevisionClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*appsv1beta1.ControllerRevision, *appsv1beta1.ControllerRevisionList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of ControllerRevisions that match those selectors across all clusters. -func (c *controllerRevisionsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta1.ControllerRevisionList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(controllerRevisionsResource, controllerRevisionsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &appsv1beta1.ControllerRevisionList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeControllerRevisionClusterClient(fake *AppsV1beta1ClusterClient) typedkcpappsv1beta1.ControllerRevisionClusterInterface { + return &controllerRevisionClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*appsv1beta1.ControllerRevision, *appsv1beta1.ControllerRevisionList]( + fake.Fake, + appsv1beta1.SchemeGroupVersion.WithResource("controllerrevisions"), + appsv1beta1.SchemeGroupVersion.WithKind("ControllerRevision"), + func() *appsv1beta1.ControllerRevision { return &appsv1beta1.ControllerRevision{} }, + func() *appsv1beta1.ControllerRevisionList { return &appsv1beta1.ControllerRevisionList{} }, + func(dst, src *appsv1beta1.ControllerRevisionList) { dst.ListMeta = src.ListMeta }, + func(list *appsv1beta1.ControllerRevisionList) []*appsv1beta1.ControllerRevision { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *appsv1beta1.ControllerRevisionList, items []*appsv1beta1.ControllerRevision) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &appsv1beta1.ControllerRevisionList{ListMeta: obj.(*appsv1beta1.ControllerRevisionList).ListMeta} - for _, item := range obj.(*appsv1beta1.ControllerRevisionList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested ControllerRevisions across all clusters. -func (c *controllerRevisionsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(controllerRevisionsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *controllerRevisionClusterClient) Cluster(cluster logicalcluster.Path) typedkcpappsv1beta1.ControllerRevisionsNamespacer { + return &controllerRevisionNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type controllerRevisionsNamespacer struct { +type controllerRevisionNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *controllerRevisionsNamespacer) Namespace(namespace string) appsv1beta1client.ControllerRevisionInterface { - return &controllerRevisionsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *controllerRevisionNamespacer) Namespace(namespace string) typedappsv1beta1.ControllerRevisionInterface { + return newFakeControllerRevisionClient(n.Fake, namespace, n.ClusterPath) } -type controllerRevisionsClient struct { - *kcptesting.Fake +// controllerRevisionScopedClient implements ControllerRevisionInterface +type controllerRevisionScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*appsv1beta1.ControllerRevision, *appsv1beta1.ControllerRevisionList, *v1beta1.ControllerRevisionApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *controllerRevisionsClient) Create(ctx context.Context, controllerRevision *appsv1beta1.ControllerRevision, opts metav1.CreateOptions) (*appsv1beta1.ControllerRevision, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(controllerRevisionsResource, c.ClusterPath, c.Namespace, controllerRevision), &appsv1beta1.ControllerRevision{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta1.ControllerRevision), err -} - -func (c *controllerRevisionsClient) Update(ctx context.Context, controllerRevision *appsv1beta1.ControllerRevision, opts metav1.UpdateOptions) (*appsv1beta1.ControllerRevision, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(controllerRevisionsResource, c.ClusterPath, c.Namespace, controllerRevision), &appsv1beta1.ControllerRevision{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta1.ControllerRevision), err -} - -func (c *controllerRevisionsClient) UpdateStatus(ctx context.Context, controllerRevision *appsv1beta1.ControllerRevision, opts metav1.UpdateOptions) (*appsv1beta1.ControllerRevision, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(controllerRevisionsResource, c.ClusterPath, "status", c.Namespace, controllerRevision), &appsv1beta1.ControllerRevision{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta1.ControllerRevision), err -} - -func (c *controllerRevisionsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(controllerRevisionsResource, c.ClusterPath, c.Namespace, name, opts), &appsv1beta1.ControllerRevision{}) - return err -} - -func (c *controllerRevisionsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(controllerRevisionsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &appsv1beta1.ControllerRevisionList{}) - return err -} - -func (c *controllerRevisionsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*appsv1beta1.ControllerRevision, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(controllerRevisionsResource, c.ClusterPath, c.Namespace, name), &appsv1beta1.ControllerRevision{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta1.ControllerRevision), err -} - -// List takes label and field selectors, and returns the list of ControllerRevisions that match those selectors. -func (c *controllerRevisionsClient) List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta1.ControllerRevisionList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(controllerRevisionsResource, controllerRevisionsKind, c.ClusterPath, c.Namespace, opts), &appsv1beta1.ControllerRevisionList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &appsv1beta1.ControllerRevisionList{ListMeta: obj.(*appsv1beta1.ControllerRevisionList).ListMeta} - for _, item := range obj.(*appsv1beta1.ControllerRevisionList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *controllerRevisionsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(controllerRevisionsResource, c.ClusterPath, c.Namespace, opts)) } -func (c *controllerRevisionsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*appsv1beta1.ControllerRevision, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(controllerRevisionsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &appsv1beta1.ControllerRevision{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta1.ControllerRevision), err -} - -func (c *controllerRevisionsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsappsv1beta1.ControllerRevisionApplyConfiguration, opts metav1.ApplyOptions) (*appsv1beta1.ControllerRevision, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(controllerRevisionsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &appsv1beta1.ControllerRevision{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta1.ControllerRevision), err -} - -func (c *controllerRevisionsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsappsv1beta1.ControllerRevisionApplyConfiguration, opts metav1.ApplyOptions) (*appsv1beta1.ControllerRevision, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(controllerRevisionsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &appsv1beta1.ControllerRevision{}) - if obj == nil { - return nil, err +func newFakeControllerRevisionClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedappsv1beta1.ControllerRevisionInterface { + return &controllerRevisionScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*appsv1beta1.ControllerRevision, *appsv1beta1.ControllerRevisionList, *v1beta1.ControllerRevisionApplyConfiguration]( + fake, + clusterPath, + namespace, + appsv1beta1.SchemeGroupVersion.WithResource("controllerrevisions"), + appsv1beta1.SchemeGroupVersion.WithKind("ControllerRevision"), + func() *appsv1beta1.ControllerRevision { return &appsv1beta1.ControllerRevision{} }, + func() *appsv1beta1.ControllerRevisionList { return &appsv1beta1.ControllerRevisionList{} }, + func(dst, src *appsv1beta1.ControllerRevisionList) { dst.ListMeta = src.ListMeta }, + func(list *appsv1beta1.ControllerRevisionList) []*appsv1beta1.ControllerRevision { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *appsv1beta1.ControllerRevisionList, items []*appsv1beta1.ControllerRevision) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*appsv1beta1.ControllerRevision), err } diff --git a/kubernetes/typed/apps/v1beta1/fake/deployment.go b/kubernetes/typed/apps/v1beta1/fake/deployment.go index 37c421e38..ca9472315 100644 --- a/kubernetes/typed/apps/v1beta1/fake/deployment.go +++ b/kubernetes/typed/apps/v1beta1/fake/deployment.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" appsv1beta1 "k8s.io/api/apps/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsappsv1beta1 "k8s.io/client-go/applyconfigurations/apps/v1beta1" - appsv1beta1client "k8s.io/client-go/kubernetes/typed/apps/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/apps/v1beta1" + typedappsv1beta1 "k8s.io/client-go/kubernetes/typed/apps/v1beta1" - kcpappsv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1beta1" + typedkcpappsv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var deploymentsResource = schema.GroupVersionResource{Group: "apps", Version: "v1beta1", Resource: "deployments"} -var deploymentsKind = schema.GroupVersionKind{Group: "apps", Version: "v1beta1", Kind: "Deployment"} - -type deploymentsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *deploymentsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpappsv1beta1.DeploymentsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &deploymentsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// deploymentClusterClient implements DeploymentClusterInterface +type deploymentClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*appsv1beta1.Deployment, *appsv1beta1.DeploymentList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of Deployments that match those selectors across all clusters. -func (c *deploymentsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta1.DeploymentList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(deploymentsResource, deploymentsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &appsv1beta1.DeploymentList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeDeploymentClusterClient(fake *AppsV1beta1ClusterClient) typedkcpappsv1beta1.DeploymentClusterInterface { + return &deploymentClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*appsv1beta1.Deployment, *appsv1beta1.DeploymentList]( + fake.Fake, + appsv1beta1.SchemeGroupVersion.WithResource("deployments"), + appsv1beta1.SchemeGroupVersion.WithKind("Deployment"), + func() *appsv1beta1.Deployment { return &appsv1beta1.Deployment{} }, + func() *appsv1beta1.DeploymentList { return &appsv1beta1.DeploymentList{} }, + func(dst, src *appsv1beta1.DeploymentList) { dst.ListMeta = src.ListMeta }, + func(list *appsv1beta1.DeploymentList) []*appsv1beta1.Deployment { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *appsv1beta1.DeploymentList, items []*appsv1beta1.Deployment) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &appsv1beta1.DeploymentList{ListMeta: obj.(*appsv1beta1.DeploymentList).ListMeta} - for _, item := range obj.(*appsv1beta1.DeploymentList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested Deployments across all clusters. -func (c *deploymentsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(deploymentsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *deploymentClusterClient) Cluster(cluster logicalcluster.Path) typedkcpappsv1beta1.DeploymentsNamespacer { + return &deploymentNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type deploymentsNamespacer struct { +type deploymentNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *deploymentsNamespacer) Namespace(namespace string) appsv1beta1client.DeploymentInterface { - return &deploymentsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *deploymentNamespacer) Namespace(namespace string) typedappsv1beta1.DeploymentInterface { + return newFakeDeploymentClient(n.Fake, namespace, n.ClusterPath) } -type deploymentsClient struct { - *kcptesting.Fake +// deploymentScopedClient implements DeploymentInterface +type deploymentScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*appsv1beta1.Deployment, *appsv1beta1.DeploymentList, *v1beta1.DeploymentApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *deploymentsClient) Create(ctx context.Context, deployment *appsv1beta1.Deployment, opts metav1.CreateOptions) (*appsv1beta1.Deployment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(deploymentsResource, c.ClusterPath, c.Namespace, deployment), &appsv1beta1.Deployment{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta1.Deployment), err -} - -func (c *deploymentsClient) Update(ctx context.Context, deployment *appsv1beta1.Deployment, opts metav1.UpdateOptions) (*appsv1beta1.Deployment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(deploymentsResource, c.ClusterPath, c.Namespace, deployment), &appsv1beta1.Deployment{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta1.Deployment), err -} - -func (c *deploymentsClient) UpdateStatus(ctx context.Context, deployment *appsv1beta1.Deployment, opts metav1.UpdateOptions) (*appsv1beta1.Deployment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(deploymentsResource, c.ClusterPath, "status", c.Namespace, deployment), &appsv1beta1.Deployment{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta1.Deployment), err -} - -func (c *deploymentsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(deploymentsResource, c.ClusterPath, c.Namespace, name, opts), &appsv1beta1.Deployment{}) - return err -} - -func (c *deploymentsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(deploymentsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &appsv1beta1.DeploymentList{}) - return err -} - -func (c *deploymentsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*appsv1beta1.Deployment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(deploymentsResource, c.ClusterPath, c.Namespace, name), &appsv1beta1.Deployment{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta1.Deployment), err -} - -// List takes label and field selectors, and returns the list of Deployments that match those selectors. -func (c *deploymentsClient) List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta1.DeploymentList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(deploymentsResource, deploymentsKind, c.ClusterPath, c.Namespace, opts), &appsv1beta1.DeploymentList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &appsv1beta1.DeploymentList{ListMeta: obj.(*appsv1beta1.DeploymentList).ListMeta} - for _, item := range obj.(*appsv1beta1.DeploymentList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *deploymentsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(deploymentsResource, c.ClusterPath, c.Namespace, opts)) } -func (c *deploymentsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*appsv1beta1.Deployment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(deploymentsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &appsv1beta1.Deployment{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta1.Deployment), err -} - -func (c *deploymentsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsappsv1beta1.DeploymentApplyConfiguration, opts metav1.ApplyOptions) (*appsv1beta1.Deployment, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(deploymentsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &appsv1beta1.Deployment{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta1.Deployment), err -} - -func (c *deploymentsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsappsv1beta1.DeploymentApplyConfiguration, opts metav1.ApplyOptions) (*appsv1beta1.Deployment, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(deploymentsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &appsv1beta1.Deployment{}) - if obj == nil { - return nil, err +func newFakeDeploymentClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedappsv1beta1.DeploymentInterface { + return &deploymentScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*appsv1beta1.Deployment, *appsv1beta1.DeploymentList, *v1beta1.DeploymentApplyConfiguration]( + fake, + clusterPath, + namespace, + appsv1beta1.SchemeGroupVersion.WithResource("deployments"), + appsv1beta1.SchemeGroupVersion.WithKind("Deployment"), + func() *appsv1beta1.Deployment { return &appsv1beta1.Deployment{} }, + func() *appsv1beta1.DeploymentList { return &appsv1beta1.DeploymentList{} }, + func(dst, src *appsv1beta1.DeploymentList) { dst.ListMeta = src.ListMeta }, + func(list *appsv1beta1.DeploymentList) []*appsv1beta1.Deployment { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *appsv1beta1.DeploymentList, items []*appsv1beta1.Deployment) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*appsv1beta1.Deployment), err } diff --git a/kubernetes/typed/apps/v1beta1/fake/doc.go b/kubernetes/typed/apps/v1beta1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/apps/v1beta1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/apps/v1beta1/fake/statefulset.go b/kubernetes/typed/apps/v1beta1/fake/statefulset.go index fa2781b33..b67655757 100644 --- a/kubernetes/typed/apps/v1beta1/fake/statefulset.go +++ b/kubernetes/typed/apps/v1beta1/fake/statefulset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" appsv1beta1 "k8s.io/api/apps/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsappsv1beta1 "k8s.io/client-go/applyconfigurations/apps/v1beta1" - appsv1beta1client "k8s.io/client-go/kubernetes/typed/apps/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/apps/v1beta1" + typedappsv1beta1 "k8s.io/client-go/kubernetes/typed/apps/v1beta1" - kcpappsv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1beta1" + typedkcpappsv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var statefulSetsResource = schema.GroupVersionResource{Group: "apps", Version: "v1beta1", Resource: "statefulsets"} -var statefulSetsKind = schema.GroupVersionKind{Group: "apps", Version: "v1beta1", Kind: "StatefulSet"} - -type statefulSetsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *statefulSetsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpappsv1beta1.StatefulSetsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &statefulSetsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// statefulSetClusterClient implements StatefulSetClusterInterface +type statefulSetClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*appsv1beta1.StatefulSet, *appsv1beta1.StatefulSetList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of StatefulSets that match those selectors across all clusters. -func (c *statefulSetsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta1.StatefulSetList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(statefulSetsResource, statefulSetsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &appsv1beta1.StatefulSetList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeStatefulSetClusterClient(fake *AppsV1beta1ClusterClient) typedkcpappsv1beta1.StatefulSetClusterInterface { + return &statefulSetClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*appsv1beta1.StatefulSet, *appsv1beta1.StatefulSetList]( + fake.Fake, + appsv1beta1.SchemeGroupVersion.WithResource("statefulsets"), + appsv1beta1.SchemeGroupVersion.WithKind("StatefulSet"), + func() *appsv1beta1.StatefulSet { return &appsv1beta1.StatefulSet{} }, + func() *appsv1beta1.StatefulSetList { return &appsv1beta1.StatefulSetList{} }, + func(dst, src *appsv1beta1.StatefulSetList) { dst.ListMeta = src.ListMeta }, + func(list *appsv1beta1.StatefulSetList) []*appsv1beta1.StatefulSet { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *appsv1beta1.StatefulSetList, items []*appsv1beta1.StatefulSet) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &appsv1beta1.StatefulSetList{ListMeta: obj.(*appsv1beta1.StatefulSetList).ListMeta} - for _, item := range obj.(*appsv1beta1.StatefulSetList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested StatefulSets across all clusters. -func (c *statefulSetsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(statefulSetsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *statefulSetClusterClient) Cluster(cluster logicalcluster.Path) typedkcpappsv1beta1.StatefulSetsNamespacer { + return &statefulSetNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type statefulSetsNamespacer struct { +type statefulSetNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *statefulSetsNamespacer) Namespace(namespace string) appsv1beta1client.StatefulSetInterface { - return &statefulSetsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *statefulSetNamespacer) Namespace(namespace string) typedappsv1beta1.StatefulSetInterface { + return newFakeStatefulSetClient(n.Fake, namespace, n.ClusterPath) } -type statefulSetsClient struct { - *kcptesting.Fake +// statefulSetScopedClient implements StatefulSetInterface +type statefulSetScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*appsv1beta1.StatefulSet, *appsv1beta1.StatefulSetList, *v1beta1.StatefulSetApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *statefulSetsClient) Create(ctx context.Context, statefulSet *appsv1beta1.StatefulSet, opts metav1.CreateOptions) (*appsv1beta1.StatefulSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(statefulSetsResource, c.ClusterPath, c.Namespace, statefulSet), &appsv1beta1.StatefulSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta1.StatefulSet), err -} - -func (c *statefulSetsClient) Update(ctx context.Context, statefulSet *appsv1beta1.StatefulSet, opts metav1.UpdateOptions) (*appsv1beta1.StatefulSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(statefulSetsResource, c.ClusterPath, c.Namespace, statefulSet), &appsv1beta1.StatefulSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta1.StatefulSet), err -} - -func (c *statefulSetsClient) UpdateStatus(ctx context.Context, statefulSet *appsv1beta1.StatefulSet, opts metav1.UpdateOptions) (*appsv1beta1.StatefulSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(statefulSetsResource, c.ClusterPath, "status", c.Namespace, statefulSet), &appsv1beta1.StatefulSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta1.StatefulSet), err -} - -func (c *statefulSetsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(statefulSetsResource, c.ClusterPath, c.Namespace, name, opts), &appsv1beta1.StatefulSet{}) - return err -} - -func (c *statefulSetsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(statefulSetsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &appsv1beta1.StatefulSetList{}) - return err -} - -func (c *statefulSetsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*appsv1beta1.StatefulSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(statefulSetsResource, c.ClusterPath, c.Namespace, name), &appsv1beta1.StatefulSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta1.StatefulSet), err -} - -// List takes label and field selectors, and returns the list of StatefulSets that match those selectors. -func (c *statefulSetsClient) List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta1.StatefulSetList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(statefulSetsResource, statefulSetsKind, c.ClusterPath, c.Namespace, opts), &appsv1beta1.StatefulSetList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &appsv1beta1.StatefulSetList{ListMeta: obj.(*appsv1beta1.StatefulSetList).ListMeta} - for _, item := range obj.(*appsv1beta1.StatefulSetList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *statefulSetsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(statefulSetsResource, c.ClusterPath, c.Namespace, opts)) } -func (c *statefulSetsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*appsv1beta1.StatefulSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(statefulSetsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &appsv1beta1.StatefulSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta1.StatefulSet), err -} - -func (c *statefulSetsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsappsv1beta1.StatefulSetApplyConfiguration, opts metav1.ApplyOptions) (*appsv1beta1.StatefulSet, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(statefulSetsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &appsv1beta1.StatefulSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta1.StatefulSet), err -} - -func (c *statefulSetsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsappsv1beta1.StatefulSetApplyConfiguration, opts metav1.ApplyOptions) (*appsv1beta1.StatefulSet, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(statefulSetsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &appsv1beta1.StatefulSet{}) - if obj == nil { - return nil, err +func newFakeStatefulSetClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedappsv1beta1.StatefulSetInterface { + return &statefulSetScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*appsv1beta1.StatefulSet, *appsv1beta1.StatefulSetList, *v1beta1.StatefulSetApplyConfiguration]( + fake, + clusterPath, + namespace, + appsv1beta1.SchemeGroupVersion.WithResource("statefulsets"), + appsv1beta1.SchemeGroupVersion.WithKind("StatefulSet"), + func() *appsv1beta1.StatefulSet { return &appsv1beta1.StatefulSet{} }, + func() *appsv1beta1.StatefulSetList { return &appsv1beta1.StatefulSetList{} }, + func(dst, src *appsv1beta1.StatefulSetList) { dst.ListMeta = src.ListMeta }, + func(list *appsv1beta1.StatefulSetList) []*appsv1beta1.StatefulSet { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *appsv1beta1.StatefulSetList, items []*appsv1beta1.StatefulSet) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*appsv1beta1.StatefulSet), err } diff --git a/kubernetes/typed/apps/v1beta1/generated_expansion.go b/kubernetes/typed/apps/v1beta1/generated_expansion.go new file mode 100644 index 000000000..c43b985f7 --- /dev/null +++ b/kubernetes/typed/apps/v1beta1/generated_expansion.go @@ -0,0 +1,25 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1beta1 + +type ControllerRevisionClusterExpansion interface{} + +type DeploymentClusterExpansion interface{} + +type StatefulSetClusterExpansion interface{} diff --git a/kubernetes/typed/apps/v1beta1/statefulset.go b/kubernetes/typed/apps/v1beta1/statefulset.go index 6350746e2..a0f9fa0db 100644 --- a/kubernetes/typed/apps/v1beta1/statefulset.go +++ b/kubernetes/typed/apps/v1beta1/statefulset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" appsv1beta1 "k8s.io/api/apps/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - appsv1beta1client "k8s.io/client-go/kubernetes/typed/apps/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedappsv1beta1 "k8s.io/client-go/kubernetes/typed/apps/v1beta1" ) // StatefulSetsClusterGetter has a method to return a StatefulSetClusterInterface. @@ -40,12 +40,13 @@ type StatefulSetsClusterGetter interface { // or scope down to one cluster and return a StatefulSetsNamespacer. type StatefulSetClusterInterface interface { Cluster(logicalcluster.Path) StatefulSetsNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta1.StatefulSetList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*appsv1beta1.StatefulSetList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + StatefulSetClusterExpansion } type statefulSetsClusterInterface struct { - clientCache kcpclient.Cache[*appsv1beta1client.AppsV1beta1Client] + clientCache kcpclient.Cache[*typedappsv1beta1.AppsV1beta1Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *statefulSetsClusterInterface) Cluster(clusterPath logicalcluster.Path) } // List returns the entire collection of all StatefulSets across all clusters. -func (c *statefulSetsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta1.StatefulSetList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).StatefulSets(metav1.NamespaceAll).List(ctx, opts) +func (c *statefulSetsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*appsv1beta1.StatefulSetList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).StatefulSets(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all StatefulSets across all clusters. -func (c *statefulSetsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).StatefulSets(metav1.NamespaceAll).Watch(ctx, opts) +func (c *statefulSetsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).StatefulSets(v1.NamespaceAll).Watch(ctx, opts) } -// StatefulSetsNamespacer can scope to objects within a namespace, returning a appsv1beta1client.StatefulSetInterface. +// StatefulSetsNamespacer can scope to objects within a namespace, returning a typedappsv1beta1.StatefulSetInterface. type StatefulSetsNamespacer interface { - Namespace(string) appsv1beta1client.StatefulSetInterface + Namespace(string) typedappsv1beta1.StatefulSetInterface } type statefulSetsNamespacer struct { - clientCache kcpclient.Cache[*appsv1beta1client.AppsV1beta1Client] + clientCache kcpclient.Cache[*typedappsv1beta1.AppsV1beta1Client] clusterPath logicalcluster.Path } -func (n *statefulSetsNamespacer) Namespace(namespace string) appsv1beta1client.StatefulSetInterface { +func (n *statefulSetsNamespacer) Namespace(namespace string) typedappsv1beta1.StatefulSetInterface { return n.clientCache.ClusterOrDie(n.clusterPath).StatefulSets(namespace) } diff --git a/kubernetes/typed/apps/v1beta2/apps_client.go b/kubernetes/typed/apps/v1beta2/apps_client.go index 10afa2371..4eceb20c0 100644 --- a/kubernetes/typed/apps/v1beta2/apps_client.go +++ b/kubernetes/typed/apps/v1beta2/apps_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,33 +14,37 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta2 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apiappsv1beta2 "k8s.io/api/apps/v1beta2" appsv1beta2 "k8s.io/client-go/kubernetes/typed/apps/v1beta2" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type AppsV1beta2ClusterInterface interface { AppsV1beta2ClusterScoper - StatefulSetsClusterGetter - DeploymentsClusterGetter + ControllerRevisionsClusterGetter DaemonSetsClusterGetter + DeploymentsClusterGetter ReplicaSetsClusterGetter - ControllerRevisionsClusterGetter + StatefulSetsClusterGetter } type AppsV1beta2ClusterScoper interface { Cluster(logicalcluster.Path) appsv1beta2.AppsV1beta2Interface } +// AppsV1beta2ClusterClient is used to interact with features provided by the apps group. type AppsV1beta2ClusterClient struct { clientCache kcpclient.Cache[*appsv1beta2.AppsV1beta2Client] } @@ -52,35 +56,37 @@ func (c *AppsV1beta2ClusterClient) Cluster(clusterPath logicalcluster.Path) apps return c.clientCache.ClusterOrDie(clusterPath) } -func (c *AppsV1beta2ClusterClient) StatefulSets() StatefulSetClusterInterface { - return &statefulSetsClusterInterface{clientCache: c.clientCache} -} - -func (c *AppsV1beta2ClusterClient) Deployments() DeploymentClusterInterface { - return &deploymentsClusterInterface{clientCache: c.clientCache} +func (c *AppsV1beta2ClusterClient) ControllerRevisions() ControllerRevisionClusterInterface { + return &controllerRevisionsClusterInterface{clientCache: c.clientCache} } func (c *AppsV1beta2ClusterClient) DaemonSets() DaemonSetClusterInterface { return &daemonSetsClusterInterface{clientCache: c.clientCache} } +func (c *AppsV1beta2ClusterClient) Deployments() DeploymentClusterInterface { + return &deploymentsClusterInterface{clientCache: c.clientCache} +} + func (c *AppsV1beta2ClusterClient) ReplicaSets() ReplicaSetClusterInterface { return &replicaSetsClusterInterface{clientCache: c.clientCache} } -func (c *AppsV1beta2ClusterClient) ControllerRevisions() ControllerRevisionClusterInterface { - return &controllerRevisionsClusterInterface{clientCache: c.clientCache} +func (c *AppsV1beta2ClusterClient) StatefulSets() StatefulSetClusterInterface { + return &statefulSetsClusterInterface{clientCache: c.clientCache} } // NewForConfig creates a new AppsV1beta2ClusterClient for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*AppsV1beta2ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new AppsV1beta2ClusterClient for the given config and http client. @@ -92,6 +98,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*AppsV1beta2ClusterC if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &AppsV1beta2ClusterClient{clientCache: cache}, nil } @@ -104,3 +111,14 @@ func NewForConfigOrDie(c *rest.Config) *AppsV1beta2ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apiappsv1beta2.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/apps/v1beta2/controllerrevision.go b/kubernetes/typed/apps/v1beta2/controllerrevision.go index 527da6f60..0318c6997 100644 --- a/kubernetes/typed/apps/v1beta2/controllerrevision.go +++ b/kubernetes/typed/apps/v1beta2/controllerrevision.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta2 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" appsv1beta2 "k8s.io/api/apps/v1beta2" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - appsv1beta2client "k8s.io/client-go/kubernetes/typed/apps/v1beta2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedappsv1beta2 "k8s.io/client-go/kubernetes/typed/apps/v1beta2" ) // ControllerRevisionsClusterGetter has a method to return a ControllerRevisionClusterInterface. @@ -40,12 +40,13 @@ type ControllerRevisionsClusterGetter interface { // or scope down to one cluster and return a ControllerRevisionsNamespacer. type ControllerRevisionClusterInterface interface { Cluster(logicalcluster.Path) ControllerRevisionsNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta2.ControllerRevisionList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*appsv1beta2.ControllerRevisionList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + ControllerRevisionClusterExpansion } type controllerRevisionsClusterInterface struct { - clientCache kcpclient.Cache[*appsv1beta2client.AppsV1beta2Client] + clientCache kcpclient.Cache[*typedappsv1beta2.AppsV1beta2Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *controllerRevisionsClusterInterface) Cluster(clusterPath logicalcluster } // List returns the entire collection of all ControllerRevisions across all clusters. -func (c *controllerRevisionsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta2.ControllerRevisionList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ControllerRevisions(metav1.NamespaceAll).List(ctx, opts) +func (c *controllerRevisionsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*appsv1beta2.ControllerRevisionList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ControllerRevisions(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all ControllerRevisions across all clusters. -func (c *controllerRevisionsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ControllerRevisions(metav1.NamespaceAll).Watch(ctx, opts) +func (c *controllerRevisionsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ControllerRevisions(v1.NamespaceAll).Watch(ctx, opts) } -// ControllerRevisionsNamespacer can scope to objects within a namespace, returning a appsv1beta2client.ControllerRevisionInterface. +// ControllerRevisionsNamespacer can scope to objects within a namespace, returning a typedappsv1beta2.ControllerRevisionInterface. type ControllerRevisionsNamespacer interface { - Namespace(string) appsv1beta2client.ControllerRevisionInterface + Namespace(string) typedappsv1beta2.ControllerRevisionInterface } type controllerRevisionsNamespacer struct { - clientCache kcpclient.Cache[*appsv1beta2client.AppsV1beta2Client] + clientCache kcpclient.Cache[*typedappsv1beta2.AppsV1beta2Client] clusterPath logicalcluster.Path } -func (n *controllerRevisionsNamespacer) Namespace(namespace string) appsv1beta2client.ControllerRevisionInterface { +func (n *controllerRevisionsNamespacer) Namespace(namespace string) typedappsv1beta2.ControllerRevisionInterface { return n.clientCache.ClusterOrDie(n.clusterPath).ControllerRevisions(namespace) } diff --git a/kubernetes/typed/apps/v1beta2/daemonset.go b/kubernetes/typed/apps/v1beta2/daemonset.go index 9375e3c12..c852408da 100644 --- a/kubernetes/typed/apps/v1beta2/daemonset.go +++ b/kubernetes/typed/apps/v1beta2/daemonset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta2 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" appsv1beta2 "k8s.io/api/apps/v1beta2" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - appsv1beta2client "k8s.io/client-go/kubernetes/typed/apps/v1beta2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedappsv1beta2 "k8s.io/client-go/kubernetes/typed/apps/v1beta2" ) // DaemonSetsClusterGetter has a method to return a DaemonSetClusterInterface. @@ -40,12 +40,13 @@ type DaemonSetsClusterGetter interface { // or scope down to one cluster and return a DaemonSetsNamespacer. type DaemonSetClusterInterface interface { Cluster(logicalcluster.Path) DaemonSetsNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta2.DaemonSetList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*appsv1beta2.DaemonSetList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + DaemonSetClusterExpansion } type daemonSetsClusterInterface struct { - clientCache kcpclient.Cache[*appsv1beta2client.AppsV1beta2Client] + clientCache kcpclient.Cache[*typedappsv1beta2.AppsV1beta2Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *daemonSetsClusterInterface) Cluster(clusterPath logicalcluster.Path) Da } // List returns the entire collection of all DaemonSets across all clusters. -func (c *daemonSetsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta2.DaemonSetList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).DaemonSets(metav1.NamespaceAll).List(ctx, opts) +func (c *daemonSetsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*appsv1beta2.DaemonSetList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).DaemonSets(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all DaemonSets across all clusters. -func (c *daemonSetsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).DaemonSets(metav1.NamespaceAll).Watch(ctx, opts) +func (c *daemonSetsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).DaemonSets(v1.NamespaceAll).Watch(ctx, opts) } -// DaemonSetsNamespacer can scope to objects within a namespace, returning a appsv1beta2client.DaemonSetInterface. +// DaemonSetsNamespacer can scope to objects within a namespace, returning a typedappsv1beta2.DaemonSetInterface. type DaemonSetsNamespacer interface { - Namespace(string) appsv1beta2client.DaemonSetInterface + Namespace(string) typedappsv1beta2.DaemonSetInterface } type daemonSetsNamespacer struct { - clientCache kcpclient.Cache[*appsv1beta2client.AppsV1beta2Client] + clientCache kcpclient.Cache[*typedappsv1beta2.AppsV1beta2Client] clusterPath logicalcluster.Path } -func (n *daemonSetsNamespacer) Namespace(namespace string) appsv1beta2client.DaemonSetInterface { +func (n *daemonSetsNamespacer) Namespace(namespace string) typedappsv1beta2.DaemonSetInterface { return n.clientCache.ClusterOrDie(n.clusterPath).DaemonSets(namespace) } diff --git a/kubernetes/typed/apps/v1beta2/deployment.go b/kubernetes/typed/apps/v1beta2/deployment.go index a004e7b9a..71fe07435 100644 --- a/kubernetes/typed/apps/v1beta2/deployment.go +++ b/kubernetes/typed/apps/v1beta2/deployment.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta2 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" appsv1beta2 "k8s.io/api/apps/v1beta2" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - appsv1beta2client "k8s.io/client-go/kubernetes/typed/apps/v1beta2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedappsv1beta2 "k8s.io/client-go/kubernetes/typed/apps/v1beta2" ) // DeploymentsClusterGetter has a method to return a DeploymentClusterInterface. @@ -40,12 +40,13 @@ type DeploymentsClusterGetter interface { // or scope down to one cluster and return a DeploymentsNamespacer. type DeploymentClusterInterface interface { Cluster(logicalcluster.Path) DeploymentsNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta2.DeploymentList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*appsv1beta2.DeploymentList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + DeploymentClusterExpansion } type deploymentsClusterInterface struct { - clientCache kcpclient.Cache[*appsv1beta2client.AppsV1beta2Client] + clientCache kcpclient.Cache[*typedappsv1beta2.AppsV1beta2Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *deploymentsClusterInterface) Cluster(clusterPath logicalcluster.Path) D } // List returns the entire collection of all Deployments across all clusters. -func (c *deploymentsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta2.DeploymentList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Deployments(metav1.NamespaceAll).List(ctx, opts) +func (c *deploymentsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*appsv1beta2.DeploymentList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Deployments(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all Deployments across all clusters. -func (c *deploymentsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Deployments(metav1.NamespaceAll).Watch(ctx, opts) +func (c *deploymentsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Deployments(v1.NamespaceAll).Watch(ctx, opts) } -// DeploymentsNamespacer can scope to objects within a namespace, returning a appsv1beta2client.DeploymentInterface. +// DeploymentsNamespacer can scope to objects within a namespace, returning a typedappsv1beta2.DeploymentInterface. type DeploymentsNamespacer interface { - Namespace(string) appsv1beta2client.DeploymentInterface + Namespace(string) typedappsv1beta2.DeploymentInterface } type deploymentsNamespacer struct { - clientCache kcpclient.Cache[*appsv1beta2client.AppsV1beta2Client] + clientCache kcpclient.Cache[*typedappsv1beta2.AppsV1beta2Client] clusterPath logicalcluster.Path } -func (n *deploymentsNamespacer) Namespace(namespace string) appsv1beta2client.DeploymentInterface { +func (n *deploymentsNamespacer) Namespace(namespace string) typedappsv1beta2.DeploymentInterface { return n.clientCache.ClusterOrDie(n.clusterPath).Deployments(namespace) } diff --git a/kubernetes/typed/apps/v1beta2/doc.go b/kubernetes/typed/apps/v1beta2/doc.go new file mode 100644 index 000000000..3f0720c40 --- /dev/null +++ b/kubernetes/typed/apps/v1beta2/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1beta2 diff --git a/kubernetes/typed/apps/v1beta2/fake/apps_client.go b/kubernetes/typed/apps/v1beta2/fake/apps_client.go index 21197e2c5..d98ced8c0 100644 --- a/kubernetes/typed/apps/v1beta2/fake/apps_client.go +++ b/kubernetes/typed/apps/v1beta2/fake/apps_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" appsv1beta2 "k8s.io/client-go/kubernetes/typed/apps/v1beta2" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpappsv1beta2 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1beta2" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -41,54 +41,54 @@ func (c *AppsV1beta2ClusterClient) Cluster(clusterPath logicalcluster.Path) apps return &AppsV1beta2Client{Fake: c.Fake, ClusterPath: clusterPath} } -func (c *AppsV1beta2ClusterClient) StatefulSets() kcpappsv1beta2.StatefulSetClusterInterface { - return &statefulSetsClusterClient{Fake: c.Fake} +func (c *AppsV1beta2ClusterClient) ControllerRevisions() kcpappsv1beta2.ControllerRevisionClusterInterface { + return newFakeControllerRevisionClusterClient(c) } -func (c *AppsV1beta2ClusterClient) Deployments() kcpappsv1beta2.DeploymentClusterInterface { - return &deploymentsClusterClient{Fake: c.Fake} +func (c *AppsV1beta2ClusterClient) DaemonSets() kcpappsv1beta2.DaemonSetClusterInterface { + return newFakeDaemonSetClusterClient(c) } -func (c *AppsV1beta2ClusterClient) DaemonSets() kcpappsv1beta2.DaemonSetClusterInterface { - return &daemonSetsClusterClient{Fake: c.Fake} +func (c *AppsV1beta2ClusterClient) Deployments() kcpappsv1beta2.DeploymentClusterInterface { + return newFakeDeploymentClusterClient(c) } func (c *AppsV1beta2ClusterClient) ReplicaSets() kcpappsv1beta2.ReplicaSetClusterInterface { - return &replicaSetsClusterClient{Fake: c.Fake} + return newFakeReplicaSetClusterClient(c) } -func (c *AppsV1beta2ClusterClient) ControllerRevisions() kcpappsv1beta2.ControllerRevisionClusterInterface { - return &controllerRevisionsClusterClient{Fake: c.Fake} +func (c *AppsV1beta2ClusterClient) StatefulSets() kcpappsv1beta2.StatefulSetClusterInterface { + return newFakeStatefulSetClusterClient(c) } -var _ appsv1beta2.AppsV1beta2Interface = (*AppsV1beta2Client)(nil) - type AppsV1beta2Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *AppsV1beta2Client) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret +func (c *AppsV1beta2Client) ControllerRevisions(namespace string) appsv1beta2.ControllerRevisionInterface { + return newFakeControllerRevisionClient(c.Fake, namespace, c.ClusterPath) } -func (c *AppsV1beta2Client) StatefulSets(namespace string) appsv1beta2.StatefulSetInterface { - return &statefulSetsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *AppsV1beta2Client) DaemonSets(namespace string) appsv1beta2.DaemonSetInterface { + return newFakeDaemonSetClient(c.Fake, namespace, c.ClusterPath) } func (c *AppsV1beta2Client) Deployments(namespace string) appsv1beta2.DeploymentInterface { - return &deploymentsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} + return newFakeDeploymentClient(c.Fake, namespace, c.ClusterPath) } -func (c *AppsV1beta2Client) DaemonSets(namespace string) appsv1beta2.DaemonSetInterface { - return &daemonSetsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *AppsV1beta2Client) ReplicaSets(namespace string) appsv1beta2.ReplicaSetInterface { + return newFakeReplicaSetClient(c.Fake, namespace, c.ClusterPath) } -func (c *AppsV1beta2Client) ReplicaSets(namespace string) appsv1beta2.ReplicaSetInterface { - return &replicaSetsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *AppsV1beta2Client) StatefulSets(namespace string) appsv1beta2.StatefulSetInterface { + return newFakeStatefulSetClient(c.Fake, namespace, c.ClusterPath) } -func (c *AppsV1beta2Client) ControllerRevisions(namespace string) appsv1beta2.ControllerRevisionInterface { - return &controllerRevisionsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *AppsV1beta2Client) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret } diff --git a/kubernetes/typed/apps/v1beta2/fake/controllerrevision.go b/kubernetes/typed/apps/v1beta2/fake/controllerrevision.go index 1a3573609..06c4565e4 100644 --- a/kubernetes/typed/apps/v1beta2/fake/controllerrevision.go +++ b/kubernetes/typed/apps/v1beta2/fake/controllerrevision.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" appsv1beta2 "k8s.io/api/apps/v1beta2" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsappsv1beta2 "k8s.io/client-go/applyconfigurations/apps/v1beta2" - appsv1beta2client "k8s.io/client-go/kubernetes/typed/apps/v1beta2" - "k8s.io/client-go/testing" + v1beta2 "k8s.io/client-go/applyconfigurations/apps/v1beta2" + typedappsv1beta2 "k8s.io/client-go/kubernetes/typed/apps/v1beta2" - kcpappsv1beta2 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1beta2" + typedkcpappsv1beta2 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1beta2" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var controllerRevisionsResource = schema.GroupVersionResource{Group: "apps", Version: "v1beta2", Resource: "controllerrevisions"} -var controllerRevisionsKind = schema.GroupVersionKind{Group: "apps", Version: "v1beta2", Kind: "ControllerRevision"} - -type controllerRevisionsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *controllerRevisionsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpappsv1beta2.ControllerRevisionsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &controllerRevisionsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// controllerRevisionClusterClient implements ControllerRevisionClusterInterface +type controllerRevisionClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*appsv1beta2.ControllerRevision, *appsv1beta2.ControllerRevisionList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of ControllerRevisions that match those selectors across all clusters. -func (c *controllerRevisionsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta2.ControllerRevisionList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(controllerRevisionsResource, controllerRevisionsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &appsv1beta2.ControllerRevisionList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeControllerRevisionClusterClient(fake *AppsV1beta2ClusterClient) typedkcpappsv1beta2.ControllerRevisionClusterInterface { + return &controllerRevisionClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*appsv1beta2.ControllerRevision, *appsv1beta2.ControllerRevisionList]( + fake.Fake, + appsv1beta2.SchemeGroupVersion.WithResource("controllerrevisions"), + appsv1beta2.SchemeGroupVersion.WithKind("ControllerRevision"), + func() *appsv1beta2.ControllerRevision { return &appsv1beta2.ControllerRevision{} }, + func() *appsv1beta2.ControllerRevisionList { return &appsv1beta2.ControllerRevisionList{} }, + func(dst, src *appsv1beta2.ControllerRevisionList) { dst.ListMeta = src.ListMeta }, + func(list *appsv1beta2.ControllerRevisionList) []*appsv1beta2.ControllerRevision { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *appsv1beta2.ControllerRevisionList, items []*appsv1beta2.ControllerRevision) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &appsv1beta2.ControllerRevisionList{ListMeta: obj.(*appsv1beta2.ControllerRevisionList).ListMeta} - for _, item := range obj.(*appsv1beta2.ControllerRevisionList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested ControllerRevisions across all clusters. -func (c *controllerRevisionsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(controllerRevisionsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *controllerRevisionClusterClient) Cluster(cluster logicalcluster.Path) typedkcpappsv1beta2.ControllerRevisionsNamespacer { + return &controllerRevisionNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type controllerRevisionsNamespacer struct { +type controllerRevisionNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *controllerRevisionsNamespacer) Namespace(namespace string) appsv1beta2client.ControllerRevisionInterface { - return &controllerRevisionsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *controllerRevisionNamespacer) Namespace(namespace string) typedappsv1beta2.ControllerRevisionInterface { + return newFakeControllerRevisionClient(n.Fake, namespace, n.ClusterPath) } -type controllerRevisionsClient struct { - *kcptesting.Fake +// controllerRevisionScopedClient implements ControllerRevisionInterface +type controllerRevisionScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*appsv1beta2.ControllerRevision, *appsv1beta2.ControllerRevisionList, *v1beta2.ControllerRevisionApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *controllerRevisionsClient) Create(ctx context.Context, controllerRevision *appsv1beta2.ControllerRevision, opts metav1.CreateOptions) (*appsv1beta2.ControllerRevision, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(controllerRevisionsResource, c.ClusterPath, c.Namespace, controllerRevision), &appsv1beta2.ControllerRevision{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta2.ControllerRevision), err -} - -func (c *controllerRevisionsClient) Update(ctx context.Context, controllerRevision *appsv1beta2.ControllerRevision, opts metav1.UpdateOptions) (*appsv1beta2.ControllerRevision, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(controllerRevisionsResource, c.ClusterPath, c.Namespace, controllerRevision), &appsv1beta2.ControllerRevision{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta2.ControllerRevision), err -} - -func (c *controllerRevisionsClient) UpdateStatus(ctx context.Context, controllerRevision *appsv1beta2.ControllerRevision, opts metav1.UpdateOptions) (*appsv1beta2.ControllerRevision, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(controllerRevisionsResource, c.ClusterPath, "status", c.Namespace, controllerRevision), &appsv1beta2.ControllerRevision{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta2.ControllerRevision), err -} - -func (c *controllerRevisionsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(controllerRevisionsResource, c.ClusterPath, c.Namespace, name, opts), &appsv1beta2.ControllerRevision{}) - return err -} - -func (c *controllerRevisionsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(controllerRevisionsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &appsv1beta2.ControllerRevisionList{}) - return err -} - -func (c *controllerRevisionsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*appsv1beta2.ControllerRevision, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(controllerRevisionsResource, c.ClusterPath, c.Namespace, name), &appsv1beta2.ControllerRevision{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta2.ControllerRevision), err -} - -// List takes label and field selectors, and returns the list of ControllerRevisions that match those selectors. -func (c *controllerRevisionsClient) List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta2.ControllerRevisionList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(controllerRevisionsResource, controllerRevisionsKind, c.ClusterPath, c.Namespace, opts), &appsv1beta2.ControllerRevisionList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &appsv1beta2.ControllerRevisionList{ListMeta: obj.(*appsv1beta2.ControllerRevisionList).ListMeta} - for _, item := range obj.(*appsv1beta2.ControllerRevisionList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *controllerRevisionsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(controllerRevisionsResource, c.ClusterPath, c.Namespace, opts)) } -func (c *controllerRevisionsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*appsv1beta2.ControllerRevision, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(controllerRevisionsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &appsv1beta2.ControllerRevision{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta2.ControllerRevision), err -} - -func (c *controllerRevisionsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsappsv1beta2.ControllerRevisionApplyConfiguration, opts metav1.ApplyOptions) (*appsv1beta2.ControllerRevision, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(controllerRevisionsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &appsv1beta2.ControllerRevision{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta2.ControllerRevision), err -} - -func (c *controllerRevisionsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsappsv1beta2.ControllerRevisionApplyConfiguration, opts metav1.ApplyOptions) (*appsv1beta2.ControllerRevision, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(controllerRevisionsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &appsv1beta2.ControllerRevision{}) - if obj == nil { - return nil, err +func newFakeControllerRevisionClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedappsv1beta2.ControllerRevisionInterface { + return &controllerRevisionScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*appsv1beta2.ControllerRevision, *appsv1beta2.ControllerRevisionList, *v1beta2.ControllerRevisionApplyConfiguration]( + fake, + clusterPath, + namespace, + appsv1beta2.SchemeGroupVersion.WithResource("controllerrevisions"), + appsv1beta2.SchemeGroupVersion.WithKind("ControllerRevision"), + func() *appsv1beta2.ControllerRevision { return &appsv1beta2.ControllerRevision{} }, + func() *appsv1beta2.ControllerRevisionList { return &appsv1beta2.ControllerRevisionList{} }, + func(dst, src *appsv1beta2.ControllerRevisionList) { dst.ListMeta = src.ListMeta }, + func(list *appsv1beta2.ControllerRevisionList) []*appsv1beta2.ControllerRevision { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *appsv1beta2.ControllerRevisionList, items []*appsv1beta2.ControllerRevision) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*appsv1beta2.ControllerRevision), err } diff --git a/kubernetes/typed/apps/v1beta2/fake/daemonset.go b/kubernetes/typed/apps/v1beta2/fake/daemonset.go index 5830c3d05..dae7584bc 100644 --- a/kubernetes/typed/apps/v1beta2/fake/daemonset.go +++ b/kubernetes/typed/apps/v1beta2/fake/daemonset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" appsv1beta2 "k8s.io/api/apps/v1beta2" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsappsv1beta2 "k8s.io/client-go/applyconfigurations/apps/v1beta2" - appsv1beta2client "k8s.io/client-go/kubernetes/typed/apps/v1beta2" - "k8s.io/client-go/testing" + v1beta2 "k8s.io/client-go/applyconfigurations/apps/v1beta2" + typedappsv1beta2 "k8s.io/client-go/kubernetes/typed/apps/v1beta2" - kcpappsv1beta2 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1beta2" + typedkcpappsv1beta2 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1beta2" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var daemonSetsResource = schema.GroupVersionResource{Group: "apps", Version: "v1beta2", Resource: "daemonsets"} -var daemonSetsKind = schema.GroupVersionKind{Group: "apps", Version: "v1beta2", Kind: "DaemonSet"} - -type daemonSetsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *daemonSetsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpappsv1beta2.DaemonSetsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &daemonSetsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// daemonSetClusterClient implements DaemonSetClusterInterface +type daemonSetClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*appsv1beta2.DaemonSet, *appsv1beta2.DaemonSetList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of DaemonSets that match those selectors across all clusters. -func (c *daemonSetsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta2.DaemonSetList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(daemonSetsResource, daemonSetsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &appsv1beta2.DaemonSetList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeDaemonSetClusterClient(fake *AppsV1beta2ClusterClient) typedkcpappsv1beta2.DaemonSetClusterInterface { + return &daemonSetClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*appsv1beta2.DaemonSet, *appsv1beta2.DaemonSetList]( + fake.Fake, + appsv1beta2.SchemeGroupVersion.WithResource("daemonsets"), + appsv1beta2.SchemeGroupVersion.WithKind("DaemonSet"), + func() *appsv1beta2.DaemonSet { return &appsv1beta2.DaemonSet{} }, + func() *appsv1beta2.DaemonSetList { return &appsv1beta2.DaemonSetList{} }, + func(dst, src *appsv1beta2.DaemonSetList) { dst.ListMeta = src.ListMeta }, + func(list *appsv1beta2.DaemonSetList) []*appsv1beta2.DaemonSet { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *appsv1beta2.DaemonSetList, items []*appsv1beta2.DaemonSet) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &appsv1beta2.DaemonSetList{ListMeta: obj.(*appsv1beta2.DaemonSetList).ListMeta} - for _, item := range obj.(*appsv1beta2.DaemonSetList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested DaemonSets across all clusters. -func (c *daemonSetsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(daemonSetsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *daemonSetClusterClient) Cluster(cluster logicalcluster.Path) typedkcpappsv1beta2.DaemonSetsNamespacer { + return &daemonSetNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type daemonSetsNamespacer struct { +type daemonSetNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *daemonSetsNamespacer) Namespace(namespace string) appsv1beta2client.DaemonSetInterface { - return &daemonSetsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *daemonSetNamespacer) Namespace(namespace string) typedappsv1beta2.DaemonSetInterface { + return newFakeDaemonSetClient(n.Fake, namespace, n.ClusterPath) } -type daemonSetsClient struct { - *kcptesting.Fake +// daemonSetScopedClient implements DaemonSetInterface +type daemonSetScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*appsv1beta2.DaemonSet, *appsv1beta2.DaemonSetList, *v1beta2.DaemonSetApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *daemonSetsClient) Create(ctx context.Context, daemonSet *appsv1beta2.DaemonSet, opts metav1.CreateOptions) (*appsv1beta2.DaemonSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(daemonSetsResource, c.ClusterPath, c.Namespace, daemonSet), &appsv1beta2.DaemonSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta2.DaemonSet), err -} - -func (c *daemonSetsClient) Update(ctx context.Context, daemonSet *appsv1beta2.DaemonSet, opts metav1.UpdateOptions) (*appsv1beta2.DaemonSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(daemonSetsResource, c.ClusterPath, c.Namespace, daemonSet), &appsv1beta2.DaemonSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta2.DaemonSet), err -} - -func (c *daemonSetsClient) UpdateStatus(ctx context.Context, daemonSet *appsv1beta2.DaemonSet, opts metav1.UpdateOptions) (*appsv1beta2.DaemonSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(daemonSetsResource, c.ClusterPath, "status", c.Namespace, daemonSet), &appsv1beta2.DaemonSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta2.DaemonSet), err -} - -func (c *daemonSetsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(daemonSetsResource, c.ClusterPath, c.Namespace, name, opts), &appsv1beta2.DaemonSet{}) - return err -} - -func (c *daemonSetsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(daemonSetsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &appsv1beta2.DaemonSetList{}) - return err -} - -func (c *daemonSetsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*appsv1beta2.DaemonSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(daemonSetsResource, c.ClusterPath, c.Namespace, name), &appsv1beta2.DaemonSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta2.DaemonSet), err -} - -// List takes label and field selectors, and returns the list of DaemonSets that match those selectors. -func (c *daemonSetsClient) List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta2.DaemonSetList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(daemonSetsResource, daemonSetsKind, c.ClusterPath, c.Namespace, opts), &appsv1beta2.DaemonSetList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &appsv1beta2.DaemonSetList{ListMeta: obj.(*appsv1beta2.DaemonSetList).ListMeta} - for _, item := range obj.(*appsv1beta2.DaemonSetList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *daemonSetsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(daemonSetsResource, c.ClusterPath, c.Namespace, opts)) } -func (c *daemonSetsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*appsv1beta2.DaemonSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(daemonSetsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &appsv1beta2.DaemonSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta2.DaemonSet), err -} - -func (c *daemonSetsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsappsv1beta2.DaemonSetApplyConfiguration, opts metav1.ApplyOptions) (*appsv1beta2.DaemonSet, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(daemonSetsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &appsv1beta2.DaemonSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta2.DaemonSet), err -} - -func (c *daemonSetsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsappsv1beta2.DaemonSetApplyConfiguration, opts metav1.ApplyOptions) (*appsv1beta2.DaemonSet, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(daemonSetsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &appsv1beta2.DaemonSet{}) - if obj == nil { - return nil, err +func newFakeDaemonSetClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedappsv1beta2.DaemonSetInterface { + return &daemonSetScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*appsv1beta2.DaemonSet, *appsv1beta2.DaemonSetList, *v1beta2.DaemonSetApplyConfiguration]( + fake, + clusterPath, + namespace, + appsv1beta2.SchemeGroupVersion.WithResource("daemonsets"), + appsv1beta2.SchemeGroupVersion.WithKind("DaemonSet"), + func() *appsv1beta2.DaemonSet { return &appsv1beta2.DaemonSet{} }, + func() *appsv1beta2.DaemonSetList { return &appsv1beta2.DaemonSetList{} }, + func(dst, src *appsv1beta2.DaemonSetList) { dst.ListMeta = src.ListMeta }, + func(list *appsv1beta2.DaemonSetList) []*appsv1beta2.DaemonSet { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *appsv1beta2.DaemonSetList, items []*appsv1beta2.DaemonSet) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*appsv1beta2.DaemonSet), err } diff --git a/kubernetes/typed/apps/v1beta2/fake/deployment.go b/kubernetes/typed/apps/v1beta2/fake/deployment.go index 0737da8c4..2397ff6f9 100644 --- a/kubernetes/typed/apps/v1beta2/fake/deployment.go +++ b/kubernetes/typed/apps/v1beta2/fake/deployment.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" appsv1beta2 "k8s.io/api/apps/v1beta2" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsappsv1beta2 "k8s.io/client-go/applyconfigurations/apps/v1beta2" - appsv1beta2client "k8s.io/client-go/kubernetes/typed/apps/v1beta2" - "k8s.io/client-go/testing" + v1beta2 "k8s.io/client-go/applyconfigurations/apps/v1beta2" + typedappsv1beta2 "k8s.io/client-go/kubernetes/typed/apps/v1beta2" - kcpappsv1beta2 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1beta2" + typedkcpappsv1beta2 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1beta2" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var deploymentsResource = schema.GroupVersionResource{Group: "apps", Version: "v1beta2", Resource: "deployments"} -var deploymentsKind = schema.GroupVersionKind{Group: "apps", Version: "v1beta2", Kind: "Deployment"} - -type deploymentsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *deploymentsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpappsv1beta2.DeploymentsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &deploymentsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// deploymentClusterClient implements DeploymentClusterInterface +type deploymentClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*appsv1beta2.Deployment, *appsv1beta2.DeploymentList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of Deployments that match those selectors across all clusters. -func (c *deploymentsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta2.DeploymentList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(deploymentsResource, deploymentsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &appsv1beta2.DeploymentList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeDeploymentClusterClient(fake *AppsV1beta2ClusterClient) typedkcpappsv1beta2.DeploymentClusterInterface { + return &deploymentClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*appsv1beta2.Deployment, *appsv1beta2.DeploymentList]( + fake.Fake, + appsv1beta2.SchemeGroupVersion.WithResource("deployments"), + appsv1beta2.SchemeGroupVersion.WithKind("Deployment"), + func() *appsv1beta2.Deployment { return &appsv1beta2.Deployment{} }, + func() *appsv1beta2.DeploymentList { return &appsv1beta2.DeploymentList{} }, + func(dst, src *appsv1beta2.DeploymentList) { dst.ListMeta = src.ListMeta }, + func(list *appsv1beta2.DeploymentList) []*appsv1beta2.Deployment { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *appsv1beta2.DeploymentList, items []*appsv1beta2.Deployment) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &appsv1beta2.DeploymentList{ListMeta: obj.(*appsv1beta2.DeploymentList).ListMeta} - for _, item := range obj.(*appsv1beta2.DeploymentList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested Deployments across all clusters. -func (c *deploymentsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(deploymentsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *deploymentClusterClient) Cluster(cluster logicalcluster.Path) typedkcpappsv1beta2.DeploymentsNamespacer { + return &deploymentNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type deploymentsNamespacer struct { +type deploymentNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *deploymentsNamespacer) Namespace(namespace string) appsv1beta2client.DeploymentInterface { - return &deploymentsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *deploymentNamespacer) Namespace(namespace string) typedappsv1beta2.DeploymentInterface { + return newFakeDeploymentClient(n.Fake, namespace, n.ClusterPath) } -type deploymentsClient struct { - *kcptesting.Fake +// deploymentScopedClient implements DeploymentInterface +type deploymentScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*appsv1beta2.Deployment, *appsv1beta2.DeploymentList, *v1beta2.DeploymentApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *deploymentsClient) Create(ctx context.Context, deployment *appsv1beta2.Deployment, opts metav1.CreateOptions) (*appsv1beta2.Deployment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(deploymentsResource, c.ClusterPath, c.Namespace, deployment), &appsv1beta2.Deployment{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta2.Deployment), err -} - -func (c *deploymentsClient) Update(ctx context.Context, deployment *appsv1beta2.Deployment, opts metav1.UpdateOptions) (*appsv1beta2.Deployment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(deploymentsResource, c.ClusterPath, c.Namespace, deployment), &appsv1beta2.Deployment{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta2.Deployment), err -} - -func (c *deploymentsClient) UpdateStatus(ctx context.Context, deployment *appsv1beta2.Deployment, opts metav1.UpdateOptions) (*appsv1beta2.Deployment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(deploymentsResource, c.ClusterPath, "status", c.Namespace, deployment), &appsv1beta2.Deployment{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta2.Deployment), err -} - -func (c *deploymentsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(deploymentsResource, c.ClusterPath, c.Namespace, name, opts), &appsv1beta2.Deployment{}) - return err -} - -func (c *deploymentsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(deploymentsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &appsv1beta2.DeploymentList{}) - return err -} - -func (c *deploymentsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*appsv1beta2.Deployment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(deploymentsResource, c.ClusterPath, c.Namespace, name), &appsv1beta2.Deployment{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta2.Deployment), err -} - -// List takes label and field selectors, and returns the list of Deployments that match those selectors. -func (c *deploymentsClient) List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta2.DeploymentList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(deploymentsResource, deploymentsKind, c.ClusterPath, c.Namespace, opts), &appsv1beta2.DeploymentList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &appsv1beta2.DeploymentList{ListMeta: obj.(*appsv1beta2.DeploymentList).ListMeta} - for _, item := range obj.(*appsv1beta2.DeploymentList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *deploymentsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(deploymentsResource, c.ClusterPath, c.Namespace, opts)) } -func (c *deploymentsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*appsv1beta2.Deployment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(deploymentsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &appsv1beta2.Deployment{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta2.Deployment), err -} - -func (c *deploymentsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsappsv1beta2.DeploymentApplyConfiguration, opts metav1.ApplyOptions) (*appsv1beta2.Deployment, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(deploymentsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &appsv1beta2.Deployment{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta2.Deployment), err -} - -func (c *deploymentsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsappsv1beta2.DeploymentApplyConfiguration, opts metav1.ApplyOptions) (*appsv1beta2.Deployment, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(deploymentsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &appsv1beta2.Deployment{}) - if obj == nil { - return nil, err +func newFakeDeploymentClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedappsv1beta2.DeploymentInterface { + return &deploymentScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*appsv1beta2.Deployment, *appsv1beta2.DeploymentList, *v1beta2.DeploymentApplyConfiguration]( + fake, + clusterPath, + namespace, + appsv1beta2.SchemeGroupVersion.WithResource("deployments"), + appsv1beta2.SchemeGroupVersion.WithKind("Deployment"), + func() *appsv1beta2.Deployment { return &appsv1beta2.Deployment{} }, + func() *appsv1beta2.DeploymentList { return &appsv1beta2.DeploymentList{} }, + func(dst, src *appsv1beta2.DeploymentList) { dst.ListMeta = src.ListMeta }, + func(list *appsv1beta2.DeploymentList) []*appsv1beta2.Deployment { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *appsv1beta2.DeploymentList, items []*appsv1beta2.Deployment) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*appsv1beta2.Deployment), err } diff --git a/kubernetes/typed/apps/v1beta2/fake/doc.go b/kubernetes/typed/apps/v1beta2/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/apps/v1beta2/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/apps/v1beta2/fake/replicaset.go b/kubernetes/typed/apps/v1beta2/fake/replicaset.go index e2f899331..ee1353a87 100644 --- a/kubernetes/typed/apps/v1beta2/fake/replicaset.go +++ b/kubernetes/typed/apps/v1beta2/fake/replicaset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" appsv1beta2 "k8s.io/api/apps/v1beta2" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsappsv1beta2 "k8s.io/client-go/applyconfigurations/apps/v1beta2" - appsv1beta2client "k8s.io/client-go/kubernetes/typed/apps/v1beta2" - "k8s.io/client-go/testing" + v1beta2 "k8s.io/client-go/applyconfigurations/apps/v1beta2" + typedappsv1beta2 "k8s.io/client-go/kubernetes/typed/apps/v1beta2" - kcpappsv1beta2 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1beta2" + typedkcpappsv1beta2 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1beta2" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var replicaSetsResource = schema.GroupVersionResource{Group: "apps", Version: "v1beta2", Resource: "replicasets"} -var replicaSetsKind = schema.GroupVersionKind{Group: "apps", Version: "v1beta2", Kind: "ReplicaSet"} - -type replicaSetsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *replicaSetsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpappsv1beta2.ReplicaSetsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &replicaSetsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// replicaSetClusterClient implements ReplicaSetClusterInterface +type replicaSetClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*appsv1beta2.ReplicaSet, *appsv1beta2.ReplicaSetList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of ReplicaSets that match those selectors across all clusters. -func (c *replicaSetsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta2.ReplicaSetList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(replicaSetsResource, replicaSetsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &appsv1beta2.ReplicaSetList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeReplicaSetClusterClient(fake *AppsV1beta2ClusterClient) typedkcpappsv1beta2.ReplicaSetClusterInterface { + return &replicaSetClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*appsv1beta2.ReplicaSet, *appsv1beta2.ReplicaSetList]( + fake.Fake, + appsv1beta2.SchemeGroupVersion.WithResource("replicasets"), + appsv1beta2.SchemeGroupVersion.WithKind("ReplicaSet"), + func() *appsv1beta2.ReplicaSet { return &appsv1beta2.ReplicaSet{} }, + func() *appsv1beta2.ReplicaSetList { return &appsv1beta2.ReplicaSetList{} }, + func(dst, src *appsv1beta2.ReplicaSetList) { dst.ListMeta = src.ListMeta }, + func(list *appsv1beta2.ReplicaSetList) []*appsv1beta2.ReplicaSet { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *appsv1beta2.ReplicaSetList, items []*appsv1beta2.ReplicaSet) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &appsv1beta2.ReplicaSetList{ListMeta: obj.(*appsv1beta2.ReplicaSetList).ListMeta} - for _, item := range obj.(*appsv1beta2.ReplicaSetList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested ReplicaSets across all clusters. -func (c *replicaSetsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(replicaSetsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *replicaSetClusterClient) Cluster(cluster logicalcluster.Path) typedkcpappsv1beta2.ReplicaSetsNamespacer { + return &replicaSetNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type replicaSetsNamespacer struct { +type replicaSetNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *replicaSetsNamespacer) Namespace(namespace string) appsv1beta2client.ReplicaSetInterface { - return &replicaSetsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *replicaSetNamespacer) Namespace(namespace string) typedappsv1beta2.ReplicaSetInterface { + return newFakeReplicaSetClient(n.Fake, namespace, n.ClusterPath) } -type replicaSetsClient struct { - *kcptesting.Fake +// replicaSetScopedClient implements ReplicaSetInterface +type replicaSetScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*appsv1beta2.ReplicaSet, *appsv1beta2.ReplicaSetList, *v1beta2.ReplicaSetApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *replicaSetsClient) Create(ctx context.Context, replicaSet *appsv1beta2.ReplicaSet, opts metav1.CreateOptions) (*appsv1beta2.ReplicaSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(replicaSetsResource, c.ClusterPath, c.Namespace, replicaSet), &appsv1beta2.ReplicaSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta2.ReplicaSet), err -} - -func (c *replicaSetsClient) Update(ctx context.Context, replicaSet *appsv1beta2.ReplicaSet, opts metav1.UpdateOptions) (*appsv1beta2.ReplicaSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(replicaSetsResource, c.ClusterPath, c.Namespace, replicaSet), &appsv1beta2.ReplicaSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta2.ReplicaSet), err -} - -func (c *replicaSetsClient) UpdateStatus(ctx context.Context, replicaSet *appsv1beta2.ReplicaSet, opts metav1.UpdateOptions) (*appsv1beta2.ReplicaSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(replicaSetsResource, c.ClusterPath, "status", c.Namespace, replicaSet), &appsv1beta2.ReplicaSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta2.ReplicaSet), err -} - -func (c *replicaSetsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(replicaSetsResource, c.ClusterPath, c.Namespace, name, opts), &appsv1beta2.ReplicaSet{}) - return err -} - -func (c *replicaSetsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(replicaSetsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &appsv1beta2.ReplicaSetList{}) - return err -} - -func (c *replicaSetsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*appsv1beta2.ReplicaSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(replicaSetsResource, c.ClusterPath, c.Namespace, name), &appsv1beta2.ReplicaSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta2.ReplicaSet), err -} - -// List takes label and field selectors, and returns the list of ReplicaSets that match those selectors. -func (c *replicaSetsClient) List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta2.ReplicaSetList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(replicaSetsResource, replicaSetsKind, c.ClusterPath, c.Namespace, opts), &appsv1beta2.ReplicaSetList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &appsv1beta2.ReplicaSetList{ListMeta: obj.(*appsv1beta2.ReplicaSetList).ListMeta} - for _, item := range obj.(*appsv1beta2.ReplicaSetList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *replicaSetsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(replicaSetsResource, c.ClusterPath, c.Namespace, opts)) } -func (c *replicaSetsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*appsv1beta2.ReplicaSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(replicaSetsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &appsv1beta2.ReplicaSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta2.ReplicaSet), err -} - -func (c *replicaSetsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsappsv1beta2.ReplicaSetApplyConfiguration, opts metav1.ApplyOptions) (*appsv1beta2.ReplicaSet, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(replicaSetsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &appsv1beta2.ReplicaSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta2.ReplicaSet), err -} - -func (c *replicaSetsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsappsv1beta2.ReplicaSetApplyConfiguration, opts metav1.ApplyOptions) (*appsv1beta2.ReplicaSet, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(replicaSetsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &appsv1beta2.ReplicaSet{}) - if obj == nil { - return nil, err +func newFakeReplicaSetClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedappsv1beta2.ReplicaSetInterface { + return &replicaSetScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*appsv1beta2.ReplicaSet, *appsv1beta2.ReplicaSetList, *v1beta2.ReplicaSetApplyConfiguration]( + fake, + clusterPath, + namespace, + appsv1beta2.SchemeGroupVersion.WithResource("replicasets"), + appsv1beta2.SchemeGroupVersion.WithKind("ReplicaSet"), + func() *appsv1beta2.ReplicaSet { return &appsv1beta2.ReplicaSet{} }, + func() *appsv1beta2.ReplicaSetList { return &appsv1beta2.ReplicaSetList{} }, + func(dst, src *appsv1beta2.ReplicaSetList) { dst.ListMeta = src.ListMeta }, + func(list *appsv1beta2.ReplicaSetList) []*appsv1beta2.ReplicaSet { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *appsv1beta2.ReplicaSetList, items []*appsv1beta2.ReplicaSet) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*appsv1beta2.ReplicaSet), err } diff --git a/kubernetes/typed/apps/v1beta2/fake/statefulset.go b/kubernetes/typed/apps/v1beta2/fake/statefulset.go index 510fbbe65..266176511 100644 --- a/kubernetes/typed/apps/v1beta2/fake/statefulset.go +++ b/kubernetes/typed/apps/v1beta2/fake/statefulset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,232 +14,131 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" + context "context" + json "encoding/json" + fmt "fmt" "github.com/kcp-dev/logicalcluster/v3" appsv1beta2 "k8s.io/api/apps/v1beta2" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsappsv1beta2 "k8s.io/client-go/applyconfigurations/apps/v1beta2" - appsv1beta2client "k8s.io/client-go/kubernetes/typed/apps/v1beta2" - "k8s.io/client-go/testing" - - kcpappsv1beta2 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1beta2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + v1beta2 "k8s.io/client-go/applyconfigurations/apps/v1beta2" + typedappsv1beta2 "k8s.io/client-go/kubernetes/typed/apps/v1beta2" + + typedkcpappsv1beta2 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1beta2" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var statefulSetsResource = schema.GroupVersionResource{Group: "apps", Version: "v1beta2", Resource: "statefulsets"} -var statefulSetsKind = schema.GroupVersionKind{Group: "apps", Version: "v1beta2", Kind: "StatefulSet"} - -type statefulSetsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *statefulSetsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpappsv1beta2.StatefulSetsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &statefulSetsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// statefulSetClusterClient implements StatefulSetClusterInterface +type statefulSetClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*appsv1beta2.StatefulSet, *appsv1beta2.StatefulSetList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of StatefulSets that match those selectors across all clusters. -func (c *statefulSetsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta2.StatefulSetList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(statefulSetsResource, statefulSetsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &appsv1beta2.StatefulSetList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &appsv1beta2.StatefulSetList{ListMeta: obj.(*appsv1beta2.StatefulSetList).ListMeta} - for _, item := range obj.(*appsv1beta2.StatefulSetList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } +func newFakeStatefulSetClusterClient(fake *AppsV1beta2ClusterClient) typedkcpappsv1beta2.StatefulSetClusterInterface { + return &statefulSetClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*appsv1beta2.StatefulSet, *appsv1beta2.StatefulSetList]( + fake.Fake, + appsv1beta2.SchemeGroupVersion.WithResource("statefulsets"), + appsv1beta2.SchemeGroupVersion.WithKind("StatefulSet"), + func() *appsv1beta2.StatefulSet { return &appsv1beta2.StatefulSet{} }, + func() *appsv1beta2.StatefulSetList { return &appsv1beta2.StatefulSetList{} }, + func(dst, src *appsv1beta2.StatefulSetList) { dst.ListMeta = src.ListMeta }, + func(list *appsv1beta2.StatefulSetList) []*appsv1beta2.StatefulSet { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *appsv1beta2.StatefulSetList, items []*appsv1beta2.StatefulSet) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - return list, err } -// Watch returns a watch.Interface that watches the requested StatefulSets across all clusters. -func (c *statefulSetsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(statefulSetsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *statefulSetClusterClient) Cluster(cluster logicalcluster.Path) typedkcpappsv1beta2.StatefulSetsNamespacer { + return &statefulSetNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type statefulSetsNamespacer struct { +type statefulSetNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *statefulSetsNamespacer) Namespace(namespace string) appsv1beta2client.StatefulSetInterface { - return &statefulSetsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *statefulSetNamespacer) Namespace(namespace string) typedappsv1beta2.StatefulSetInterface { + return newFakeStatefulSetClient(n.Fake, namespace, n.ClusterPath) } -type statefulSetsClient struct { - *kcptesting.Fake +// statefulSetScopedClient implements StatefulSetInterface +type statefulSetScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*appsv1beta2.StatefulSet, *appsv1beta2.StatefulSetList, *v1beta2.StatefulSetApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *statefulSetsClient) Create(ctx context.Context, statefulSet *appsv1beta2.StatefulSet, opts metav1.CreateOptions) (*appsv1beta2.StatefulSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(statefulSetsResource, c.ClusterPath, c.Namespace, statefulSet), &appsv1beta2.StatefulSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta2.StatefulSet), err } -func (c *statefulSetsClient) Update(ctx context.Context, statefulSet *appsv1beta2.StatefulSet, opts metav1.UpdateOptions) (*appsv1beta2.StatefulSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(statefulSetsResource, c.ClusterPath, c.Namespace, statefulSet), &appsv1beta2.StatefulSet{}) +func newFakeStatefulSetClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedappsv1beta2.StatefulSetInterface { + return &statefulSetScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*appsv1beta2.StatefulSet, *appsv1beta2.StatefulSetList, *v1beta2.StatefulSetApplyConfiguration]( + fake, + clusterPath, + namespace, + appsv1beta2.SchemeGroupVersion.WithResource("statefulsets"), + appsv1beta2.SchemeGroupVersion.WithKind("StatefulSet"), + func() *appsv1beta2.StatefulSet { return &appsv1beta2.StatefulSet{} }, + func() *appsv1beta2.StatefulSetList { return &appsv1beta2.StatefulSetList{} }, + func(dst, src *appsv1beta2.StatefulSetList) { dst.ListMeta = src.ListMeta }, + func(list *appsv1beta2.StatefulSetList) []*appsv1beta2.StatefulSet { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *appsv1beta2.StatefulSetList, items []*appsv1beta2.StatefulSet) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, + } +} + +// GetScale takes name of the statefulSet, and returns the corresponding scale object, and an error if there is any. +func (c *statefulSetScopedClient) GetScale(ctx context.Context, statefulSetName string, _ v1.GetOptions) (result *appsv1beta2.Scale, err error) { + emptyResult := &appsv1beta2.Scale{} + obj, err := c.Fake.Invokes(kcptesting.NewGetSubresourceAction(c.Resource(), c.ClusterPath, c.Namespace(), "scale", statefulSetName), emptyResult) if obj == nil { - return nil, err - } - return obj.(*appsv1beta2.StatefulSet), err -} - -func (c *statefulSetsClient) UpdateStatus(ctx context.Context, statefulSet *appsv1beta2.StatefulSet, opts metav1.UpdateOptions) (*appsv1beta2.StatefulSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(statefulSetsResource, c.ClusterPath, "status", c.Namespace, statefulSet), &appsv1beta2.StatefulSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta2.StatefulSet), err -} - -func (c *statefulSetsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(statefulSetsResource, c.ClusterPath, c.Namespace, name, opts), &appsv1beta2.StatefulSet{}) - return err -} - -func (c *statefulSetsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(statefulSetsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &appsv1beta2.StatefulSetList{}) - return err -} - -func (c *statefulSetsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*appsv1beta2.StatefulSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(statefulSetsResource, c.ClusterPath, c.Namespace, name), &appsv1beta2.StatefulSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta2.StatefulSet), err -} - -// List takes label and field selectors, and returns the list of StatefulSets that match those selectors. -func (c *statefulSetsClient) List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta2.StatefulSetList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(statefulSetsResource, statefulSetsKind, c.ClusterPath, c.Namespace, opts), &appsv1beta2.StatefulSetList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &appsv1beta2.StatefulSetList{ListMeta: obj.(*appsv1beta2.StatefulSetList).ListMeta} - for _, item := range obj.(*appsv1beta2.StatefulSetList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *statefulSetsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(statefulSetsResource, c.ClusterPath, c.Namespace, opts)) -} - -func (c *statefulSetsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*appsv1beta2.StatefulSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(statefulSetsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &appsv1beta2.StatefulSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta2.StatefulSet), err -} - -func (c *statefulSetsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsappsv1beta2.StatefulSetApplyConfiguration, opts metav1.ApplyOptions) (*appsv1beta2.StatefulSet, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(statefulSetsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &appsv1beta2.StatefulSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta2.StatefulSet), err -} - -func (c *statefulSetsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsappsv1beta2.StatefulSetApplyConfiguration, opts metav1.ApplyOptions) (*appsv1beta2.StatefulSet, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(statefulSetsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &appsv1beta2.StatefulSet{}) - if obj == nil { - return nil, err - } - return obj.(*appsv1beta2.StatefulSet), err -} - -func (c *statefulSetsClient) GetScale(ctx context.Context, statefulSetName string, options metav1.GetOptions) (*appsv1beta2.Scale, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetSubresourceAction(statefulSetsResource, c.ClusterPath, "scale", c.Namespace, statefulSetName), &appsv1beta2.Scale{}) - if obj == nil { - return nil, err + return emptyResult, err } return obj.(*appsv1beta2.Scale), err } -func (c *statefulSetsClient) UpdateScale(ctx context.Context, statefulSetName string, scale *appsv1beta2.Scale, opts metav1.UpdateOptions) (*appsv1beta2.Scale, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(statefulSetsResource, c.ClusterPath, "scale", c.Namespace, scale), &appsv1beta2.Scale{}) +// UpdateScale takes the representation of a scale and updates it. Returns the server's representation of the scale, and an error, if there is any. +func (c *statefulSetScopedClient) UpdateScale(ctx context.Context, statefulSetName string, scale *appsv1beta2.Scale, _ v1.UpdateOptions) (result *appsv1beta2.Scale, err error) { + emptyResult := &appsv1beta2.Scale{} + obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(c.Resource(), c.ClusterPath, "scale", c.Namespace(), scale), &appsv1beta2.Scale{}) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*appsv1beta2.Scale), err } -func (c *statefulSetsClient) ApplyScale(ctx context.Context, statefulSetName string, applyConfiguration *applyconfigurationsappsv1beta2.ScaleApplyConfiguration, opts metav1.ApplyOptions) (*appsv1beta2.Scale, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") +// ApplyScale takes top resource name and the apply declarative configuration for scale, +// applies it and returns the applied scale, and an error, if there is any. +func (c *statefulSetScopedClient) ApplyScale(ctx context.Context, statefulSetName string, scale *v1beta2.ScaleApplyConfiguration, _ v1.ApplyOptions) (result *appsv1beta2.Scale, err error) { + if scale == nil { + return nil, fmt.Errorf("scale provided to ApplyScale must not be nil") } - data, err := json.Marshal(applyConfiguration) + data, err := json.Marshal(scale) if err != nil { return nil, err } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(statefulSetsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &appsv1beta2.Scale{}) + emptyResult := &appsv1beta2.Scale{} + obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(c.Resource(), c.ClusterPath, c.Namespace(), statefulSetName, types.ApplyPatchType, data, "scale"), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*appsv1beta2.Scale), err } diff --git a/kubernetes/typed/apps/v1beta2/generated_expansion.go b/kubernetes/typed/apps/v1beta2/generated_expansion.go new file mode 100644 index 000000000..86f5db2f6 --- /dev/null +++ b/kubernetes/typed/apps/v1beta2/generated_expansion.go @@ -0,0 +1,29 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1beta2 + +type ControllerRevisionClusterExpansion interface{} + +type DaemonSetClusterExpansion interface{} + +type DeploymentClusterExpansion interface{} + +type ReplicaSetClusterExpansion interface{} + +type StatefulSetClusterExpansion interface{} diff --git a/kubernetes/typed/apps/v1beta2/replicaset.go b/kubernetes/typed/apps/v1beta2/replicaset.go index 9726f1e4e..5f3645421 100644 --- a/kubernetes/typed/apps/v1beta2/replicaset.go +++ b/kubernetes/typed/apps/v1beta2/replicaset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta2 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" appsv1beta2 "k8s.io/api/apps/v1beta2" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - appsv1beta2client "k8s.io/client-go/kubernetes/typed/apps/v1beta2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedappsv1beta2 "k8s.io/client-go/kubernetes/typed/apps/v1beta2" ) // ReplicaSetsClusterGetter has a method to return a ReplicaSetClusterInterface. @@ -40,12 +40,13 @@ type ReplicaSetsClusterGetter interface { // or scope down to one cluster and return a ReplicaSetsNamespacer. type ReplicaSetClusterInterface interface { Cluster(logicalcluster.Path) ReplicaSetsNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta2.ReplicaSetList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*appsv1beta2.ReplicaSetList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + ReplicaSetClusterExpansion } type replicaSetsClusterInterface struct { - clientCache kcpclient.Cache[*appsv1beta2client.AppsV1beta2Client] + clientCache kcpclient.Cache[*typedappsv1beta2.AppsV1beta2Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *replicaSetsClusterInterface) Cluster(clusterPath logicalcluster.Path) R } // List returns the entire collection of all ReplicaSets across all clusters. -func (c *replicaSetsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta2.ReplicaSetList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ReplicaSets(metav1.NamespaceAll).List(ctx, opts) +func (c *replicaSetsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*appsv1beta2.ReplicaSetList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ReplicaSets(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all ReplicaSets across all clusters. -func (c *replicaSetsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ReplicaSets(metav1.NamespaceAll).Watch(ctx, opts) +func (c *replicaSetsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ReplicaSets(v1.NamespaceAll).Watch(ctx, opts) } -// ReplicaSetsNamespacer can scope to objects within a namespace, returning a appsv1beta2client.ReplicaSetInterface. +// ReplicaSetsNamespacer can scope to objects within a namespace, returning a typedappsv1beta2.ReplicaSetInterface. type ReplicaSetsNamespacer interface { - Namespace(string) appsv1beta2client.ReplicaSetInterface + Namespace(string) typedappsv1beta2.ReplicaSetInterface } type replicaSetsNamespacer struct { - clientCache kcpclient.Cache[*appsv1beta2client.AppsV1beta2Client] + clientCache kcpclient.Cache[*typedappsv1beta2.AppsV1beta2Client] clusterPath logicalcluster.Path } -func (n *replicaSetsNamespacer) Namespace(namespace string) appsv1beta2client.ReplicaSetInterface { +func (n *replicaSetsNamespacer) Namespace(namespace string) typedappsv1beta2.ReplicaSetInterface { return n.clientCache.ClusterOrDie(n.clusterPath).ReplicaSets(namespace) } diff --git a/kubernetes/typed/apps/v1beta2/statefulset.go b/kubernetes/typed/apps/v1beta2/statefulset.go index 2f68d1815..04ffca1da 100644 --- a/kubernetes/typed/apps/v1beta2/statefulset.go +++ b/kubernetes/typed/apps/v1beta2/statefulset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta2 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" appsv1beta2 "k8s.io/api/apps/v1beta2" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - appsv1beta2client "k8s.io/client-go/kubernetes/typed/apps/v1beta2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedappsv1beta2 "k8s.io/client-go/kubernetes/typed/apps/v1beta2" ) // StatefulSetsClusterGetter has a method to return a StatefulSetClusterInterface. @@ -40,12 +40,13 @@ type StatefulSetsClusterGetter interface { // or scope down to one cluster and return a StatefulSetsNamespacer. type StatefulSetClusterInterface interface { Cluster(logicalcluster.Path) StatefulSetsNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta2.StatefulSetList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*appsv1beta2.StatefulSetList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + StatefulSetClusterExpansion } type statefulSetsClusterInterface struct { - clientCache kcpclient.Cache[*appsv1beta2client.AppsV1beta2Client] + clientCache kcpclient.Cache[*typedappsv1beta2.AppsV1beta2Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *statefulSetsClusterInterface) Cluster(clusterPath logicalcluster.Path) } // List returns the entire collection of all StatefulSets across all clusters. -func (c *statefulSetsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta2.StatefulSetList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).StatefulSets(metav1.NamespaceAll).List(ctx, opts) +func (c *statefulSetsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*appsv1beta2.StatefulSetList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).StatefulSets(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all StatefulSets across all clusters. -func (c *statefulSetsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).StatefulSets(metav1.NamespaceAll).Watch(ctx, opts) +func (c *statefulSetsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).StatefulSets(v1.NamespaceAll).Watch(ctx, opts) } -// StatefulSetsNamespacer can scope to objects within a namespace, returning a appsv1beta2client.StatefulSetInterface. +// StatefulSetsNamespacer can scope to objects within a namespace, returning a typedappsv1beta2.StatefulSetInterface. type StatefulSetsNamespacer interface { - Namespace(string) appsv1beta2client.StatefulSetInterface + Namespace(string) typedappsv1beta2.StatefulSetInterface } type statefulSetsNamespacer struct { - clientCache kcpclient.Cache[*appsv1beta2client.AppsV1beta2Client] + clientCache kcpclient.Cache[*typedappsv1beta2.AppsV1beta2Client] clusterPath logicalcluster.Path } -func (n *statefulSetsNamespacer) Namespace(namespace string) appsv1beta2client.StatefulSetInterface { +func (n *statefulSetsNamespacer) Namespace(namespace string) typedappsv1beta2.StatefulSetInterface { return n.clientCache.ClusterOrDie(n.clusterPath).StatefulSets(namespace) } diff --git a/kubernetes/typed/authentication/v1/authentication_client.go b/kubernetes/typed/authentication/v1/authentication_client.go index 23dbb7bd0..31287d3ad 100644 --- a/kubernetes/typed/authentication/v1/authentication_client.go +++ b/kubernetes/typed/authentication/v1/authentication_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,30 +14,34 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apiauthenticationv1 "k8s.io/api/authentication/v1" authenticationv1 "k8s.io/client-go/kubernetes/typed/authentication/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type AuthenticationV1ClusterInterface interface { AuthenticationV1ClusterScoper - TokenReviewsClusterGetter SelfSubjectReviewsClusterGetter + TokenReviewsClusterGetter } type AuthenticationV1ClusterScoper interface { Cluster(logicalcluster.Path) authenticationv1.AuthenticationV1Interface } +// AuthenticationV1ClusterClient is used to interact with features provided by the authentication.k8s.io group. type AuthenticationV1ClusterClient struct { clientCache kcpclient.Cache[*authenticationv1.AuthenticationV1Client] } @@ -49,23 +53,25 @@ func (c *AuthenticationV1ClusterClient) Cluster(clusterPath logicalcluster.Path) return c.clientCache.ClusterOrDie(clusterPath) } -func (c *AuthenticationV1ClusterClient) TokenReviews() TokenReviewClusterInterface { - return &tokenReviewsClusterInterface{clientCache: c.clientCache} -} - func (c *AuthenticationV1ClusterClient) SelfSubjectReviews() SelfSubjectReviewClusterInterface { return &selfSubjectReviewsClusterInterface{clientCache: c.clientCache} } +func (c *AuthenticationV1ClusterClient) TokenReviews() TokenReviewClusterInterface { + return &tokenReviewsClusterInterface{clientCache: c.clientCache} +} + // NewForConfig creates a new AuthenticationV1ClusterClient for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*AuthenticationV1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new AuthenticationV1ClusterClient for the given config and http client. @@ -77,6 +83,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*AuthenticationV1Clu if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &AuthenticationV1ClusterClient{clientCache: cache}, nil } @@ -89,3 +96,14 @@ func NewForConfigOrDie(c *rest.Config) *AuthenticationV1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apiauthenticationv1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/authentication/v1/doc.go b/kubernetes/typed/authentication/v1/doc.go new file mode 100644 index 000000000..d2f3412ab --- /dev/null +++ b/kubernetes/typed/authentication/v1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1 diff --git a/kubernetes/typed/authentication/v1/fake/authentication_client.go b/kubernetes/typed/authentication/v1/fake/authentication_client.go index 8a594dbed..5752afdde 100644 --- a/kubernetes/typed/authentication/v1/fake/authentication_client.go +++ b/kubernetes/typed/authentication/v1/fake/authentication_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" authenticationv1 "k8s.io/client-go/kubernetes/typed/authentication/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpauthenticationv1 "github.com/kcp-dev/client-go/kubernetes/typed/authentication/v1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -41,30 +41,30 @@ func (c *AuthenticationV1ClusterClient) Cluster(clusterPath logicalcluster.Path) return &AuthenticationV1Client{Fake: c.Fake, ClusterPath: clusterPath} } -func (c *AuthenticationV1ClusterClient) TokenReviews() kcpauthenticationv1.TokenReviewClusterInterface { - return &tokenReviewsClusterClient{Fake: c.Fake} -} - func (c *AuthenticationV1ClusterClient) SelfSubjectReviews() kcpauthenticationv1.SelfSubjectReviewClusterInterface { - return &selfSubjectReviewsClusterClient{Fake: c.Fake} + return newFakeSelfSubjectReviewClusterClient(c) } -var _ authenticationv1.AuthenticationV1Interface = (*AuthenticationV1Client)(nil) +func (c *AuthenticationV1ClusterClient) TokenReviews() kcpauthenticationv1.TokenReviewClusterInterface { + return newFakeTokenReviewClusterClient(c) +} type AuthenticationV1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *AuthenticationV1Client) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret +func (c *AuthenticationV1Client) SelfSubjectReviews() authenticationv1.SelfSubjectReviewInterface { + return newFakeSelfSubjectReviewClient(c.Fake, c.ClusterPath) } func (c *AuthenticationV1Client) TokenReviews() authenticationv1.TokenReviewInterface { - return &tokenReviewsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} + return newFakeTokenReviewClient(c.Fake, c.ClusterPath) } -func (c *AuthenticationV1Client) SelfSubjectReviews() authenticationv1.SelfSubjectReviewInterface { - return &selfSubjectReviewsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *AuthenticationV1Client) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret } diff --git a/kubernetes/typed/authentication/v1/fake/doc.go b/kubernetes/typed/authentication/v1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/authentication/v1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/authentication/v1/fake/selfsubjectreview.go b/kubernetes/typed/authentication/v1/fake/selfsubjectreview.go index b7c4f8051..078283ba4 100644 --- a/kubernetes/typed/authentication/v1/fake/selfsubjectreview.go +++ b/kubernetes/typed/authentication/v1/fake/selfsubjectreview.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,48 +14,61 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "github.com/kcp-dev/logicalcluster/v3" authenticationv1 "k8s.io/api/authentication/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - authenticationv1client "k8s.io/client-go/kubernetes/typed/authentication/v1" + typedauthenticationv1 "k8s.io/client-go/kubernetes/typed/authentication/v1" + typedkcpauthenticationv1 "github.com/kcp-dev/client-go/kubernetes/typed/authentication/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var selfSubjectReviewsResource = schema.GroupVersionResource{Group: "authentication.k8s.io", Version: "v1", Resource: "selfsubjectreviews"} -var selfSubjectReviewsKind = schema.GroupVersionKind{Group: "authentication.k8s.io", Version: "v1", Kind: "SelfSubjectReview"} - -type selfSubjectReviewsClusterClient struct { - *kcptesting.Fake +// selfSubjectReviewClusterClient implements SelfSubjectReviewClusterInterface +type selfSubjectReviewClusterClient struct { + *kcpgentype.FakeClusterClient[*authenticationv1.SelfSubjectReview] + Fake *kcptesting.Fake } -// Cluster scopes the client down to a particular cluster. -func (c *selfSubjectReviewsClusterClient) Cluster(clusterPath logicalcluster.Path) authenticationv1client.SelfSubjectReviewInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") +func newFakeSelfSubjectReviewClusterClient(fake *AuthenticationV1ClusterClient) typedkcpauthenticationv1.SelfSubjectReviewClusterInterface { + return &selfSubjectReviewClusterClient{ + kcpgentype.NewFakeClusterClient[*authenticationv1.SelfSubjectReview]( + fake.Fake, + authenticationv1.SchemeGroupVersion.WithResource("selfsubjectreviews"), + authenticationv1.SchemeGroupVersion.WithKind("SelfSubjectReview"), + func() *authenticationv1.SelfSubjectReview { return &authenticationv1.SelfSubjectReview{} }, + ), + fake.Fake, } +} - return &selfSubjectReviewsClient{Fake: c.Fake, ClusterPath: clusterPath} +func (c *selfSubjectReviewClusterClient) Cluster(cluster logicalcluster.Path) typedauthenticationv1.SelfSubjectReviewInterface { + return newFakeSelfSubjectReviewClient(c.Fake, cluster) } -type selfSubjectReviewsClient struct { - *kcptesting.Fake +// selfSubjectReviewScopedClient implements SelfSubjectReviewInterface +type selfSubjectReviewScopedClient struct { + *kcpgentype.FakeClient[*authenticationv1.SelfSubjectReview] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *selfSubjectReviewsClient) Create(ctx context.Context, selfSubjectReview *authenticationv1.SelfSubjectReview, opts metav1.CreateOptions) (*authenticationv1.SelfSubjectReview, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(selfSubjectReviewsResource, c.ClusterPath, selfSubjectReview), &authenticationv1.SelfSubjectReview{}) - if obj == nil { - return nil, err +func newFakeSelfSubjectReviewClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedauthenticationv1.SelfSubjectReviewInterface { + return &selfSubjectReviewScopedClient{ + kcpgentype.NewFakeClient[*authenticationv1.SelfSubjectReview]( + fake, + clusterPath, + "", + authenticationv1.SchemeGroupVersion.WithResource("selfsubjectreviews"), + authenticationv1.SchemeGroupVersion.WithKind("SelfSubjectReview"), + func() *authenticationv1.SelfSubjectReview { return &authenticationv1.SelfSubjectReview{} }, + ), + fake, + clusterPath, } - return obj.(*authenticationv1.SelfSubjectReview), err } diff --git a/kubernetes/typed/authentication/v1/fake/tokenreview.go b/kubernetes/typed/authentication/v1/fake/tokenreview.go index 0996d79ac..36e7111dc 100644 --- a/kubernetes/typed/authentication/v1/fake/tokenreview.go +++ b/kubernetes/typed/authentication/v1/fake/tokenreview.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,48 +14,61 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "github.com/kcp-dev/logicalcluster/v3" authenticationv1 "k8s.io/api/authentication/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - authenticationv1client "k8s.io/client-go/kubernetes/typed/authentication/v1" + typedauthenticationv1 "k8s.io/client-go/kubernetes/typed/authentication/v1" + typedkcpauthenticationv1 "github.com/kcp-dev/client-go/kubernetes/typed/authentication/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var tokenReviewsResource = schema.GroupVersionResource{Group: "authentication.k8s.io", Version: "v1", Resource: "tokenreviews"} -var tokenReviewsKind = schema.GroupVersionKind{Group: "authentication.k8s.io", Version: "v1", Kind: "TokenReview"} - -type tokenReviewsClusterClient struct { - *kcptesting.Fake +// tokenReviewClusterClient implements TokenReviewClusterInterface +type tokenReviewClusterClient struct { + *kcpgentype.FakeClusterClient[*authenticationv1.TokenReview] + Fake *kcptesting.Fake } -// Cluster scopes the client down to a particular cluster. -func (c *tokenReviewsClusterClient) Cluster(clusterPath logicalcluster.Path) authenticationv1client.TokenReviewInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") +func newFakeTokenReviewClusterClient(fake *AuthenticationV1ClusterClient) typedkcpauthenticationv1.TokenReviewClusterInterface { + return &tokenReviewClusterClient{ + kcpgentype.NewFakeClusterClient[*authenticationv1.TokenReview]( + fake.Fake, + authenticationv1.SchemeGroupVersion.WithResource("tokenreviews"), + authenticationv1.SchemeGroupVersion.WithKind("TokenReview"), + func() *authenticationv1.TokenReview { return &authenticationv1.TokenReview{} }, + ), + fake.Fake, } +} - return &tokenReviewsClient{Fake: c.Fake, ClusterPath: clusterPath} +func (c *tokenReviewClusterClient) Cluster(cluster logicalcluster.Path) typedauthenticationv1.TokenReviewInterface { + return newFakeTokenReviewClient(c.Fake, cluster) } -type tokenReviewsClient struct { - *kcptesting.Fake +// tokenReviewScopedClient implements TokenReviewInterface +type tokenReviewScopedClient struct { + *kcpgentype.FakeClient[*authenticationv1.TokenReview] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *tokenReviewsClient) Create(ctx context.Context, tokenReview *authenticationv1.TokenReview, opts metav1.CreateOptions) (*authenticationv1.TokenReview, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(tokenReviewsResource, c.ClusterPath, tokenReview), &authenticationv1.TokenReview{}) - if obj == nil { - return nil, err +func newFakeTokenReviewClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedauthenticationv1.TokenReviewInterface { + return &tokenReviewScopedClient{ + kcpgentype.NewFakeClient[*authenticationv1.TokenReview]( + fake, + clusterPath, + "", + authenticationv1.SchemeGroupVersion.WithResource("tokenreviews"), + authenticationv1.SchemeGroupVersion.WithKind("TokenReview"), + func() *authenticationv1.TokenReview { return &authenticationv1.TokenReview{} }, + ), + fake, + clusterPath, } - return obj.(*authenticationv1.TokenReview), err } diff --git a/kubernetes/typed/authentication/v1/generated_expansion.go b/kubernetes/typed/authentication/v1/generated_expansion.go new file mode 100644 index 000000000..5076e9f82 --- /dev/null +++ b/kubernetes/typed/authentication/v1/generated_expansion.go @@ -0,0 +1,23 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1 + +type SelfSubjectReviewClusterExpansion interface{} + +type TokenReviewClusterExpansion interface{} diff --git a/kubernetes/typed/authentication/v1/selfsubjectreview.go b/kubernetes/typed/authentication/v1/selfsubjectreview.go index 2789d6d48..bfd04b7b3 100644 --- a/kubernetes/typed/authentication/v1/selfsubjectreview.go +++ b/kubernetes/typed/authentication/v1/selfsubjectreview.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 @@ -22,7 +22,7 @@ import ( kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - authenticationv1client "k8s.io/client-go/kubernetes/typed/authentication/v1" + authenticationv1 "k8s.io/client-go/kubernetes/typed/authentication/v1" ) // SelfSubjectReviewsClusterGetter has a method to return a SelfSubjectReviewClusterInterface. @@ -31,17 +31,20 @@ type SelfSubjectReviewsClusterGetter interface { SelfSubjectReviews() SelfSubjectReviewClusterInterface } -// SelfSubjectReviewClusterInterface can scope down to one cluster and return a authenticationv1client.SelfSubjectReviewInterface. +// SelfSubjectReviewClusterInterface can operate on SelfSubjectReviews across all clusters, +// or scope down to one cluster and return a authenticationv1.SelfSubjectReviewInterface. type SelfSubjectReviewClusterInterface interface { - Cluster(logicalcluster.Path) authenticationv1client.SelfSubjectReviewInterface + Cluster(logicalcluster.Path) authenticationv1.SelfSubjectReviewInterface + + SelfSubjectReviewClusterExpansion } type selfSubjectReviewsClusterInterface struct { - clientCache kcpclient.Cache[*authenticationv1client.AuthenticationV1Client] + clientCache kcpclient.Cache[*authenticationv1.AuthenticationV1Client] } // Cluster scopes the client down to a particular cluster. -func (c *selfSubjectReviewsClusterInterface) Cluster(clusterPath logicalcluster.Path) authenticationv1client.SelfSubjectReviewInterface { +func (c *selfSubjectReviewsClusterInterface) Cluster(clusterPath logicalcluster.Path) authenticationv1.SelfSubjectReviewInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } diff --git a/kubernetes/typed/authentication/v1/tokenreview.go b/kubernetes/typed/authentication/v1/tokenreview.go index 524050f5c..c55a60de6 100644 --- a/kubernetes/typed/authentication/v1/tokenreview.go +++ b/kubernetes/typed/authentication/v1/tokenreview.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 @@ -22,7 +22,7 @@ import ( kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - authenticationv1client "k8s.io/client-go/kubernetes/typed/authentication/v1" + authenticationv1 "k8s.io/client-go/kubernetes/typed/authentication/v1" ) // TokenReviewsClusterGetter has a method to return a TokenReviewClusterInterface. @@ -31,17 +31,20 @@ type TokenReviewsClusterGetter interface { TokenReviews() TokenReviewClusterInterface } -// TokenReviewClusterInterface can scope down to one cluster and return a authenticationv1client.TokenReviewInterface. +// TokenReviewClusterInterface can operate on TokenReviews across all clusters, +// or scope down to one cluster and return a authenticationv1.TokenReviewInterface. type TokenReviewClusterInterface interface { - Cluster(logicalcluster.Path) authenticationv1client.TokenReviewInterface + Cluster(logicalcluster.Path) authenticationv1.TokenReviewInterface + + TokenReviewClusterExpansion } type tokenReviewsClusterInterface struct { - clientCache kcpclient.Cache[*authenticationv1client.AuthenticationV1Client] + clientCache kcpclient.Cache[*authenticationv1.AuthenticationV1Client] } // Cluster scopes the client down to a particular cluster. -func (c *tokenReviewsClusterInterface) Cluster(clusterPath logicalcluster.Path) authenticationv1client.TokenReviewInterface { +func (c *tokenReviewsClusterInterface) Cluster(clusterPath logicalcluster.Path) authenticationv1.TokenReviewInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } diff --git a/kubernetes/typed/authentication/v1alpha1/authentication_client.go b/kubernetes/typed/authentication/v1alpha1/authentication_client.go index efca67bfa..c439f64d0 100644 --- a/kubernetes/typed/authentication/v1alpha1/authentication_client.go +++ b/kubernetes/typed/authentication/v1alpha1/authentication_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apiauthenticationv1alpha1 "k8s.io/api/authentication/v1alpha1" authenticationv1alpha1 "k8s.io/client-go/kubernetes/typed/authentication/v1alpha1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type AuthenticationV1alpha1ClusterInterface interface { @@ -37,6 +40,7 @@ type AuthenticationV1alpha1ClusterScoper interface { Cluster(logicalcluster.Path) authenticationv1alpha1.AuthenticationV1alpha1Interface } +// AuthenticationV1alpha1ClusterClient is used to interact with features provided by the authentication.k8s.io group. type AuthenticationV1alpha1ClusterClient struct { clientCache kcpclient.Cache[*authenticationv1alpha1.AuthenticationV1alpha1Client] } @@ -56,11 +60,13 @@ func (c *AuthenticationV1alpha1ClusterClient) SelfSubjectReviews() SelfSubjectRe // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*AuthenticationV1alpha1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new AuthenticationV1alpha1ClusterClient for the given config and http client. @@ -72,6 +78,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*AuthenticationV1alp if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &AuthenticationV1alpha1ClusterClient{clientCache: cache}, nil } @@ -84,3 +91,14 @@ func NewForConfigOrDie(c *rest.Config) *AuthenticationV1alpha1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apiauthenticationv1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/authentication/v1alpha1/doc.go b/kubernetes/typed/authentication/v1alpha1/doc.go new file mode 100644 index 000000000..08b80237c --- /dev/null +++ b/kubernetes/typed/authentication/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/kubernetes/typed/authentication/v1alpha1/fake/authentication_client.go b/kubernetes/typed/authentication/v1alpha1/fake/authentication_client.go index c0b76b73d..0f03e11c2 100644 --- a/kubernetes/typed/authentication/v1alpha1/fake/authentication_client.go +++ b/kubernetes/typed/authentication/v1alpha1/fake/authentication_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" authenticationv1alpha1 "k8s.io/client-go/kubernetes/typed/authentication/v1alpha1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpauthenticationv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/authentication/v1alpha1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -42,21 +42,21 @@ func (c *AuthenticationV1alpha1ClusterClient) Cluster(clusterPath logicalcluster } func (c *AuthenticationV1alpha1ClusterClient) SelfSubjectReviews() kcpauthenticationv1alpha1.SelfSubjectReviewClusterInterface { - return &selfSubjectReviewsClusterClient{Fake: c.Fake} + return newFakeSelfSubjectReviewClusterClient(c) } -var _ authenticationv1alpha1.AuthenticationV1alpha1Interface = (*AuthenticationV1alpha1Client)(nil) - type AuthenticationV1alpha1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } +func (c *AuthenticationV1alpha1Client) SelfSubjectReviews() authenticationv1alpha1.SelfSubjectReviewInterface { + return newFakeSelfSubjectReviewClient(c.Fake, c.ClusterPath) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. func (c *AuthenticationV1alpha1Client) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } - -func (c *AuthenticationV1alpha1Client) SelfSubjectReviews() authenticationv1alpha1.SelfSubjectReviewInterface { - return &selfSubjectReviewsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} -} diff --git a/kubernetes/typed/authentication/v1alpha1/fake/doc.go b/kubernetes/typed/authentication/v1alpha1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/authentication/v1alpha1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/authentication/v1alpha1/fake/selfsubjectreview.go b/kubernetes/typed/authentication/v1alpha1/fake/selfsubjectreview.go index ca1ad489b..333aa64b5 100644 --- a/kubernetes/typed/authentication/v1alpha1/fake/selfsubjectreview.go +++ b/kubernetes/typed/authentication/v1alpha1/fake/selfsubjectreview.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,48 +14,61 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "github.com/kcp-dev/logicalcluster/v3" authenticationv1alpha1 "k8s.io/api/authentication/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - authenticationv1alpha1client "k8s.io/client-go/kubernetes/typed/authentication/v1alpha1" + typedauthenticationv1alpha1 "k8s.io/client-go/kubernetes/typed/authentication/v1alpha1" + typedkcpauthenticationv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/authentication/v1alpha1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var selfSubjectReviewsResource = schema.GroupVersionResource{Group: "authentication.k8s.io", Version: "v1alpha1", Resource: "selfsubjectreviews"} -var selfSubjectReviewsKind = schema.GroupVersionKind{Group: "authentication.k8s.io", Version: "v1alpha1", Kind: "SelfSubjectReview"} - -type selfSubjectReviewsClusterClient struct { - *kcptesting.Fake +// selfSubjectReviewClusterClient implements SelfSubjectReviewClusterInterface +type selfSubjectReviewClusterClient struct { + *kcpgentype.FakeClusterClient[*authenticationv1alpha1.SelfSubjectReview] + Fake *kcptesting.Fake } -// Cluster scopes the client down to a particular cluster. -func (c *selfSubjectReviewsClusterClient) Cluster(clusterPath logicalcluster.Path) authenticationv1alpha1client.SelfSubjectReviewInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") +func newFakeSelfSubjectReviewClusterClient(fake *AuthenticationV1alpha1ClusterClient) typedkcpauthenticationv1alpha1.SelfSubjectReviewClusterInterface { + return &selfSubjectReviewClusterClient{ + kcpgentype.NewFakeClusterClient[*authenticationv1alpha1.SelfSubjectReview]( + fake.Fake, + authenticationv1alpha1.SchemeGroupVersion.WithResource("selfsubjectreviews"), + authenticationv1alpha1.SchemeGroupVersion.WithKind("SelfSubjectReview"), + func() *authenticationv1alpha1.SelfSubjectReview { return &authenticationv1alpha1.SelfSubjectReview{} }, + ), + fake.Fake, } +} - return &selfSubjectReviewsClient{Fake: c.Fake, ClusterPath: clusterPath} +func (c *selfSubjectReviewClusterClient) Cluster(cluster logicalcluster.Path) typedauthenticationv1alpha1.SelfSubjectReviewInterface { + return newFakeSelfSubjectReviewClient(c.Fake, cluster) } -type selfSubjectReviewsClient struct { - *kcptesting.Fake +// selfSubjectReviewScopedClient implements SelfSubjectReviewInterface +type selfSubjectReviewScopedClient struct { + *kcpgentype.FakeClient[*authenticationv1alpha1.SelfSubjectReview] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *selfSubjectReviewsClient) Create(ctx context.Context, selfSubjectReview *authenticationv1alpha1.SelfSubjectReview, opts metav1.CreateOptions) (*authenticationv1alpha1.SelfSubjectReview, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(selfSubjectReviewsResource, c.ClusterPath, selfSubjectReview), &authenticationv1alpha1.SelfSubjectReview{}) - if obj == nil { - return nil, err +func newFakeSelfSubjectReviewClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedauthenticationv1alpha1.SelfSubjectReviewInterface { + return &selfSubjectReviewScopedClient{ + kcpgentype.NewFakeClient[*authenticationv1alpha1.SelfSubjectReview]( + fake, + clusterPath, + "", + authenticationv1alpha1.SchemeGroupVersion.WithResource("selfsubjectreviews"), + authenticationv1alpha1.SchemeGroupVersion.WithKind("SelfSubjectReview"), + func() *authenticationv1alpha1.SelfSubjectReview { return &authenticationv1alpha1.SelfSubjectReview{} }, + ), + fake, + clusterPath, } - return obj.(*authenticationv1alpha1.SelfSubjectReview), err } diff --git a/kubernetes/typed/authentication/v1alpha1/generated_expansion.go b/kubernetes/typed/authentication/v1alpha1/generated_expansion.go new file mode 100644 index 000000000..fcc072a13 --- /dev/null +++ b/kubernetes/typed/authentication/v1alpha1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1alpha1 + +type SelfSubjectReviewClusterExpansion interface{} diff --git a/kubernetes/typed/authentication/v1alpha1/selfsubjectreview.go b/kubernetes/typed/authentication/v1alpha1/selfsubjectreview.go index 5aaf31dba..70fd71113 100644 --- a/kubernetes/typed/authentication/v1alpha1/selfsubjectreview.go +++ b/kubernetes/typed/authentication/v1alpha1/selfsubjectreview.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha1 @@ -22,7 +22,7 @@ import ( kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - authenticationv1alpha1client "k8s.io/client-go/kubernetes/typed/authentication/v1alpha1" + authenticationv1alpha1 "k8s.io/client-go/kubernetes/typed/authentication/v1alpha1" ) // SelfSubjectReviewsClusterGetter has a method to return a SelfSubjectReviewClusterInterface. @@ -31,17 +31,20 @@ type SelfSubjectReviewsClusterGetter interface { SelfSubjectReviews() SelfSubjectReviewClusterInterface } -// SelfSubjectReviewClusterInterface can scope down to one cluster and return a authenticationv1alpha1client.SelfSubjectReviewInterface. +// SelfSubjectReviewClusterInterface can operate on SelfSubjectReviews across all clusters, +// or scope down to one cluster and return a authenticationv1alpha1.SelfSubjectReviewInterface. type SelfSubjectReviewClusterInterface interface { - Cluster(logicalcluster.Path) authenticationv1alpha1client.SelfSubjectReviewInterface + Cluster(logicalcluster.Path) authenticationv1alpha1.SelfSubjectReviewInterface + + SelfSubjectReviewClusterExpansion } type selfSubjectReviewsClusterInterface struct { - clientCache kcpclient.Cache[*authenticationv1alpha1client.AuthenticationV1alpha1Client] + clientCache kcpclient.Cache[*authenticationv1alpha1.AuthenticationV1alpha1Client] } // Cluster scopes the client down to a particular cluster. -func (c *selfSubjectReviewsClusterInterface) Cluster(clusterPath logicalcluster.Path) authenticationv1alpha1client.SelfSubjectReviewInterface { +func (c *selfSubjectReviewsClusterInterface) Cluster(clusterPath logicalcluster.Path) authenticationv1alpha1.SelfSubjectReviewInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } diff --git a/kubernetes/typed/authentication/v1beta1/authentication_client.go b/kubernetes/typed/authentication/v1beta1/authentication_client.go index a39f44bf5..513af36d8 100644 --- a/kubernetes/typed/authentication/v1beta1/authentication_client.go +++ b/kubernetes/typed/authentication/v1beta1/authentication_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,30 +14,34 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apiauthenticationv1beta1 "k8s.io/api/authentication/v1beta1" authenticationv1beta1 "k8s.io/client-go/kubernetes/typed/authentication/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type AuthenticationV1beta1ClusterInterface interface { AuthenticationV1beta1ClusterScoper - TokenReviewsClusterGetter SelfSubjectReviewsClusterGetter + TokenReviewsClusterGetter } type AuthenticationV1beta1ClusterScoper interface { Cluster(logicalcluster.Path) authenticationv1beta1.AuthenticationV1beta1Interface } +// AuthenticationV1beta1ClusterClient is used to interact with features provided by the authentication.k8s.io group. type AuthenticationV1beta1ClusterClient struct { clientCache kcpclient.Cache[*authenticationv1beta1.AuthenticationV1beta1Client] } @@ -49,23 +53,25 @@ func (c *AuthenticationV1beta1ClusterClient) Cluster(clusterPath logicalcluster. return c.clientCache.ClusterOrDie(clusterPath) } -func (c *AuthenticationV1beta1ClusterClient) TokenReviews() TokenReviewClusterInterface { - return &tokenReviewsClusterInterface{clientCache: c.clientCache} -} - func (c *AuthenticationV1beta1ClusterClient) SelfSubjectReviews() SelfSubjectReviewClusterInterface { return &selfSubjectReviewsClusterInterface{clientCache: c.clientCache} } +func (c *AuthenticationV1beta1ClusterClient) TokenReviews() TokenReviewClusterInterface { + return &tokenReviewsClusterInterface{clientCache: c.clientCache} +} + // NewForConfig creates a new AuthenticationV1beta1ClusterClient for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*AuthenticationV1beta1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new AuthenticationV1beta1ClusterClient for the given config and http client. @@ -77,6 +83,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*AuthenticationV1bet if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &AuthenticationV1beta1ClusterClient{clientCache: cache}, nil } @@ -89,3 +96,14 @@ func NewForConfigOrDie(c *rest.Config) *AuthenticationV1beta1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apiauthenticationv1beta1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/authentication/v1beta1/doc.go b/kubernetes/typed/authentication/v1beta1/doc.go new file mode 100644 index 000000000..541e9d258 --- /dev/null +++ b/kubernetes/typed/authentication/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1beta1 diff --git a/kubernetes/typed/authentication/v1beta1/fake/authentication_client.go b/kubernetes/typed/authentication/v1beta1/fake/authentication_client.go index f195ad961..278bafc65 100644 --- a/kubernetes/typed/authentication/v1beta1/fake/authentication_client.go +++ b/kubernetes/typed/authentication/v1beta1/fake/authentication_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" authenticationv1beta1 "k8s.io/client-go/kubernetes/typed/authentication/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpauthenticationv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/authentication/v1beta1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -41,30 +41,30 @@ func (c *AuthenticationV1beta1ClusterClient) Cluster(clusterPath logicalcluster. return &AuthenticationV1beta1Client{Fake: c.Fake, ClusterPath: clusterPath} } -func (c *AuthenticationV1beta1ClusterClient) TokenReviews() kcpauthenticationv1beta1.TokenReviewClusterInterface { - return &tokenReviewsClusterClient{Fake: c.Fake} -} - func (c *AuthenticationV1beta1ClusterClient) SelfSubjectReviews() kcpauthenticationv1beta1.SelfSubjectReviewClusterInterface { - return &selfSubjectReviewsClusterClient{Fake: c.Fake} + return newFakeSelfSubjectReviewClusterClient(c) } -var _ authenticationv1beta1.AuthenticationV1beta1Interface = (*AuthenticationV1beta1Client)(nil) +func (c *AuthenticationV1beta1ClusterClient) TokenReviews() kcpauthenticationv1beta1.TokenReviewClusterInterface { + return newFakeTokenReviewClusterClient(c) +} type AuthenticationV1beta1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *AuthenticationV1beta1Client) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret +func (c *AuthenticationV1beta1Client) SelfSubjectReviews() authenticationv1beta1.SelfSubjectReviewInterface { + return newFakeSelfSubjectReviewClient(c.Fake, c.ClusterPath) } func (c *AuthenticationV1beta1Client) TokenReviews() authenticationv1beta1.TokenReviewInterface { - return &tokenReviewsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} + return newFakeTokenReviewClient(c.Fake, c.ClusterPath) } -func (c *AuthenticationV1beta1Client) SelfSubjectReviews() authenticationv1beta1.SelfSubjectReviewInterface { - return &selfSubjectReviewsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *AuthenticationV1beta1Client) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret } diff --git a/kubernetes/typed/authentication/v1beta1/fake/doc.go b/kubernetes/typed/authentication/v1beta1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/authentication/v1beta1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/authentication/v1beta1/fake/selfsubjectreview.go b/kubernetes/typed/authentication/v1beta1/fake/selfsubjectreview.go index 120f1dd01..66d970297 100644 --- a/kubernetes/typed/authentication/v1beta1/fake/selfsubjectreview.go +++ b/kubernetes/typed/authentication/v1beta1/fake/selfsubjectreview.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,48 +14,61 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "github.com/kcp-dev/logicalcluster/v3" authenticationv1beta1 "k8s.io/api/authentication/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - authenticationv1beta1client "k8s.io/client-go/kubernetes/typed/authentication/v1beta1" + typedauthenticationv1beta1 "k8s.io/client-go/kubernetes/typed/authentication/v1beta1" + typedkcpauthenticationv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/authentication/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var selfSubjectReviewsResource = schema.GroupVersionResource{Group: "authentication.k8s.io", Version: "v1beta1", Resource: "selfsubjectreviews"} -var selfSubjectReviewsKind = schema.GroupVersionKind{Group: "authentication.k8s.io", Version: "v1beta1", Kind: "SelfSubjectReview"} - -type selfSubjectReviewsClusterClient struct { - *kcptesting.Fake +// selfSubjectReviewClusterClient implements SelfSubjectReviewClusterInterface +type selfSubjectReviewClusterClient struct { + *kcpgentype.FakeClusterClient[*authenticationv1beta1.SelfSubjectReview] + Fake *kcptesting.Fake } -// Cluster scopes the client down to a particular cluster. -func (c *selfSubjectReviewsClusterClient) Cluster(clusterPath logicalcluster.Path) authenticationv1beta1client.SelfSubjectReviewInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") +func newFakeSelfSubjectReviewClusterClient(fake *AuthenticationV1beta1ClusterClient) typedkcpauthenticationv1beta1.SelfSubjectReviewClusterInterface { + return &selfSubjectReviewClusterClient{ + kcpgentype.NewFakeClusterClient[*authenticationv1beta1.SelfSubjectReview]( + fake.Fake, + authenticationv1beta1.SchemeGroupVersion.WithResource("selfsubjectreviews"), + authenticationv1beta1.SchemeGroupVersion.WithKind("SelfSubjectReview"), + func() *authenticationv1beta1.SelfSubjectReview { return &authenticationv1beta1.SelfSubjectReview{} }, + ), + fake.Fake, } +} - return &selfSubjectReviewsClient{Fake: c.Fake, ClusterPath: clusterPath} +func (c *selfSubjectReviewClusterClient) Cluster(cluster logicalcluster.Path) typedauthenticationv1beta1.SelfSubjectReviewInterface { + return newFakeSelfSubjectReviewClient(c.Fake, cluster) } -type selfSubjectReviewsClient struct { - *kcptesting.Fake +// selfSubjectReviewScopedClient implements SelfSubjectReviewInterface +type selfSubjectReviewScopedClient struct { + *kcpgentype.FakeClient[*authenticationv1beta1.SelfSubjectReview] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *selfSubjectReviewsClient) Create(ctx context.Context, selfSubjectReview *authenticationv1beta1.SelfSubjectReview, opts metav1.CreateOptions) (*authenticationv1beta1.SelfSubjectReview, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(selfSubjectReviewsResource, c.ClusterPath, selfSubjectReview), &authenticationv1beta1.SelfSubjectReview{}) - if obj == nil { - return nil, err +func newFakeSelfSubjectReviewClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedauthenticationv1beta1.SelfSubjectReviewInterface { + return &selfSubjectReviewScopedClient{ + kcpgentype.NewFakeClient[*authenticationv1beta1.SelfSubjectReview]( + fake, + clusterPath, + "", + authenticationv1beta1.SchemeGroupVersion.WithResource("selfsubjectreviews"), + authenticationv1beta1.SchemeGroupVersion.WithKind("SelfSubjectReview"), + func() *authenticationv1beta1.SelfSubjectReview { return &authenticationv1beta1.SelfSubjectReview{} }, + ), + fake, + clusterPath, } - return obj.(*authenticationv1beta1.SelfSubjectReview), err } diff --git a/kubernetes/typed/authentication/v1beta1/fake/tokenreview.go b/kubernetes/typed/authentication/v1beta1/fake/tokenreview.go index 8efb5bb94..5d8f26724 100644 --- a/kubernetes/typed/authentication/v1beta1/fake/tokenreview.go +++ b/kubernetes/typed/authentication/v1beta1/fake/tokenreview.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,48 +14,61 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "github.com/kcp-dev/logicalcluster/v3" authenticationv1beta1 "k8s.io/api/authentication/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - authenticationv1beta1client "k8s.io/client-go/kubernetes/typed/authentication/v1beta1" + typedauthenticationv1beta1 "k8s.io/client-go/kubernetes/typed/authentication/v1beta1" + typedkcpauthenticationv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/authentication/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var tokenReviewsResource = schema.GroupVersionResource{Group: "authentication.k8s.io", Version: "v1beta1", Resource: "tokenreviews"} -var tokenReviewsKind = schema.GroupVersionKind{Group: "authentication.k8s.io", Version: "v1beta1", Kind: "TokenReview"} - -type tokenReviewsClusterClient struct { - *kcptesting.Fake +// tokenReviewClusterClient implements TokenReviewClusterInterface +type tokenReviewClusterClient struct { + *kcpgentype.FakeClusterClient[*authenticationv1beta1.TokenReview] + Fake *kcptesting.Fake } -// Cluster scopes the client down to a particular cluster. -func (c *tokenReviewsClusterClient) Cluster(clusterPath logicalcluster.Path) authenticationv1beta1client.TokenReviewInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") +func newFakeTokenReviewClusterClient(fake *AuthenticationV1beta1ClusterClient) typedkcpauthenticationv1beta1.TokenReviewClusterInterface { + return &tokenReviewClusterClient{ + kcpgentype.NewFakeClusterClient[*authenticationv1beta1.TokenReview]( + fake.Fake, + authenticationv1beta1.SchemeGroupVersion.WithResource("tokenreviews"), + authenticationv1beta1.SchemeGroupVersion.WithKind("TokenReview"), + func() *authenticationv1beta1.TokenReview { return &authenticationv1beta1.TokenReview{} }, + ), + fake.Fake, } +} - return &tokenReviewsClient{Fake: c.Fake, ClusterPath: clusterPath} +func (c *tokenReviewClusterClient) Cluster(cluster logicalcluster.Path) typedauthenticationv1beta1.TokenReviewInterface { + return newFakeTokenReviewClient(c.Fake, cluster) } -type tokenReviewsClient struct { - *kcptesting.Fake +// tokenReviewScopedClient implements TokenReviewInterface +type tokenReviewScopedClient struct { + *kcpgentype.FakeClient[*authenticationv1beta1.TokenReview] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *tokenReviewsClient) Create(ctx context.Context, tokenReview *authenticationv1beta1.TokenReview, opts metav1.CreateOptions) (*authenticationv1beta1.TokenReview, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(tokenReviewsResource, c.ClusterPath, tokenReview), &authenticationv1beta1.TokenReview{}) - if obj == nil { - return nil, err +func newFakeTokenReviewClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedauthenticationv1beta1.TokenReviewInterface { + return &tokenReviewScopedClient{ + kcpgentype.NewFakeClient[*authenticationv1beta1.TokenReview]( + fake, + clusterPath, + "", + authenticationv1beta1.SchemeGroupVersion.WithResource("tokenreviews"), + authenticationv1beta1.SchemeGroupVersion.WithKind("TokenReview"), + func() *authenticationv1beta1.TokenReview { return &authenticationv1beta1.TokenReview{} }, + ), + fake, + clusterPath, } - return obj.(*authenticationv1beta1.TokenReview), err } diff --git a/kubernetes/typed/authentication/v1beta1/generated_expansion.go b/kubernetes/typed/authentication/v1beta1/generated_expansion.go new file mode 100644 index 000000000..797d42095 --- /dev/null +++ b/kubernetes/typed/authentication/v1beta1/generated_expansion.go @@ -0,0 +1,23 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1beta1 + +type SelfSubjectReviewClusterExpansion interface{} + +type TokenReviewClusterExpansion interface{} diff --git a/kubernetes/typed/authentication/v1beta1/selfsubjectreview.go b/kubernetes/typed/authentication/v1beta1/selfsubjectreview.go index 6170218bf..12e2560ea 100644 --- a/kubernetes/typed/authentication/v1beta1/selfsubjectreview.go +++ b/kubernetes/typed/authentication/v1beta1/selfsubjectreview.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 @@ -22,7 +22,7 @@ import ( kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - authenticationv1beta1client "k8s.io/client-go/kubernetes/typed/authentication/v1beta1" + authenticationv1beta1 "k8s.io/client-go/kubernetes/typed/authentication/v1beta1" ) // SelfSubjectReviewsClusterGetter has a method to return a SelfSubjectReviewClusterInterface. @@ -31,17 +31,20 @@ type SelfSubjectReviewsClusterGetter interface { SelfSubjectReviews() SelfSubjectReviewClusterInterface } -// SelfSubjectReviewClusterInterface can scope down to one cluster and return a authenticationv1beta1client.SelfSubjectReviewInterface. +// SelfSubjectReviewClusterInterface can operate on SelfSubjectReviews across all clusters, +// or scope down to one cluster and return a authenticationv1beta1.SelfSubjectReviewInterface. type SelfSubjectReviewClusterInterface interface { - Cluster(logicalcluster.Path) authenticationv1beta1client.SelfSubjectReviewInterface + Cluster(logicalcluster.Path) authenticationv1beta1.SelfSubjectReviewInterface + + SelfSubjectReviewClusterExpansion } type selfSubjectReviewsClusterInterface struct { - clientCache kcpclient.Cache[*authenticationv1beta1client.AuthenticationV1beta1Client] + clientCache kcpclient.Cache[*authenticationv1beta1.AuthenticationV1beta1Client] } // Cluster scopes the client down to a particular cluster. -func (c *selfSubjectReviewsClusterInterface) Cluster(clusterPath logicalcluster.Path) authenticationv1beta1client.SelfSubjectReviewInterface { +func (c *selfSubjectReviewsClusterInterface) Cluster(clusterPath logicalcluster.Path) authenticationv1beta1.SelfSubjectReviewInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } diff --git a/kubernetes/typed/authentication/v1beta1/tokenreview.go b/kubernetes/typed/authentication/v1beta1/tokenreview.go index 36f78b9b3..952a95ca4 100644 --- a/kubernetes/typed/authentication/v1beta1/tokenreview.go +++ b/kubernetes/typed/authentication/v1beta1/tokenreview.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 @@ -22,7 +22,7 @@ import ( kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - authenticationv1beta1client "k8s.io/client-go/kubernetes/typed/authentication/v1beta1" + authenticationv1beta1 "k8s.io/client-go/kubernetes/typed/authentication/v1beta1" ) // TokenReviewsClusterGetter has a method to return a TokenReviewClusterInterface. @@ -31,17 +31,20 @@ type TokenReviewsClusterGetter interface { TokenReviews() TokenReviewClusterInterface } -// TokenReviewClusterInterface can scope down to one cluster and return a authenticationv1beta1client.TokenReviewInterface. +// TokenReviewClusterInterface can operate on TokenReviews across all clusters, +// or scope down to one cluster and return a authenticationv1beta1.TokenReviewInterface. type TokenReviewClusterInterface interface { - Cluster(logicalcluster.Path) authenticationv1beta1client.TokenReviewInterface + Cluster(logicalcluster.Path) authenticationv1beta1.TokenReviewInterface + + TokenReviewClusterExpansion } type tokenReviewsClusterInterface struct { - clientCache kcpclient.Cache[*authenticationv1beta1client.AuthenticationV1beta1Client] + clientCache kcpclient.Cache[*authenticationv1beta1.AuthenticationV1beta1Client] } // Cluster scopes the client down to a particular cluster. -func (c *tokenReviewsClusterInterface) Cluster(clusterPath logicalcluster.Path) authenticationv1beta1client.TokenReviewInterface { +func (c *tokenReviewsClusterInterface) Cluster(clusterPath logicalcluster.Path) authenticationv1beta1.TokenReviewInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } diff --git a/kubernetes/typed/authorization/v1/authorization_client.go b/kubernetes/typed/authorization/v1/authorization_client.go index b5c596691..b655cb983 100644 --- a/kubernetes/typed/authorization/v1/authorization_client.go +++ b/kubernetes/typed/authorization/v1/authorization_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,32 +14,36 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apiauthorizationv1 "k8s.io/api/authorization/v1" authorizationv1 "k8s.io/client-go/kubernetes/typed/authorization/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type AuthorizationV1ClusterInterface interface { AuthorizationV1ClusterScoper - SubjectAccessReviewsClusterGetter - SelfSubjectAccessReviewsClusterGetter LocalSubjectAccessReviewsClusterGetter + SelfSubjectAccessReviewsClusterGetter SelfSubjectRulesReviewsClusterGetter + SubjectAccessReviewsClusterGetter } type AuthorizationV1ClusterScoper interface { Cluster(logicalcluster.Path) authorizationv1.AuthorizationV1Interface } +// AuthorizationV1ClusterClient is used to interact with features provided by the authorization.k8s.io group. type AuthorizationV1ClusterClient struct { clientCache kcpclient.Cache[*authorizationv1.AuthorizationV1Client] } @@ -51,31 +55,33 @@ func (c *AuthorizationV1ClusterClient) Cluster(clusterPath logicalcluster.Path) return c.clientCache.ClusterOrDie(clusterPath) } -func (c *AuthorizationV1ClusterClient) SubjectAccessReviews() SubjectAccessReviewClusterInterface { - return &subjectAccessReviewsClusterInterface{clientCache: c.clientCache} +func (c *AuthorizationV1ClusterClient) LocalSubjectAccessReviews() LocalSubjectAccessReviewClusterInterface { + return &localSubjectAccessReviewsClusterInterface{clientCache: c.clientCache} } func (c *AuthorizationV1ClusterClient) SelfSubjectAccessReviews() SelfSubjectAccessReviewClusterInterface { return &selfSubjectAccessReviewsClusterInterface{clientCache: c.clientCache} } -func (c *AuthorizationV1ClusterClient) LocalSubjectAccessReviews() LocalSubjectAccessReviewClusterInterface { - return &localSubjectAccessReviewsClusterInterface{clientCache: c.clientCache} -} - func (c *AuthorizationV1ClusterClient) SelfSubjectRulesReviews() SelfSubjectRulesReviewClusterInterface { return &selfSubjectRulesReviewsClusterInterface{clientCache: c.clientCache} } +func (c *AuthorizationV1ClusterClient) SubjectAccessReviews() SubjectAccessReviewClusterInterface { + return &subjectAccessReviewsClusterInterface{clientCache: c.clientCache} +} + // NewForConfig creates a new AuthorizationV1ClusterClient for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*AuthorizationV1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new AuthorizationV1ClusterClient for the given config and http client. @@ -87,6 +93,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*AuthorizationV1Clus if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &AuthorizationV1ClusterClient{clientCache: cache}, nil } @@ -99,3 +106,14 @@ func NewForConfigOrDie(c *rest.Config) *AuthorizationV1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apiauthorizationv1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/authorization/v1/doc.go b/kubernetes/typed/authorization/v1/doc.go new file mode 100644 index 000000000..d2f3412ab --- /dev/null +++ b/kubernetes/typed/authorization/v1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1 diff --git a/kubernetes/typed/authorization/v1/fake/authorization_client.go b/kubernetes/typed/authorization/v1/fake/authorization_client.go index acd20048e..d6c84d535 100644 --- a/kubernetes/typed/authorization/v1/fake/authorization_client.go +++ b/kubernetes/typed/authorization/v1/fake/authorization_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" authorizationv1 "k8s.io/client-go/kubernetes/typed/authorization/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpauthorizationv1 "github.com/kcp-dev/client-go/kubernetes/typed/authorization/v1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -41,46 +41,46 @@ func (c *AuthorizationV1ClusterClient) Cluster(clusterPath logicalcluster.Path) return &AuthorizationV1Client{Fake: c.Fake, ClusterPath: clusterPath} } -func (c *AuthorizationV1ClusterClient) SubjectAccessReviews() kcpauthorizationv1.SubjectAccessReviewClusterInterface { - return &subjectAccessReviewsClusterClient{Fake: c.Fake} +func (c *AuthorizationV1ClusterClient) LocalSubjectAccessReviews() kcpauthorizationv1.LocalSubjectAccessReviewClusterInterface { + return newFakeLocalSubjectAccessReviewClusterClient(c) } func (c *AuthorizationV1ClusterClient) SelfSubjectAccessReviews() kcpauthorizationv1.SelfSubjectAccessReviewClusterInterface { - return &selfSubjectAccessReviewsClusterClient{Fake: c.Fake} -} - -func (c *AuthorizationV1ClusterClient) LocalSubjectAccessReviews() kcpauthorizationv1.LocalSubjectAccessReviewClusterInterface { - return &localSubjectAccessReviewsClusterClient{Fake: c.Fake} + return newFakeSelfSubjectAccessReviewClusterClient(c) } func (c *AuthorizationV1ClusterClient) SelfSubjectRulesReviews() kcpauthorizationv1.SelfSubjectRulesReviewClusterInterface { - return &selfSubjectRulesReviewsClusterClient{Fake: c.Fake} + return newFakeSelfSubjectRulesReviewClusterClient(c) } -var _ authorizationv1.AuthorizationV1Interface = (*AuthorizationV1Client)(nil) +func (c *AuthorizationV1ClusterClient) SubjectAccessReviews() kcpauthorizationv1.SubjectAccessReviewClusterInterface { + return newFakeSubjectAccessReviewClusterClient(c) +} type AuthorizationV1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *AuthorizationV1Client) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret +func (c *AuthorizationV1Client) LocalSubjectAccessReviews(namespace string) authorizationv1.LocalSubjectAccessReviewInterface { + return newFakeLocalSubjectAccessReviewClient(c.Fake, namespace, c.ClusterPath) } -func (c *AuthorizationV1Client) SubjectAccessReviews() authorizationv1.SubjectAccessReviewInterface { - return &subjectAccessReviewsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +func (c *AuthorizationV1Client) SelfSubjectAccessReviews() authorizationv1.SelfSubjectAccessReviewInterface { + return newFakeSelfSubjectAccessReviewClient(c.Fake, c.ClusterPath) } -func (c *AuthorizationV1Client) SelfSubjectAccessReviews() authorizationv1.SelfSubjectAccessReviewInterface { - return &selfSubjectAccessReviewsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +func (c *AuthorizationV1Client) SelfSubjectRulesReviews() authorizationv1.SelfSubjectRulesReviewInterface { + return newFakeSelfSubjectRulesReviewClient(c.Fake, c.ClusterPath) } -func (c *AuthorizationV1Client) LocalSubjectAccessReviews(namespace string) authorizationv1.LocalSubjectAccessReviewInterface { - return &localSubjectAccessReviewsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *AuthorizationV1Client) SubjectAccessReviews() authorizationv1.SubjectAccessReviewInterface { + return newFakeSubjectAccessReviewClient(c.Fake, c.ClusterPath) } -func (c *AuthorizationV1Client) SelfSubjectRulesReviews() authorizationv1.SelfSubjectRulesReviewInterface { - return &selfSubjectRulesReviewsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *AuthorizationV1Client) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret } diff --git a/kubernetes/typed/authorization/v1/fake/doc.go b/kubernetes/typed/authorization/v1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/authorization/v1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/authorization/v1/fake/localsubjectaccessreview.go b/kubernetes/typed/authorization/v1/fake/localsubjectaccessreview.go index be3ddbf6e..f13db754a 100644 --- a/kubernetes/typed/authorization/v1/fake/localsubjectaccessreview.go +++ b/kubernetes/typed/authorization/v1/fake/localsubjectaccessreview.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,59 +14,70 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "github.com/kcp-dev/logicalcluster/v3" authorizationv1 "k8s.io/api/authorization/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - authorizationv1client "k8s.io/client-go/kubernetes/typed/authorization/v1" + typedauthorizationv1 "k8s.io/client-go/kubernetes/typed/authorization/v1" - kcpauthorizationv1 "github.com/kcp-dev/client-go/kubernetes/typed/authorization/v1" + typedkcpauthorizationv1 "github.com/kcp-dev/client-go/kubernetes/typed/authorization/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var localSubjectAccessReviewsResource = schema.GroupVersionResource{Group: "authorization.k8s.io", Version: "v1", Resource: "localsubjectaccessreviews"} -var localSubjectAccessReviewsKind = schema.GroupVersionKind{Group: "authorization.k8s.io", Version: "v1", Kind: "LocalSubjectAccessReview"} - -type localSubjectAccessReviewsClusterClient struct { - *kcptesting.Fake +// localSubjectAccessReviewClusterClient implements LocalSubjectAccessReviewClusterInterface +type localSubjectAccessReviewClusterClient struct { + *kcpgentype.FakeClusterClient[*authorizationv1.LocalSubjectAccessReview] + Fake *kcptesting.Fake } -// Cluster scopes the client down to a particular cluster. -func (c *localSubjectAccessReviewsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpauthorizationv1.LocalSubjectAccessReviewsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") +func newFakeLocalSubjectAccessReviewClusterClient(fake *AuthorizationV1ClusterClient) typedkcpauthorizationv1.LocalSubjectAccessReviewClusterInterface { + return &localSubjectAccessReviewClusterClient{ + kcpgentype.NewFakeClusterClient[*authorizationv1.LocalSubjectAccessReview]( + fake.Fake, + authorizationv1.SchemeGroupVersion.WithResource("localsubjectaccessreviews"), + authorizationv1.SchemeGroupVersion.WithKind("LocalSubjectAccessReview"), + func() *authorizationv1.LocalSubjectAccessReview { return &authorizationv1.LocalSubjectAccessReview{} }, + ), + fake.Fake, } +} - return &localSubjectAccessReviewsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +func (c *localSubjectAccessReviewClusterClient) Cluster(cluster logicalcluster.Path) typedkcpauthorizationv1.LocalSubjectAccessReviewsNamespacer { + return &localSubjectAccessReviewNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type localSubjectAccessReviewsNamespacer struct { +type localSubjectAccessReviewNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *localSubjectAccessReviewsNamespacer) Namespace(namespace string) authorizationv1client.LocalSubjectAccessReviewInterface { - return &localSubjectAccessReviewsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *localSubjectAccessReviewNamespacer) Namespace(namespace string) typedauthorizationv1.LocalSubjectAccessReviewInterface { + return newFakeLocalSubjectAccessReviewClient(n.Fake, namespace, n.ClusterPath) } -type localSubjectAccessReviewsClient struct { - *kcptesting.Fake +// localSubjectAccessReviewScopedClient implements LocalSubjectAccessReviewInterface +type localSubjectAccessReviewScopedClient struct { + *kcpgentype.FakeClient[*authorizationv1.LocalSubjectAccessReview] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string } -func (c *localSubjectAccessReviewsClient) Create(ctx context.Context, localSubjectAccessReview *authorizationv1.LocalSubjectAccessReview, opts metav1.CreateOptions) (*authorizationv1.LocalSubjectAccessReview, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(localSubjectAccessReviewsResource, c.ClusterPath, c.Namespace, localSubjectAccessReview), &authorizationv1.LocalSubjectAccessReview{}) - if obj == nil { - return nil, err +func newFakeLocalSubjectAccessReviewClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedauthorizationv1.LocalSubjectAccessReviewInterface { + return &localSubjectAccessReviewScopedClient{ + kcpgentype.NewFakeClient[*authorizationv1.LocalSubjectAccessReview]( + fake, + clusterPath, + namespace, + authorizationv1.SchemeGroupVersion.WithResource("localsubjectaccessreviews"), + authorizationv1.SchemeGroupVersion.WithKind("LocalSubjectAccessReview"), + func() *authorizationv1.LocalSubjectAccessReview { return &authorizationv1.LocalSubjectAccessReview{} }, + ), + fake, + clusterPath, } - return obj.(*authorizationv1.LocalSubjectAccessReview), err } diff --git a/kubernetes/typed/authorization/v1/fake/selfsubjectaccessreview.go b/kubernetes/typed/authorization/v1/fake/selfsubjectaccessreview.go index eed47d795..c37e34d59 100644 --- a/kubernetes/typed/authorization/v1/fake/selfsubjectaccessreview.go +++ b/kubernetes/typed/authorization/v1/fake/selfsubjectaccessreview.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,48 +14,61 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "github.com/kcp-dev/logicalcluster/v3" authorizationv1 "k8s.io/api/authorization/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - authorizationv1client "k8s.io/client-go/kubernetes/typed/authorization/v1" + typedauthorizationv1 "k8s.io/client-go/kubernetes/typed/authorization/v1" + typedkcpauthorizationv1 "github.com/kcp-dev/client-go/kubernetes/typed/authorization/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var selfSubjectAccessReviewsResource = schema.GroupVersionResource{Group: "authorization.k8s.io", Version: "v1", Resource: "selfsubjectaccessreviews"} -var selfSubjectAccessReviewsKind = schema.GroupVersionKind{Group: "authorization.k8s.io", Version: "v1", Kind: "SelfSubjectAccessReview"} - -type selfSubjectAccessReviewsClusterClient struct { - *kcptesting.Fake +// selfSubjectAccessReviewClusterClient implements SelfSubjectAccessReviewClusterInterface +type selfSubjectAccessReviewClusterClient struct { + *kcpgentype.FakeClusterClient[*authorizationv1.SelfSubjectAccessReview] + Fake *kcptesting.Fake } -// Cluster scopes the client down to a particular cluster. -func (c *selfSubjectAccessReviewsClusterClient) Cluster(clusterPath logicalcluster.Path) authorizationv1client.SelfSubjectAccessReviewInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") +func newFakeSelfSubjectAccessReviewClusterClient(fake *AuthorizationV1ClusterClient) typedkcpauthorizationv1.SelfSubjectAccessReviewClusterInterface { + return &selfSubjectAccessReviewClusterClient{ + kcpgentype.NewFakeClusterClient[*authorizationv1.SelfSubjectAccessReview]( + fake.Fake, + authorizationv1.SchemeGroupVersion.WithResource("selfsubjectaccessreviews"), + authorizationv1.SchemeGroupVersion.WithKind("SelfSubjectAccessReview"), + func() *authorizationv1.SelfSubjectAccessReview { return &authorizationv1.SelfSubjectAccessReview{} }, + ), + fake.Fake, } +} - return &selfSubjectAccessReviewsClient{Fake: c.Fake, ClusterPath: clusterPath} +func (c *selfSubjectAccessReviewClusterClient) Cluster(cluster logicalcluster.Path) typedauthorizationv1.SelfSubjectAccessReviewInterface { + return newFakeSelfSubjectAccessReviewClient(c.Fake, cluster) } -type selfSubjectAccessReviewsClient struct { - *kcptesting.Fake +// selfSubjectAccessReviewScopedClient implements SelfSubjectAccessReviewInterface +type selfSubjectAccessReviewScopedClient struct { + *kcpgentype.FakeClient[*authorizationv1.SelfSubjectAccessReview] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *selfSubjectAccessReviewsClient) Create(ctx context.Context, selfSubjectAccessReview *authorizationv1.SelfSubjectAccessReview, opts metav1.CreateOptions) (*authorizationv1.SelfSubjectAccessReview, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(selfSubjectAccessReviewsResource, c.ClusterPath, selfSubjectAccessReview), &authorizationv1.SelfSubjectAccessReview{}) - if obj == nil { - return nil, err +func newFakeSelfSubjectAccessReviewClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedauthorizationv1.SelfSubjectAccessReviewInterface { + return &selfSubjectAccessReviewScopedClient{ + kcpgentype.NewFakeClient[*authorizationv1.SelfSubjectAccessReview]( + fake, + clusterPath, + "", + authorizationv1.SchemeGroupVersion.WithResource("selfsubjectaccessreviews"), + authorizationv1.SchemeGroupVersion.WithKind("SelfSubjectAccessReview"), + func() *authorizationv1.SelfSubjectAccessReview { return &authorizationv1.SelfSubjectAccessReview{} }, + ), + fake, + clusterPath, } - return obj.(*authorizationv1.SelfSubjectAccessReview), err } diff --git a/kubernetes/typed/authorization/v1/fake/selfsubjectrulesreview.go b/kubernetes/typed/authorization/v1/fake/selfsubjectrulesreview.go index 977418601..eb838ade9 100644 --- a/kubernetes/typed/authorization/v1/fake/selfsubjectrulesreview.go +++ b/kubernetes/typed/authorization/v1/fake/selfsubjectrulesreview.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,48 +14,61 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "github.com/kcp-dev/logicalcluster/v3" authorizationv1 "k8s.io/api/authorization/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - authorizationv1client "k8s.io/client-go/kubernetes/typed/authorization/v1" + typedauthorizationv1 "k8s.io/client-go/kubernetes/typed/authorization/v1" + typedkcpauthorizationv1 "github.com/kcp-dev/client-go/kubernetes/typed/authorization/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var selfSubjectRulesReviewsResource = schema.GroupVersionResource{Group: "authorization.k8s.io", Version: "v1", Resource: "selfsubjectrulesreviews"} -var selfSubjectRulesReviewsKind = schema.GroupVersionKind{Group: "authorization.k8s.io", Version: "v1", Kind: "SelfSubjectRulesReview"} - -type selfSubjectRulesReviewsClusterClient struct { - *kcptesting.Fake +// selfSubjectRulesReviewClusterClient implements SelfSubjectRulesReviewClusterInterface +type selfSubjectRulesReviewClusterClient struct { + *kcpgentype.FakeClusterClient[*authorizationv1.SelfSubjectRulesReview] + Fake *kcptesting.Fake } -// Cluster scopes the client down to a particular cluster. -func (c *selfSubjectRulesReviewsClusterClient) Cluster(clusterPath logicalcluster.Path) authorizationv1client.SelfSubjectRulesReviewInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") +func newFakeSelfSubjectRulesReviewClusterClient(fake *AuthorizationV1ClusterClient) typedkcpauthorizationv1.SelfSubjectRulesReviewClusterInterface { + return &selfSubjectRulesReviewClusterClient{ + kcpgentype.NewFakeClusterClient[*authorizationv1.SelfSubjectRulesReview]( + fake.Fake, + authorizationv1.SchemeGroupVersion.WithResource("selfsubjectrulesreviews"), + authorizationv1.SchemeGroupVersion.WithKind("SelfSubjectRulesReview"), + func() *authorizationv1.SelfSubjectRulesReview { return &authorizationv1.SelfSubjectRulesReview{} }, + ), + fake.Fake, } +} - return &selfSubjectRulesReviewsClient{Fake: c.Fake, ClusterPath: clusterPath} +func (c *selfSubjectRulesReviewClusterClient) Cluster(cluster logicalcluster.Path) typedauthorizationv1.SelfSubjectRulesReviewInterface { + return newFakeSelfSubjectRulesReviewClient(c.Fake, cluster) } -type selfSubjectRulesReviewsClient struct { - *kcptesting.Fake +// selfSubjectRulesReviewScopedClient implements SelfSubjectRulesReviewInterface +type selfSubjectRulesReviewScopedClient struct { + *kcpgentype.FakeClient[*authorizationv1.SelfSubjectRulesReview] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *selfSubjectRulesReviewsClient) Create(ctx context.Context, selfSubjectRulesReview *authorizationv1.SelfSubjectRulesReview, opts metav1.CreateOptions) (*authorizationv1.SelfSubjectRulesReview, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(selfSubjectRulesReviewsResource, c.ClusterPath, selfSubjectRulesReview), &authorizationv1.SelfSubjectRulesReview{}) - if obj == nil { - return nil, err +func newFakeSelfSubjectRulesReviewClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedauthorizationv1.SelfSubjectRulesReviewInterface { + return &selfSubjectRulesReviewScopedClient{ + kcpgentype.NewFakeClient[*authorizationv1.SelfSubjectRulesReview]( + fake, + clusterPath, + "", + authorizationv1.SchemeGroupVersion.WithResource("selfsubjectrulesreviews"), + authorizationv1.SchemeGroupVersion.WithKind("SelfSubjectRulesReview"), + func() *authorizationv1.SelfSubjectRulesReview { return &authorizationv1.SelfSubjectRulesReview{} }, + ), + fake, + clusterPath, } - return obj.(*authorizationv1.SelfSubjectRulesReview), err } diff --git a/kubernetes/typed/authorization/v1/fake/subjectaccessreview.go b/kubernetes/typed/authorization/v1/fake/subjectaccessreview.go index 2e1fb46e1..81e33d1c7 100644 --- a/kubernetes/typed/authorization/v1/fake/subjectaccessreview.go +++ b/kubernetes/typed/authorization/v1/fake/subjectaccessreview.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,48 +14,61 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "github.com/kcp-dev/logicalcluster/v3" authorizationv1 "k8s.io/api/authorization/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - authorizationv1client "k8s.io/client-go/kubernetes/typed/authorization/v1" + typedauthorizationv1 "k8s.io/client-go/kubernetes/typed/authorization/v1" + typedkcpauthorizationv1 "github.com/kcp-dev/client-go/kubernetes/typed/authorization/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var subjectAccessReviewsResource = schema.GroupVersionResource{Group: "authorization.k8s.io", Version: "v1", Resource: "subjectaccessreviews"} -var subjectAccessReviewsKind = schema.GroupVersionKind{Group: "authorization.k8s.io", Version: "v1", Kind: "SubjectAccessReview"} - -type subjectAccessReviewsClusterClient struct { - *kcptesting.Fake +// subjectAccessReviewClusterClient implements SubjectAccessReviewClusterInterface +type subjectAccessReviewClusterClient struct { + *kcpgentype.FakeClusterClient[*authorizationv1.SubjectAccessReview] + Fake *kcptesting.Fake } -// Cluster scopes the client down to a particular cluster. -func (c *subjectAccessReviewsClusterClient) Cluster(clusterPath logicalcluster.Path) authorizationv1client.SubjectAccessReviewInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") +func newFakeSubjectAccessReviewClusterClient(fake *AuthorizationV1ClusterClient) typedkcpauthorizationv1.SubjectAccessReviewClusterInterface { + return &subjectAccessReviewClusterClient{ + kcpgentype.NewFakeClusterClient[*authorizationv1.SubjectAccessReview]( + fake.Fake, + authorizationv1.SchemeGroupVersion.WithResource("subjectaccessreviews"), + authorizationv1.SchemeGroupVersion.WithKind("SubjectAccessReview"), + func() *authorizationv1.SubjectAccessReview { return &authorizationv1.SubjectAccessReview{} }, + ), + fake.Fake, } +} - return &subjectAccessReviewsClient{Fake: c.Fake, ClusterPath: clusterPath} +func (c *subjectAccessReviewClusterClient) Cluster(cluster logicalcluster.Path) typedauthorizationv1.SubjectAccessReviewInterface { + return newFakeSubjectAccessReviewClient(c.Fake, cluster) } -type subjectAccessReviewsClient struct { - *kcptesting.Fake +// subjectAccessReviewScopedClient implements SubjectAccessReviewInterface +type subjectAccessReviewScopedClient struct { + *kcpgentype.FakeClient[*authorizationv1.SubjectAccessReview] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *subjectAccessReviewsClient) Create(ctx context.Context, subjectAccessReview *authorizationv1.SubjectAccessReview, opts metav1.CreateOptions) (*authorizationv1.SubjectAccessReview, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(subjectAccessReviewsResource, c.ClusterPath, subjectAccessReview), &authorizationv1.SubjectAccessReview{}) - if obj == nil { - return nil, err +func newFakeSubjectAccessReviewClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedauthorizationv1.SubjectAccessReviewInterface { + return &subjectAccessReviewScopedClient{ + kcpgentype.NewFakeClient[*authorizationv1.SubjectAccessReview]( + fake, + clusterPath, + "", + authorizationv1.SchemeGroupVersion.WithResource("subjectaccessreviews"), + authorizationv1.SchemeGroupVersion.WithKind("SubjectAccessReview"), + func() *authorizationv1.SubjectAccessReview { return &authorizationv1.SubjectAccessReview{} }, + ), + fake, + clusterPath, } - return obj.(*authorizationv1.SubjectAccessReview), err } diff --git a/kubernetes/typed/authorization/v1/generated_expansion.go b/kubernetes/typed/authorization/v1/generated_expansion.go new file mode 100644 index 000000000..4e6b8110d --- /dev/null +++ b/kubernetes/typed/authorization/v1/generated_expansion.go @@ -0,0 +1,27 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1 + +type LocalSubjectAccessReviewClusterExpansion interface{} + +type SelfSubjectAccessReviewClusterExpansion interface{} + +type SelfSubjectRulesReviewClusterExpansion interface{} + +type SubjectAccessReviewClusterExpansion interface{} diff --git a/kubernetes/typed/authorization/v1/localsubjectaccessreview.go b/kubernetes/typed/authorization/v1/localsubjectaccessreview.go index 8d4f5f209..5ba8b970b 100644 --- a/kubernetes/typed/authorization/v1/localsubjectaccessreview.go +++ b/kubernetes/typed/authorization/v1/localsubjectaccessreview.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 @@ -22,7 +22,7 @@ import ( kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - authorizationv1client "k8s.io/client-go/kubernetes/typed/authorization/v1" + authorizationv1 "k8s.io/client-go/kubernetes/typed/authorization/v1" ) // LocalSubjectAccessReviewsClusterGetter has a method to return a LocalSubjectAccessReviewClusterInterface. @@ -31,13 +31,16 @@ type LocalSubjectAccessReviewsClusterGetter interface { LocalSubjectAccessReviews() LocalSubjectAccessReviewClusterInterface } -// LocalSubjectAccessReviewClusterInterface can scope down to one cluster and return a LocalSubjectAccessReviewsNamespacer. +// LocalSubjectAccessReviewClusterInterface can operate on LocalSubjectAccessReviews across all clusters, +// or scope down to one cluster and return a LocalSubjectAccessReviewsNamespacer. type LocalSubjectAccessReviewClusterInterface interface { Cluster(logicalcluster.Path) LocalSubjectAccessReviewsNamespacer + + LocalSubjectAccessReviewClusterExpansion } type localSubjectAccessReviewsClusterInterface struct { - clientCache kcpclient.Cache[*authorizationv1client.AuthorizationV1Client] + clientCache kcpclient.Cache[*authorizationv1.AuthorizationV1Client] } // Cluster scopes the client down to a particular cluster. @@ -49,16 +52,16 @@ func (c *localSubjectAccessReviewsClusterInterface) Cluster(clusterPath logicalc return &localSubjectAccessReviewsNamespacer{clientCache: c.clientCache, clusterPath: clusterPath} } -// LocalSubjectAccessReviewsNamespacer can scope to objects within a namespace, returning a authorizationv1client.LocalSubjectAccessReviewInterface. +// LocalSubjectAccessReviewsNamespacer can scope to objects within a namespace, returning a authorizationv1.LocalSubjectAccessReviewInterface. type LocalSubjectAccessReviewsNamespacer interface { - Namespace(string) authorizationv1client.LocalSubjectAccessReviewInterface + Namespace(string) authorizationv1.LocalSubjectAccessReviewInterface } type localSubjectAccessReviewsNamespacer struct { - clientCache kcpclient.Cache[*authorizationv1client.AuthorizationV1Client] + clientCache kcpclient.Cache[*authorizationv1.AuthorizationV1Client] clusterPath logicalcluster.Path } -func (n *localSubjectAccessReviewsNamespacer) Namespace(namespace string) authorizationv1client.LocalSubjectAccessReviewInterface { +func (n *localSubjectAccessReviewsNamespacer) Namespace(namespace string) authorizationv1.LocalSubjectAccessReviewInterface { return n.clientCache.ClusterOrDie(n.clusterPath).LocalSubjectAccessReviews(namespace) } diff --git a/kubernetes/typed/authorization/v1/selfsubjectaccessreview.go b/kubernetes/typed/authorization/v1/selfsubjectaccessreview.go index ed3428639..f13e610f4 100644 --- a/kubernetes/typed/authorization/v1/selfsubjectaccessreview.go +++ b/kubernetes/typed/authorization/v1/selfsubjectaccessreview.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 @@ -22,7 +22,7 @@ import ( kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - authorizationv1client "k8s.io/client-go/kubernetes/typed/authorization/v1" + authorizationv1 "k8s.io/client-go/kubernetes/typed/authorization/v1" ) // SelfSubjectAccessReviewsClusterGetter has a method to return a SelfSubjectAccessReviewClusterInterface. @@ -31,17 +31,20 @@ type SelfSubjectAccessReviewsClusterGetter interface { SelfSubjectAccessReviews() SelfSubjectAccessReviewClusterInterface } -// SelfSubjectAccessReviewClusterInterface can scope down to one cluster and return a authorizationv1client.SelfSubjectAccessReviewInterface. +// SelfSubjectAccessReviewClusterInterface can operate on SelfSubjectAccessReviews across all clusters, +// or scope down to one cluster and return a authorizationv1.SelfSubjectAccessReviewInterface. type SelfSubjectAccessReviewClusterInterface interface { - Cluster(logicalcluster.Path) authorizationv1client.SelfSubjectAccessReviewInterface + Cluster(logicalcluster.Path) authorizationv1.SelfSubjectAccessReviewInterface + + SelfSubjectAccessReviewClusterExpansion } type selfSubjectAccessReviewsClusterInterface struct { - clientCache kcpclient.Cache[*authorizationv1client.AuthorizationV1Client] + clientCache kcpclient.Cache[*authorizationv1.AuthorizationV1Client] } // Cluster scopes the client down to a particular cluster. -func (c *selfSubjectAccessReviewsClusterInterface) Cluster(clusterPath logicalcluster.Path) authorizationv1client.SelfSubjectAccessReviewInterface { +func (c *selfSubjectAccessReviewsClusterInterface) Cluster(clusterPath logicalcluster.Path) authorizationv1.SelfSubjectAccessReviewInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } diff --git a/kubernetes/typed/authorization/v1/selfsubjectrulesreview.go b/kubernetes/typed/authorization/v1/selfsubjectrulesreview.go index 44da896f4..5c4157ca5 100644 --- a/kubernetes/typed/authorization/v1/selfsubjectrulesreview.go +++ b/kubernetes/typed/authorization/v1/selfsubjectrulesreview.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 @@ -22,7 +22,7 @@ import ( kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - authorizationv1client "k8s.io/client-go/kubernetes/typed/authorization/v1" + authorizationv1 "k8s.io/client-go/kubernetes/typed/authorization/v1" ) // SelfSubjectRulesReviewsClusterGetter has a method to return a SelfSubjectRulesReviewClusterInterface. @@ -31,17 +31,20 @@ type SelfSubjectRulesReviewsClusterGetter interface { SelfSubjectRulesReviews() SelfSubjectRulesReviewClusterInterface } -// SelfSubjectRulesReviewClusterInterface can scope down to one cluster and return a authorizationv1client.SelfSubjectRulesReviewInterface. +// SelfSubjectRulesReviewClusterInterface can operate on SelfSubjectRulesReviews across all clusters, +// or scope down to one cluster and return a authorizationv1.SelfSubjectRulesReviewInterface. type SelfSubjectRulesReviewClusterInterface interface { - Cluster(logicalcluster.Path) authorizationv1client.SelfSubjectRulesReviewInterface + Cluster(logicalcluster.Path) authorizationv1.SelfSubjectRulesReviewInterface + + SelfSubjectRulesReviewClusterExpansion } type selfSubjectRulesReviewsClusterInterface struct { - clientCache kcpclient.Cache[*authorizationv1client.AuthorizationV1Client] + clientCache kcpclient.Cache[*authorizationv1.AuthorizationV1Client] } // Cluster scopes the client down to a particular cluster. -func (c *selfSubjectRulesReviewsClusterInterface) Cluster(clusterPath logicalcluster.Path) authorizationv1client.SelfSubjectRulesReviewInterface { +func (c *selfSubjectRulesReviewsClusterInterface) Cluster(clusterPath logicalcluster.Path) authorizationv1.SelfSubjectRulesReviewInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } diff --git a/kubernetes/typed/authorization/v1/subjectaccessreview.go b/kubernetes/typed/authorization/v1/subjectaccessreview.go index fb000275f..338acf720 100644 --- a/kubernetes/typed/authorization/v1/subjectaccessreview.go +++ b/kubernetes/typed/authorization/v1/subjectaccessreview.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 @@ -22,7 +22,7 @@ import ( kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - authorizationv1client "k8s.io/client-go/kubernetes/typed/authorization/v1" + authorizationv1 "k8s.io/client-go/kubernetes/typed/authorization/v1" ) // SubjectAccessReviewsClusterGetter has a method to return a SubjectAccessReviewClusterInterface. @@ -31,17 +31,20 @@ type SubjectAccessReviewsClusterGetter interface { SubjectAccessReviews() SubjectAccessReviewClusterInterface } -// SubjectAccessReviewClusterInterface can scope down to one cluster and return a authorizationv1client.SubjectAccessReviewInterface. +// SubjectAccessReviewClusterInterface can operate on SubjectAccessReviews across all clusters, +// or scope down to one cluster and return a authorizationv1.SubjectAccessReviewInterface. type SubjectAccessReviewClusterInterface interface { - Cluster(logicalcluster.Path) authorizationv1client.SubjectAccessReviewInterface + Cluster(logicalcluster.Path) authorizationv1.SubjectAccessReviewInterface + + SubjectAccessReviewClusterExpansion } type subjectAccessReviewsClusterInterface struct { - clientCache kcpclient.Cache[*authorizationv1client.AuthorizationV1Client] + clientCache kcpclient.Cache[*authorizationv1.AuthorizationV1Client] } // Cluster scopes the client down to a particular cluster. -func (c *subjectAccessReviewsClusterInterface) Cluster(clusterPath logicalcluster.Path) authorizationv1client.SubjectAccessReviewInterface { +func (c *subjectAccessReviewsClusterInterface) Cluster(clusterPath logicalcluster.Path) authorizationv1.SubjectAccessReviewInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } diff --git a/kubernetes/typed/authorization/v1beta1/authorization_client.go b/kubernetes/typed/authorization/v1beta1/authorization_client.go index cb8dcfd9a..340b62348 100644 --- a/kubernetes/typed/authorization/v1beta1/authorization_client.go +++ b/kubernetes/typed/authorization/v1beta1/authorization_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,32 +14,36 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apiauthorizationv1beta1 "k8s.io/api/authorization/v1beta1" authorizationv1beta1 "k8s.io/client-go/kubernetes/typed/authorization/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type AuthorizationV1beta1ClusterInterface interface { AuthorizationV1beta1ClusterScoper - SubjectAccessReviewsClusterGetter - SelfSubjectAccessReviewsClusterGetter LocalSubjectAccessReviewsClusterGetter + SelfSubjectAccessReviewsClusterGetter SelfSubjectRulesReviewsClusterGetter + SubjectAccessReviewsClusterGetter } type AuthorizationV1beta1ClusterScoper interface { Cluster(logicalcluster.Path) authorizationv1beta1.AuthorizationV1beta1Interface } +// AuthorizationV1beta1ClusterClient is used to interact with features provided by the authorization.k8s.io group. type AuthorizationV1beta1ClusterClient struct { clientCache kcpclient.Cache[*authorizationv1beta1.AuthorizationV1beta1Client] } @@ -51,31 +55,33 @@ func (c *AuthorizationV1beta1ClusterClient) Cluster(clusterPath logicalcluster.P return c.clientCache.ClusterOrDie(clusterPath) } -func (c *AuthorizationV1beta1ClusterClient) SubjectAccessReviews() SubjectAccessReviewClusterInterface { - return &subjectAccessReviewsClusterInterface{clientCache: c.clientCache} +func (c *AuthorizationV1beta1ClusterClient) LocalSubjectAccessReviews() LocalSubjectAccessReviewClusterInterface { + return &localSubjectAccessReviewsClusterInterface{clientCache: c.clientCache} } func (c *AuthorizationV1beta1ClusterClient) SelfSubjectAccessReviews() SelfSubjectAccessReviewClusterInterface { return &selfSubjectAccessReviewsClusterInterface{clientCache: c.clientCache} } -func (c *AuthorizationV1beta1ClusterClient) LocalSubjectAccessReviews() LocalSubjectAccessReviewClusterInterface { - return &localSubjectAccessReviewsClusterInterface{clientCache: c.clientCache} -} - func (c *AuthorizationV1beta1ClusterClient) SelfSubjectRulesReviews() SelfSubjectRulesReviewClusterInterface { return &selfSubjectRulesReviewsClusterInterface{clientCache: c.clientCache} } +func (c *AuthorizationV1beta1ClusterClient) SubjectAccessReviews() SubjectAccessReviewClusterInterface { + return &subjectAccessReviewsClusterInterface{clientCache: c.clientCache} +} + // NewForConfig creates a new AuthorizationV1beta1ClusterClient for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*AuthorizationV1beta1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new AuthorizationV1beta1ClusterClient for the given config and http client. @@ -87,6 +93,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*AuthorizationV1beta if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &AuthorizationV1beta1ClusterClient{clientCache: cache}, nil } @@ -99,3 +106,14 @@ func NewForConfigOrDie(c *rest.Config) *AuthorizationV1beta1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apiauthorizationv1beta1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/authorization/v1beta1/doc.go b/kubernetes/typed/authorization/v1beta1/doc.go new file mode 100644 index 000000000..541e9d258 --- /dev/null +++ b/kubernetes/typed/authorization/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1beta1 diff --git a/kubernetes/typed/authorization/v1beta1/fake/authorization_client.go b/kubernetes/typed/authorization/v1beta1/fake/authorization_client.go index 59e59e22b..bdc8c6378 100644 --- a/kubernetes/typed/authorization/v1beta1/fake/authorization_client.go +++ b/kubernetes/typed/authorization/v1beta1/fake/authorization_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" authorizationv1beta1 "k8s.io/client-go/kubernetes/typed/authorization/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpauthorizationv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/authorization/v1beta1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -41,46 +41,46 @@ func (c *AuthorizationV1beta1ClusterClient) Cluster(clusterPath logicalcluster.P return &AuthorizationV1beta1Client{Fake: c.Fake, ClusterPath: clusterPath} } -func (c *AuthorizationV1beta1ClusterClient) SubjectAccessReviews() kcpauthorizationv1beta1.SubjectAccessReviewClusterInterface { - return &subjectAccessReviewsClusterClient{Fake: c.Fake} +func (c *AuthorizationV1beta1ClusterClient) LocalSubjectAccessReviews() kcpauthorizationv1beta1.LocalSubjectAccessReviewClusterInterface { + return newFakeLocalSubjectAccessReviewClusterClient(c) } func (c *AuthorizationV1beta1ClusterClient) SelfSubjectAccessReviews() kcpauthorizationv1beta1.SelfSubjectAccessReviewClusterInterface { - return &selfSubjectAccessReviewsClusterClient{Fake: c.Fake} -} - -func (c *AuthorizationV1beta1ClusterClient) LocalSubjectAccessReviews() kcpauthorizationv1beta1.LocalSubjectAccessReviewClusterInterface { - return &localSubjectAccessReviewsClusterClient{Fake: c.Fake} + return newFakeSelfSubjectAccessReviewClusterClient(c) } func (c *AuthorizationV1beta1ClusterClient) SelfSubjectRulesReviews() kcpauthorizationv1beta1.SelfSubjectRulesReviewClusterInterface { - return &selfSubjectRulesReviewsClusterClient{Fake: c.Fake} + return newFakeSelfSubjectRulesReviewClusterClient(c) } -var _ authorizationv1beta1.AuthorizationV1beta1Interface = (*AuthorizationV1beta1Client)(nil) +func (c *AuthorizationV1beta1ClusterClient) SubjectAccessReviews() kcpauthorizationv1beta1.SubjectAccessReviewClusterInterface { + return newFakeSubjectAccessReviewClusterClient(c) +} type AuthorizationV1beta1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *AuthorizationV1beta1Client) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret +func (c *AuthorizationV1beta1Client) LocalSubjectAccessReviews(namespace string) authorizationv1beta1.LocalSubjectAccessReviewInterface { + return newFakeLocalSubjectAccessReviewClient(c.Fake, namespace, c.ClusterPath) } -func (c *AuthorizationV1beta1Client) SubjectAccessReviews() authorizationv1beta1.SubjectAccessReviewInterface { - return &subjectAccessReviewsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +func (c *AuthorizationV1beta1Client) SelfSubjectAccessReviews() authorizationv1beta1.SelfSubjectAccessReviewInterface { + return newFakeSelfSubjectAccessReviewClient(c.Fake, c.ClusterPath) } -func (c *AuthorizationV1beta1Client) SelfSubjectAccessReviews() authorizationv1beta1.SelfSubjectAccessReviewInterface { - return &selfSubjectAccessReviewsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +func (c *AuthorizationV1beta1Client) SelfSubjectRulesReviews() authorizationv1beta1.SelfSubjectRulesReviewInterface { + return newFakeSelfSubjectRulesReviewClient(c.Fake, c.ClusterPath) } -func (c *AuthorizationV1beta1Client) LocalSubjectAccessReviews(namespace string) authorizationv1beta1.LocalSubjectAccessReviewInterface { - return &localSubjectAccessReviewsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *AuthorizationV1beta1Client) SubjectAccessReviews() authorizationv1beta1.SubjectAccessReviewInterface { + return newFakeSubjectAccessReviewClient(c.Fake, c.ClusterPath) } -func (c *AuthorizationV1beta1Client) SelfSubjectRulesReviews() authorizationv1beta1.SelfSubjectRulesReviewInterface { - return &selfSubjectRulesReviewsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *AuthorizationV1beta1Client) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret } diff --git a/kubernetes/typed/authorization/v1beta1/fake/doc.go b/kubernetes/typed/authorization/v1beta1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/authorization/v1beta1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/authorization/v1beta1/fake/localsubjectaccessreview.go b/kubernetes/typed/authorization/v1beta1/fake/localsubjectaccessreview.go index 74407ad5e..3b0b7da82 100644 --- a/kubernetes/typed/authorization/v1beta1/fake/localsubjectaccessreview.go +++ b/kubernetes/typed/authorization/v1beta1/fake/localsubjectaccessreview.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,59 +14,74 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "github.com/kcp-dev/logicalcluster/v3" authorizationv1beta1 "k8s.io/api/authorization/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - authorizationv1beta1client "k8s.io/client-go/kubernetes/typed/authorization/v1beta1" + typedauthorizationv1beta1 "k8s.io/client-go/kubernetes/typed/authorization/v1beta1" - kcpauthorizationv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/authorization/v1beta1" + typedkcpauthorizationv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/authorization/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var localSubjectAccessReviewsResource = schema.GroupVersionResource{Group: "authorization.k8s.io", Version: "v1beta1", Resource: "localsubjectaccessreviews"} -var localSubjectAccessReviewsKind = schema.GroupVersionKind{Group: "authorization.k8s.io", Version: "v1beta1", Kind: "LocalSubjectAccessReview"} - -type localSubjectAccessReviewsClusterClient struct { - *kcptesting.Fake +// localSubjectAccessReviewClusterClient implements LocalSubjectAccessReviewClusterInterface +type localSubjectAccessReviewClusterClient struct { + *kcpgentype.FakeClusterClient[*authorizationv1beta1.LocalSubjectAccessReview] + Fake *kcptesting.Fake } -// Cluster scopes the client down to a particular cluster. -func (c *localSubjectAccessReviewsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpauthorizationv1beta1.LocalSubjectAccessReviewsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") +func newFakeLocalSubjectAccessReviewClusterClient(fake *AuthorizationV1beta1ClusterClient) typedkcpauthorizationv1beta1.LocalSubjectAccessReviewClusterInterface { + return &localSubjectAccessReviewClusterClient{ + kcpgentype.NewFakeClusterClient[*authorizationv1beta1.LocalSubjectAccessReview]( + fake.Fake, + authorizationv1beta1.SchemeGroupVersion.WithResource("localsubjectaccessreviews"), + authorizationv1beta1.SchemeGroupVersion.WithKind("LocalSubjectAccessReview"), + func() *authorizationv1beta1.LocalSubjectAccessReview { + return &authorizationv1beta1.LocalSubjectAccessReview{} + }, + ), + fake.Fake, } +} - return &localSubjectAccessReviewsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +func (c *localSubjectAccessReviewClusterClient) Cluster(cluster logicalcluster.Path) typedkcpauthorizationv1beta1.LocalSubjectAccessReviewsNamespacer { + return &localSubjectAccessReviewNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type localSubjectAccessReviewsNamespacer struct { +type localSubjectAccessReviewNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *localSubjectAccessReviewsNamespacer) Namespace(namespace string) authorizationv1beta1client.LocalSubjectAccessReviewInterface { - return &localSubjectAccessReviewsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *localSubjectAccessReviewNamespacer) Namespace(namespace string) typedauthorizationv1beta1.LocalSubjectAccessReviewInterface { + return newFakeLocalSubjectAccessReviewClient(n.Fake, namespace, n.ClusterPath) } -type localSubjectAccessReviewsClient struct { - *kcptesting.Fake +// localSubjectAccessReviewScopedClient implements LocalSubjectAccessReviewInterface +type localSubjectAccessReviewScopedClient struct { + *kcpgentype.FakeClient[*authorizationv1beta1.LocalSubjectAccessReview] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string } -func (c *localSubjectAccessReviewsClient) Create(ctx context.Context, localSubjectAccessReview *authorizationv1beta1.LocalSubjectAccessReview, opts metav1.CreateOptions) (*authorizationv1beta1.LocalSubjectAccessReview, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(localSubjectAccessReviewsResource, c.ClusterPath, c.Namespace, localSubjectAccessReview), &authorizationv1beta1.LocalSubjectAccessReview{}) - if obj == nil { - return nil, err +func newFakeLocalSubjectAccessReviewClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedauthorizationv1beta1.LocalSubjectAccessReviewInterface { + return &localSubjectAccessReviewScopedClient{ + kcpgentype.NewFakeClient[*authorizationv1beta1.LocalSubjectAccessReview]( + fake, + clusterPath, + namespace, + authorizationv1beta1.SchemeGroupVersion.WithResource("localsubjectaccessreviews"), + authorizationv1beta1.SchemeGroupVersion.WithKind("LocalSubjectAccessReview"), + func() *authorizationv1beta1.LocalSubjectAccessReview { + return &authorizationv1beta1.LocalSubjectAccessReview{} + }, + ), + fake, + clusterPath, } - return obj.(*authorizationv1beta1.LocalSubjectAccessReview), err } diff --git a/kubernetes/typed/authorization/v1beta1/fake/selfsubjectaccessreview.go b/kubernetes/typed/authorization/v1beta1/fake/selfsubjectaccessreview.go index ffe7421c9..266b8273a 100644 --- a/kubernetes/typed/authorization/v1beta1/fake/selfsubjectaccessreview.go +++ b/kubernetes/typed/authorization/v1beta1/fake/selfsubjectaccessreview.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,48 +14,65 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "github.com/kcp-dev/logicalcluster/v3" authorizationv1beta1 "k8s.io/api/authorization/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - authorizationv1beta1client "k8s.io/client-go/kubernetes/typed/authorization/v1beta1" + typedauthorizationv1beta1 "k8s.io/client-go/kubernetes/typed/authorization/v1beta1" + typedkcpauthorizationv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/authorization/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var selfSubjectAccessReviewsResource = schema.GroupVersionResource{Group: "authorization.k8s.io", Version: "v1beta1", Resource: "selfsubjectaccessreviews"} -var selfSubjectAccessReviewsKind = schema.GroupVersionKind{Group: "authorization.k8s.io", Version: "v1beta1", Kind: "SelfSubjectAccessReview"} - -type selfSubjectAccessReviewsClusterClient struct { - *kcptesting.Fake +// selfSubjectAccessReviewClusterClient implements SelfSubjectAccessReviewClusterInterface +type selfSubjectAccessReviewClusterClient struct { + *kcpgentype.FakeClusterClient[*authorizationv1beta1.SelfSubjectAccessReview] + Fake *kcptesting.Fake } -// Cluster scopes the client down to a particular cluster. -func (c *selfSubjectAccessReviewsClusterClient) Cluster(clusterPath logicalcluster.Path) authorizationv1beta1client.SelfSubjectAccessReviewInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") +func newFakeSelfSubjectAccessReviewClusterClient(fake *AuthorizationV1beta1ClusterClient) typedkcpauthorizationv1beta1.SelfSubjectAccessReviewClusterInterface { + return &selfSubjectAccessReviewClusterClient{ + kcpgentype.NewFakeClusterClient[*authorizationv1beta1.SelfSubjectAccessReview]( + fake.Fake, + authorizationv1beta1.SchemeGroupVersion.WithResource("selfsubjectaccessreviews"), + authorizationv1beta1.SchemeGroupVersion.WithKind("SelfSubjectAccessReview"), + func() *authorizationv1beta1.SelfSubjectAccessReview { + return &authorizationv1beta1.SelfSubjectAccessReview{} + }, + ), + fake.Fake, } +} - return &selfSubjectAccessReviewsClient{Fake: c.Fake, ClusterPath: clusterPath} +func (c *selfSubjectAccessReviewClusterClient) Cluster(cluster logicalcluster.Path) typedauthorizationv1beta1.SelfSubjectAccessReviewInterface { + return newFakeSelfSubjectAccessReviewClient(c.Fake, cluster) } -type selfSubjectAccessReviewsClient struct { - *kcptesting.Fake +// selfSubjectAccessReviewScopedClient implements SelfSubjectAccessReviewInterface +type selfSubjectAccessReviewScopedClient struct { + *kcpgentype.FakeClient[*authorizationv1beta1.SelfSubjectAccessReview] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *selfSubjectAccessReviewsClient) Create(ctx context.Context, selfSubjectAccessReview *authorizationv1beta1.SelfSubjectAccessReview, opts metav1.CreateOptions) (*authorizationv1beta1.SelfSubjectAccessReview, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(selfSubjectAccessReviewsResource, c.ClusterPath, selfSubjectAccessReview), &authorizationv1beta1.SelfSubjectAccessReview{}) - if obj == nil { - return nil, err +func newFakeSelfSubjectAccessReviewClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedauthorizationv1beta1.SelfSubjectAccessReviewInterface { + return &selfSubjectAccessReviewScopedClient{ + kcpgentype.NewFakeClient[*authorizationv1beta1.SelfSubjectAccessReview]( + fake, + clusterPath, + "", + authorizationv1beta1.SchemeGroupVersion.WithResource("selfsubjectaccessreviews"), + authorizationv1beta1.SchemeGroupVersion.WithKind("SelfSubjectAccessReview"), + func() *authorizationv1beta1.SelfSubjectAccessReview { + return &authorizationv1beta1.SelfSubjectAccessReview{} + }, + ), + fake, + clusterPath, } - return obj.(*authorizationv1beta1.SelfSubjectAccessReview), err } diff --git a/kubernetes/typed/authorization/v1beta1/fake/selfsubjectrulesreview.go b/kubernetes/typed/authorization/v1beta1/fake/selfsubjectrulesreview.go index f844cd52a..f6c43dbba 100644 --- a/kubernetes/typed/authorization/v1beta1/fake/selfsubjectrulesreview.go +++ b/kubernetes/typed/authorization/v1beta1/fake/selfsubjectrulesreview.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,48 +14,65 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "github.com/kcp-dev/logicalcluster/v3" authorizationv1beta1 "k8s.io/api/authorization/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - authorizationv1beta1client "k8s.io/client-go/kubernetes/typed/authorization/v1beta1" + typedauthorizationv1beta1 "k8s.io/client-go/kubernetes/typed/authorization/v1beta1" + typedkcpauthorizationv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/authorization/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var selfSubjectRulesReviewsResource = schema.GroupVersionResource{Group: "authorization.k8s.io", Version: "v1beta1", Resource: "selfsubjectrulesreviews"} -var selfSubjectRulesReviewsKind = schema.GroupVersionKind{Group: "authorization.k8s.io", Version: "v1beta1", Kind: "SelfSubjectRulesReview"} - -type selfSubjectRulesReviewsClusterClient struct { - *kcptesting.Fake +// selfSubjectRulesReviewClusterClient implements SelfSubjectRulesReviewClusterInterface +type selfSubjectRulesReviewClusterClient struct { + *kcpgentype.FakeClusterClient[*authorizationv1beta1.SelfSubjectRulesReview] + Fake *kcptesting.Fake } -// Cluster scopes the client down to a particular cluster. -func (c *selfSubjectRulesReviewsClusterClient) Cluster(clusterPath logicalcluster.Path) authorizationv1beta1client.SelfSubjectRulesReviewInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") +func newFakeSelfSubjectRulesReviewClusterClient(fake *AuthorizationV1beta1ClusterClient) typedkcpauthorizationv1beta1.SelfSubjectRulesReviewClusterInterface { + return &selfSubjectRulesReviewClusterClient{ + kcpgentype.NewFakeClusterClient[*authorizationv1beta1.SelfSubjectRulesReview]( + fake.Fake, + authorizationv1beta1.SchemeGroupVersion.WithResource("selfsubjectrulesreviews"), + authorizationv1beta1.SchemeGroupVersion.WithKind("SelfSubjectRulesReview"), + func() *authorizationv1beta1.SelfSubjectRulesReview { + return &authorizationv1beta1.SelfSubjectRulesReview{} + }, + ), + fake.Fake, } +} - return &selfSubjectRulesReviewsClient{Fake: c.Fake, ClusterPath: clusterPath} +func (c *selfSubjectRulesReviewClusterClient) Cluster(cluster logicalcluster.Path) typedauthorizationv1beta1.SelfSubjectRulesReviewInterface { + return newFakeSelfSubjectRulesReviewClient(c.Fake, cluster) } -type selfSubjectRulesReviewsClient struct { - *kcptesting.Fake +// selfSubjectRulesReviewScopedClient implements SelfSubjectRulesReviewInterface +type selfSubjectRulesReviewScopedClient struct { + *kcpgentype.FakeClient[*authorizationv1beta1.SelfSubjectRulesReview] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *selfSubjectRulesReviewsClient) Create(ctx context.Context, selfSubjectRulesReview *authorizationv1beta1.SelfSubjectRulesReview, opts metav1.CreateOptions) (*authorizationv1beta1.SelfSubjectRulesReview, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(selfSubjectRulesReviewsResource, c.ClusterPath, selfSubjectRulesReview), &authorizationv1beta1.SelfSubjectRulesReview{}) - if obj == nil { - return nil, err +func newFakeSelfSubjectRulesReviewClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedauthorizationv1beta1.SelfSubjectRulesReviewInterface { + return &selfSubjectRulesReviewScopedClient{ + kcpgentype.NewFakeClient[*authorizationv1beta1.SelfSubjectRulesReview]( + fake, + clusterPath, + "", + authorizationv1beta1.SchemeGroupVersion.WithResource("selfsubjectrulesreviews"), + authorizationv1beta1.SchemeGroupVersion.WithKind("SelfSubjectRulesReview"), + func() *authorizationv1beta1.SelfSubjectRulesReview { + return &authorizationv1beta1.SelfSubjectRulesReview{} + }, + ), + fake, + clusterPath, } - return obj.(*authorizationv1beta1.SelfSubjectRulesReview), err } diff --git a/kubernetes/typed/authorization/v1beta1/fake/subjectaccessreview.go b/kubernetes/typed/authorization/v1beta1/fake/subjectaccessreview.go index 4d19fc3d5..a74f3d02a 100644 --- a/kubernetes/typed/authorization/v1beta1/fake/subjectaccessreview.go +++ b/kubernetes/typed/authorization/v1beta1/fake/subjectaccessreview.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,48 +14,61 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "github.com/kcp-dev/logicalcluster/v3" authorizationv1beta1 "k8s.io/api/authorization/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - authorizationv1beta1client "k8s.io/client-go/kubernetes/typed/authorization/v1beta1" + typedauthorizationv1beta1 "k8s.io/client-go/kubernetes/typed/authorization/v1beta1" + typedkcpauthorizationv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/authorization/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var subjectAccessReviewsResource = schema.GroupVersionResource{Group: "authorization.k8s.io", Version: "v1beta1", Resource: "subjectaccessreviews"} -var subjectAccessReviewsKind = schema.GroupVersionKind{Group: "authorization.k8s.io", Version: "v1beta1", Kind: "SubjectAccessReview"} - -type subjectAccessReviewsClusterClient struct { - *kcptesting.Fake +// subjectAccessReviewClusterClient implements SubjectAccessReviewClusterInterface +type subjectAccessReviewClusterClient struct { + *kcpgentype.FakeClusterClient[*authorizationv1beta1.SubjectAccessReview] + Fake *kcptesting.Fake } -// Cluster scopes the client down to a particular cluster. -func (c *subjectAccessReviewsClusterClient) Cluster(clusterPath logicalcluster.Path) authorizationv1beta1client.SubjectAccessReviewInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") +func newFakeSubjectAccessReviewClusterClient(fake *AuthorizationV1beta1ClusterClient) typedkcpauthorizationv1beta1.SubjectAccessReviewClusterInterface { + return &subjectAccessReviewClusterClient{ + kcpgentype.NewFakeClusterClient[*authorizationv1beta1.SubjectAccessReview]( + fake.Fake, + authorizationv1beta1.SchemeGroupVersion.WithResource("subjectaccessreviews"), + authorizationv1beta1.SchemeGroupVersion.WithKind("SubjectAccessReview"), + func() *authorizationv1beta1.SubjectAccessReview { return &authorizationv1beta1.SubjectAccessReview{} }, + ), + fake.Fake, } +} - return &subjectAccessReviewsClient{Fake: c.Fake, ClusterPath: clusterPath} +func (c *subjectAccessReviewClusterClient) Cluster(cluster logicalcluster.Path) typedauthorizationv1beta1.SubjectAccessReviewInterface { + return newFakeSubjectAccessReviewClient(c.Fake, cluster) } -type subjectAccessReviewsClient struct { - *kcptesting.Fake +// subjectAccessReviewScopedClient implements SubjectAccessReviewInterface +type subjectAccessReviewScopedClient struct { + *kcpgentype.FakeClient[*authorizationv1beta1.SubjectAccessReview] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *subjectAccessReviewsClient) Create(ctx context.Context, subjectAccessReview *authorizationv1beta1.SubjectAccessReview, opts metav1.CreateOptions) (*authorizationv1beta1.SubjectAccessReview, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(subjectAccessReviewsResource, c.ClusterPath, subjectAccessReview), &authorizationv1beta1.SubjectAccessReview{}) - if obj == nil { - return nil, err +func newFakeSubjectAccessReviewClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedauthorizationv1beta1.SubjectAccessReviewInterface { + return &subjectAccessReviewScopedClient{ + kcpgentype.NewFakeClient[*authorizationv1beta1.SubjectAccessReview]( + fake, + clusterPath, + "", + authorizationv1beta1.SchemeGroupVersion.WithResource("subjectaccessreviews"), + authorizationv1beta1.SchemeGroupVersion.WithKind("SubjectAccessReview"), + func() *authorizationv1beta1.SubjectAccessReview { return &authorizationv1beta1.SubjectAccessReview{} }, + ), + fake, + clusterPath, } - return obj.(*authorizationv1beta1.SubjectAccessReview), err } diff --git a/kubernetes/typed/authorization/v1beta1/generated_expansion.go b/kubernetes/typed/authorization/v1beta1/generated_expansion.go new file mode 100644 index 000000000..48f2247fe --- /dev/null +++ b/kubernetes/typed/authorization/v1beta1/generated_expansion.go @@ -0,0 +1,27 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1beta1 + +type LocalSubjectAccessReviewClusterExpansion interface{} + +type SelfSubjectAccessReviewClusterExpansion interface{} + +type SelfSubjectRulesReviewClusterExpansion interface{} + +type SubjectAccessReviewClusterExpansion interface{} diff --git a/kubernetes/typed/authorization/v1beta1/localsubjectaccessreview.go b/kubernetes/typed/authorization/v1beta1/localsubjectaccessreview.go index 99e4e0e55..f2de8fa5c 100644 --- a/kubernetes/typed/authorization/v1beta1/localsubjectaccessreview.go +++ b/kubernetes/typed/authorization/v1beta1/localsubjectaccessreview.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 @@ -22,7 +22,7 @@ import ( kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - authorizationv1beta1client "k8s.io/client-go/kubernetes/typed/authorization/v1beta1" + authorizationv1beta1 "k8s.io/client-go/kubernetes/typed/authorization/v1beta1" ) // LocalSubjectAccessReviewsClusterGetter has a method to return a LocalSubjectAccessReviewClusterInterface. @@ -31,13 +31,16 @@ type LocalSubjectAccessReviewsClusterGetter interface { LocalSubjectAccessReviews() LocalSubjectAccessReviewClusterInterface } -// LocalSubjectAccessReviewClusterInterface can scope down to one cluster and return a LocalSubjectAccessReviewsNamespacer. +// LocalSubjectAccessReviewClusterInterface can operate on LocalSubjectAccessReviews across all clusters, +// or scope down to one cluster and return a LocalSubjectAccessReviewsNamespacer. type LocalSubjectAccessReviewClusterInterface interface { Cluster(logicalcluster.Path) LocalSubjectAccessReviewsNamespacer + + LocalSubjectAccessReviewClusterExpansion } type localSubjectAccessReviewsClusterInterface struct { - clientCache kcpclient.Cache[*authorizationv1beta1client.AuthorizationV1beta1Client] + clientCache kcpclient.Cache[*authorizationv1beta1.AuthorizationV1beta1Client] } // Cluster scopes the client down to a particular cluster. @@ -49,16 +52,16 @@ func (c *localSubjectAccessReviewsClusterInterface) Cluster(clusterPath logicalc return &localSubjectAccessReviewsNamespacer{clientCache: c.clientCache, clusterPath: clusterPath} } -// LocalSubjectAccessReviewsNamespacer can scope to objects within a namespace, returning a authorizationv1beta1client.LocalSubjectAccessReviewInterface. +// LocalSubjectAccessReviewsNamespacer can scope to objects within a namespace, returning a authorizationv1beta1.LocalSubjectAccessReviewInterface. type LocalSubjectAccessReviewsNamespacer interface { - Namespace(string) authorizationv1beta1client.LocalSubjectAccessReviewInterface + Namespace(string) authorizationv1beta1.LocalSubjectAccessReviewInterface } type localSubjectAccessReviewsNamespacer struct { - clientCache kcpclient.Cache[*authorizationv1beta1client.AuthorizationV1beta1Client] + clientCache kcpclient.Cache[*authorizationv1beta1.AuthorizationV1beta1Client] clusterPath logicalcluster.Path } -func (n *localSubjectAccessReviewsNamespacer) Namespace(namespace string) authorizationv1beta1client.LocalSubjectAccessReviewInterface { +func (n *localSubjectAccessReviewsNamespacer) Namespace(namespace string) authorizationv1beta1.LocalSubjectAccessReviewInterface { return n.clientCache.ClusterOrDie(n.clusterPath).LocalSubjectAccessReviews(namespace) } diff --git a/kubernetes/typed/authorization/v1beta1/selfsubjectaccessreview.go b/kubernetes/typed/authorization/v1beta1/selfsubjectaccessreview.go index f1b57e921..8a6b91a5e 100644 --- a/kubernetes/typed/authorization/v1beta1/selfsubjectaccessreview.go +++ b/kubernetes/typed/authorization/v1beta1/selfsubjectaccessreview.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 @@ -22,7 +22,7 @@ import ( kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - authorizationv1beta1client "k8s.io/client-go/kubernetes/typed/authorization/v1beta1" + authorizationv1beta1 "k8s.io/client-go/kubernetes/typed/authorization/v1beta1" ) // SelfSubjectAccessReviewsClusterGetter has a method to return a SelfSubjectAccessReviewClusterInterface. @@ -31,17 +31,20 @@ type SelfSubjectAccessReviewsClusterGetter interface { SelfSubjectAccessReviews() SelfSubjectAccessReviewClusterInterface } -// SelfSubjectAccessReviewClusterInterface can scope down to one cluster and return a authorizationv1beta1client.SelfSubjectAccessReviewInterface. +// SelfSubjectAccessReviewClusterInterface can operate on SelfSubjectAccessReviews across all clusters, +// or scope down to one cluster and return a authorizationv1beta1.SelfSubjectAccessReviewInterface. type SelfSubjectAccessReviewClusterInterface interface { - Cluster(logicalcluster.Path) authorizationv1beta1client.SelfSubjectAccessReviewInterface + Cluster(logicalcluster.Path) authorizationv1beta1.SelfSubjectAccessReviewInterface + + SelfSubjectAccessReviewClusterExpansion } type selfSubjectAccessReviewsClusterInterface struct { - clientCache kcpclient.Cache[*authorizationv1beta1client.AuthorizationV1beta1Client] + clientCache kcpclient.Cache[*authorizationv1beta1.AuthorizationV1beta1Client] } // Cluster scopes the client down to a particular cluster. -func (c *selfSubjectAccessReviewsClusterInterface) Cluster(clusterPath logicalcluster.Path) authorizationv1beta1client.SelfSubjectAccessReviewInterface { +func (c *selfSubjectAccessReviewsClusterInterface) Cluster(clusterPath logicalcluster.Path) authorizationv1beta1.SelfSubjectAccessReviewInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } diff --git a/kubernetes/typed/authorization/v1beta1/selfsubjectrulesreview.go b/kubernetes/typed/authorization/v1beta1/selfsubjectrulesreview.go index 0737d7065..f50b0e415 100644 --- a/kubernetes/typed/authorization/v1beta1/selfsubjectrulesreview.go +++ b/kubernetes/typed/authorization/v1beta1/selfsubjectrulesreview.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 @@ -22,7 +22,7 @@ import ( kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - authorizationv1beta1client "k8s.io/client-go/kubernetes/typed/authorization/v1beta1" + authorizationv1beta1 "k8s.io/client-go/kubernetes/typed/authorization/v1beta1" ) // SelfSubjectRulesReviewsClusterGetter has a method to return a SelfSubjectRulesReviewClusterInterface. @@ -31,17 +31,20 @@ type SelfSubjectRulesReviewsClusterGetter interface { SelfSubjectRulesReviews() SelfSubjectRulesReviewClusterInterface } -// SelfSubjectRulesReviewClusterInterface can scope down to one cluster and return a authorizationv1beta1client.SelfSubjectRulesReviewInterface. +// SelfSubjectRulesReviewClusterInterface can operate on SelfSubjectRulesReviews across all clusters, +// or scope down to one cluster and return a authorizationv1beta1.SelfSubjectRulesReviewInterface. type SelfSubjectRulesReviewClusterInterface interface { - Cluster(logicalcluster.Path) authorizationv1beta1client.SelfSubjectRulesReviewInterface + Cluster(logicalcluster.Path) authorizationv1beta1.SelfSubjectRulesReviewInterface + + SelfSubjectRulesReviewClusterExpansion } type selfSubjectRulesReviewsClusterInterface struct { - clientCache kcpclient.Cache[*authorizationv1beta1client.AuthorizationV1beta1Client] + clientCache kcpclient.Cache[*authorizationv1beta1.AuthorizationV1beta1Client] } // Cluster scopes the client down to a particular cluster. -func (c *selfSubjectRulesReviewsClusterInterface) Cluster(clusterPath logicalcluster.Path) authorizationv1beta1client.SelfSubjectRulesReviewInterface { +func (c *selfSubjectRulesReviewsClusterInterface) Cluster(clusterPath logicalcluster.Path) authorizationv1beta1.SelfSubjectRulesReviewInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } diff --git a/kubernetes/typed/authorization/v1beta1/subjectaccessreview.go b/kubernetes/typed/authorization/v1beta1/subjectaccessreview.go index 2892f1d00..f64c06aca 100644 --- a/kubernetes/typed/authorization/v1beta1/subjectaccessreview.go +++ b/kubernetes/typed/authorization/v1beta1/subjectaccessreview.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 @@ -22,7 +22,7 @@ import ( kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - authorizationv1beta1client "k8s.io/client-go/kubernetes/typed/authorization/v1beta1" + authorizationv1beta1 "k8s.io/client-go/kubernetes/typed/authorization/v1beta1" ) // SubjectAccessReviewsClusterGetter has a method to return a SubjectAccessReviewClusterInterface. @@ -31,17 +31,20 @@ type SubjectAccessReviewsClusterGetter interface { SubjectAccessReviews() SubjectAccessReviewClusterInterface } -// SubjectAccessReviewClusterInterface can scope down to one cluster and return a authorizationv1beta1client.SubjectAccessReviewInterface. +// SubjectAccessReviewClusterInterface can operate on SubjectAccessReviews across all clusters, +// or scope down to one cluster and return a authorizationv1beta1.SubjectAccessReviewInterface. type SubjectAccessReviewClusterInterface interface { - Cluster(logicalcluster.Path) authorizationv1beta1client.SubjectAccessReviewInterface + Cluster(logicalcluster.Path) authorizationv1beta1.SubjectAccessReviewInterface + + SubjectAccessReviewClusterExpansion } type subjectAccessReviewsClusterInterface struct { - clientCache kcpclient.Cache[*authorizationv1beta1client.AuthorizationV1beta1Client] + clientCache kcpclient.Cache[*authorizationv1beta1.AuthorizationV1beta1Client] } // Cluster scopes the client down to a particular cluster. -func (c *subjectAccessReviewsClusterInterface) Cluster(clusterPath logicalcluster.Path) authorizationv1beta1client.SubjectAccessReviewInterface { +func (c *subjectAccessReviewsClusterInterface) Cluster(clusterPath logicalcluster.Path) authorizationv1beta1.SubjectAccessReviewInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } diff --git a/kubernetes/typed/autoscaling/v1/autoscaling_client.go b/kubernetes/typed/autoscaling/v1/autoscaling_client.go index eb5e2e90e..d4713f5d3 100644 --- a/kubernetes/typed/autoscaling/v1/autoscaling_client.go +++ b/kubernetes/typed/autoscaling/v1/autoscaling_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apiautoscalingv1 "k8s.io/api/autoscaling/v1" autoscalingv1 "k8s.io/client-go/kubernetes/typed/autoscaling/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type AutoscalingV1ClusterInterface interface { @@ -37,6 +40,7 @@ type AutoscalingV1ClusterScoper interface { Cluster(logicalcluster.Path) autoscalingv1.AutoscalingV1Interface } +// AutoscalingV1ClusterClient is used to interact with features provided by the autoscaling group. type AutoscalingV1ClusterClient struct { clientCache kcpclient.Cache[*autoscalingv1.AutoscalingV1Client] } @@ -56,11 +60,13 @@ func (c *AutoscalingV1ClusterClient) HorizontalPodAutoscalers() HorizontalPodAut // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*AutoscalingV1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new AutoscalingV1ClusterClient for the given config and http client. @@ -72,6 +78,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*AutoscalingV1Cluste if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &AutoscalingV1ClusterClient{clientCache: cache}, nil } @@ -84,3 +91,14 @@ func NewForConfigOrDie(c *rest.Config) *AutoscalingV1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apiautoscalingv1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/autoscaling/v1/doc.go b/kubernetes/typed/autoscaling/v1/doc.go new file mode 100644 index 000000000..d2f3412ab --- /dev/null +++ b/kubernetes/typed/autoscaling/v1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1 diff --git a/kubernetes/typed/autoscaling/v1/fake/autoscaling_client.go b/kubernetes/typed/autoscaling/v1/fake/autoscaling_client.go index 9c4db6af2..d3bb1fc3d 100644 --- a/kubernetes/typed/autoscaling/v1/fake/autoscaling_client.go +++ b/kubernetes/typed/autoscaling/v1/fake/autoscaling_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" autoscalingv1 "k8s.io/client-go/kubernetes/typed/autoscaling/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpautoscalingv1 "github.com/kcp-dev/client-go/kubernetes/typed/autoscaling/v1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -42,21 +42,21 @@ func (c *AutoscalingV1ClusterClient) Cluster(clusterPath logicalcluster.Path) au } func (c *AutoscalingV1ClusterClient) HorizontalPodAutoscalers() kcpautoscalingv1.HorizontalPodAutoscalerClusterInterface { - return &horizontalPodAutoscalersClusterClient{Fake: c.Fake} + return newFakeHorizontalPodAutoscalerClusterClient(c) } -var _ autoscalingv1.AutoscalingV1Interface = (*AutoscalingV1Client)(nil) - type AutoscalingV1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } +func (c *AutoscalingV1Client) HorizontalPodAutoscalers(namespace string) autoscalingv1.HorizontalPodAutoscalerInterface { + return newFakeHorizontalPodAutoscalerClient(c.Fake, namespace, c.ClusterPath) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. func (c *AutoscalingV1Client) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } - -func (c *AutoscalingV1Client) HorizontalPodAutoscalers(namespace string) autoscalingv1.HorizontalPodAutoscalerInterface { - return &horizontalPodAutoscalersClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} -} diff --git a/kubernetes/typed/autoscaling/v1/fake/doc.go b/kubernetes/typed/autoscaling/v1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/autoscaling/v1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/autoscaling/v1/fake/horizontalpodautoscaler.go b/kubernetes/typed/autoscaling/v1/fake/horizontalpodautoscaler.go index 90224178d..03a88b29b 100644 --- a/kubernetes/typed/autoscaling/v1/fake/horizontalpodautoscaler.go +++ b/kubernetes/typed/autoscaling/v1/fake/horizontalpodautoscaler.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" autoscalingv1 "k8s.io/api/autoscaling/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsautoscalingv1 "k8s.io/client-go/applyconfigurations/autoscaling/v1" - autoscalingv1client "k8s.io/client-go/kubernetes/typed/autoscaling/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/autoscaling/v1" + typedautoscalingv1 "k8s.io/client-go/kubernetes/typed/autoscaling/v1" - kcpautoscalingv1 "github.com/kcp-dev/client-go/kubernetes/typed/autoscaling/v1" + typedkcpautoscalingv1 "github.com/kcp-dev/client-go/kubernetes/typed/autoscaling/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var horizontalPodAutoscalersResource = schema.GroupVersionResource{Group: "autoscaling", Version: "v1", Resource: "horizontalpodautoscalers"} -var horizontalPodAutoscalersKind = schema.GroupVersionKind{Group: "autoscaling", Version: "v1", Kind: "HorizontalPodAutoscaler"} - -type horizontalPodAutoscalersClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *horizontalPodAutoscalersClusterClient) Cluster(clusterPath logicalcluster.Path) kcpautoscalingv1.HorizontalPodAutoscalersNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &horizontalPodAutoscalersNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// horizontalPodAutoscalerClusterClient implements HorizontalPodAutoscalerClusterInterface +type horizontalPodAutoscalerClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*autoscalingv1.HorizontalPodAutoscaler, *autoscalingv1.HorizontalPodAutoscalerList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of HorizontalPodAutoscalers that match those selectors across all clusters. -func (c *horizontalPodAutoscalersClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*autoscalingv1.HorizontalPodAutoscalerList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(horizontalPodAutoscalersResource, horizontalPodAutoscalersKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &autoscalingv1.HorizontalPodAutoscalerList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeHorizontalPodAutoscalerClusterClient(fake *AutoscalingV1ClusterClient) typedkcpautoscalingv1.HorizontalPodAutoscalerClusterInterface { + return &horizontalPodAutoscalerClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*autoscalingv1.HorizontalPodAutoscaler, *autoscalingv1.HorizontalPodAutoscalerList]( + fake.Fake, + autoscalingv1.SchemeGroupVersion.WithResource("horizontalpodautoscalers"), + autoscalingv1.SchemeGroupVersion.WithKind("HorizontalPodAutoscaler"), + func() *autoscalingv1.HorizontalPodAutoscaler { return &autoscalingv1.HorizontalPodAutoscaler{} }, + func() *autoscalingv1.HorizontalPodAutoscalerList { return &autoscalingv1.HorizontalPodAutoscalerList{} }, + func(dst, src *autoscalingv1.HorizontalPodAutoscalerList) { dst.ListMeta = src.ListMeta }, + func(list *autoscalingv1.HorizontalPodAutoscalerList) []*autoscalingv1.HorizontalPodAutoscaler { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *autoscalingv1.HorizontalPodAutoscalerList, items []*autoscalingv1.HorizontalPodAutoscaler) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &autoscalingv1.HorizontalPodAutoscalerList{ListMeta: obj.(*autoscalingv1.HorizontalPodAutoscalerList).ListMeta} - for _, item := range obj.(*autoscalingv1.HorizontalPodAutoscalerList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested HorizontalPodAutoscalers across all clusters. -func (c *horizontalPodAutoscalersClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(horizontalPodAutoscalersResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *horizontalPodAutoscalerClusterClient) Cluster(cluster logicalcluster.Path) typedkcpautoscalingv1.HorizontalPodAutoscalersNamespacer { + return &horizontalPodAutoscalerNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type horizontalPodAutoscalersNamespacer struct { +type horizontalPodAutoscalerNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *horizontalPodAutoscalersNamespacer) Namespace(namespace string) autoscalingv1client.HorizontalPodAutoscalerInterface { - return &horizontalPodAutoscalersClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *horizontalPodAutoscalerNamespacer) Namespace(namespace string) typedautoscalingv1.HorizontalPodAutoscalerInterface { + return newFakeHorizontalPodAutoscalerClient(n.Fake, namespace, n.ClusterPath) } -type horizontalPodAutoscalersClient struct { - *kcptesting.Fake +// horizontalPodAutoscalerScopedClient implements HorizontalPodAutoscalerInterface +type horizontalPodAutoscalerScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*autoscalingv1.HorizontalPodAutoscaler, *autoscalingv1.HorizontalPodAutoscalerList, *v1.HorizontalPodAutoscalerApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *horizontalPodAutoscalersClient) Create(ctx context.Context, horizontalPodAutoscaler *autoscalingv1.HorizontalPodAutoscaler, opts metav1.CreateOptions) (*autoscalingv1.HorizontalPodAutoscaler, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, horizontalPodAutoscaler), &autoscalingv1.HorizontalPodAutoscaler{}) - if obj == nil { - return nil, err - } - return obj.(*autoscalingv1.HorizontalPodAutoscaler), err -} - -func (c *horizontalPodAutoscalersClient) Update(ctx context.Context, horizontalPodAutoscaler *autoscalingv1.HorizontalPodAutoscaler, opts metav1.UpdateOptions) (*autoscalingv1.HorizontalPodAutoscaler, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, horizontalPodAutoscaler), &autoscalingv1.HorizontalPodAutoscaler{}) - if obj == nil { - return nil, err - } - return obj.(*autoscalingv1.HorizontalPodAutoscaler), err -} - -func (c *horizontalPodAutoscalersClient) UpdateStatus(ctx context.Context, horizontalPodAutoscaler *autoscalingv1.HorizontalPodAutoscaler, opts metav1.UpdateOptions) (*autoscalingv1.HorizontalPodAutoscaler, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(horizontalPodAutoscalersResource, c.ClusterPath, "status", c.Namespace, horizontalPodAutoscaler), &autoscalingv1.HorizontalPodAutoscaler{}) - if obj == nil { - return nil, err - } - return obj.(*autoscalingv1.HorizontalPodAutoscaler), err -} - -func (c *horizontalPodAutoscalersClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, name, opts), &autoscalingv1.HorizontalPodAutoscaler{}) - return err -} - -func (c *horizontalPodAutoscalersClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &autoscalingv1.HorizontalPodAutoscalerList{}) - return err -} - -func (c *horizontalPodAutoscalersClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*autoscalingv1.HorizontalPodAutoscaler, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, name), &autoscalingv1.HorizontalPodAutoscaler{}) - if obj == nil { - return nil, err - } - return obj.(*autoscalingv1.HorizontalPodAutoscaler), err -} - -// List takes label and field selectors, and returns the list of HorizontalPodAutoscalers that match those selectors. -func (c *horizontalPodAutoscalersClient) List(ctx context.Context, opts metav1.ListOptions) (*autoscalingv1.HorizontalPodAutoscalerList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(horizontalPodAutoscalersResource, horizontalPodAutoscalersKind, c.ClusterPath, c.Namespace, opts), &autoscalingv1.HorizontalPodAutoscalerList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &autoscalingv1.HorizontalPodAutoscalerList{ListMeta: obj.(*autoscalingv1.HorizontalPodAutoscalerList).ListMeta} - for _, item := range obj.(*autoscalingv1.HorizontalPodAutoscalerList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *horizontalPodAutoscalersClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, opts)) } -func (c *horizontalPodAutoscalersClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*autoscalingv1.HorizontalPodAutoscaler, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &autoscalingv1.HorizontalPodAutoscaler{}) - if obj == nil { - return nil, err - } - return obj.(*autoscalingv1.HorizontalPodAutoscaler), err -} - -func (c *horizontalPodAutoscalersClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsautoscalingv1.HorizontalPodAutoscalerApplyConfiguration, opts metav1.ApplyOptions) (*autoscalingv1.HorizontalPodAutoscaler, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &autoscalingv1.HorizontalPodAutoscaler{}) - if obj == nil { - return nil, err - } - return obj.(*autoscalingv1.HorizontalPodAutoscaler), err -} - -func (c *horizontalPodAutoscalersClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsautoscalingv1.HorizontalPodAutoscalerApplyConfiguration, opts metav1.ApplyOptions) (*autoscalingv1.HorizontalPodAutoscaler, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &autoscalingv1.HorizontalPodAutoscaler{}) - if obj == nil { - return nil, err +func newFakeHorizontalPodAutoscalerClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedautoscalingv1.HorizontalPodAutoscalerInterface { + return &horizontalPodAutoscalerScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*autoscalingv1.HorizontalPodAutoscaler, *autoscalingv1.HorizontalPodAutoscalerList, *v1.HorizontalPodAutoscalerApplyConfiguration]( + fake, + clusterPath, + namespace, + autoscalingv1.SchemeGroupVersion.WithResource("horizontalpodautoscalers"), + autoscalingv1.SchemeGroupVersion.WithKind("HorizontalPodAutoscaler"), + func() *autoscalingv1.HorizontalPodAutoscaler { return &autoscalingv1.HorizontalPodAutoscaler{} }, + func() *autoscalingv1.HorizontalPodAutoscalerList { return &autoscalingv1.HorizontalPodAutoscalerList{} }, + func(dst, src *autoscalingv1.HorizontalPodAutoscalerList) { dst.ListMeta = src.ListMeta }, + func(list *autoscalingv1.HorizontalPodAutoscalerList) []*autoscalingv1.HorizontalPodAutoscaler { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *autoscalingv1.HorizontalPodAutoscalerList, items []*autoscalingv1.HorizontalPodAutoscaler) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*autoscalingv1.HorizontalPodAutoscaler), err } diff --git a/kubernetes/typed/autoscaling/v1/generated_expansion.go b/kubernetes/typed/autoscaling/v1/generated_expansion.go new file mode 100644 index 000000000..48f6add05 --- /dev/null +++ b/kubernetes/typed/autoscaling/v1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1 + +type HorizontalPodAutoscalerClusterExpansion interface{} diff --git a/kubernetes/typed/autoscaling/v1/horizontalpodautoscaler.go b/kubernetes/typed/autoscaling/v1/horizontalpodautoscaler.go index 8f716830c..94e531b99 100644 --- a/kubernetes/typed/autoscaling/v1/horizontalpodautoscaler.go +++ b/kubernetes/typed/autoscaling/v1/horizontalpodautoscaler.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" autoscalingv1 "k8s.io/api/autoscaling/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - autoscalingv1client "k8s.io/client-go/kubernetes/typed/autoscaling/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedautoscalingv1 "k8s.io/client-go/kubernetes/typed/autoscaling/v1" ) // HorizontalPodAutoscalersClusterGetter has a method to return a HorizontalPodAutoscalerClusterInterface. @@ -42,10 +42,11 @@ type HorizontalPodAutoscalerClusterInterface interface { Cluster(logicalcluster.Path) HorizontalPodAutoscalersNamespacer List(ctx context.Context, opts metav1.ListOptions) (*autoscalingv1.HorizontalPodAutoscalerList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + HorizontalPodAutoscalerClusterExpansion } type horizontalPodAutoscalersClusterInterface struct { - clientCache kcpclient.Cache[*autoscalingv1client.AutoscalingV1Client] + clientCache kcpclient.Cache[*typedautoscalingv1.AutoscalingV1Client] } // Cluster scopes the client down to a particular cluster. @@ -67,16 +68,16 @@ func (c *horizontalPodAutoscalersClusterInterface) Watch(ctx context.Context, op return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).HorizontalPodAutoscalers(metav1.NamespaceAll).Watch(ctx, opts) } -// HorizontalPodAutoscalersNamespacer can scope to objects within a namespace, returning a autoscalingv1client.HorizontalPodAutoscalerInterface. +// HorizontalPodAutoscalersNamespacer can scope to objects within a namespace, returning a typedautoscalingv1.HorizontalPodAutoscalerInterface. type HorizontalPodAutoscalersNamespacer interface { - Namespace(string) autoscalingv1client.HorizontalPodAutoscalerInterface + Namespace(string) typedautoscalingv1.HorizontalPodAutoscalerInterface } type horizontalPodAutoscalersNamespacer struct { - clientCache kcpclient.Cache[*autoscalingv1client.AutoscalingV1Client] + clientCache kcpclient.Cache[*typedautoscalingv1.AutoscalingV1Client] clusterPath logicalcluster.Path } -func (n *horizontalPodAutoscalersNamespacer) Namespace(namespace string) autoscalingv1client.HorizontalPodAutoscalerInterface { +func (n *horizontalPodAutoscalersNamespacer) Namespace(namespace string) typedautoscalingv1.HorizontalPodAutoscalerInterface { return n.clientCache.ClusterOrDie(n.clusterPath).HorizontalPodAutoscalers(namespace) } diff --git a/kubernetes/typed/autoscaling/v2/autoscaling_client.go b/kubernetes/typed/autoscaling/v2/autoscaling_client.go index 48427523e..e20897d38 100644 --- a/kubernetes/typed/autoscaling/v2/autoscaling_client.go +++ b/kubernetes/typed/autoscaling/v2/autoscaling_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v2 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apiautoscalingv2 "k8s.io/api/autoscaling/v2" autoscalingv2 "k8s.io/client-go/kubernetes/typed/autoscaling/v2" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type AutoscalingV2ClusterInterface interface { @@ -37,6 +40,7 @@ type AutoscalingV2ClusterScoper interface { Cluster(logicalcluster.Path) autoscalingv2.AutoscalingV2Interface } +// AutoscalingV2ClusterClient is used to interact with features provided by the autoscaling group. type AutoscalingV2ClusterClient struct { clientCache kcpclient.Cache[*autoscalingv2.AutoscalingV2Client] } @@ -56,11 +60,13 @@ func (c *AutoscalingV2ClusterClient) HorizontalPodAutoscalers() HorizontalPodAut // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*AutoscalingV2ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new AutoscalingV2ClusterClient for the given config and http client. @@ -72,6 +78,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*AutoscalingV2Cluste if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &AutoscalingV2ClusterClient{clientCache: cache}, nil } @@ -84,3 +91,14 @@ func NewForConfigOrDie(c *rest.Config) *AutoscalingV2ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apiautoscalingv2.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/autoscaling/v2/doc.go b/kubernetes/typed/autoscaling/v2/doc.go new file mode 100644 index 000000000..4d145b873 --- /dev/null +++ b/kubernetes/typed/autoscaling/v2/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v2 diff --git a/kubernetes/typed/autoscaling/v2/fake/autoscaling_client.go b/kubernetes/typed/autoscaling/v2/fake/autoscaling_client.go index f4e0a5e6b..8c43d576f 100644 --- a/kubernetes/typed/autoscaling/v2/fake/autoscaling_client.go +++ b/kubernetes/typed/autoscaling/v2/fake/autoscaling_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" autoscalingv2 "k8s.io/client-go/kubernetes/typed/autoscaling/v2" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpautoscalingv2 "github.com/kcp-dev/client-go/kubernetes/typed/autoscaling/v2" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -42,21 +42,21 @@ func (c *AutoscalingV2ClusterClient) Cluster(clusterPath logicalcluster.Path) au } func (c *AutoscalingV2ClusterClient) HorizontalPodAutoscalers() kcpautoscalingv2.HorizontalPodAutoscalerClusterInterface { - return &horizontalPodAutoscalersClusterClient{Fake: c.Fake} + return newFakeHorizontalPodAutoscalerClusterClient(c) } -var _ autoscalingv2.AutoscalingV2Interface = (*AutoscalingV2Client)(nil) - type AutoscalingV2Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } +func (c *AutoscalingV2Client) HorizontalPodAutoscalers(namespace string) autoscalingv2.HorizontalPodAutoscalerInterface { + return newFakeHorizontalPodAutoscalerClient(c.Fake, namespace, c.ClusterPath) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. func (c *AutoscalingV2Client) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } - -func (c *AutoscalingV2Client) HorizontalPodAutoscalers(namespace string) autoscalingv2.HorizontalPodAutoscalerInterface { - return &horizontalPodAutoscalersClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} -} diff --git a/kubernetes/typed/autoscaling/v2/fake/doc.go b/kubernetes/typed/autoscaling/v2/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/autoscaling/v2/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/autoscaling/v2/fake/horizontalpodautoscaler.go b/kubernetes/typed/autoscaling/v2/fake/horizontalpodautoscaler.go index 01b29f8c2..ef5df5c5b 100644 --- a/kubernetes/typed/autoscaling/v2/fake/horizontalpodautoscaler.go +++ b/kubernetes/typed/autoscaling/v2/fake/horizontalpodautoscaler.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" autoscalingv2 "k8s.io/api/autoscaling/v2" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsautoscalingv2 "k8s.io/client-go/applyconfigurations/autoscaling/v2" - autoscalingv2client "k8s.io/client-go/kubernetes/typed/autoscaling/v2" - "k8s.io/client-go/testing" + v2 "k8s.io/client-go/applyconfigurations/autoscaling/v2" + typedautoscalingv2 "k8s.io/client-go/kubernetes/typed/autoscaling/v2" - kcpautoscalingv2 "github.com/kcp-dev/client-go/kubernetes/typed/autoscaling/v2" + typedkcpautoscalingv2 "github.com/kcp-dev/client-go/kubernetes/typed/autoscaling/v2" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var horizontalPodAutoscalersResource = schema.GroupVersionResource{Group: "autoscaling", Version: "v2", Resource: "horizontalpodautoscalers"} -var horizontalPodAutoscalersKind = schema.GroupVersionKind{Group: "autoscaling", Version: "v2", Kind: "HorizontalPodAutoscaler"} - -type horizontalPodAutoscalersClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *horizontalPodAutoscalersClusterClient) Cluster(clusterPath logicalcluster.Path) kcpautoscalingv2.HorizontalPodAutoscalersNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &horizontalPodAutoscalersNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// horizontalPodAutoscalerClusterClient implements HorizontalPodAutoscalerClusterInterface +type horizontalPodAutoscalerClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*autoscalingv2.HorizontalPodAutoscaler, *autoscalingv2.HorizontalPodAutoscalerList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of HorizontalPodAutoscalers that match those selectors across all clusters. -func (c *horizontalPodAutoscalersClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*autoscalingv2.HorizontalPodAutoscalerList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(horizontalPodAutoscalersResource, horizontalPodAutoscalersKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &autoscalingv2.HorizontalPodAutoscalerList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeHorizontalPodAutoscalerClusterClient(fake *AutoscalingV2ClusterClient) typedkcpautoscalingv2.HorizontalPodAutoscalerClusterInterface { + return &horizontalPodAutoscalerClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*autoscalingv2.HorizontalPodAutoscaler, *autoscalingv2.HorizontalPodAutoscalerList]( + fake.Fake, + autoscalingv2.SchemeGroupVersion.WithResource("horizontalpodautoscalers"), + autoscalingv2.SchemeGroupVersion.WithKind("HorizontalPodAutoscaler"), + func() *autoscalingv2.HorizontalPodAutoscaler { return &autoscalingv2.HorizontalPodAutoscaler{} }, + func() *autoscalingv2.HorizontalPodAutoscalerList { return &autoscalingv2.HorizontalPodAutoscalerList{} }, + func(dst, src *autoscalingv2.HorizontalPodAutoscalerList) { dst.ListMeta = src.ListMeta }, + func(list *autoscalingv2.HorizontalPodAutoscalerList) []*autoscalingv2.HorizontalPodAutoscaler { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *autoscalingv2.HorizontalPodAutoscalerList, items []*autoscalingv2.HorizontalPodAutoscaler) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &autoscalingv2.HorizontalPodAutoscalerList{ListMeta: obj.(*autoscalingv2.HorizontalPodAutoscalerList).ListMeta} - for _, item := range obj.(*autoscalingv2.HorizontalPodAutoscalerList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested HorizontalPodAutoscalers across all clusters. -func (c *horizontalPodAutoscalersClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(horizontalPodAutoscalersResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *horizontalPodAutoscalerClusterClient) Cluster(cluster logicalcluster.Path) typedkcpautoscalingv2.HorizontalPodAutoscalersNamespacer { + return &horizontalPodAutoscalerNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type horizontalPodAutoscalersNamespacer struct { +type horizontalPodAutoscalerNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *horizontalPodAutoscalersNamespacer) Namespace(namespace string) autoscalingv2client.HorizontalPodAutoscalerInterface { - return &horizontalPodAutoscalersClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *horizontalPodAutoscalerNamespacer) Namespace(namespace string) typedautoscalingv2.HorizontalPodAutoscalerInterface { + return newFakeHorizontalPodAutoscalerClient(n.Fake, namespace, n.ClusterPath) } -type horizontalPodAutoscalersClient struct { - *kcptesting.Fake +// horizontalPodAutoscalerScopedClient implements HorizontalPodAutoscalerInterface +type horizontalPodAutoscalerScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*autoscalingv2.HorizontalPodAutoscaler, *autoscalingv2.HorizontalPodAutoscalerList, *v2.HorizontalPodAutoscalerApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *horizontalPodAutoscalersClient) Create(ctx context.Context, horizontalPodAutoscaler *autoscalingv2.HorizontalPodAutoscaler, opts metav1.CreateOptions) (*autoscalingv2.HorizontalPodAutoscaler, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, horizontalPodAutoscaler), &autoscalingv2.HorizontalPodAutoscaler{}) - if obj == nil { - return nil, err - } - return obj.(*autoscalingv2.HorizontalPodAutoscaler), err -} - -func (c *horizontalPodAutoscalersClient) Update(ctx context.Context, horizontalPodAutoscaler *autoscalingv2.HorizontalPodAutoscaler, opts metav1.UpdateOptions) (*autoscalingv2.HorizontalPodAutoscaler, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, horizontalPodAutoscaler), &autoscalingv2.HorizontalPodAutoscaler{}) - if obj == nil { - return nil, err - } - return obj.(*autoscalingv2.HorizontalPodAutoscaler), err -} - -func (c *horizontalPodAutoscalersClient) UpdateStatus(ctx context.Context, horizontalPodAutoscaler *autoscalingv2.HorizontalPodAutoscaler, opts metav1.UpdateOptions) (*autoscalingv2.HorizontalPodAutoscaler, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(horizontalPodAutoscalersResource, c.ClusterPath, "status", c.Namespace, horizontalPodAutoscaler), &autoscalingv2.HorizontalPodAutoscaler{}) - if obj == nil { - return nil, err - } - return obj.(*autoscalingv2.HorizontalPodAutoscaler), err -} - -func (c *horizontalPodAutoscalersClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, name, opts), &autoscalingv2.HorizontalPodAutoscaler{}) - return err -} - -func (c *horizontalPodAutoscalersClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &autoscalingv2.HorizontalPodAutoscalerList{}) - return err -} - -func (c *horizontalPodAutoscalersClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*autoscalingv2.HorizontalPodAutoscaler, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, name), &autoscalingv2.HorizontalPodAutoscaler{}) - if obj == nil { - return nil, err - } - return obj.(*autoscalingv2.HorizontalPodAutoscaler), err -} - -// List takes label and field selectors, and returns the list of HorizontalPodAutoscalers that match those selectors. -func (c *horizontalPodAutoscalersClient) List(ctx context.Context, opts metav1.ListOptions) (*autoscalingv2.HorizontalPodAutoscalerList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(horizontalPodAutoscalersResource, horizontalPodAutoscalersKind, c.ClusterPath, c.Namespace, opts), &autoscalingv2.HorizontalPodAutoscalerList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &autoscalingv2.HorizontalPodAutoscalerList{ListMeta: obj.(*autoscalingv2.HorizontalPodAutoscalerList).ListMeta} - for _, item := range obj.(*autoscalingv2.HorizontalPodAutoscalerList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *horizontalPodAutoscalersClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, opts)) } -func (c *horizontalPodAutoscalersClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*autoscalingv2.HorizontalPodAutoscaler, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &autoscalingv2.HorizontalPodAutoscaler{}) - if obj == nil { - return nil, err - } - return obj.(*autoscalingv2.HorizontalPodAutoscaler), err -} - -func (c *horizontalPodAutoscalersClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsautoscalingv2.HorizontalPodAutoscalerApplyConfiguration, opts metav1.ApplyOptions) (*autoscalingv2.HorizontalPodAutoscaler, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &autoscalingv2.HorizontalPodAutoscaler{}) - if obj == nil { - return nil, err - } - return obj.(*autoscalingv2.HorizontalPodAutoscaler), err -} - -func (c *horizontalPodAutoscalersClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsautoscalingv2.HorizontalPodAutoscalerApplyConfiguration, opts metav1.ApplyOptions) (*autoscalingv2.HorizontalPodAutoscaler, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &autoscalingv2.HorizontalPodAutoscaler{}) - if obj == nil { - return nil, err +func newFakeHorizontalPodAutoscalerClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedautoscalingv2.HorizontalPodAutoscalerInterface { + return &horizontalPodAutoscalerScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*autoscalingv2.HorizontalPodAutoscaler, *autoscalingv2.HorizontalPodAutoscalerList, *v2.HorizontalPodAutoscalerApplyConfiguration]( + fake, + clusterPath, + namespace, + autoscalingv2.SchemeGroupVersion.WithResource("horizontalpodautoscalers"), + autoscalingv2.SchemeGroupVersion.WithKind("HorizontalPodAutoscaler"), + func() *autoscalingv2.HorizontalPodAutoscaler { return &autoscalingv2.HorizontalPodAutoscaler{} }, + func() *autoscalingv2.HorizontalPodAutoscalerList { return &autoscalingv2.HorizontalPodAutoscalerList{} }, + func(dst, src *autoscalingv2.HorizontalPodAutoscalerList) { dst.ListMeta = src.ListMeta }, + func(list *autoscalingv2.HorizontalPodAutoscalerList) []*autoscalingv2.HorizontalPodAutoscaler { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *autoscalingv2.HorizontalPodAutoscalerList, items []*autoscalingv2.HorizontalPodAutoscaler) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*autoscalingv2.HorizontalPodAutoscaler), err } diff --git a/kubernetes/typed/autoscaling/v2/generated_expansion.go b/kubernetes/typed/autoscaling/v2/generated_expansion.go new file mode 100644 index 000000000..359b4f4ac --- /dev/null +++ b/kubernetes/typed/autoscaling/v2/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v2 + +type HorizontalPodAutoscalerClusterExpansion interface{} diff --git a/kubernetes/typed/autoscaling/v2/horizontalpodautoscaler.go b/kubernetes/typed/autoscaling/v2/horizontalpodautoscaler.go index ee54b3c9f..3c0cbea53 100644 --- a/kubernetes/typed/autoscaling/v2/horizontalpodautoscaler.go +++ b/kubernetes/typed/autoscaling/v2/horizontalpodautoscaler.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v2 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" autoscalingv2 "k8s.io/api/autoscaling/v2" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - autoscalingv2client "k8s.io/client-go/kubernetes/typed/autoscaling/v2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedautoscalingv2 "k8s.io/client-go/kubernetes/typed/autoscaling/v2" ) // HorizontalPodAutoscalersClusterGetter has a method to return a HorizontalPodAutoscalerClusterInterface. @@ -40,12 +40,13 @@ type HorizontalPodAutoscalersClusterGetter interface { // or scope down to one cluster and return a HorizontalPodAutoscalersNamespacer. type HorizontalPodAutoscalerClusterInterface interface { Cluster(logicalcluster.Path) HorizontalPodAutoscalersNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*autoscalingv2.HorizontalPodAutoscalerList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*autoscalingv2.HorizontalPodAutoscalerList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + HorizontalPodAutoscalerClusterExpansion } type horizontalPodAutoscalersClusterInterface struct { - clientCache kcpclient.Cache[*autoscalingv2client.AutoscalingV2Client] + clientCache kcpclient.Cache[*typedautoscalingv2.AutoscalingV2Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *horizontalPodAutoscalersClusterInterface) Cluster(clusterPath logicalcl } // List returns the entire collection of all HorizontalPodAutoscalers across all clusters. -func (c *horizontalPodAutoscalersClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*autoscalingv2.HorizontalPodAutoscalerList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).HorizontalPodAutoscalers(metav1.NamespaceAll).List(ctx, opts) +func (c *horizontalPodAutoscalersClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*autoscalingv2.HorizontalPodAutoscalerList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).HorizontalPodAutoscalers(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all HorizontalPodAutoscalers across all clusters. -func (c *horizontalPodAutoscalersClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).HorizontalPodAutoscalers(metav1.NamespaceAll).Watch(ctx, opts) +func (c *horizontalPodAutoscalersClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).HorizontalPodAutoscalers(v1.NamespaceAll).Watch(ctx, opts) } -// HorizontalPodAutoscalersNamespacer can scope to objects within a namespace, returning a autoscalingv2client.HorizontalPodAutoscalerInterface. +// HorizontalPodAutoscalersNamespacer can scope to objects within a namespace, returning a typedautoscalingv2.HorizontalPodAutoscalerInterface. type HorizontalPodAutoscalersNamespacer interface { - Namespace(string) autoscalingv2client.HorizontalPodAutoscalerInterface + Namespace(string) typedautoscalingv2.HorizontalPodAutoscalerInterface } type horizontalPodAutoscalersNamespacer struct { - clientCache kcpclient.Cache[*autoscalingv2client.AutoscalingV2Client] + clientCache kcpclient.Cache[*typedautoscalingv2.AutoscalingV2Client] clusterPath logicalcluster.Path } -func (n *horizontalPodAutoscalersNamespacer) Namespace(namespace string) autoscalingv2client.HorizontalPodAutoscalerInterface { +func (n *horizontalPodAutoscalersNamespacer) Namespace(namespace string) typedautoscalingv2.HorizontalPodAutoscalerInterface { return n.clientCache.ClusterOrDie(n.clusterPath).HorizontalPodAutoscalers(namespace) } diff --git a/kubernetes/typed/autoscaling/v2beta1/autoscaling_client.go b/kubernetes/typed/autoscaling/v2beta1/autoscaling_client.go index 14fac74f1..5c67fdeb3 100644 --- a/kubernetes/typed/autoscaling/v2beta1/autoscaling_client.go +++ b/kubernetes/typed/autoscaling/v2beta1/autoscaling_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v2beta1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apiautoscalingv2beta1 "k8s.io/api/autoscaling/v2beta1" autoscalingv2beta1 "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type AutoscalingV2beta1ClusterInterface interface { @@ -37,6 +40,7 @@ type AutoscalingV2beta1ClusterScoper interface { Cluster(logicalcluster.Path) autoscalingv2beta1.AutoscalingV2beta1Interface } +// AutoscalingV2beta1ClusterClient is used to interact with features provided by the autoscaling group. type AutoscalingV2beta1ClusterClient struct { clientCache kcpclient.Cache[*autoscalingv2beta1.AutoscalingV2beta1Client] } @@ -56,11 +60,13 @@ func (c *AutoscalingV2beta1ClusterClient) HorizontalPodAutoscalers() HorizontalP // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*AutoscalingV2beta1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new AutoscalingV2beta1ClusterClient for the given config and http client. @@ -72,6 +78,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*AutoscalingV2beta1C if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &AutoscalingV2beta1ClusterClient{clientCache: cache}, nil } @@ -84,3 +91,14 @@ func NewForConfigOrDie(c *rest.Config) *AutoscalingV2beta1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apiautoscalingv2beta1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/autoscaling/v2beta1/doc.go b/kubernetes/typed/autoscaling/v2beta1/doc.go new file mode 100644 index 000000000..bca1e22cc --- /dev/null +++ b/kubernetes/typed/autoscaling/v2beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v2beta1 diff --git a/kubernetes/typed/autoscaling/v2beta1/fake/autoscaling_client.go b/kubernetes/typed/autoscaling/v2beta1/fake/autoscaling_client.go index 9b89522f1..94341c473 100644 --- a/kubernetes/typed/autoscaling/v2beta1/fake/autoscaling_client.go +++ b/kubernetes/typed/autoscaling/v2beta1/fake/autoscaling_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" autoscalingv2beta1 "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpautoscalingv2beta1 "github.com/kcp-dev/client-go/kubernetes/typed/autoscaling/v2beta1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -42,21 +42,21 @@ func (c *AutoscalingV2beta1ClusterClient) Cluster(clusterPath logicalcluster.Pat } func (c *AutoscalingV2beta1ClusterClient) HorizontalPodAutoscalers() kcpautoscalingv2beta1.HorizontalPodAutoscalerClusterInterface { - return &horizontalPodAutoscalersClusterClient{Fake: c.Fake} + return newFakeHorizontalPodAutoscalerClusterClient(c) } -var _ autoscalingv2beta1.AutoscalingV2beta1Interface = (*AutoscalingV2beta1Client)(nil) - type AutoscalingV2beta1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } +func (c *AutoscalingV2beta1Client) HorizontalPodAutoscalers(namespace string) autoscalingv2beta1.HorizontalPodAutoscalerInterface { + return newFakeHorizontalPodAutoscalerClient(c.Fake, namespace, c.ClusterPath) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. func (c *AutoscalingV2beta1Client) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } - -func (c *AutoscalingV2beta1Client) HorizontalPodAutoscalers(namespace string) autoscalingv2beta1.HorizontalPodAutoscalerInterface { - return &horizontalPodAutoscalersClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} -} diff --git a/kubernetes/typed/autoscaling/v2beta1/fake/doc.go b/kubernetes/typed/autoscaling/v2beta1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/autoscaling/v2beta1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/autoscaling/v2beta1/fake/horizontalpodautoscaler.go b/kubernetes/typed/autoscaling/v2beta1/fake/horizontalpodautoscaler.go index 7b4bec06c..f650d3873 100644 --- a/kubernetes/typed/autoscaling/v2beta1/fake/horizontalpodautoscaler.go +++ b/kubernetes/typed/autoscaling/v2beta1/fake/horizontalpodautoscaler.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,95 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" autoscalingv2beta1 "k8s.io/api/autoscaling/v2beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsautoscalingv2beta1 "k8s.io/client-go/applyconfigurations/autoscaling/v2beta1" - autoscalingv2beta1client "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1" - "k8s.io/client-go/testing" + v2beta1 "k8s.io/client-go/applyconfigurations/autoscaling/v2beta1" + typedautoscalingv2beta1 "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1" - kcpautoscalingv2beta1 "github.com/kcp-dev/client-go/kubernetes/typed/autoscaling/v2beta1" + typedkcpautoscalingv2beta1 "github.com/kcp-dev/client-go/kubernetes/typed/autoscaling/v2beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var horizontalPodAutoscalersResource = schema.GroupVersionResource{Group: "autoscaling", Version: "v2beta1", Resource: "horizontalpodautoscalers"} -var horizontalPodAutoscalersKind = schema.GroupVersionKind{Group: "autoscaling", Version: "v2beta1", Kind: "HorizontalPodAutoscaler"} - -type horizontalPodAutoscalersClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *horizontalPodAutoscalersClusterClient) Cluster(clusterPath logicalcluster.Path) kcpautoscalingv2beta1.HorizontalPodAutoscalersNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &horizontalPodAutoscalersNamespacer{Fake: c.Fake, ClusterPath: clusterPath} -} - -// List takes label and field selectors, and returns the list of HorizontalPodAutoscalers that match those selectors across all clusters. -func (c *horizontalPodAutoscalersClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*autoscalingv2beta1.HorizontalPodAutoscalerList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(horizontalPodAutoscalersResource, horizontalPodAutoscalersKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &autoscalingv2beta1.HorizontalPodAutoscalerList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &autoscalingv2beta1.HorizontalPodAutoscalerList{ListMeta: obj.(*autoscalingv2beta1.HorizontalPodAutoscalerList).ListMeta} - for _, item := range obj.(*autoscalingv2beta1.HorizontalPodAutoscalerList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested HorizontalPodAutoscalers across all clusters. -func (c *horizontalPodAutoscalersClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(horizontalPodAutoscalersResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) -} - -type horizontalPodAutoscalersNamespacer struct { +// horizontalPodAutoscalerClusterClient implements HorizontalPodAutoscalerClusterInterface +type horizontalPodAutoscalerClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*autoscalingv2beta1.HorizontalPodAutoscaler, *autoscalingv2beta1.HorizontalPodAutoscalerList] + Fake *kcptesting.Fake +} + +func newFakeHorizontalPodAutoscalerClusterClient(fake *AutoscalingV2beta1ClusterClient) typedkcpautoscalingv2beta1.HorizontalPodAutoscalerClusterInterface { + return &horizontalPodAutoscalerClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*autoscalingv2beta1.HorizontalPodAutoscaler, *autoscalingv2beta1.HorizontalPodAutoscalerList]( + fake.Fake, + autoscalingv2beta1.SchemeGroupVersion.WithResource("horizontalpodautoscalers"), + autoscalingv2beta1.SchemeGroupVersion.WithKind("HorizontalPodAutoscaler"), + func() *autoscalingv2beta1.HorizontalPodAutoscaler { + return &autoscalingv2beta1.HorizontalPodAutoscaler{} + }, + func() *autoscalingv2beta1.HorizontalPodAutoscalerList { + return &autoscalingv2beta1.HorizontalPodAutoscalerList{} + }, + func(dst, src *autoscalingv2beta1.HorizontalPodAutoscalerList) { dst.ListMeta = src.ListMeta }, + func(list *autoscalingv2beta1.HorizontalPodAutoscalerList) []*autoscalingv2beta1.HorizontalPodAutoscaler { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *autoscalingv2beta1.HorizontalPodAutoscalerList, items []*autoscalingv2beta1.HorizontalPodAutoscaler) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, + } +} + +func (c *horizontalPodAutoscalerClusterClient) Cluster(cluster logicalcluster.Path) typedkcpautoscalingv2beta1.HorizontalPodAutoscalersNamespacer { + return &horizontalPodAutoscalerNamespacer{Fake: c.Fake, ClusterPath: cluster} +} + +type horizontalPodAutoscalerNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *horizontalPodAutoscalersNamespacer) Namespace(namespace string) autoscalingv2beta1client.HorizontalPodAutoscalerInterface { - return &horizontalPodAutoscalersClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *horizontalPodAutoscalerNamespacer) Namespace(namespace string) typedautoscalingv2beta1.HorizontalPodAutoscalerInterface { + return newFakeHorizontalPodAutoscalerClient(n.Fake, namespace, n.ClusterPath) } -type horizontalPodAutoscalersClient struct { - *kcptesting.Fake +// horizontalPodAutoscalerScopedClient implements HorizontalPodAutoscalerInterface +type horizontalPodAutoscalerScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*autoscalingv2beta1.HorizontalPodAutoscaler, *autoscalingv2beta1.HorizontalPodAutoscalerList, *v2beta1.HorizontalPodAutoscalerApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *horizontalPodAutoscalersClient) Create(ctx context.Context, horizontalPodAutoscaler *autoscalingv2beta1.HorizontalPodAutoscaler, opts metav1.CreateOptions) (*autoscalingv2beta1.HorizontalPodAutoscaler, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, horizontalPodAutoscaler), &autoscalingv2beta1.HorizontalPodAutoscaler{}) - if obj == nil { - return nil, err - } - return obj.(*autoscalingv2beta1.HorizontalPodAutoscaler), err } -func (c *horizontalPodAutoscalersClient) Update(ctx context.Context, horizontalPodAutoscaler *autoscalingv2beta1.HorizontalPodAutoscaler, opts metav1.UpdateOptions) (*autoscalingv2beta1.HorizontalPodAutoscaler, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, horizontalPodAutoscaler), &autoscalingv2beta1.HorizontalPodAutoscaler{}) - if obj == nil { - return nil, err - } - return obj.(*autoscalingv2beta1.HorizontalPodAutoscaler), err -} - -func (c *horizontalPodAutoscalersClient) UpdateStatus(ctx context.Context, horizontalPodAutoscaler *autoscalingv2beta1.HorizontalPodAutoscaler, opts metav1.UpdateOptions) (*autoscalingv2beta1.HorizontalPodAutoscaler, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(horizontalPodAutoscalersResource, c.ClusterPath, "status", c.Namespace, horizontalPodAutoscaler), &autoscalingv2beta1.HorizontalPodAutoscaler{}) - if obj == nil { - return nil, err - } - return obj.(*autoscalingv2beta1.HorizontalPodAutoscaler), err -} - -func (c *horizontalPodAutoscalersClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, name, opts), &autoscalingv2beta1.HorizontalPodAutoscaler{}) - return err -} - -func (c *horizontalPodAutoscalersClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &autoscalingv2beta1.HorizontalPodAutoscalerList{}) - return err -} - -func (c *horizontalPodAutoscalersClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*autoscalingv2beta1.HorizontalPodAutoscaler, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, name), &autoscalingv2beta1.HorizontalPodAutoscaler{}) - if obj == nil { - return nil, err - } - return obj.(*autoscalingv2beta1.HorizontalPodAutoscaler), err -} - -// List takes label and field selectors, and returns the list of HorizontalPodAutoscalers that match those selectors. -func (c *horizontalPodAutoscalersClient) List(ctx context.Context, opts metav1.ListOptions) (*autoscalingv2beta1.HorizontalPodAutoscalerList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(horizontalPodAutoscalersResource, horizontalPodAutoscalersKind, c.ClusterPath, c.Namespace, opts), &autoscalingv2beta1.HorizontalPodAutoscalerList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &autoscalingv2beta1.HorizontalPodAutoscalerList{ListMeta: obj.(*autoscalingv2beta1.HorizontalPodAutoscalerList).ListMeta} - for _, item := range obj.(*autoscalingv2beta1.HorizontalPodAutoscalerList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *horizontalPodAutoscalersClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, opts)) -} - -func (c *horizontalPodAutoscalersClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*autoscalingv2beta1.HorizontalPodAutoscaler, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &autoscalingv2beta1.HorizontalPodAutoscaler{}) - if obj == nil { - return nil, err - } - return obj.(*autoscalingv2beta1.HorizontalPodAutoscaler), err -} - -func (c *horizontalPodAutoscalersClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsautoscalingv2beta1.HorizontalPodAutoscalerApplyConfiguration, opts metav1.ApplyOptions) (*autoscalingv2beta1.HorizontalPodAutoscaler, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &autoscalingv2beta1.HorizontalPodAutoscaler{}) - if obj == nil { - return nil, err - } - return obj.(*autoscalingv2beta1.HorizontalPodAutoscaler), err -} - -func (c *horizontalPodAutoscalersClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsautoscalingv2beta1.HorizontalPodAutoscalerApplyConfiguration, opts metav1.ApplyOptions) (*autoscalingv2beta1.HorizontalPodAutoscaler, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &autoscalingv2beta1.HorizontalPodAutoscaler{}) - if obj == nil { - return nil, err +func newFakeHorizontalPodAutoscalerClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedautoscalingv2beta1.HorizontalPodAutoscalerInterface { + return &horizontalPodAutoscalerScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*autoscalingv2beta1.HorizontalPodAutoscaler, *autoscalingv2beta1.HorizontalPodAutoscalerList, *v2beta1.HorizontalPodAutoscalerApplyConfiguration]( + fake, + clusterPath, + namespace, + autoscalingv2beta1.SchemeGroupVersion.WithResource("horizontalpodautoscalers"), + autoscalingv2beta1.SchemeGroupVersion.WithKind("HorizontalPodAutoscaler"), + func() *autoscalingv2beta1.HorizontalPodAutoscaler { + return &autoscalingv2beta1.HorizontalPodAutoscaler{} + }, + func() *autoscalingv2beta1.HorizontalPodAutoscalerList { + return &autoscalingv2beta1.HorizontalPodAutoscalerList{} + }, + func(dst, src *autoscalingv2beta1.HorizontalPodAutoscalerList) { dst.ListMeta = src.ListMeta }, + func(list *autoscalingv2beta1.HorizontalPodAutoscalerList) []*autoscalingv2beta1.HorizontalPodAutoscaler { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *autoscalingv2beta1.HorizontalPodAutoscalerList, items []*autoscalingv2beta1.HorizontalPodAutoscaler) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*autoscalingv2beta1.HorizontalPodAutoscaler), err } diff --git a/kubernetes/typed/autoscaling/v2beta1/generated_expansion.go b/kubernetes/typed/autoscaling/v2beta1/generated_expansion.go new file mode 100644 index 000000000..ffdeb08c2 --- /dev/null +++ b/kubernetes/typed/autoscaling/v2beta1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v2beta1 + +type HorizontalPodAutoscalerClusterExpansion interface{} diff --git a/kubernetes/typed/autoscaling/v2beta1/horizontalpodautoscaler.go b/kubernetes/typed/autoscaling/v2beta1/horizontalpodautoscaler.go index 2ab3fa526..fc5816469 100644 --- a/kubernetes/typed/autoscaling/v2beta1/horizontalpodautoscaler.go +++ b/kubernetes/typed/autoscaling/v2beta1/horizontalpodautoscaler.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v2beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" autoscalingv2beta1 "k8s.io/api/autoscaling/v2beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - autoscalingv2beta1client "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedautoscalingv2beta1 "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1" ) // HorizontalPodAutoscalersClusterGetter has a method to return a HorizontalPodAutoscalerClusterInterface. @@ -40,12 +40,13 @@ type HorizontalPodAutoscalersClusterGetter interface { // or scope down to one cluster and return a HorizontalPodAutoscalersNamespacer. type HorizontalPodAutoscalerClusterInterface interface { Cluster(logicalcluster.Path) HorizontalPodAutoscalersNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*autoscalingv2beta1.HorizontalPodAutoscalerList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*autoscalingv2beta1.HorizontalPodAutoscalerList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + HorizontalPodAutoscalerClusterExpansion } type horizontalPodAutoscalersClusterInterface struct { - clientCache kcpclient.Cache[*autoscalingv2beta1client.AutoscalingV2beta1Client] + clientCache kcpclient.Cache[*typedautoscalingv2beta1.AutoscalingV2beta1Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *horizontalPodAutoscalersClusterInterface) Cluster(clusterPath logicalcl } // List returns the entire collection of all HorizontalPodAutoscalers across all clusters. -func (c *horizontalPodAutoscalersClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*autoscalingv2beta1.HorizontalPodAutoscalerList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).HorizontalPodAutoscalers(metav1.NamespaceAll).List(ctx, opts) +func (c *horizontalPodAutoscalersClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*autoscalingv2beta1.HorizontalPodAutoscalerList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).HorizontalPodAutoscalers(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all HorizontalPodAutoscalers across all clusters. -func (c *horizontalPodAutoscalersClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).HorizontalPodAutoscalers(metav1.NamespaceAll).Watch(ctx, opts) +func (c *horizontalPodAutoscalersClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).HorizontalPodAutoscalers(v1.NamespaceAll).Watch(ctx, opts) } -// HorizontalPodAutoscalersNamespacer can scope to objects within a namespace, returning a autoscalingv2beta1client.HorizontalPodAutoscalerInterface. +// HorizontalPodAutoscalersNamespacer can scope to objects within a namespace, returning a typedautoscalingv2beta1.HorizontalPodAutoscalerInterface. type HorizontalPodAutoscalersNamespacer interface { - Namespace(string) autoscalingv2beta1client.HorizontalPodAutoscalerInterface + Namespace(string) typedautoscalingv2beta1.HorizontalPodAutoscalerInterface } type horizontalPodAutoscalersNamespacer struct { - clientCache kcpclient.Cache[*autoscalingv2beta1client.AutoscalingV2beta1Client] + clientCache kcpclient.Cache[*typedautoscalingv2beta1.AutoscalingV2beta1Client] clusterPath logicalcluster.Path } -func (n *horizontalPodAutoscalersNamespacer) Namespace(namespace string) autoscalingv2beta1client.HorizontalPodAutoscalerInterface { +func (n *horizontalPodAutoscalersNamespacer) Namespace(namespace string) typedautoscalingv2beta1.HorizontalPodAutoscalerInterface { return n.clientCache.ClusterOrDie(n.clusterPath).HorizontalPodAutoscalers(namespace) } diff --git a/kubernetes/typed/autoscaling/v2beta2/autoscaling_client.go b/kubernetes/typed/autoscaling/v2beta2/autoscaling_client.go index e7bc5c4f6..593d80cb6 100644 --- a/kubernetes/typed/autoscaling/v2beta2/autoscaling_client.go +++ b/kubernetes/typed/autoscaling/v2beta2/autoscaling_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v2beta2 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apiautoscalingv2beta2 "k8s.io/api/autoscaling/v2beta2" autoscalingv2beta2 "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type AutoscalingV2beta2ClusterInterface interface { @@ -37,6 +40,7 @@ type AutoscalingV2beta2ClusterScoper interface { Cluster(logicalcluster.Path) autoscalingv2beta2.AutoscalingV2beta2Interface } +// AutoscalingV2beta2ClusterClient is used to interact with features provided by the autoscaling group. type AutoscalingV2beta2ClusterClient struct { clientCache kcpclient.Cache[*autoscalingv2beta2.AutoscalingV2beta2Client] } @@ -56,11 +60,13 @@ func (c *AutoscalingV2beta2ClusterClient) HorizontalPodAutoscalers() HorizontalP // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*AutoscalingV2beta2ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new AutoscalingV2beta2ClusterClient for the given config and http client. @@ -72,6 +78,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*AutoscalingV2beta2C if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &AutoscalingV2beta2ClusterClient{clientCache: cache}, nil } @@ -84,3 +91,14 @@ func NewForConfigOrDie(c *rest.Config) *AutoscalingV2beta2ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apiautoscalingv2beta2.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/autoscaling/v2beta2/doc.go b/kubernetes/typed/autoscaling/v2beta2/doc.go new file mode 100644 index 000000000..773f95bc5 --- /dev/null +++ b/kubernetes/typed/autoscaling/v2beta2/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v2beta2 diff --git a/kubernetes/typed/autoscaling/v2beta2/fake/autoscaling_client.go b/kubernetes/typed/autoscaling/v2beta2/fake/autoscaling_client.go index 57d1fdec4..b4aa7d786 100644 --- a/kubernetes/typed/autoscaling/v2beta2/fake/autoscaling_client.go +++ b/kubernetes/typed/autoscaling/v2beta2/fake/autoscaling_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" autoscalingv2beta2 "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpautoscalingv2beta2 "github.com/kcp-dev/client-go/kubernetes/typed/autoscaling/v2beta2" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -42,21 +42,21 @@ func (c *AutoscalingV2beta2ClusterClient) Cluster(clusterPath logicalcluster.Pat } func (c *AutoscalingV2beta2ClusterClient) HorizontalPodAutoscalers() kcpautoscalingv2beta2.HorizontalPodAutoscalerClusterInterface { - return &horizontalPodAutoscalersClusterClient{Fake: c.Fake} + return newFakeHorizontalPodAutoscalerClusterClient(c) } -var _ autoscalingv2beta2.AutoscalingV2beta2Interface = (*AutoscalingV2beta2Client)(nil) - type AutoscalingV2beta2Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } +func (c *AutoscalingV2beta2Client) HorizontalPodAutoscalers(namespace string) autoscalingv2beta2.HorizontalPodAutoscalerInterface { + return newFakeHorizontalPodAutoscalerClient(c.Fake, namespace, c.ClusterPath) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. func (c *AutoscalingV2beta2Client) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } - -func (c *AutoscalingV2beta2Client) HorizontalPodAutoscalers(namespace string) autoscalingv2beta2.HorizontalPodAutoscalerInterface { - return &horizontalPodAutoscalersClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} -} diff --git a/kubernetes/typed/autoscaling/v2beta2/fake/doc.go b/kubernetes/typed/autoscaling/v2beta2/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/autoscaling/v2beta2/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/autoscaling/v2beta2/fake/horizontalpodautoscaler.go b/kubernetes/typed/autoscaling/v2beta2/fake/horizontalpodautoscaler.go index 21a9e06c7..9e969dc9b 100644 --- a/kubernetes/typed/autoscaling/v2beta2/fake/horizontalpodautoscaler.go +++ b/kubernetes/typed/autoscaling/v2beta2/fake/horizontalpodautoscaler.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,95 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" autoscalingv2beta2 "k8s.io/api/autoscaling/v2beta2" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsautoscalingv2beta2 "k8s.io/client-go/applyconfigurations/autoscaling/v2beta2" - autoscalingv2beta2client "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2" - "k8s.io/client-go/testing" + v2beta2 "k8s.io/client-go/applyconfigurations/autoscaling/v2beta2" + typedautoscalingv2beta2 "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2" - kcpautoscalingv2beta2 "github.com/kcp-dev/client-go/kubernetes/typed/autoscaling/v2beta2" + typedkcpautoscalingv2beta2 "github.com/kcp-dev/client-go/kubernetes/typed/autoscaling/v2beta2" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var horizontalPodAutoscalersResource = schema.GroupVersionResource{Group: "autoscaling", Version: "v2beta2", Resource: "horizontalpodautoscalers"} -var horizontalPodAutoscalersKind = schema.GroupVersionKind{Group: "autoscaling", Version: "v2beta2", Kind: "HorizontalPodAutoscaler"} - -type horizontalPodAutoscalersClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *horizontalPodAutoscalersClusterClient) Cluster(clusterPath logicalcluster.Path) kcpautoscalingv2beta2.HorizontalPodAutoscalersNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &horizontalPodAutoscalersNamespacer{Fake: c.Fake, ClusterPath: clusterPath} -} - -// List takes label and field selectors, and returns the list of HorizontalPodAutoscalers that match those selectors across all clusters. -func (c *horizontalPodAutoscalersClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*autoscalingv2beta2.HorizontalPodAutoscalerList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(horizontalPodAutoscalersResource, horizontalPodAutoscalersKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &autoscalingv2beta2.HorizontalPodAutoscalerList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &autoscalingv2beta2.HorizontalPodAutoscalerList{ListMeta: obj.(*autoscalingv2beta2.HorizontalPodAutoscalerList).ListMeta} - for _, item := range obj.(*autoscalingv2beta2.HorizontalPodAutoscalerList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested HorizontalPodAutoscalers across all clusters. -func (c *horizontalPodAutoscalersClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(horizontalPodAutoscalersResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) -} - -type horizontalPodAutoscalersNamespacer struct { +// horizontalPodAutoscalerClusterClient implements HorizontalPodAutoscalerClusterInterface +type horizontalPodAutoscalerClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*autoscalingv2beta2.HorizontalPodAutoscaler, *autoscalingv2beta2.HorizontalPodAutoscalerList] + Fake *kcptesting.Fake +} + +func newFakeHorizontalPodAutoscalerClusterClient(fake *AutoscalingV2beta2ClusterClient) typedkcpautoscalingv2beta2.HorizontalPodAutoscalerClusterInterface { + return &horizontalPodAutoscalerClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*autoscalingv2beta2.HorizontalPodAutoscaler, *autoscalingv2beta2.HorizontalPodAutoscalerList]( + fake.Fake, + autoscalingv2beta2.SchemeGroupVersion.WithResource("horizontalpodautoscalers"), + autoscalingv2beta2.SchemeGroupVersion.WithKind("HorizontalPodAutoscaler"), + func() *autoscalingv2beta2.HorizontalPodAutoscaler { + return &autoscalingv2beta2.HorizontalPodAutoscaler{} + }, + func() *autoscalingv2beta2.HorizontalPodAutoscalerList { + return &autoscalingv2beta2.HorizontalPodAutoscalerList{} + }, + func(dst, src *autoscalingv2beta2.HorizontalPodAutoscalerList) { dst.ListMeta = src.ListMeta }, + func(list *autoscalingv2beta2.HorizontalPodAutoscalerList) []*autoscalingv2beta2.HorizontalPodAutoscaler { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *autoscalingv2beta2.HorizontalPodAutoscalerList, items []*autoscalingv2beta2.HorizontalPodAutoscaler) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, + } +} + +func (c *horizontalPodAutoscalerClusterClient) Cluster(cluster logicalcluster.Path) typedkcpautoscalingv2beta2.HorizontalPodAutoscalersNamespacer { + return &horizontalPodAutoscalerNamespacer{Fake: c.Fake, ClusterPath: cluster} +} + +type horizontalPodAutoscalerNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *horizontalPodAutoscalersNamespacer) Namespace(namespace string) autoscalingv2beta2client.HorizontalPodAutoscalerInterface { - return &horizontalPodAutoscalersClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *horizontalPodAutoscalerNamespacer) Namespace(namespace string) typedautoscalingv2beta2.HorizontalPodAutoscalerInterface { + return newFakeHorizontalPodAutoscalerClient(n.Fake, namespace, n.ClusterPath) } -type horizontalPodAutoscalersClient struct { - *kcptesting.Fake +// horizontalPodAutoscalerScopedClient implements HorizontalPodAutoscalerInterface +type horizontalPodAutoscalerScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*autoscalingv2beta2.HorizontalPodAutoscaler, *autoscalingv2beta2.HorizontalPodAutoscalerList, *v2beta2.HorizontalPodAutoscalerApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *horizontalPodAutoscalersClient) Create(ctx context.Context, horizontalPodAutoscaler *autoscalingv2beta2.HorizontalPodAutoscaler, opts metav1.CreateOptions) (*autoscalingv2beta2.HorizontalPodAutoscaler, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, horizontalPodAutoscaler), &autoscalingv2beta2.HorizontalPodAutoscaler{}) - if obj == nil { - return nil, err - } - return obj.(*autoscalingv2beta2.HorizontalPodAutoscaler), err } -func (c *horizontalPodAutoscalersClient) Update(ctx context.Context, horizontalPodAutoscaler *autoscalingv2beta2.HorizontalPodAutoscaler, opts metav1.UpdateOptions) (*autoscalingv2beta2.HorizontalPodAutoscaler, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, horizontalPodAutoscaler), &autoscalingv2beta2.HorizontalPodAutoscaler{}) - if obj == nil { - return nil, err - } - return obj.(*autoscalingv2beta2.HorizontalPodAutoscaler), err -} - -func (c *horizontalPodAutoscalersClient) UpdateStatus(ctx context.Context, horizontalPodAutoscaler *autoscalingv2beta2.HorizontalPodAutoscaler, opts metav1.UpdateOptions) (*autoscalingv2beta2.HorizontalPodAutoscaler, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(horizontalPodAutoscalersResource, c.ClusterPath, "status", c.Namespace, horizontalPodAutoscaler), &autoscalingv2beta2.HorizontalPodAutoscaler{}) - if obj == nil { - return nil, err - } - return obj.(*autoscalingv2beta2.HorizontalPodAutoscaler), err -} - -func (c *horizontalPodAutoscalersClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, name, opts), &autoscalingv2beta2.HorizontalPodAutoscaler{}) - return err -} - -func (c *horizontalPodAutoscalersClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &autoscalingv2beta2.HorizontalPodAutoscalerList{}) - return err -} - -func (c *horizontalPodAutoscalersClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*autoscalingv2beta2.HorizontalPodAutoscaler, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, name), &autoscalingv2beta2.HorizontalPodAutoscaler{}) - if obj == nil { - return nil, err - } - return obj.(*autoscalingv2beta2.HorizontalPodAutoscaler), err -} - -// List takes label and field selectors, and returns the list of HorizontalPodAutoscalers that match those selectors. -func (c *horizontalPodAutoscalersClient) List(ctx context.Context, opts metav1.ListOptions) (*autoscalingv2beta2.HorizontalPodAutoscalerList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(horizontalPodAutoscalersResource, horizontalPodAutoscalersKind, c.ClusterPath, c.Namespace, opts), &autoscalingv2beta2.HorizontalPodAutoscalerList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &autoscalingv2beta2.HorizontalPodAutoscalerList{ListMeta: obj.(*autoscalingv2beta2.HorizontalPodAutoscalerList).ListMeta} - for _, item := range obj.(*autoscalingv2beta2.HorizontalPodAutoscalerList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *horizontalPodAutoscalersClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, opts)) -} - -func (c *horizontalPodAutoscalersClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*autoscalingv2beta2.HorizontalPodAutoscaler, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &autoscalingv2beta2.HorizontalPodAutoscaler{}) - if obj == nil { - return nil, err - } - return obj.(*autoscalingv2beta2.HorizontalPodAutoscaler), err -} - -func (c *horizontalPodAutoscalersClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsautoscalingv2beta2.HorizontalPodAutoscalerApplyConfiguration, opts metav1.ApplyOptions) (*autoscalingv2beta2.HorizontalPodAutoscaler, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &autoscalingv2beta2.HorizontalPodAutoscaler{}) - if obj == nil { - return nil, err - } - return obj.(*autoscalingv2beta2.HorizontalPodAutoscaler), err -} - -func (c *horizontalPodAutoscalersClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsautoscalingv2beta2.HorizontalPodAutoscalerApplyConfiguration, opts metav1.ApplyOptions) (*autoscalingv2beta2.HorizontalPodAutoscaler, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(horizontalPodAutoscalersResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &autoscalingv2beta2.HorizontalPodAutoscaler{}) - if obj == nil { - return nil, err +func newFakeHorizontalPodAutoscalerClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedautoscalingv2beta2.HorizontalPodAutoscalerInterface { + return &horizontalPodAutoscalerScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*autoscalingv2beta2.HorizontalPodAutoscaler, *autoscalingv2beta2.HorizontalPodAutoscalerList, *v2beta2.HorizontalPodAutoscalerApplyConfiguration]( + fake, + clusterPath, + namespace, + autoscalingv2beta2.SchemeGroupVersion.WithResource("horizontalpodautoscalers"), + autoscalingv2beta2.SchemeGroupVersion.WithKind("HorizontalPodAutoscaler"), + func() *autoscalingv2beta2.HorizontalPodAutoscaler { + return &autoscalingv2beta2.HorizontalPodAutoscaler{} + }, + func() *autoscalingv2beta2.HorizontalPodAutoscalerList { + return &autoscalingv2beta2.HorizontalPodAutoscalerList{} + }, + func(dst, src *autoscalingv2beta2.HorizontalPodAutoscalerList) { dst.ListMeta = src.ListMeta }, + func(list *autoscalingv2beta2.HorizontalPodAutoscalerList) []*autoscalingv2beta2.HorizontalPodAutoscaler { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *autoscalingv2beta2.HorizontalPodAutoscalerList, items []*autoscalingv2beta2.HorizontalPodAutoscaler) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*autoscalingv2beta2.HorizontalPodAutoscaler), err } diff --git a/kubernetes/typed/autoscaling/v2beta2/generated_expansion.go b/kubernetes/typed/autoscaling/v2beta2/generated_expansion.go new file mode 100644 index 000000000..2535677d7 --- /dev/null +++ b/kubernetes/typed/autoscaling/v2beta2/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v2beta2 + +type HorizontalPodAutoscalerClusterExpansion interface{} diff --git a/kubernetes/typed/autoscaling/v2beta2/horizontalpodautoscaler.go b/kubernetes/typed/autoscaling/v2beta2/horizontalpodautoscaler.go index def230188..011aaf469 100644 --- a/kubernetes/typed/autoscaling/v2beta2/horizontalpodautoscaler.go +++ b/kubernetes/typed/autoscaling/v2beta2/horizontalpodautoscaler.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v2beta2 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" autoscalingv2beta2 "k8s.io/api/autoscaling/v2beta2" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - autoscalingv2beta2client "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedautoscalingv2beta2 "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2" ) // HorizontalPodAutoscalersClusterGetter has a method to return a HorizontalPodAutoscalerClusterInterface. @@ -40,12 +40,13 @@ type HorizontalPodAutoscalersClusterGetter interface { // or scope down to one cluster and return a HorizontalPodAutoscalersNamespacer. type HorizontalPodAutoscalerClusterInterface interface { Cluster(logicalcluster.Path) HorizontalPodAutoscalersNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*autoscalingv2beta2.HorizontalPodAutoscalerList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*autoscalingv2beta2.HorizontalPodAutoscalerList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + HorizontalPodAutoscalerClusterExpansion } type horizontalPodAutoscalersClusterInterface struct { - clientCache kcpclient.Cache[*autoscalingv2beta2client.AutoscalingV2beta2Client] + clientCache kcpclient.Cache[*typedautoscalingv2beta2.AutoscalingV2beta2Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *horizontalPodAutoscalersClusterInterface) Cluster(clusterPath logicalcl } // List returns the entire collection of all HorizontalPodAutoscalers across all clusters. -func (c *horizontalPodAutoscalersClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*autoscalingv2beta2.HorizontalPodAutoscalerList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).HorizontalPodAutoscalers(metav1.NamespaceAll).List(ctx, opts) +func (c *horizontalPodAutoscalersClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*autoscalingv2beta2.HorizontalPodAutoscalerList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).HorizontalPodAutoscalers(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all HorizontalPodAutoscalers across all clusters. -func (c *horizontalPodAutoscalersClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).HorizontalPodAutoscalers(metav1.NamespaceAll).Watch(ctx, opts) +func (c *horizontalPodAutoscalersClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).HorizontalPodAutoscalers(v1.NamespaceAll).Watch(ctx, opts) } -// HorizontalPodAutoscalersNamespacer can scope to objects within a namespace, returning a autoscalingv2beta2client.HorizontalPodAutoscalerInterface. +// HorizontalPodAutoscalersNamespacer can scope to objects within a namespace, returning a typedautoscalingv2beta2.HorizontalPodAutoscalerInterface. type HorizontalPodAutoscalersNamespacer interface { - Namespace(string) autoscalingv2beta2client.HorizontalPodAutoscalerInterface + Namespace(string) typedautoscalingv2beta2.HorizontalPodAutoscalerInterface } type horizontalPodAutoscalersNamespacer struct { - clientCache kcpclient.Cache[*autoscalingv2beta2client.AutoscalingV2beta2Client] + clientCache kcpclient.Cache[*typedautoscalingv2beta2.AutoscalingV2beta2Client] clusterPath logicalcluster.Path } -func (n *horizontalPodAutoscalersNamespacer) Namespace(namespace string) autoscalingv2beta2client.HorizontalPodAutoscalerInterface { +func (n *horizontalPodAutoscalersNamespacer) Namespace(namespace string) typedautoscalingv2beta2.HorizontalPodAutoscalerInterface { return n.clientCache.ClusterOrDie(n.clusterPath).HorizontalPodAutoscalers(namespace) } diff --git a/kubernetes/typed/batch/v1/batch_client.go b/kubernetes/typed/batch/v1/batch_client.go index 1cd786665..e312ff6bd 100644 --- a/kubernetes/typed/batch/v1/batch_client.go +++ b/kubernetes/typed/batch/v1/batch_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,30 +14,34 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apibatchv1 "k8s.io/api/batch/v1" batchv1 "k8s.io/client-go/kubernetes/typed/batch/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type BatchV1ClusterInterface interface { BatchV1ClusterScoper - JobsClusterGetter CronJobsClusterGetter + JobsClusterGetter } type BatchV1ClusterScoper interface { Cluster(logicalcluster.Path) batchv1.BatchV1Interface } +// BatchV1ClusterClient is used to interact with features provided by the batch group. type BatchV1ClusterClient struct { clientCache kcpclient.Cache[*batchv1.BatchV1Client] } @@ -49,23 +53,25 @@ func (c *BatchV1ClusterClient) Cluster(clusterPath logicalcluster.Path) batchv1. return c.clientCache.ClusterOrDie(clusterPath) } -func (c *BatchV1ClusterClient) Jobs() JobClusterInterface { - return &jobsClusterInterface{clientCache: c.clientCache} -} - func (c *BatchV1ClusterClient) CronJobs() CronJobClusterInterface { return &cronJobsClusterInterface{clientCache: c.clientCache} } +func (c *BatchV1ClusterClient) Jobs() JobClusterInterface { + return &jobsClusterInterface{clientCache: c.clientCache} +} + // NewForConfig creates a new BatchV1ClusterClient for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*BatchV1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new BatchV1ClusterClient for the given config and http client. @@ -77,6 +83,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*BatchV1ClusterClien if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &BatchV1ClusterClient{clientCache: cache}, nil } @@ -89,3 +96,14 @@ func NewForConfigOrDie(c *rest.Config) *BatchV1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apibatchv1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/batch/v1/cronjob.go b/kubernetes/typed/batch/v1/cronjob.go index be4712b5e..4b8f7fcf0 100644 --- a/kubernetes/typed/batch/v1/cronjob.go +++ b/kubernetes/typed/batch/v1/cronjob.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" batchv1 "k8s.io/api/batch/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - batchv1client "k8s.io/client-go/kubernetes/typed/batch/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedbatchv1 "k8s.io/client-go/kubernetes/typed/batch/v1" ) // CronJobsClusterGetter has a method to return a CronJobClusterInterface. @@ -42,10 +42,11 @@ type CronJobClusterInterface interface { Cluster(logicalcluster.Path) CronJobsNamespacer List(ctx context.Context, opts metav1.ListOptions) (*batchv1.CronJobList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + CronJobClusterExpansion } type cronJobsClusterInterface struct { - clientCache kcpclient.Cache[*batchv1client.BatchV1Client] + clientCache kcpclient.Cache[*typedbatchv1.BatchV1Client] } // Cluster scopes the client down to a particular cluster. @@ -67,16 +68,16 @@ func (c *cronJobsClusterInterface) Watch(ctx context.Context, opts metav1.ListOp return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).CronJobs(metav1.NamespaceAll).Watch(ctx, opts) } -// CronJobsNamespacer can scope to objects within a namespace, returning a batchv1client.CronJobInterface. +// CronJobsNamespacer can scope to objects within a namespace, returning a typedbatchv1.CronJobInterface. type CronJobsNamespacer interface { - Namespace(string) batchv1client.CronJobInterface + Namespace(string) typedbatchv1.CronJobInterface } type cronJobsNamespacer struct { - clientCache kcpclient.Cache[*batchv1client.BatchV1Client] + clientCache kcpclient.Cache[*typedbatchv1.BatchV1Client] clusterPath logicalcluster.Path } -func (n *cronJobsNamespacer) Namespace(namespace string) batchv1client.CronJobInterface { +func (n *cronJobsNamespacer) Namespace(namespace string) typedbatchv1.CronJobInterface { return n.clientCache.ClusterOrDie(n.clusterPath).CronJobs(namespace) } diff --git a/kubernetes/typed/batch/v1/doc.go b/kubernetes/typed/batch/v1/doc.go new file mode 100644 index 000000000..d2f3412ab --- /dev/null +++ b/kubernetes/typed/batch/v1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1 diff --git a/kubernetes/typed/batch/v1/fake/batch_client.go b/kubernetes/typed/batch/v1/fake/batch_client.go index 2a12d9e04..7e3bdcac7 100644 --- a/kubernetes/typed/batch/v1/fake/batch_client.go +++ b/kubernetes/typed/batch/v1/fake/batch_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" batchv1 "k8s.io/client-go/kubernetes/typed/batch/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpbatchv1 "github.com/kcp-dev/client-go/kubernetes/typed/batch/v1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -41,30 +41,30 @@ func (c *BatchV1ClusterClient) Cluster(clusterPath logicalcluster.Path) batchv1. return &BatchV1Client{Fake: c.Fake, ClusterPath: clusterPath} } -func (c *BatchV1ClusterClient) Jobs() kcpbatchv1.JobClusterInterface { - return &jobsClusterClient{Fake: c.Fake} -} - func (c *BatchV1ClusterClient) CronJobs() kcpbatchv1.CronJobClusterInterface { - return &cronJobsClusterClient{Fake: c.Fake} + return newFakeCronJobClusterClient(c) } -var _ batchv1.BatchV1Interface = (*BatchV1Client)(nil) +func (c *BatchV1ClusterClient) Jobs() kcpbatchv1.JobClusterInterface { + return newFakeJobClusterClient(c) +} type BatchV1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *BatchV1Client) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret +func (c *BatchV1Client) CronJobs(namespace string) batchv1.CronJobInterface { + return newFakeCronJobClient(c.Fake, namespace, c.ClusterPath) } func (c *BatchV1Client) Jobs(namespace string) batchv1.JobInterface { - return &jobsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} + return newFakeJobClient(c.Fake, namespace, c.ClusterPath) } -func (c *BatchV1Client) CronJobs(namespace string) batchv1.CronJobInterface { - return &cronJobsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *BatchV1Client) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret } diff --git a/kubernetes/typed/batch/v1/fake/cronjob.go b/kubernetes/typed/batch/v1/fake/cronjob.go index cc2e0685c..17b43e757 100644 --- a/kubernetes/typed/batch/v1/fake/cronjob.go +++ b/kubernetes/typed/batch/v1/fake/cronjob.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,83 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" batchv1 "k8s.io/api/batch/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsbatchv1 "k8s.io/client-go/applyconfigurations/batch/v1" - batchv1client "k8s.io/client-go/kubernetes/typed/batch/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/batch/v1" + typedbatchv1 "k8s.io/client-go/kubernetes/typed/batch/v1" - kcpbatchv1 "github.com/kcp-dev/client-go/kubernetes/typed/batch/v1" + typedkcpbatchv1 "github.com/kcp-dev/client-go/kubernetes/typed/batch/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var cronJobsResource = schema.GroupVersionResource{Group: "batch", Version: "v1", Resource: "cronjobs"} -var cronJobsKind = schema.GroupVersionKind{Group: "batch", Version: "v1", Kind: "CronJob"} - -type cronJobsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *cronJobsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpbatchv1.CronJobsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &cronJobsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// cronJobClusterClient implements CronJobClusterInterface +type cronJobClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*batchv1.CronJob, *batchv1.CronJobList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of CronJobs that match those selectors across all clusters. -func (c *cronJobsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*batchv1.CronJobList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(cronJobsResource, cronJobsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &batchv1.CronJobList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeCronJobClusterClient(fake *BatchV1ClusterClient) typedkcpbatchv1.CronJobClusterInterface { + return &cronJobClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*batchv1.CronJob, *batchv1.CronJobList]( + fake.Fake, + batchv1.SchemeGroupVersion.WithResource("cronjobs"), + batchv1.SchemeGroupVersion.WithKind("CronJob"), + func() *batchv1.CronJob { return &batchv1.CronJob{} }, + func() *batchv1.CronJobList { return &batchv1.CronJobList{} }, + func(dst, src *batchv1.CronJobList) { dst.ListMeta = src.ListMeta }, + func(list *batchv1.CronJobList) []*batchv1.CronJob { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *batchv1.CronJobList, items []*batchv1.CronJob) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &batchv1.CronJobList{ListMeta: obj.(*batchv1.CronJobList).ListMeta} - for _, item := range obj.(*batchv1.CronJobList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested CronJobs across all clusters. -func (c *cronJobsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(cronJobsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *cronJobClusterClient) Cluster(cluster logicalcluster.Path) typedkcpbatchv1.CronJobsNamespacer { + return &cronJobNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type cronJobsNamespacer struct { +type cronJobNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *cronJobsNamespacer) Namespace(namespace string) batchv1client.CronJobInterface { - return &cronJobsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *cronJobNamespacer) Namespace(namespace string) typedbatchv1.CronJobInterface { + return newFakeCronJobClient(n.Fake, namespace, n.ClusterPath) } -type cronJobsClient struct { - *kcptesting.Fake +// cronJobScopedClient implements CronJobInterface +type cronJobScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*batchv1.CronJob, *batchv1.CronJobList, *v1.CronJobApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *cronJobsClient) Create(ctx context.Context, cronJob *batchv1.CronJob, opts metav1.CreateOptions) (*batchv1.CronJob, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(cronJobsResource, c.ClusterPath, c.Namespace, cronJob), &batchv1.CronJob{}) - if obj == nil { - return nil, err - } - return obj.(*batchv1.CronJob), err -} - -func (c *cronJobsClient) Update(ctx context.Context, cronJob *batchv1.CronJob, opts metav1.UpdateOptions) (*batchv1.CronJob, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(cronJobsResource, c.ClusterPath, c.Namespace, cronJob), &batchv1.CronJob{}) - if obj == nil { - return nil, err - } - return obj.(*batchv1.CronJob), err -} - -func (c *cronJobsClient) UpdateStatus(ctx context.Context, cronJob *batchv1.CronJob, opts metav1.UpdateOptions) (*batchv1.CronJob, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(cronJobsResource, c.ClusterPath, "status", c.Namespace, cronJob), &batchv1.CronJob{}) - if obj == nil { - return nil, err - } - return obj.(*batchv1.CronJob), err -} - -func (c *cronJobsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(cronJobsResource, c.ClusterPath, c.Namespace, name, opts), &batchv1.CronJob{}) - return err -} - -func (c *cronJobsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(cronJobsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &batchv1.CronJobList{}) - return err -} - -func (c *cronJobsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*batchv1.CronJob, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(cronJobsResource, c.ClusterPath, c.Namespace, name), &batchv1.CronJob{}) - if obj == nil { - return nil, err - } - return obj.(*batchv1.CronJob), err -} - -// List takes label and field selectors, and returns the list of CronJobs that match those selectors. -func (c *cronJobsClient) List(ctx context.Context, opts metav1.ListOptions) (*batchv1.CronJobList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(cronJobsResource, cronJobsKind, c.ClusterPath, c.Namespace, opts), &batchv1.CronJobList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &batchv1.CronJobList{ListMeta: obj.(*batchv1.CronJobList).ListMeta} - for _, item := range obj.(*batchv1.CronJobList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *cronJobsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(cronJobsResource, c.ClusterPath, c.Namespace, opts)) } -func (c *cronJobsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*batchv1.CronJob, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(cronJobsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &batchv1.CronJob{}) - if obj == nil { - return nil, err - } - return obj.(*batchv1.CronJob), err -} - -func (c *cronJobsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsbatchv1.CronJobApplyConfiguration, opts metav1.ApplyOptions) (*batchv1.CronJob, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(cronJobsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &batchv1.CronJob{}) - if obj == nil { - return nil, err - } - return obj.(*batchv1.CronJob), err -} - -func (c *cronJobsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsbatchv1.CronJobApplyConfiguration, opts metav1.ApplyOptions) (*batchv1.CronJob, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(cronJobsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &batchv1.CronJob{}) - if obj == nil { - return nil, err +func newFakeCronJobClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedbatchv1.CronJobInterface { + return &cronJobScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*batchv1.CronJob, *batchv1.CronJobList, *v1.CronJobApplyConfiguration]( + fake, + clusterPath, + namespace, + batchv1.SchemeGroupVersion.WithResource("cronjobs"), + batchv1.SchemeGroupVersion.WithKind("CronJob"), + func() *batchv1.CronJob { return &batchv1.CronJob{} }, + func() *batchv1.CronJobList { return &batchv1.CronJobList{} }, + func(dst, src *batchv1.CronJobList) { dst.ListMeta = src.ListMeta }, + func(list *batchv1.CronJobList) []*batchv1.CronJob { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *batchv1.CronJobList, items []*batchv1.CronJob) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*batchv1.CronJob), err } diff --git a/kubernetes/typed/batch/v1/fake/doc.go b/kubernetes/typed/batch/v1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/batch/v1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/batch/v1/fake/job.go b/kubernetes/typed/batch/v1/fake/job.go index 8ed6337ee..bab39a0d7 100644 --- a/kubernetes/typed/batch/v1/fake/job.go +++ b/kubernetes/typed/batch/v1/fake/job.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" batchv1 "k8s.io/api/batch/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsbatchv1 "k8s.io/client-go/applyconfigurations/batch/v1" - batchv1client "k8s.io/client-go/kubernetes/typed/batch/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/batch/v1" + typedbatchv1 "k8s.io/client-go/kubernetes/typed/batch/v1" - kcpbatchv1 "github.com/kcp-dev/client-go/kubernetes/typed/batch/v1" + typedkcpbatchv1 "github.com/kcp-dev/client-go/kubernetes/typed/batch/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var jobsResource = schema.GroupVersionResource{Group: "batch", Version: "v1", Resource: "jobs"} -var jobsKind = schema.GroupVersionKind{Group: "batch", Version: "v1", Kind: "Job"} - -type jobsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *jobsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpbatchv1.JobsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &jobsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// jobClusterClient implements JobClusterInterface +type jobClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*batchv1.Job, *batchv1.JobList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of Jobs that match those selectors across all clusters. -func (c *jobsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*batchv1.JobList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(jobsResource, jobsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &batchv1.JobList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeJobClusterClient(fake *BatchV1ClusterClient) typedkcpbatchv1.JobClusterInterface { + return &jobClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*batchv1.Job, *batchv1.JobList]( + fake.Fake, + batchv1.SchemeGroupVersion.WithResource("jobs"), + batchv1.SchemeGroupVersion.WithKind("Job"), + func() *batchv1.Job { return &batchv1.Job{} }, + func() *batchv1.JobList { return &batchv1.JobList{} }, + func(dst, src *batchv1.JobList) { dst.ListMeta = src.ListMeta }, + func(list *batchv1.JobList) []*batchv1.Job { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *batchv1.JobList, items []*batchv1.Job) { list.Items = kcpgentype.FromPointerSlice(items) }, + ), + fake.Fake, } - list := &batchv1.JobList{ListMeta: obj.(*batchv1.JobList).ListMeta} - for _, item := range obj.(*batchv1.JobList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested Jobs across all clusters. -func (c *jobsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(jobsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *jobClusterClient) Cluster(cluster logicalcluster.Path) typedkcpbatchv1.JobsNamespacer { + return &jobNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type jobsNamespacer struct { +type jobNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *jobsNamespacer) Namespace(namespace string) batchv1client.JobInterface { - return &jobsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *jobNamespacer) Namespace(namespace string) typedbatchv1.JobInterface { + return newFakeJobClient(n.Fake, namespace, n.ClusterPath) } -type jobsClient struct { - *kcptesting.Fake +// jobScopedClient implements JobInterface +type jobScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*batchv1.Job, *batchv1.JobList, *v1.JobApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *jobsClient) Create(ctx context.Context, job *batchv1.Job, opts metav1.CreateOptions) (*batchv1.Job, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(jobsResource, c.ClusterPath, c.Namespace, job), &batchv1.Job{}) - if obj == nil { - return nil, err - } - return obj.(*batchv1.Job), err -} - -func (c *jobsClient) Update(ctx context.Context, job *batchv1.Job, opts metav1.UpdateOptions) (*batchv1.Job, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(jobsResource, c.ClusterPath, c.Namespace, job), &batchv1.Job{}) - if obj == nil { - return nil, err - } - return obj.(*batchv1.Job), err -} - -func (c *jobsClient) UpdateStatus(ctx context.Context, job *batchv1.Job, opts metav1.UpdateOptions) (*batchv1.Job, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(jobsResource, c.ClusterPath, "status", c.Namespace, job), &batchv1.Job{}) - if obj == nil { - return nil, err - } - return obj.(*batchv1.Job), err -} - -func (c *jobsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(jobsResource, c.ClusterPath, c.Namespace, name, opts), &batchv1.Job{}) - return err -} - -func (c *jobsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(jobsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &batchv1.JobList{}) - return err -} - -func (c *jobsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*batchv1.Job, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(jobsResource, c.ClusterPath, c.Namespace, name), &batchv1.Job{}) - if obj == nil { - return nil, err - } - return obj.(*batchv1.Job), err -} - -// List takes label and field selectors, and returns the list of Jobs that match those selectors. -func (c *jobsClient) List(ctx context.Context, opts metav1.ListOptions) (*batchv1.JobList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(jobsResource, jobsKind, c.ClusterPath, c.Namespace, opts), &batchv1.JobList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &batchv1.JobList{ListMeta: obj.(*batchv1.JobList).ListMeta} - for _, item := range obj.(*batchv1.JobList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *jobsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(jobsResource, c.ClusterPath, c.Namespace, opts)) } -func (c *jobsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*batchv1.Job, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(jobsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &batchv1.Job{}) - if obj == nil { - return nil, err - } - return obj.(*batchv1.Job), err -} - -func (c *jobsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsbatchv1.JobApplyConfiguration, opts metav1.ApplyOptions) (*batchv1.Job, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(jobsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &batchv1.Job{}) - if obj == nil { - return nil, err - } - return obj.(*batchv1.Job), err -} - -func (c *jobsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsbatchv1.JobApplyConfiguration, opts metav1.ApplyOptions) (*batchv1.Job, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(jobsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &batchv1.Job{}) - if obj == nil { - return nil, err +func newFakeJobClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedbatchv1.JobInterface { + return &jobScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*batchv1.Job, *batchv1.JobList, *v1.JobApplyConfiguration]( + fake, + clusterPath, + namespace, + batchv1.SchemeGroupVersion.WithResource("jobs"), + batchv1.SchemeGroupVersion.WithKind("Job"), + func() *batchv1.Job { return &batchv1.Job{} }, + func() *batchv1.JobList { return &batchv1.JobList{} }, + func(dst, src *batchv1.JobList) { dst.ListMeta = src.ListMeta }, + func(list *batchv1.JobList) []*batchv1.Job { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *batchv1.JobList, items []*batchv1.Job) { list.Items = kcpgentype.FromPointerSlice(items) }, + ), + fake, + clusterPath, } - return obj.(*batchv1.Job), err } diff --git a/kubernetes/typed/batch/v1/generated_expansion.go b/kubernetes/typed/batch/v1/generated_expansion.go new file mode 100644 index 000000000..68dfc618b --- /dev/null +++ b/kubernetes/typed/batch/v1/generated_expansion.go @@ -0,0 +1,23 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1 + +type CronJobClusterExpansion interface{} + +type JobClusterExpansion interface{} diff --git a/kubernetes/typed/batch/v1/job.go b/kubernetes/typed/batch/v1/job.go index 006baa0a3..da50d0617 100644 --- a/kubernetes/typed/batch/v1/job.go +++ b/kubernetes/typed/batch/v1/job.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" batchv1 "k8s.io/api/batch/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - batchv1client "k8s.io/client-go/kubernetes/typed/batch/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedbatchv1 "k8s.io/client-go/kubernetes/typed/batch/v1" ) // JobsClusterGetter has a method to return a JobClusterInterface. @@ -42,10 +42,11 @@ type JobClusterInterface interface { Cluster(logicalcluster.Path) JobsNamespacer List(ctx context.Context, opts metav1.ListOptions) (*batchv1.JobList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + JobClusterExpansion } type jobsClusterInterface struct { - clientCache kcpclient.Cache[*batchv1client.BatchV1Client] + clientCache kcpclient.Cache[*typedbatchv1.BatchV1Client] } // Cluster scopes the client down to a particular cluster. @@ -67,16 +68,16 @@ func (c *jobsClusterInterface) Watch(ctx context.Context, opts metav1.ListOption return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Jobs(metav1.NamespaceAll).Watch(ctx, opts) } -// JobsNamespacer can scope to objects within a namespace, returning a batchv1client.JobInterface. +// JobsNamespacer can scope to objects within a namespace, returning a typedbatchv1.JobInterface. type JobsNamespacer interface { - Namespace(string) batchv1client.JobInterface + Namespace(string) typedbatchv1.JobInterface } type jobsNamespacer struct { - clientCache kcpclient.Cache[*batchv1client.BatchV1Client] + clientCache kcpclient.Cache[*typedbatchv1.BatchV1Client] clusterPath logicalcluster.Path } -func (n *jobsNamespacer) Namespace(namespace string) batchv1client.JobInterface { +func (n *jobsNamespacer) Namespace(namespace string) typedbatchv1.JobInterface { return n.clientCache.ClusterOrDie(n.clusterPath).Jobs(namespace) } diff --git a/kubernetes/typed/batch/v1beta1/batch_client.go b/kubernetes/typed/batch/v1beta1/batch_client.go index f57bdf139..44925fa17 100644 --- a/kubernetes/typed/batch/v1beta1/batch_client.go +++ b/kubernetes/typed/batch/v1beta1/batch_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apibatchv1beta1 "k8s.io/api/batch/v1beta1" batchv1beta1 "k8s.io/client-go/kubernetes/typed/batch/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type BatchV1beta1ClusterInterface interface { @@ -37,6 +40,7 @@ type BatchV1beta1ClusterScoper interface { Cluster(logicalcluster.Path) batchv1beta1.BatchV1beta1Interface } +// BatchV1beta1ClusterClient is used to interact with features provided by the batch group. type BatchV1beta1ClusterClient struct { clientCache kcpclient.Cache[*batchv1beta1.BatchV1beta1Client] } @@ -56,11 +60,13 @@ func (c *BatchV1beta1ClusterClient) CronJobs() CronJobClusterInterface { // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*BatchV1beta1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new BatchV1beta1ClusterClient for the given config and http client. @@ -72,6 +78,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*BatchV1beta1Cluster if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &BatchV1beta1ClusterClient{clientCache: cache}, nil } @@ -84,3 +91,14 @@ func NewForConfigOrDie(c *rest.Config) *BatchV1beta1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apibatchv1beta1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/batch/v1beta1/cronjob.go b/kubernetes/typed/batch/v1beta1/cronjob.go index 528b4c3b8..4513cb666 100644 --- a/kubernetes/typed/batch/v1beta1/cronjob.go +++ b/kubernetes/typed/batch/v1beta1/cronjob.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" batchv1beta1 "k8s.io/api/batch/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - batchv1beta1client "k8s.io/client-go/kubernetes/typed/batch/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedbatchv1beta1 "k8s.io/client-go/kubernetes/typed/batch/v1beta1" ) // CronJobsClusterGetter has a method to return a CronJobClusterInterface. @@ -40,12 +40,13 @@ type CronJobsClusterGetter interface { // or scope down to one cluster and return a CronJobsNamespacer. type CronJobClusterInterface interface { Cluster(logicalcluster.Path) CronJobsNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*batchv1beta1.CronJobList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*batchv1beta1.CronJobList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + CronJobClusterExpansion } type cronJobsClusterInterface struct { - clientCache kcpclient.Cache[*batchv1beta1client.BatchV1beta1Client] + clientCache kcpclient.Cache[*typedbatchv1beta1.BatchV1beta1Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *cronJobsClusterInterface) Cluster(clusterPath logicalcluster.Path) Cron } // List returns the entire collection of all CronJobs across all clusters. -func (c *cronJobsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*batchv1beta1.CronJobList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).CronJobs(metav1.NamespaceAll).List(ctx, opts) +func (c *cronJobsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*batchv1beta1.CronJobList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).CronJobs(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all CronJobs across all clusters. -func (c *cronJobsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).CronJobs(metav1.NamespaceAll).Watch(ctx, opts) +func (c *cronJobsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).CronJobs(v1.NamespaceAll).Watch(ctx, opts) } -// CronJobsNamespacer can scope to objects within a namespace, returning a batchv1beta1client.CronJobInterface. +// CronJobsNamespacer can scope to objects within a namespace, returning a typedbatchv1beta1.CronJobInterface. type CronJobsNamespacer interface { - Namespace(string) batchv1beta1client.CronJobInterface + Namespace(string) typedbatchv1beta1.CronJobInterface } type cronJobsNamespacer struct { - clientCache kcpclient.Cache[*batchv1beta1client.BatchV1beta1Client] + clientCache kcpclient.Cache[*typedbatchv1beta1.BatchV1beta1Client] clusterPath logicalcluster.Path } -func (n *cronJobsNamespacer) Namespace(namespace string) batchv1beta1client.CronJobInterface { +func (n *cronJobsNamespacer) Namespace(namespace string) typedbatchv1beta1.CronJobInterface { return n.clientCache.ClusterOrDie(n.clusterPath).CronJobs(namespace) } diff --git a/kubernetes/typed/batch/v1beta1/doc.go b/kubernetes/typed/batch/v1beta1/doc.go new file mode 100644 index 000000000..541e9d258 --- /dev/null +++ b/kubernetes/typed/batch/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1beta1 diff --git a/kubernetes/typed/batch/v1beta1/fake/batch_client.go b/kubernetes/typed/batch/v1beta1/fake/batch_client.go index 4e733e196..c1a374659 100644 --- a/kubernetes/typed/batch/v1beta1/fake/batch_client.go +++ b/kubernetes/typed/batch/v1beta1/fake/batch_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" batchv1beta1 "k8s.io/client-go/kubernetes/typed/batch/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpbatchv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/batch/v1beta1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -42,21 +42,21 @@ func (c *BatchV1beta1ClusterClient) Cluster(clusterPath logicalcluster.Path) bat } func (c *BatchV1beta1ClusterClient) CronJobs() kcpbatchv1beta1.CronJobClusterInterface { - return &cronJobsClusterClient{Fake: c.Fake} + return newFakeCronJobClusterClient(c) } -var _ batchv1beta1.BatchV1beta1Interface = (*BatchV1beta1Client)(nil) - type BatchV1beta1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } +func (c *BatchV1beta1Client) CronJobs(namespace string) batchv1beta1.CronJobInterface { + return newFakeCronJobClient(c.Fake, namespace, c.ClusterPath) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. func (c *BatchV1beta1Client) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } - -func (c *BatchV1beta1Client) CronJobs(namespace string) batchv1beta1.CronJobInterface { - return &cronJobsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} -} diff --git a/kubernetes/typed/batch/v1beta1/fake/cronjob.go b/kubernetes/typed/batch/v1beta1/fake/cronjob.go index c40fc0af8..225838a32 100644 --- a/kubernetes/typed/batch/v1beta1/fake/cronjob.go +++ b/kubernetes/typed/batch/v1beta1/fake/cronjob.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" batchv1beta1 "k8s.io/api/batch/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsbatchv1beta1 "k8s.io/client-go/applyconfigurations/batch/v1beta1" - batchv1beta1client "k8s.io/client-go/kubernetes/typed/batch/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/batch/v1beta1" + typedbatchv1beta1 "k8s.io/client-go/kubernetes/typed/batch/v1beta1" - kcpbatchv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/batch/v1beta1" + typedkcpbatchv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/batch/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var cronJobsResource = schema.GroupVersionResource{Group: "batch", Version: "v1beta1", Resource: "cronjobs"} -var cronJobsKind = schema.GroupVersionKind{Group: "batch", Version: "v1beta1", Kind: "CronJob"} - -type cronJobsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *cronJobsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpbatchv1beta1.CronJobsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &cronJobsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// cronJobClusterClient implements CronJobClusterInterface +type cronJobClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*batchv1beta1.CronJob, *batchv1beta1.CronJobList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of CronJobs that match those selectors across all clusters. -func (c *cronJobsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*batchv1beta1.CronJobList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(cronJobsResource, cronJobsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &batchv1beta1.CronJobList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeCronJobClusterClient(fake *BatchV1beta1ClusterClient) typedkcpbatchv1beta1.CronJobClusterInterface { + return &cronJobClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*batchv1beta1.CronJob, *batchv1beta1.CronJobList]( + fake.Fake, + batchv1beta1.SchemeGroupVersion.WithResource("cronjobs"), + batchv1beta1.SchemeGroupVersion.WithKind("CronJob"), + func() *batchv1beta1.CronJob { return &batchv1beta1.CronJob{} }, + func() *batchv1beta1.CronJobList { return &batchv1beta1.CronJobList{} }, + func(dst, src *batchv1beta1.CronJobList) { dst.ListMeta = src.ListMeta }, + func(list *batchv1beta1.CronJobList) []*batchv1beta1.CronJob { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *batchv1beta1.CronJobList, items []*batchv1beta1.CronJob) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &batchv1beta1.CronJobList{ListMeta: obj.(*batchv1beta1.CronJobList).ListMeta} - for _, item := range obj.(*batchv1beta1.CronJobList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested CronJobs across all clusters. -func (c *cronJobsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(cronJobsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *cronJobClusterClient) Cluster(cluster logicalcluster.Path) typedkcpbatchv1beta1.CronJobsNamespacer { + return &cronJobNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type cronJobsNamespacer struct { +type cronJobNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *cronJobsNamespacer) Namespace(namespace string) batchv1beta1client.CronJobInterface { - return &cronJobsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *cronJobNamespacer) Namespace(namespace string) typedbatchv1beta1.CronJobInterface { + return newFakeCronJobClient(n.Fake, namespace, n.ClusterPath) } -type cronJobsClient struct { - *kcptesting.Fake +// cronJobScopedClient implements CronJobInterface +type cronJobScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*batchv1beta1.CronJob, *batchv1beta1.CronJobList, *v1beta1.CronJobApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *cronJobsClient) Create(ctx context.Context, cronJob *batchv1beta1.CronJob, opts metav1.CreateOptions) (*batchv1beta1.CronJob, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(cronJobsResource, c.ClusterPath, c.Namespace, cronJob), &batchv1beta1.CronJob{}) - if obj == nil { - return nil, err - } - return obj.(*batchv1beta1.CronJob), err -} - -func (c *cronJobsClient) Update(ctx context.Context, cronJob *batchv1beta1.CronJob, opts metav1.UpdateOptions) (*batchv1beta1.CronJob, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(cronJobsResource, c.ClusterPath, c.Namespace, cronJob), &batchv1beta1.CronJob{}) - if obj == nil { - return nil, err - } - return obj.(*batchv1beta1.CronJob), err -} - -func (c *cronJobsClient) UpdateStatus(ctx context.Context, cronJob *batchv1beta1.CronJob, opts metav1.UpdateOptions) (*batchv1beta1.CronJob, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(cronJobsResource, c.ClusterPath, "status", c.Namespace, cronJob), &batchv1beta1.CronJob{}) - if obj == nil { - return nil, err - } - return obj.(*batchv1beta1.CronJob), err -} - -func (c *cronJobsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(cronJobsResource, c.ClusterPath, c.Namespace, name, opts), &batchv1beta1.CronJob{}) - return err -} - -func (c *cronJobsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(cronJobsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &batchv1beta1.CronJobList{}) - return err -} - -func (c *cronJobsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*batchv1beta1.CronJob, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(cronJobsResource, c.ClusterPath, c.Namespace, name), &batchv1beta1.CronJob{}) - if obj == nil { - return nil, err - } - return obj.(*batchv1beta1.CronJob), err -} - -// List takes label and field selectors, and returns the list of CronJobs that match those selectors. -func (c *cronJobsClient) List(ctx context.Context, opts metav1.ListOptions) (*batchv1beta1.CronJobList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(cronJobsResource, cronJobsKind, c.ClusterPath, c.Namespace, opts), &batchv1beta1.CronJobList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &batchv1beta1.CronJobList{ListMeta: obj.(*batchv1beta1.CronJobList).ListMeta} - for _, item := range obj.(*batchv1beta1.CronJobList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *cronJobsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(cronJobsResource, c.ClusterPath, c.Namespace, opts)) } -func (c *cronJobsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*batchv1beta1.CronJob, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(cronJobsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &batchv1beta1.CronJob{}) - if obj == nil { - return nil, err - } - return obj.(*batchv1beta1.CronJob), err -} - -func (c *cronJobsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsbatchv1beta1.CronJobApplyConfiguration, opts metav1.ApplyOptions) (*batchv1beta1.CronJob, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(cronJobsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &batchv1beta1.CronJob{}) - if obj == nil { - return nil, err - } - return obj.(*batchv1beta1.CronJob), err -} - -func (c *cronJobsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsbatchv1beta1.CronJobApplyConfiguration, opts metav1.ApplyOptions) (*batchv1beta1.CronJob, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(cronJobsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &batchv1beta1.CronJob{}) - if obj == nil { - return nil, err +func newFakeCronJobClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedbatchv1beta1.CronJobInterface { + return &cronJobScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*batchv1beta1.CronJob, *batchv1beta1.CronJobList, *v1beta1.CronJobApplyConfiguration]( + fake, + clusterPath, + namespace, + batchv1beta1.SchemeGroupVersion.WithResource("cronjobs"), + batchv1beta1.SchemeGroupVersion.WithKind("CronJob"), + func() *batchv1beta1.CronJob { return &batchv1beta1.CronJob{} }, + func() *batchv1beta1.CronJobList { return &batchv1beta1.CronJobList{} }, + func(dst, src *batchv1beta1.CronJobList) { dst.ListMeta = src.ListMeta }, + func(list *batchv1beta1.CronJobList) []*batchv1beta1.CronJob { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *batchv1beta1.CronJobList, items []*batchv1beta1.CronJob) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*batchv1beta1.CronJob), err } diff --git a/kubernetes/typed/batch/v1beta1/fake/doc.go b/kubernetes/typed/batch/v1beta1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/batch/v1beta1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/batch/v1beta1/generated_expansion.go b/kubernetes/typed/batch/v1beta1/generated_expansion.go new file mode 100644 index 000000000..502fb1518 --- /dev/null +++ b/kubernetes/typed/batch/v1beta1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1beta1 + +type CronJobClusterExpansion interface{} diff --git a/kubernetes/typed/certificates/v1/certificates_client.go b/kubernetes/typed/certificates/v1/certificates_client.go index da4c8fca9..9c04b0303 100644 --- a/kubernetes/typed/certificates/v1/certificates_client.go +++ b/kubernetes/typed/certificates/v1/certificates_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apicertificatesv1 "k8s.io/api/certificates/v1" certificatesv1 "k8s.io/client-go/kubernetes/typed/certificates/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type CertificatesV1ClusterInterface interface { @@ -37,6 +40,7 @@ type CertificatesV1ClusterScoper interface { Cluster(logicalcluster.Path) certificatesv1.CertificatesV1Interface } +// CertificatesV1ClusterClient is used to interact with features provided by the certificates.k8s.io group. type CertificatesV1ClusterClient struct { clientCache kcpclient.Cache[*certificatesv1.CertificatesV1Client] } @@ -56,11 +60,13 @@ func (c *CertificatesV1ClusterClient) CertificateSigningRequests() CertificateSi // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*CertificatesV1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new CertificatesV1ClusterClient for the given config and http client. @@ -72,6 +78,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*CertificatesV1Clust if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &CertificatesV1ClusterClient{clientCache: cache}, nil } @@ -84,3 +91,14 @@ func NewForConfigOrDie(c *rest.Config) *CertificatesV1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apicertificatesv1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/certificates/v1/certificatesigningrequest.go b/kubernetes/typed/certificates/v1/certificatesigningrequest.go index c9e38f3f2..5fdd46438 100644 --- a/kubernetes/typed/certificates/v1/certificatesigningrequest.go +++ b/kubernetes/typed/certificates/v1/certificatesigningrequest.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - certificatesv1 "k8s.io/api/certificates/v1" + apicertificatesv1 "k8s.io/api/certificates/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - certificatesv1client "k8s.io/client-go/kubernetes/typed/certificates/v1" + watch "k8s.io/apimachinery/pkg/watch" + certificatesv1 "k8s.io/client-go/kubernetes/typed/certificates/v1" ) // CertificateSigningRequestsClusterGetter has a method to return a CertificateSigningRequestClusterInterface. @@ -37,19 +37,20 @@ type CertificateSigningRequestsClusterGetter interface { } // CertificateSigningRequestClusterInterface can operate on CertificateSigningRequests across all clusters, -// or scope down to one cluster and return a certificatesv1client.CertificateSigningRequestInterface. +// or scope down to one cluster and return a certificatesv1.CertificateSigningRequestInterface. type CertificateSigningRequestClusterInterface interface { - Cluster(logicalcluster.Path) certificatesv1client.CertificateSigningRequestInterface - List(ctx context.Context, opts metav1.ListOptions) (*certificatesv1.CertificateSigningRequestList, error) + Cluster(logicalcluster.Path) certificatesv1.CertificateSigningRequestInterface + List(ctx context.Context, opts metav1.ListOptions) (*apicertificatesv1.CertificateSigningRequestList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + CertificateSigningRequestClusterExpansion } type certificateSigningRequestsClusterInterface struct { - clientCache kcpclient.Cache[*certificatesv1client.CertificatesV1Client] + clientCache kcpclient.Cache[*certificatesv1.CertificatesV1Client] } // Cluster scopes the client down to a particular cluster. -func (c *certificateSigningRequestsClusterInterface) Cluster(clusterPath logicalcluster.Path) certificatesv1client.CertificateSigningRequestInterface { +func (c *certificateSigningRequestsClusterInterface) Cluster(clusterPath logicalcluster.Path) certificatesv1.CertificateSigningRequestInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,7 +59,7 @@ func (c *certificateSigningRequestsClusterInterface) Cluster(clusterPath logical } // List returns the entire collection of all CertificateSigningRequests across all clusters. -func (c *certificateSigningRequestsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*certificatesv1.CertificateSigningRequestList, error) { +func (c *certificateSigningRequestsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*apicertificatesv1.CertificateSigningRequestList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).CertificateSigningRequests().List(ctx, opts) } diff --git a/kubernetes/typed/certificates/v1/doc.go b/kubernetes/typed/certificates/v1/doc.go new file mode 100644 index 000000000..d2f3412ab --- /dev/null +++ b/kubernetes/typed/certificates/v1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1 diff --git a/kubernetes/typed/certificates/v1/fake/certificates_client.go b/kubernetes/typed/certificates/v1/fake/certificates_client.go index 7397fbfc4..57a8cff9d 100644 --- a/kubernetes/typed/certificates/v1/fake/certificates_client.go +++ b/kubernetes/typed/certificates/v1/fake/certificates_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" certificatesv1 "k8s.io/client-go/kubernetes/typed/certificates/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpcertificatesv1 "github.com/kcp-dev/client-go/kubernetes/typed/certificates/v1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -42,21 +42,21 @@ func (c *CertificatesV1ClusterClient) Cluster(clusterPath logicalcluster.Path) c } func (c *CertificatesV1ClusterClient) CertificateSigningRequests() kcpcertificatesv1.CertificateSigningRequestClusterInterface { - return &certificateSigningRequestsClusterClient{Fake: c.Fake} + return newFakeCertificateSigningRequestClusterClient(c) } -var _ certificatesv1.CertificatesV1Interface = (*CertificatesV1Client)(nil) - type CertificatesV1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } +func (c *CertificatesV1Client) CertificateSigningRequests() certificatesv1.CertificateSigningRequestInterface { + return newFakeCertificateSigningRequestClient(c.Fake, c.ClusterPath) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. func (c *CertificatesV1Client) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } - -func (c *CertificatesV1Client) CertificateSigningRequests() certificatesv1.CertificateSigningRequestInterface { - return &certificateSigningRequestsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} -} diff --git a/kubernetes/typed/certificates/v1/fake/certificatesigningrequest.go b/kubernetes/typed/certificates/v1/fake/certificatesigningrequest.go index 4b000cace..f48c2947e 100644 --- a/kubernetes/typed/certificates/v1/fake/certificatesigningrequest.go +++ b/kubernetes/typed/certificates/v1/fake/certificatesigningrequest.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,194 +14,95 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" + context "context" "github.com/kcp-dev/logicalcluster/v3" certificatesv1 "k8s.io/api/certificates/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationscertificatesv1 "k8s.io/client-go/applyconfigurations/certificates/v1" - certificatesv1client "k8s.io/client-go/kubernetes/typed/certificates/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/certificates/v1" + typedcertificatesv1 "k8s.io/client-go/kubernetes/typed/certificates/v1" + typedkcpcertificatesv1 "github.com/kcp-dev/client-go/kubernetes/typed/certificates/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var certificateSigningRequestsResource = schema.GroupVersionResource{Group: "certificates.k8s.io", Version: "v1", Resource: "certificatesigningrequests"} -var certificateSigningRequestsKind = schema.GroupVersionKind{Group: "certificates.k8s.io", Version: "v1", Kind: "CertificateSigningRequest"} - -type certificateSigningRequestsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *certificateSigningRequestsClusterClient) Cluster(clusterPath logicalcluster.Path) certificatesv1client.CertificateSigningRequestInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &certificateSigningRequestsClient{Fake: c.Fake, ClusterPath: clusterPath} -} - -// List takes label and field selectors, and returns the list of CertificateSigningRequests that match those selectors across all clusters. -func (c *certificateSigningRequestsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*certificatesv1.CertificateSigningRequestList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(certificateSigningRequestsResource, certificateSigningRequestsKind, logicalcluster.Wildcard, opts), &certificatesv1.CertificateSigningRequestList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &certificatesv1.CertificateSigningRequestList{ListMeta: obj.(*certificatesv1.CertificateSigningRequestList).ListMeta} - for _, item := range obj.(*certificatesv1.CertificateSigningRequestList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested CertificateSigningRequests across all clusters. -func (c *certificateSigningRequestsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(certificateSigningRequestsResource, logicalcluster.Wildcard, opts)) -} - -type certificateSigningRequestsClient struct { - *kcptesting.Fake +// certificateSigningRequestClusterClient implements CertificateSigningRequestClusterInterface +type certificateSigningRequestClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*certificatesv1.CertificateSigningRequest, *certificatesv1.CertificateSigningRequestList] + Fake *kcptesting.Fake +} + +func newFakeCertificateSigningRequestClusterClient(fake *CertificatesV1ClusterClient) typedkcpcertificatesv1.CertificateSigningRequestClusterInterface { + return &certificateSigningRequestClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*certificatesv1.CertificateSigningRequest, *certificatesv1.CertificateSigningRequestList]( + fake.Fake, + certificatesv1.SchemeGroupVersion.WithResource("certificatesigningrequests"), + certificatesv1.SchemeGroupVersion.WithKind("CertificateSigningRequest"), + func() *certificatesv1.CertificateSigningRequest { return &certificatesv1.CertificateSigningRequest{} }, + func() *certificatesv1.CertificateSigningRequestList { + return &certificatesv1.CertificateSigningRequestList{} + }, + func(dst, src *certificatesv1.CertificateSigningRequestList) { dst.ListMeta = src.ListMeta }, + func(list *certificatesv1.CertificateSigningRequestList) []*certificatesv1.CertificateSigningRequest { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *certificatesv1.CertificateSigningRequestList, items []*certificatesv1.CertificateSigningRequest) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, + } +} + +func (c *certificateSigningRequestClusterClient) Cluster(cluster logicalcluster.Path) typedcertificatesv1.CertificateSigningRequestInterface { + return newFakeCertificateSigningRequestClient(c.Fake, cluster) +} + +// certificateSigningRequestScopedClient implements CertificateSigningRequestInterface +type certificateSigningRequestScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*certificatesv1.CertificateSigningRequest, *certificatesv1.CertificateSigningRequestList, *v1.CertificateSigningRequestApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *certificateSigningRequestsClient) Create(ctx context.Context, certificateSigningRequest *certificatesv1.CertificateSigningRequest, opts metav1.CreateOptions) (*certificatesv1.CertificateSigningRequest, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(certificateSigningRequestsResource, c.ClusterPath, certificateSigningRequest), &certificatesv1.CertificateSigningRequest{}) - if obj == nil { - return nil, err - } - return obj.(*certificatesv1.CertificateSigningRequest), err -} - -func (c *certificateSigningRequestsClient) Update(ctx context.Context, certificateSigningRequest *certificatesv1.CertificateSigningRequest, opts metav1.UpdateOptions) (*certificatesv1.CertificateSigningRequest, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(certificateSigningRequestsResource, c.ClusterPath, certificateSigningRequest), &certificatesv1.CertificateSigningRequest{}) - if obj == nil { - return nil, err - } - return obj.(*certificatesv1.CertificateSigningRequest), err -} - -func (c *certificateSigningRequestsClient) UpdateStatus(ctx context.Context, certificateSigningRequest *certificatesv1.CertificateSigningRequest, opts metav1.UpdateOptions) (*certificatesv1.CertificateSigningRequest, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(certificateSigningRequestsResource, c.ClusterPath, "status", certificateSigningRequest), &certificatesv1.CertificateSigningRequest{}) - if obj == nil { - return nil, err - } - return obj.(*certificatesv1.CertificateSigningRequest), err -} - -func (c *certificateSigningRequestsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(certificateSigningRequestsResource, c.ClusterPath, name, opts), &certificatesv1.CertificateSigningRequest{}) - return err -} - -func (c *certificateSigningRequestsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(certificateSigningRequestsResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &certificatesv1.CertificateSigningRequestList{}) - return err -} - -func (c *certificateSigningRequestsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*certificatesv1.CertificateSigningRequest, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(certificateSigningRequestsResource, c.ClusterPath, name), &certificatesv1.CertificateSigningRequest{}) - if obj == nil { - return nil, err - } - return obj.(*certificatesv1.CertificateSigningRequest), err -} - -// List takes label and field selectors, and returns the list of CertificateSigningRequests that match those selectors. -func (c *certificateSigningRequestsClient) List(ctx context.Context, opts metav1.ListOptions) (*certificatesv1.CertificateSigningRequestList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(certificateSigningRequestsResource, certificateSigningRequestsKind, c.ClusterPath, opts), &certificatesv1.CertificateSigningRequestList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &certificatesv1.CertificateSigningRequestList{ListMeta: obj.(*certificatesv1.CertificateSigningRequestList).ListMeta} - for _, item := range obj.(*certificatesv1.CertificateSigningRequestList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *certificateSigningRequestsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(certificateSigningRequestsResource, c.ClusterPath, opts)) -} - -func (c *certificateSigningRequestsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*certificatesv1.CertificateSigningRequest, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(certificateSigningRequestsResource, c.ClusterPath, name, pt, data, subresources...), &certificatesv1.CertificateSigningRequest{}) - if obj == nil { - return nil, err - } - return obj.(*certificatesv1.CertificateSigningRequest), err -} - -func (c *certificateSigningRequestsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationscertificatesv1.CertificateSigningRequestApplyConfiguration, opts metav1.ApplyOptions) (*certificatesv1.CertificateSigningRequest, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(certificateSigningRequestsResource, c.ClusterPath, *name, types.ApplyPatchType, data), &certificatesv1.CertificateSigningRequest{}) - if obj == nil { - return nil, err - } - return obj.(*certificatesv1.CertificateSigningRequest), err -} - -func (c *certificateSigningRequestsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationscertificatesv1.CertificateSigningRequestApplyConfiguration, opts metav1.ApplyOptions) (*certificatesv1.CertificateSigningRequest, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(certificateSigningRequestsResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &certificatesv1.CertificateSigningRequest{}) - if obj == nil { - return nil, err - } - return obj.(*certificatesv1.CertificateSigningRequest), err -} - -func (c *certificateSigningRequestsClient) UpdateApproval(ctx context.Context, certificateSigningRequestName string, certificateSigningRequest *certificatesv1.CertificateSigningRequest, opts metav1.UpdateOptions) (*certificatesv1.CertificateSigningRequest, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(certificateSigningRequestsResource, c.ClusterPath, "approval", certificateSigningRequest), &certificatesv1.CertificateSigningRequest{}) +func newFakeCertificateSigningRequestClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedcertificatesv1.CertificateSigningRequestInterface { + return &certificateSigningRequestScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*certificatesv1.CertificateSigningRequest, *certificatesv1.CertificateSigningRequestList, *v1.CertificateSigningRequestApplyConfiguration]( + fake, + clusterPath, + "", + certificatesv1.SchemeGroupVersion.WithResource("certificatesigningrequests"), + certificatesv1.SchemeGroupVersion.WithKind("CertificateSigningRequest"), + func() *certificatesv1.CertificateSigningRequest { return &certificatesv1.CertificateSigningRequest{} }, + func() *certificatesv1.CertificateSigningRequestList { + return &certificatesv1.CertificateSigningRequestList{} + }, + func(dst, src *certificatesv1.CertificateSigningRequestList) { dst.ListMeta = src.ListMeta }, + func(list *certificatesv1.CertificateSigningRequestList) []*certificatesv1.CertificateSigningRequest { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *certificatesv1.CertificateSigningRequestList, items []*certificatesv1.CertificateSigningRequest) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, + } +} + +// UpdateApproval takes the representation of a certificateSigningRequest and updates it. Returns the server's representation of the certificateSigningRequest, and an error, if there is any. +func (c *certificateSigningRequestScopedClient) UpdateApproval(ctx context.Context, certificateSigningRequestName string, certificateSigningRequest *certificatesv1.CertificateSigningRequest, _ metav1.UpdateOptions) (result *certificatesv1.CertificateSigningRequest, err error) { + emptyResult := &certificatesv1.CertificateSigningRequest{} + obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(c.Resource(), c.ClusterPath, "approval", certificateSigningRequest), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*certificatesv1.CertificateSigningRequest), err } diff --git a/kubernetes/typed/certificates/v1/fake/doc.go b/kubernetes/typed/certificates/v1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/certificates/v1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/certificates/v1/generated_expansion.go b/kubernetes/typed/certificates/v1/generated_expansion.go new file mode 100644 index 000000000..49eb67ef4 --- /dev/null +++ b/kubernetes/typed/certificates/v1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1 + +type CertificateSigningRequestClusterExpansion interface{} diff --git a/kubernetes/typed/certificates/v1alpha1/certificates_client.go b/kubernetes/typed/certificates/v1alpha1/certificates_client.go index 76c06711a..7c497b2e0 100644 --- a/kubernetes/typed/certificates/v1alpha1/certificates_client.go +++ b/kubernetes/typed/certificates/v1alpha1/certificates_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apicertificatesv1alpha1 "k8s.io/api/certificates/v1alpha1" certificatesv1alpha1 "k8s.io/client-go/kubernetes/typed/certificates/v1alpha1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type CertificatesV1alpha1ClusterInterface interface { @@ -37,6 +40,7 @@ type CertificatesV1alpha1ClusterScoper interface { Cluster(logicalcluster.Path) certificatesv1alpha1.CertificatesV1alpha1Interface } +// CertificatesV1alpha1ClusterClient is used to interact with features provided by the certificates.k8s.io group. type CertificatesV1alpha1ClusterClient struct { clientCache kcpclient.Cache[*certificatesv1alpha1.CertificatesV1alpha1Client] } @@ -56,11 +60,13 @@ func (c *CertificatesV1alpha1ClusterClient) ClusterTrustBundles() ClusterTrustBu // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*CertificatesV1alpha1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new CertificatesV1alpha1ClusterClient for the given config and http client. @@ -72,6 +78,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*CertificatesV1alpha if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &CertificatesV1alpha1ClusterClient{clientCache: cache}, nil } @@ -84,3 +91,14 @@ func NewForConfigOrDie(c *rest.Config) *CertificatesV1alpha1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apicertificatesv1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/certificates/v1alpha1/clustertrustbundle.go b/kubernetes/typed/certificates/v1alpha1/clustertrustbundle.go index 398e83c44..e723b4711 100644 --- a/kubernetes/typed/certificates/v1alpha1/clustertrustbundle.go +++ b/kubernetes/typed/certificates/v1alpha1/clustertrustbundle.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - certificatesv1alpha1 "k8s.io/api/certificates/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - certificatesv1alpha1client "k8s.io/client-go/kubernetes/typed/certificates/v1alpha1" + apicertificatesv1alpha1 "k8s.io/api/certificates/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + certificatesv1alpha1 "k8s.io/client-go/kubernetes/typed/certificates/v1alpha1" ) // ClusterTrustBundlesClusterGetter has a method to return a ClusterTrustBundleClusterInterface. @@ -37,19 +37,20 @@ type ClusterTrustBundlesClusterGetter interface { } // ClusterTrustBundleClusterInterface can operate on ClusterTrustBundles across all clusters, -// or scope down to one cluster and return a certificatesv1alpha1client.ClusterTrustBundleInterface. +// or scope down to one cluster and return a certificatesv1alpha1.ClusterTrustBundleInterface. type ClusterTrustBundleClusterInterface interface { - Cluster(logicalcluster.Path) certificatesv1alpha1client.ClusterTrustBundleInterface - List(ctx context.Context, opts metav1.ListOptions) (*certificatesv1alpha1.ClusterTrustBundleList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) certificatesv1alpha1.ClusterTrustBundleInterface + List(ctx context.Context, opts v1.ListOptions) (*apicertificatesv1alpha1.ClusterTrustBundleList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + ClusterTrustBundleClusterExpansion } type clusterTrustBundlesClusterInterface struct { - clientCache kcpclient.Cache[*certificatesv1alpha1client.CertificatesV1alpha1Client] + clientCache kcpclient.Cache[*certificatesv1alpha1.CertificatesV1alpha1Client] } // Cluster scopes the client down to a particular cluster. -func (c *clusterTrustBundlesClusterInterface) Cluster(clusterPath logicalcluster.Path) certificatesv1alpha1client.ClusterTrustBundleInterface { +func (c *clusterTrustBundlesClusterInterface) Cluster(clusterPath logicalcluster.Path) certificatesv1alpha1.ClusterTrustBundleInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *clusterTrustBundlesClusterInterface) Cluster(clusterPath logicalcluster } // List returns the entire collection of all ClusterTrustBundles across all clusters. -func (c *clusterTrustBundlesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*certificatesv1alpha1.ClusterTrustBundleList, error) { +func (c *clusterTrustBundlesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apicertificatesv1alpha1.ClusterTrustBundleList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ClusterTrustBundles().List(ctx, opts) } // Watch begins to watch all ClusterTrustBundles across all clusters. -func (c *clusterTrustBundlesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *clusterTrustBundlesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ClusterTrustBundles().Watch(ctx, opts) } diff --git a/kubernetes/typed/certificates/v1alpha1/doc.go b/kubernetes/typed/certificates/v1alpha1/doc.go new file mode 100644 index 000000000..08b80237c --- /dev/null +++ b/kubernetes/typed/certificates/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/kubernetes/typed/certificates/v1alpha1/fake/certificates_client.go b/kubernetes/typed/certificates/v1alpha1/fake/certificates_client.go index 1ecb12940..caaa946bb 100644 --- a/kubernetes/typed/certificates/v1alpha1/fake/certificates_client.go +++ b/kubernetes/typed/certificates/v1alpha1/fake/certificates_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" certificatesv1alpha1 "k8s.io/client-go/kubernetes/typed/certificates/v1alpha1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpcertificatesv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/certificates/v1alpha1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -42,21 +42,21 @@ func (c *CertificatesV1alpha1ClusterClient) Cluster(clusterPath logicalcluster.P } func (c *CertificatesV1alpha1ClusterClient) ClusterTrustBundles() kcpcertificatesv1alpha1.ClusterTrustBundleClusterInterface { - return &clusterTrustBundlesClusterClient{Fake: c.Fake} + return newFakeClusterTrustBundleClusterClient(c) } -var _ certificatesv1alpha1.CertificatesV1alpha1Interface = (*CertificatesV1alpha1Client)(nil) - type CertificatesV1alpha1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } +func (c *CertificatesV1alpha1Client) ClusterTrustBundles() certificatesv1alpha1.ClusterTrustBundleInterface { + return newFakeClusterTrustBundleClient(c.Fake, c.ClusterPath) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. func (c *CertificatesV1alpha1Client) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } - -func (c *CertificatesV1alpha1Client) ClusterTrustBundles() certificatesv1alpha1.ClusterTrustBundleInterface { - return &clusterTrustBundlesClient{Fake: c.Fake, ClusterPath: c.ClusterPath} -} diff --git a/kubernetes/typed/certificates/v1alpha1/fake/clustertrustbundle.go b/kubernetes/typed/certificates/v1alpha1/fake/clustertrustbundle.go index ea659e15e..cc6a7cff3 100644 --- a/kubernetes/typed/certificates/v1alpha1/fake/clustertrustbundle.go +++ b/kubernetes/typed/certificates/v1alpha1/fake/clustertrustbundle.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,82 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" certificatesv1alpha1 "k8s.io/api/certificates/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationscertificatesv1alpha1 "k8s.io/client-go/applyconfigurations/certificates/v1alpha1" - certificatesv1alpha1client "k8s.io/client-go/kubernetes/typed/certificates/v1alpha1" - "k8s.io/client-go/testing" + v1alpha1 "k8s.io/client-go/applyconfigurations/certificates/v1alpha1" + typedcertificatesv1alpha1 "k8s.io/client-go/kubernetes/typed/certificates/v1alpha1" + typedkcpcertificatesv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/certificates/v1alpha1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var clusterTrustBundlesResource = schema.GroupVersionResource{Group: "certificates.k8s.io", Version: "v1alpha1", Resource: "clustertrustbundles"} -var clusterTrustBundlesKind = schema.GroupVersionKind{Group: "certificates.k8s.io", Version: "v1alpha1", Kind: "ClusterTrustBundle"} - -type clusterTrustBundlesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *clusterTrustBundlesClusterClient) Cluster(clusterPath logicalcluster.Path) certificatesv1alpha1client.ClusterTrustBundleInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &clusterTrustBundlesClient{Fake: c.Fake, ClusterPath: clusterPath} -} - -// List takes label and field selectors, and returns the list of ClusterTrustBundles that match those selectors across all clusters. -func (c *clusterTrustBundlesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*certificatesv1alpha1.ClusterTrustBundleList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(clusterTrustBundlesResource, clusterTrustBundlesKind, logicalcluster.Wildcard, opts), &certificatesv1alpha1.ClusterTrustBundleList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &certificatesv1alpha1.ClusterTrustBundleList{ListMeta: obj.(*certificatesv1alpha1.ClusterTrustBundleList).ListMeta} - for _, item := range obj.(*certificatesv1alpha1.ClusterTrustBundleList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested ClusterTrustBundles across all clusters. -func (c *clusterTrustBundlesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(clusterTrustBundlesResource, logicalcluster.Wildcard, opts)) -} - -type clusterTrustBundlesClient struct { - *kcptesting.Fake +// clusterTrustBundleClusterClient implements ClusterTrustBundleClusterInterface +type clusterTrustBundleClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*certificatesv1alpha1.ClusterTrustBundle, *certificatesv1alpha1.ClusterTrustBundleList] + Fake *kcptesting.Fake +} + +func newFakeClusterTrustBundleClusterClient(fake *CertificatesV1alpha1ClusterClient) typedkcpcertificatesv1alpha1.ClusterTrustBundleClusterInterface { + return &clusterTrustBundleClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*certificatesv1alpha1.ClusterTrustBundle, *certificatesv1alpha1.ClusterTrustBundleList]( + fake.Fake, + certificatesv1alpha1.SchemeGroupVersion.WithResource("clustertrustbundles"), + certificatesv1alpha1.SchemeGroupVersion.WithKind("ClusterTrustBundle"), + func() *certificatesv1alpha1.ClusterTrustBundle { return &certificatesv1alpha1.ClusterTrustBundle{} }, + func() *certificatesv1alpha1.ClusterTrustBundleList { + return &certificatesv1alpha1.ClusterTrustBundleList{} + }, + func(dst, src *certificatesv1alpha1.ClusterTrustBundleList) { dst.ListMeta = src.ListMeta }, + func(list *certificatesv1alpha1.ClusterTrustBundleList) []*certificatesv1alpha1.ClusterTrustBundle { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *certificatesv1alpha1.ClusterTrustBundleList, items []*certificatesv1alpha1.ClusterTrustBundle) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, + } +} + +func (c *clusterTrustBundleClusterClient) Cluster(cluster logicalcluster.Path) typedcertificatesv1alpha1.ClusterTrustBundleInterface { + return newFakeClusterTrustBundleClient(c.Fake, cluster) +} + +// clusterTrustBundleScopedClient implements ClusterTrustBundleInterface +type clusterTrustBundleScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*certificatesv1alpha1.ClusterTrustBundle, *certificatesv1alpha1.ClusterTrustBundleList, *v1alpha1.ClusterTrustBundleApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *clusterTrustBundlesClient) Create(ctx context.Context, clusterTrustBundle *certificatesv1alpha1.ClusterTrustBundle, opts metav1.CreateOptions) (*certificatesv1alpha1.ClusterTrustBundle, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(clusterTrustBundlesResource, c.ClusterPath, clusterTrustBundle), &certificatesv1alpha1.ClusterTrustBundle{}) - if obj == nil { - return nil, err - } - return obj.(*certificatesv1alpha1.ClusterTrustBundle), err -} - -func (c *clusterTrustBundlesClient) Update(ctx context.Context, clusterTrustBundle *certificatesv1alpha1.ClusterTrustBundle, opts metav1.UpdateOptions) (*certificatesv1alpha1.ClusterTrustBundle, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(clusterTrustBundlesResource, c.ClusterPath, clusterTrustBundle), &certificatesv1alpha1.ClusterTrustBundle{}) - if obj == nil { - return nil, err - } - return obj.(*certificatesv1alpha1.ClusterTrustBundle), err -} - -func (c *clusterTrustBundlesClient) UpdateStatus(ctx context.Context, clusterTrustBundle *certificatesv1alpha1.ClusterTrustBundle, opts metav1.UpdateOptions) (*certificatesv1alpha1.ClusterTrustBundle, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(clusterTrustBundlesResource, c.ClusterPath, "status", clusterTrustBundle), &certificatesv1alpha1.ClusterTrustBundle{}) - if obj == nil { - return nil, err - } - return obj.(*certificatesv1alpha1.ClusterTrustBundle), err -} - -func (c *clusterTrustBundlesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(clusterTrustBundlesResource, c.ClusterPath, name, opts), &certificatesv1alpha1.ClusterTrustBundle{}) - return err -} - -func (c *clusterTrustBundlesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(clusterTrustBundlesResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &certificatesv1alpha1.ClusterTrustBundleList{}) - return err -} - -func (c *clusterTrustBundlesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*certificatesv1alpha1.ClusterTrustBundle, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(clusterTrustBundlesResource, c.ClusterPath, name), &certificatesv1alpha1.ClusterTrustBundle{}) - if obj == nil { - return nil, err - } - return obj.(*certificatesv1alpha1.ClusterTrustBundle), err -} - -// List takes label and field selectors, and returns the list of ClusterTrustBundles that match those selectors. -func (c *clusterTrustBundlesClient) List(ctx context.Context, opts metav1.ListOptions) (*certificatesv1alpha1.ClusterTrustBundleList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(clusterTrustBundlesResource, clusterTrustBundlesKind, c.ClusterPath, opts), &certificatesv1alpha1.ClusterTrustBundleList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &certificatesv1alpha1.ClusterTrustBundleList{ListMeta: obj.(*certificatesv1alpha1.ClusterTrustBundleList).ListMeta} - for _, item := range obj.(*certificatesv1alpha1.ClusterTrustBundleList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *clusterTrustBundlesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(clusterTrustBundlesResource, c.ClusterPath, opts)) -} - -func (c *clusterTrustBundlesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*certificatesv1alpha1.ClusterTrustBundle, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(clusterTrustBundlesResource, c.ClusterPath, name, pt, data, subresources...), &certificatesv1alpha1.ClusterTrustBundle{}) - if obj == nil { - return nil, err - } - return obj.(*certificatesv1alpha1.ClusterTrustBundle), err -} - -func (c *clusterTrustBundlesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationscertificatesv1alpha1.ClusterTrustBundleApplyConfiguration, opts metav1.ApplyOptions) (*certificatesv1alpha1.ClusterTrustBundle, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(clusterTrustBundlesResource, c.ClusterPath, *name, types.ApplyPatchType, data), &certificatesv1alpha1.ClusterTrustBundle{}) - if obj == nil { - return nil, err - } - return obj.(*certificatesv1alpha1.ClusterTrustBundle), err -} - -func (c *clusterTrustBundlesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationscertificatesv1alpha1.ClusterTrustBundleApplyConfiguration, opts metav1.ApplyOptions) (*certificatesv1alpha1.ClusterTrustBundle, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(clusterTrustBundlesResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &certificatesv1alpha1.ClusterTrustBundle{}) - if obj == nil { - return nil, err +func newFakeClusterTrustBundleClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedcertificatesv1alpha1.ClusterTrustBundleInterface { + return &clusterTrustBundleScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*certificatesv1alpha1.ClusterTrustBundle, *certificatesv1alpha1.ClusterTrustBundleList, *v1alpha1.ClusterTrustBundleApplyConfiguration]( + fake, + clusterPath, + "", + certificatesv1alpha1.SchemeGroupVersion.WithResource("clustertrustbundles"), + certificatesv1alpha1.SchemeGroupVersion.WithKind("ClusterTrustBundle"), + func() *certificatesv1alpha1.ClusterTrustBundle { return &certificatesv1alpha1.ClusterTrustBundle{} }, + func() *certificatesv1alpha1.ClusterTrustBundleList { + return &certificatesv1alpha1.ClusterTrustBundleList{} + }, + func(dst, src *certificatesv1alpha1.ClusterTrustBundleList) { dst.ListMeta = src.ListMeta }, + func(list *certificatesv1alpha1.ClusterTrustBundleList) []*certificatesv1alpha1.ClusterTrustBundle { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *certificatesv1alpha1.ClusterTrustBundleList, items []*certificatesv1alpha1.ClusterTrustBundle) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*certificatesv1alpha1.ClusterTrustBundle), err } diff --git a/kubernetes/typed/certificates/v1alpha1/fake/doc.go b/kubernetes/typed/certificates/v1alpha1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/certificates/v1alpha1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/certificates/v1alpha1/generated_expansion.go b/kubernetes/typed/certificates/v1alpha1/generated_expansion.go new file mode 100644 index 000000000..7e3e8577c --- /dev/null +++ b/kubernetes/typed/certificates/v1alpha1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1alpha1 + +type ClusterTrustBundleClusterExpansion interface{} diff --git a/kubernetes/typed/certificates/v1beta1/certificates_client.go b/kubernetes/typed/certificates/v1beta1/certificates_client.go index 77df70be0..e512506f8 100644 --- a/kubernetes/typed/certificates/v1beta1/certificates_client.go +++ b/kubernetes/typed/certificates/v1beta1/certificates_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apicertificatesv1beta1 "k8s.io/api/certificates/v1beta1" certificatesv1beta1 "k8s.io/client-go/kubernetes/typed/certificates/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type CertificatesV1beta1ClusterInterface interface { @@ -37,6 +40,7 @@ type CertificatesV1beta1ClusterScoper interface { Cluster(logicalcluster.Path) certificatesv1beta1.CertificatesV1beta1Interface } +// CertificatesV1beta1ClusterClient is used to interact with features provided by the certificates.k8s.io group. type CertificatesV1beta1ClusterClient struct { clientCache kcpclient.Cache[*certificatesv1beta1.CertificatesV1beta1Client] } @@ -56,11 +60,13 @@ func (c *CertificatesV1beta1ClusterClient) CertificateSigningRequests() Certific // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*CertificatesV1beta1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new CertificatesV1beta1ClusterClient for the given config and http client. @@ -72,6 +78,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*CertificatesV1beta1 if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &CertificatesV1beta1ClusterClient{clientCache: cache}, nil } @@ -84,3 +91,14 @@ func NewForConfigOrDie(c *rest.Config) *CertificatesV1beta1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apicertificatesv1beta1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/certificates/v1beta1/certificatesigningrequest.go b/kubernetes/typed/certificates/v1beta1/certificatesigningrequest.go index 86bb78199..a11949950 100644 --- a/kubernetes/typed/certificates/v1beta1/certificatesigningrequest.go +++ b/kubernetes/typed/certificates/v1beta1/certificatesigningrequest.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - certificatesv1beta1 "k8s.io/api/certificates/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - certificatesv1beta1client "k8s.io/client-go/kubernetes/typed/certificates/v1beta1" + apicertificatesv1beta1 "k8s.io/api/certificates/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + certificatesv1beta1 "k8s.io/client-go/kubernetes/typed/certificates/v1beta1" ) // CertificateSigningRequestsClusterGetter has a method to return a CertificateSigningRequestClusterInterface. @@ -37,19 +37,20 @@ type CertificateSigningRequestsClusterGetter interface { } // CertificateSigningRequestClusterInterface can operate on CertificateSigningRequests across all clusters, -// or scope down to one cluster and return a certificatesv1beta1client.CertificateSigningRequestInterface. +// or scope down to one cluster and return a certificatesv1beta1.CertificateSigningRequestInterface. type CertificateSigningRequestClusterInterface interface { - Cluster(logicalcluster.Path) certificatesv1beta1client.CertificateSigningRequestInterface - List(ctx context.Context, opts metav1.ListOptions) (*certificatesv1beta1.CertificateSigningRequestList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) certificatesv1beta1.CertificateSigningRequestInterface + List(ctx context.Context, opts v1.ListOptions) (*apicertificatesv1beta1.CertificateSigningRequestList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + CertificateSigningRequestClusterExpansion } type certificateSigningRequestsClusterInterface struct { - clientCache kcpclient.Cache[*certificatesv1beta1client.CertificatesV1beta1Client] + clientCache kcpclient.Cache[*certificatesv1beta1.CertificatesV1beta1Client] } // Cluster scopes the client down to a particular cluster. -func (c *certificateSigningRequestsClusterInterface) Cluster(clusterPath logicalcluster.Path) certificatesv1beta1client.CertificateSigningRequestInterface { +func (c *certificateSigningRequestsClusterInterface) Cluster(clusterPath logicalcluster.Path) certificatesv1beta1.CertificateSigningRequestInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *certificateSigningRequestsClusterInterface) Cluster(clusterPath logical } // List returns the entire collection of all CertificateSigningRequests across all clusters. -func (c *certificateSigningRequestsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*certificatesv1beta1.CertificateSigningRequestList, error) { +func (c *certificateSigningRequestsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apicertificatesv1beta1.CertificateSigningRequestList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).CertificateSigningRequests().List(ctx, opts) } // Watch begins to watch all CertificateSigningRequests across all clusters. -func (c *certificateSigningRequestsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *certificateSigningRequestsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).CertificateSigningRequests().Watch(ctx, opts) } diff --git a/kubernetes/typed/certificates/v1beta1/doc.go b/kubernetes/typed/certificates/v1beta1/doc.go new file mode 100644 index 000000000..541e9d258 --- /dev/null +++ b/kubernetes/typed/certificates/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1beta1 diff --git a/kubernetes/typed/certificates/v1beta1/fake/certificates_client.go b/kubernetes/typed/certificates/v1beta1/fake/certificates_client.go index 3f191cdff..03a199f00 100644 --- a/kubernetes/typed/certificates/v1beta1/fake/certificates_client.go +++ b/kubernetes/typed/certificates/v1beta1/fake/certificates_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" certificatesv1beta1 "k8s.io/client-go/kubernetes/typed/certificates/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpcertificatesv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/certificates/v1beta1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -42,21 +42,21 @@ func (c *CertificatesV1beta1ClusterClient) Cluster(clusterPath logicalcluster.Pa } func (c *CertificatesV1beta1ClusterClient) CertificateSigningRequests() kcpcertificatesv1beta1.CertificateSigningRequestClusterInterface { - return &certificateSigningRequestsClusterClient{Fake: c.Fake} + return newFakeCertificateSigningRequestClusterClient(c) } -var _ certificatesv1beta1.CertificatesV1beta1Interface = (*CertificatesV1beta1Client)(nil) - type CertificatesV1beta1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } +func (c *CertificatesV1beta1Client) CertificateSigningRequests() certificatesv1beta1.CertificateSigningRequestInterface { + return newFakeCertificateSigningRequestClient(c.Fake, c.ClusterPath) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. func (c *CertificatesV1beta1Client) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } - -func (c *CertificatesV1beta1Client) CertificateSigningRequests() certificatesv1beta1.CertificateSigningRequestInterface { - return &certificateSigningRequestsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} -} diff --git a/kubernetes/typed/certificates/v1beta1/fake/certificatesigningrequest.go b/kubernetes/typed/certificates/v1beta1/fake/certificatesigningrequest.go index 71307f565..c58380f6f 100644 --- a/kubernetes/typed/certificates/v1beta1/fake/certificatesigningrequest.go +++ b/kubernetes/typed/certificates/v1beta1/fake/certificatesigningrequest.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,86 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" certificatesv1beta1 "k8s.io/api/certificates/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationscertificatesv1beta1 "k8s.io/client-go/applyconfigurations/certificates/v1beta1" - certificatesv1beta1client "k8s.io/client-go/kubernetes/typed/certificates/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/certificates/v1beta1" + typedcertificatesv1beta1 "k8s.io/client-go/kubernetes/typed/certificates/v1beta1" + typedkcpcertificatesv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/certificates/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var certificateSigningRequestsResource = schema.GroupVersionResource{Group: "certificates.k8s.io", Version: "v1beta1", Resource: "certificatesigningrequests"} -var certificateSigningRequestsKind = schema.GroupVersionKind{Group: "certificates.k8s.io", Version: "v1beta1", Kind: "CertificateSigningRequest"} - -type certificateSigningRequestsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *certificateSigningRequestsClusterClient) Cluster(clusterPath logicalcluster.Path) certificatesv1beta1client.CertificateSigningRequestInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &certificateSigningRequestsClient{Fake: c.Fake, ClusterPath: clusterPath} -} - -// List takes label and field selectors, and returns the list of CertificateSigningRequests that match those selectors across all clusters. -func (c *certificateSigningRequestsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*certificatesv1beta1.CertificateSigningRequestList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(certificateSigningRequestsResource, certificateSigningRequestsKind, logicalcluster.Wildcard, opts), &certificatesv1beta1.CertificateSigningRequestList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &certificatesv1beta1.CertificateSigningRequestList{ListMeta: obj.(*certificatesv1beta1.CertificateSigningRequestList).ListMeta} - for _, item := range obj.(*certificatesv1beta1.CertificateSigningRequestList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested CertificateSigningRequests across all clusters. -func (c *certificateSigningRequestsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(certificateSigningRequestsResource, logicalcluster.Wildcard, opts)) -} - -type certificateSigningRequestsClient struct { - *kcptesting.Fake +// certificateSigningRequestClusterClient implements CertificateSigningRequestClusterInterface +type certificateSigningRequestClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*certificatesv1beta1.CertificateSigningRequest, *certificatesv1beta1.CertificateSigningRequestList] + Fake *kcptesting.Fake +} + +func newFakeCertificateSigningRequestClusterClient(fake *CertificatesV1beta1ClusterClient) typedkcpcertificatesv1beta1.CertificateSigningRequestClusterInterface { + return &certificateSigningRequestClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*certificatesv1beta1.CertificateSigningRequest, *certificatesv1beta1.CertificateSigningRequestList]( + fake.Fake, + certificatesv1beta1.SchemeGroupVersion.WithResource("certificatesigningrequests"), + certificatesv1beta1.SchemeGroupVersion.WithKind("CertificateSigningRequest"), + func() *certificatesv1beta1.CertificateSigningRequest { + return &certificatesv1beta1.CertificateSigningRequest{} + }, + func() *certificatesv1beta1.CertificateSigningRequestList { + return &certificatesv1beta1.CertificateSigningRequestList{} + }, + func(dst, src *certificatesv1beta1.CertificateSigningRequestList) { dst.ListMeta = src.ListMeta }, + func(list *certificatesv1beta1.CertificateSigningRequestList) []*certificatesv1beta1.CertificateSigningRequest { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *certificatesv1beta1.CertificateSigningRequestList, items []*certificatesv1beta1.CertificateSigningRequest) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, + } +} + +func (c *certificateSigningRequestClusterClient) Cluster(cluster logicalcluster.Path) typedcertificatesv1beta1.CertificateSigningRequestInterface { + return newFakeCertificateSigningRequestClient(c.Fake, cluster) +} + +// certificateSigningRequestScopedClient implements CertificateSigningRequestInterface +type certificateSigningRequestScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*certificatesv1beta1.CertificateSigningRequest, *certificatesv1beta1.CertificateSigningRequestList, *v1beta1.CertificateSigningRequestApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *certificateSigningRequestsClient) Create(ctx context.Context, certificateSigningRequest *certificatesv1beta1.CertificateSigningRequest, opts metav1.CreateOptions) (*certificatesv1beta1.CertificateSigningRequest, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(certificateSigningRequestsResource, c.ClusterPath, certificateSigningRequest), &certificatesv1beta1.CertificateSigningRequest{}) - if obj == nil { - return nil, err - } - return obj.(*certificatesv1beta1.CertificateSigningRequest), err -} - -func (c *certificateSigningRequestsClient) Update(ctx context.Context, certificateSigningRequest *certificatesv1beta1.CertificateSigningRequest, opts metav1.UpdateOptions) (*certificatesv1beta1.CertificateSigningRequest, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(certificateSigningRequestsResource, c.ClusterPath, certificateSigningRequest), &certificatesv1beta1.CertificateSigningRequest{}) - if obj == nil { - return nil, err - } - return obj.(*certificatesv1beta1.CertificateSigningRequest), err -} - -func (c *certificateSigningRequestsClient) UpdateStatus(ctx context.Context, certificateSigningRequest *certificatesv1beta1.CertificateSigningRequest, opts metav1.UpdateOptions) (*certificatesv1beta1.CertificateSigningRequest, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(certificateSigningRequestsResource, c.ClusterPath, "status", certificateSigningRequest), &certificatesv1beta1.CertificateSigningRequest{}) - if obj == nil { - return nil, err - } - return obj.(*certificatesv1beta1.CertificateSigningRequest), err -} - -func (c *certificateSigningRequestsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(certificateSigningRequestsResource, c.ClusterPath, name, opts), &certificatesv1beta1.CertificateSigningRequest{}) - return err -} - -func (c *certificateSigningRequestsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(certificateSigningRequestsResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &certificatesv1beta1.CertificateSigningRequestList{}) - return err -} - -func (c *certificateSigningRequestsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*certificatesv1beta1.CertificateSigningRequest, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(certificateSigningRequestsResource, c.ClusterPath, name), &certificatesv1beta1.CertificateSigningRequest{}) - if obj == nil { - return nil, err - } - return obj.(*certificatesv1beta1.CertificateSigningRequest), err -} - -// List takes label and field selectors, and returns the list of CertificateSigningRequests that match those selectors. -func (c *certificateSigningRequestsClient) List(ctx context.Context, opts metav1.ListOptions) (*certificatesv1beta1.CertificateSigningRequestList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(certificateSigningRequestsResource, certificateSigningRequestsKind, c.ClusterPath, opts), &certificatesv1beta1.CertificateSigningRequestList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &certificatesv1beta1.CertificateSigningRequestList{ListMeta: obj.(*certificatesv1beta1.CertificateSigningRequestList).ListMeta} - for _, item := range obj.(*certificatesv1beta1.CertificateSigningRequestList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *certificateSigningRequestsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(certificateSigningRequestsResource, c.ClusterPath, opts)) -} - -func (c *certificateSigningRequestsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*certificatesv1beta1.CertificateSigningRequest, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(certificateSigningRequestsResource, c.ClusterPath, name, pt, data, subresources...), &certificatesv1beta1.CertificateSigningRequest{}) - if obj == nil { - return nil, err - } - return obj.(*certificatesv1beta1.CertificateSigningRequest), err -} - -func (c *certificateSigningRequestsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationscertificatesv1beta1.CertificateSigningRequestApplyConfiguration, opts metav1.ApplyOptions) (*certificatesv1beta1.CertificateSigningRequest, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(certificateSigningRequestsResource, c.ClusterPath, *name, types.ApplyPatchType, data), &certificatesv1beta1.CertificateSigningRequest{}) - if obj == nil { - return nil, err - } - return obj.(*certificatesv1beta1.CertificateSigningRequest), err -} - -func (c *certificateSigningRequestsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationscertificatesv1beta1.CertificateSigningRequestApplyConfiguration, opts metav1.ApplyOptions) (*certificatesv1beta1.CertificateSigningRequest, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(certificateSigningRequestsResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &certificatesv1beta1.CertificateSigningRequest{}) - if obj == nil { - return nil, err +func newFakeCertificateSigningRequestClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedcertificatesv1beta1.CertificateSigningRequestInterface { + return &certificateSigningRequestScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*certificatesv1beta1.CertificateSigningRequest, *certificatesv1beta1.CertificateSigningRequestList, *v1beta1.CertificateSigningRequestApplyConfiguration]( + fake, + clusterPath, + "", + certificatesv1beta1.SchemeGroupVersion.WithResource("certificatesigningrequests"), + certificatesv1beta1.SchemeGroupVersion.WithKind("CertificateSigningRequest"), + func() *certificatesv1beta1.CertificateSigningRequest { + return &certificatesv1beta1.CertificateSigningRequest{} + }, + func() *certificatesv1beta1.CertificateSigningRequestList { + return &certificatesv1beta1.CertificateSigningRequestList{} + }, + func(dst, src *certificatesv1beta1.CertificateSigningRequestList) { dst.ListMeta = src.ListMeta }, + func(list *certificatesv1beta1.CertificateSigningRequestList) []*certificatesv1beta1.CertificateSigningRequest { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *certificatesv1beta1.CertificateSigningRequestList, items []*certificatesv1beta1.CertificateSigningRequest) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*certificatesv1beta1.CertificateSigningRequest), err } diff --git a/kubernetes/typed/certificates/v1beta1/fake/doc.go b/kubernetes/typed/certificates/v1beta1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/certificates/v1beta1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/certificates/v1beta1/fake/fake_certificatesigningrequest_expansion.go b/kubernetes/typed/certificates/v1beta1/fake/fake_certificatesigningrequest_expansion.go index 2cf232cf4..7a6b1dc48 100644 --- a/kubernetes/typed/certificates/v1beta1/fake/fake_certificatesigningrequest_expansion.go +++ b/kubernetes/typed/certificates/v1beta1/fake/fake_certificatesigningrequest_expansion.go @@ -22,11 +22,14 @@ import ( certificates "k8s.io/api/certificates/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" core "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -func (c *certificateSigningRequestsClient) UpdateApproval(ctx context.Context, certificateSigningRequest *certificates.CertificateSigningRequest, opts metav1.UpdateOptions) (result *certificates.CertificateSigningRequest, err error) { +var certificateSigningRequestsResource = schema.GroupVersionResource{Group: "certificates.k8s.io", Version: "v1beta1", Resource: "certificatesigningrequests"} + +func (c *certificateSigningRequestScopedClient) UpdateApproval(ctx context.Context, certificateSigningRequest *certificates.CertificateSigningRequest, opts metav1.UpdateOptions) (result *certificates.CertificateSigningRequest, err error) { obj, err := c.Fake.Invokes(core.NewRootUpdateSubresourceAction(certificateSigningRequestsResource, c.ClusterPath, "approval", certificateSigningRequest), &certificates.CertificateSigningRequest{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/certificates/v1beta1/generated_expansion.go b/kubernetes/typed/certificates/v1beta1/generated_expansion.go new file mode 100644 index 000000000..27759c4a9 --- /dev/null +++ b/kubernetes/typed/certificates/v1beta1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1beta1 + +type CertificateSigningRequestClusterExpansion interface{} diff --git a/kubernetes/typed/coordination/v1/coordination_client.go b/kubernetes/typed/coordination/v1/coordination_client.go index 53b80c3ad..ff3bb9d62 100644 --- a/kubernetes/typed/coordination/v1/coordination_client.go +++ b/kubernetes/typed/coordination/v1/coordination_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apicoordinationv1 "k8s.io/api/coordination/v1" coordinationv1 "k8s.io/client-go/kubernetes/typed/coordination/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type CoordinationV1ClusterInterface interface { @@ -37,6 +40,7 @@ type CoordinationV1ClusterScoper interface { Cluster(logicalcluster.Path) coordinationv1.CoordinationV1Interface } +// CoordinationV1ClusterClient is used to interact with features provided by the coordination.k8s.io group. type CoordinationV1ClusterClient struct { clientCache kcpclient.Cache[*coordinationv1.CoordinationV1Client] } @@ -56,11 +60,13 @@ func (c *CoordinationV1ClusterClient) Leases() LeaseClusterInterface { // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*CoordinationV1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new CoordinationV1ClusterClient for the given config and http client. @@ -72,6 +78,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*CoordinationV1Clust if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &CoordinationV1ClusterClient{clientCache: cache}, nil } @@ -84,3 +91,14 @@ func NewForConfigOrDie(c *rest.Config) *CoordinationV1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apicoordinationv1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/coordination/v1/doc.go b/kubernetes/typed/coordination/v1/doc.go new file mode 100644 index 000000000..d2f3412ab --- /dev/null +++ b/kubernetes/typed/coordination/v1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1 diff --git a/kubernetes/typed/coordination/v1/fake/coordination_client.go b/kubernetes/typed/coordination/v1/fake/coordination_client.go index 84f611d73..866ae359d 100644 --- a/kubernetes/typed/coordination/v1/fake/coordination_client.go +++ b/kubernetes/typed/coordination/v1/fake/coordination_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" coordinationv1 "k8s.io/client-go/kubernetes/typed/coordination/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpcoordinationv1 "github.com/kcp-dev/client-go/kubernetes/typed/coordination/v1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -42,21 +42,21 @@ func (c *CoordinationV1ClusterClient) Cluster(clusterPath logicalcluster.Path) c } func (c *CoordinationV1ClusterClient) Leases() kcpcoordinationv1.LeaseClusterInterface { - return &leasesClusterClient{Fake: c.Fake} + return newFakeLeaseClusterClient(c) } -var _ coordinationv1.CoordinationV1Interface = (*CoordinationV1Client)(nil) - type CoordinationV1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } +func (c *CoordinationV1Client) Leases(namespace string) coordinationv1.LeaseInterface { + return newFakeLeaseClient(c.Fake, namespace, c.ClusterPath) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. func (c *CoordinationV1Client) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } - -func (c *CoordinationV1Client) Leases(namespace string) coordinationv1.LeaseInterface { - return &leasesClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} -} diff --git a/kubernetes/typed/coordination/v1/fake/doc.go b/kubernetes/typed/coordination/v1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/coordination/v1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/coordination/v1/fake/lease.go b/kubernetes/typed/coordination/v1/fake/lease.go index 6128d183f..7b3768fe5 100644 --- a/kubernetes/typed/coordination/v1/fake/lease.go +++ b/kubernetes/typed/coordination/v1/fake/lease.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" coordinationv1 "k8s.io/api/coordination/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationscoordinationv1 "k8s.io/client-go/applyconfigurations/coordination/v1" - coordinationv1client "k8s.io/client-go/kubernetes/typed/coordination/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/coordination/v1" + typedcoordinationv1 "k8s.io/client-go/kubernetes/typed/coordination/v1" - kcpcoordinationv1 "github.com/kcp-dev/client-go/kubernetes/typed/coordination/v1" + typedkcpcoordinationv1 "github.com/kcp-dev/client-go/kubernetes/typed/coordination/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var leasesResource = schema.GroupVersionResource{Group: "coordination.k8s.io", Version: "v1", Resource: "leases"} -var leasesKind = schema.GroupVersionKind{Group: "coordination.k8s.io", Version: "v1", Kind: "Lease"} - -type leasesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *leasesClusterClient) Cluster(clusterPath logicalcluster.Path) kcpcoordinationv1.LeasesNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &leasesNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// leaseClusterClient implements LeaseClusterInterface +type leaseClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*coordinationv1.Lease, *coordinationv1.LeaseList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of Leases that match those selectors across all clusters. -func (c *leasesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*coordinationv1.LeaseList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(leasesResource, leasesKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &coordinationv1.LeaseList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeLeaseClusterClient(fake *CoordinationV1ClusterClient) typedkcpcoordinationv1.LeaseClusterInterface { + return &leaseClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*coordinationv1.Lease, *coordinationv1.LeaseList]( + fake.Fake, + coordinationv1.SchemeGroupVersion.WithResource("leases"), + coordinationv1.SchemeGroupVersion.WithKind("Lease"), + func() *coordinationv1.Lease { return &coordinationv1.Lease{} }, + func() *coordinationv1.LeaseList { return &coordinationv1.LeaseList{} }, + func(dst, src *coordinationv1.LeaseList) { dst.ListMeta = src.ListMeta }, + func(list *coordinationv1.LeaseList) []*coordinationv1.Lease { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *coordinationv1.LeaseList, items []*coordinationv1.Lease) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &coordinationv1.LeaseList{ListMeta: obj.(*coordinationv1.LeaseList).ListMeta} - for _, item := range obj.(*coordinationv1.LeaseList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested Leases across all clusters. -func (c *leasesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(leasesResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *leaseClusterClient) Cluster(cluster logicalcluster.Path) typedkcpcoordinationv1.LeasesNamespacer { + return &leaseNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type leasesNamespacer struct { +type leaseNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *leasesNamespacer) Namespace(namespace string) coordinationv1client.LeaseInterface { - return &leasesClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *leaseNamespacer) Namespace(namespace string) typedcoordinationv1.LeaseInterface { + return newFakeLeaseClient(n.Fake, namespace, n.ClusterPath) } -type leasesClient struct { - *kcptesting.Fake +// leaseScopedClient implements LeaseInterface +type leaseScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*coordinationv1.Lease, *coordinationv1.LeaseList, *v1.LeaseApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *leasesClient) Create(ctx context.Context, lease *coordinationv1.Lease, opts metav1.CreateOptions) (*coordinationv1.Lease, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(leasesResource, c.ClusterPath, c.Namespace, lease), &coordinationv1.Lease{}) - if obj == nil { - return nil, err - } - return obj.(*coordinationv1.Lease), err -} - -func (c *leasesClient) Update(ctx context.Context, lease *coordinationv1.Lease, opts metav1.UpdateOptions) (*coordinationv1.Lease, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(leasesResource, c.ClusterPath, c.Namespace, lease), &coordinationv1.Lease{}) - if obj == nil { - return nil, err - } - return obj.(*coordinationv1.Lease), err -} - -func (c *leasesClient) UpdateStatus(ctx context.Context, lease *coordinationv1.Lease, opts metav1.UpdateOptions) (*coordinationv1.Lease, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(leasesResource, c.ClusterPath, "status", c.Namespace, lease), &coordinationv1.Lease{}) - if obj == nil { - return nil, err - } - return obj.(*coordinationv1.Lease), err -} - -func (c *leasesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(leasesResource, c.ClusterPath, c.Namespace, name, opts), &coordinationv1.Lease{}) - return err -} - -func (c *leasesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(leasesResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &coordinationv1.LeaseList{}) - return err -} - -func (c *leasesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*coordinationv1.Lease, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(leasesResource, c.ClusterPath, c.Namespace, name), &coordinationv1.Lease{}) - if obj == nil { - return nil, err - } - return obj.(*coordinationv1.Lease), err -} - -// List takes label and field selectors, and returns the list of Leases that match those selectors. -func (c *leasesClient) List(ctx context.Context, opts metav1.ListOptions) (*coordinationv1.LeaseList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(leasesResource, leasesKind, c.ClusterPath, c.Namespace, opts), &coordinationv1.LeaseList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &coordinationv1.LeaseList{ListMeta: obj.(*coordinationv1.LeaseList).ListMeta} - for _, item := range obj.(*coordinationv1.LeaseList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *leasesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(leasesResource, c.ClusterPath, c.Namespace, opts)) } -func (c *leasesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*coordinationv1.Lease, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(leasesResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &coordinationv1.Lease{}) - if obj == nil { - return nil, err - } - return obj.(*coordinationv1.Lease), err -} - -func (c *leasesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationscoordinationv1.LeaseApplyConfiguration, opts metav1.ApplyOptions) (*coordinationv1.Lease, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(leasesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &coordinationv1.Lease{}) - if obj == nil { - return nil, err - } - return obj.(*coordinationv1.Lease), err -} - -func (c *leasesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationscoordinationv1.LeaseApplyConfiguration, opts metav1.ApplyOptions) (*coordinationv1.Lease, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(leasesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &coordinationv1.Lease{}) - if obj == nil { - return nil, err +func newFakeLeaseClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedcoordinationv1.LeaseInterface { + return &leaseScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*coordinationv1.Lease, *coordinationv1.LeaseList, *v1.LeaseApplyConfiguration]( + fake, + clusterPath, + namespace, + coordinationv1.SchemeGroupVersion.WithResource("leases"), + coordinationv1.SchemeGroupVersion.WithKind("Lease"), + func() *coordinationv1.Lease { return &coordinationv1.Lease{} }, + func() *coordinationv1.LeaseList { return &coordinationv1.LeaseList{} }, + func(dst, src *coordinationv1.LeaseList) { dst.ListMeta = src.ListMeta }, + func(list *coordinationv1.LeaseList) []*coordinationv1.Lease { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *coordinationv1.LeaseList, items []*coordinationv1.Lease) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*coordinationv1.Lease), err } diff --git a/kubernetes/typed/coordination/v1/generated_expansion.go b/kubernetes/typed/coordination/v1/generated_expansion.go new file mode 100644 index 000000000..9e050f2c2 --- /dev/null +++ b/kubernetes/typed/coordination/v1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1 + +type LeaseClusterExpansion interface{} diff --git a/kubernetes/typed/coordination/v1/lease.go b/kubernetes/typed/coordination/v1/lease.go index df8eb9215..b67ce9b4b 100644 --- a/kubernetes/typed/coordination/v1/lease.go +++ b/kubernetes/typed/coordination/v1/lease.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" coordinationv1 "k8s.io/api/coordination/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - coordinationv1client "k8s.io/client-go/kubernetes/typed/coordination/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedcoordinationv1 "k8s.io/client-go/kubernetes/typed/coordination/v1" ) // LeasesClusterGetter has a method to return a LeaseClusterInterface. @@ -42,10 +42,11 @@ type LeaseClusterInterface interface { Cluster(logicalcluster.Path) LeasesNamespacer List(ctx context.Context, opts metav1.ListOptions) (*coordinationv1.LeaseList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + LeaseClusterExpansion } type leasesClusterInterface struct { - clientCache kcpclient.Cache[*coordinationv1client.CoordinationV1Client] + clientCache kcpclient.Cache[*typedcoordinationv1.CoordinationV1Client] } // Cluster scopes the client down to a particular cluster. @@ -67,16 +68,16 @@ func (c *leasesClusterInterface) Watch(ctx context.Context, opts metav1.ListOpti return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Leases(metav1.NamespaceAll).Watch(ctx, opts) } -// LeasesNamespacer can scope to objects within a namespace, returning a coordinationv1client.LeaseInterface. +// LeasesNamespacer can scope to objects within a namespace, returning a typedcoordinationv1.LeaseInterface. type LeasesNamespacer interface { - Namespace(string) coordinationv1client.LeaseInterface + Namespace(string) typedcoordinationv1.LeaseInterface } type leasesNamespacer struct { - clientCache kcpclient.Cache[*coordinationv1client.CoordinationV1Client] + clientCache kcpclient.Cache[*typedcoordinationv1.CoordinationV1Client] clusterPath logicalcluster.Path } -func (n *leasesNamespacer) Namespace(namespace string) coordinationv1client.LeaseInterface { +func (n *leasesNamespacer) Namespace(namespace string) typedcoordinationv1.LeaseInterface { return n.clientCache.ClusterOrDie(n.clusterPath).Leases(namespace) } diff --git a/kubernetes/typed/coordination/v1alpha2/coordination_client.go b/kubernetes/typed/coordination/v1alpha2/coordination_client.go index 94d5b6dda..2dbc07dc2 100644 --- a/kubernetes/typed/coordination/v1alpha2/coordination_client.go +++ b/kubernetes/typed/coordination/v1alpha2/coordination_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha2 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apicoordinationv1alpha2 "k8s.io/api/coordination/v1alpha2" coordinationv1alpha2 "k8s.io/client-go/kubernetes/typed/coordination/v1alpha2" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type CoordinationV1alpha2ClusterInterface interface { @@ -37,6 +40,7 @@ type CoordinationV1alpha2ClusterScoper interface { Cluster(logicalcluster.Path) coordinationv1alpha2.CoordinationV1alpha2Interface } +// CoordinationV1alpha2ClusterClient is used to interact with features provided by the coordination.k8s.io group. type CoordinationV1alpha2ClusterClient struct { clientCache kcpclient.Cache[*coordinationv1alpha2.CoordinationV1alpha2Client] } @@ -56,11 +60,13 @@ func (c *CoordinationV1alpha2ClusterClient) LeaseCandidates() LeaseCandidateClus // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*CoordinationV1alpha2ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new CoordinationV1alpha2ClusterClient for the given config and http client. @@ -72,6 +78,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*CoordinationV1alpha if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &CoordinationV1alpha2ClusterClient{clientCache: cache}, nil } @@ -84,3 +91,14 @@ func NewForConfigOrDie(c *rest.Config) *CoordinationV1alpha2ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apicoordinationv1alpha2.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/coordination/v1alpha2/doc.go b/kubernetes/typed/coordination/v1alpha2/doc.go new file mode 100644 index 000000000..d6c1a4590 --- /dev/null +++ b/kubernetes/typed/coordination/v1alpha2/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha2 diff --git a/kubernetes/typed/coordination/v1alpha2/fake/coordination_client.go b/kubernetes/typed/coordination/v1alpha2/fake/coordination_client.go index 851bbb35c..f4d99f692 100644 --- a/kubernetes/typed/coordination/v1alpha2/fake/coordination_client.go +++ b/kubernetes/typed/coordination/v1alpha2/fake/coordination_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" coordinationv1alpha2 "k8s.io/client-go/kubernetes/typed/coordination/v1alpha2" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpcoordinationv1alpha2 "github.com/kcp-dev/client-go/kubernetes/typed/coordination/v1alpha2" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -42,21 +42,21 @@ func (c *CoordinationV1alpha2ClusterClient) Cluster(clusterPath logicalcluster.P } func (c *CoordinationV1alpha2ClusterClient) LeaseCandidates() kcpcoordinationv1alpha2.LeaseCandidateClusterInterface { - return &leaseCandidatesClusterClient{Fake: c.Fake} + return newFakeLeaseCandidateClusterClient(c) } -var _ coordinationv1alpha2.CoordinationV1alpha2Interface = (*CoordinationV1alpha2Client)(nil) - type CoordinationV1alpha2Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } +func (c *CoordinationV1alpha2Client) LeaseCandidates(namespace string) coordinationv1alpha2.LeaseCandidateInterface { + return newFakeLeaseCandidateClient(c.Fake, namespace, c.ClusterPath) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. func (c *CoordinationV1alpha2Client) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } - -func (c *CoordinationV1alpha2Client) LeaseCandidates(namespace string) coordinationv1alpha2.LeaseCandidateInterface { - return &leaseCandidatesClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} -} diff --git a/kubernetes/typed/coordination/v1alpha2/fake/doc.go b/kubernetes/typed/coordination/v1alpha2/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/coordination/v1alpha2/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/coordination/v1alpha2/fake/leasecandidate.go b/kubernetes/typed/coordination/v1alpha2/fake/leasecandidate.go index 6c0a495aa..da1a0ef06 100644 --- a/kubernetes/typed/coordination/v1alpha2/fake/leasecandidate.go +++ b/kubernetes/typed/coordination/v1alpha2/fake/leasecandidate.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" coordinationv1alpha2 "k8s.io/api/coordination/v1alpha2" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationscoordinationv1alpha2 "k8s.io/client-go/applyconfigurations/coordination/v1alpha2" - coordinationv1alpha2client "k8s.io/client-go/kubernetes/typed/coordination/v1alpha2" - "k8s.io/client-go/testing" + v1alpha2 "k8s.io/client-go/applyconfigurations/coordination/v1alpha2" + typedcoordinationv1alpha2 "k8s.io/client-go/kubernetes/typed/coordination/v1alpha2" - kcpcoordinationv1alpha2 "github.com/kcp-dev/client-go/kubernetes/typed/coordination/v1alpha2" + typedkcpcoordinationv1alpha2 "github.com/kcp-dev/client-go/kubernetes/typed/coordination/v1alpha2" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var leaseCandidatesResource = schema.GroupVersionResource{Group: "coordination.k8s.io", Version: "v1alpha2", Resource: "leasecandidates"} -var leaseCandidatesKind = schema.GroupVersionKind{Group: "coordination.k8s.io", Version: "v1alpha2", Kind: "LeaseCandidate"} - -type leaseCandidatesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *leaseCandidatesClusterClient) Cluster(clusterPath logicalcluster.Path) kcpcoordinationv1alpha2.LeaseCandidatesNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &leaseCandidatesNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// leaseCandidateClusterClient implements LeaseCandidateClusterInterface +type leaseCandidateClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*coordinationv1alpha2.LeaseCandidate, *coordinationv1alpha2.LeaseCandidateList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of LeaseCandidates that match those selectors across all clusters. -func (c *leaseCandidatesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*coordinationv1alpha2.LeaseCandidateList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(leaseCandidatesResource, leaseCandidatesKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &coordinationv1alpha2.LeaseCandidateList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeLeaseCandidateClusterClient(fake *CoordinationV1alpha2ClusterClient) typedkcpcoordinationv1alpha2.LeaseCandidateClusterInterface { + return &leaseCandidateClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*coordinationv1alpha2.LeaseCandidate, *coordinationv1alpha2.LeaseCandidateList]( + fake.Fake, + coordinationv1alpha2.SchemeGroupVersion.WithResource("leasecandidates"), + coordinationv1alpha2.SchemeGroupVersion.WithKind("LeaseCandidate"), + func() *coordinationv1alpha2.LeaseCandidate { return &coordinationv1alpha2.LeaseCandidate{} }, + func() *coordinationv1alpha2.LeaseCandidateList { return &coordinationv1alpha2.LeaseCandidateList{} }, + func(dst, src *coordinationv1alpha2.LeaseCandidateList) { dst.ListMeta = src.ListMeta }, + func(list *coordinationv1alpha2.LeaseCandidateList) []*coordinationv1alpha2.LeaseCandidate { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *coordinationv1alpha2.LeaseCandidateList, items []*coordinationv1alpha2.LeaseCandidate) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &coordinationv1alpha2.LeaseCandidateList{ListMeta: obj.(*coordinationv1alpha2.LeaseCandidateList).ListMeta} - for _, item := range obj.(*coordinationv1alpha2.LeaseCandidateList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested LeaseCandidates across all clusters. -func (c *leaseCandidatesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(leaseCandidatesResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *leaseCandidateClusterClient) Cluster(cluster logicalcluster.Path) typedkcpcoordinationv1alpha2.LeaseCandidatesNamespacer { + return &leaseCandidateNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type leaseCandidatesNamespacer struct { +type leaseCandidateNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *leaseCandidatesNamespacer) Namespace(namespace string) coordinationv1alpha2client.LeaseCandidateInterface { - return &leaseCandidatesClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *leaseCandidateNamespacer) Namespace(namespace string) typedcoordinationv1alpha2.LeaseCandidateInterface { + return newFakeLeaseCandidateClient(n.Fake, namespace, n.ClusterPath) } -type leaseCandidatesClient struct { - *kcptesting.Fake +// leaseCandidateScopedClient implements LeaseCandidateInterface +type leaseCandidateScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*coordinationv1alpha2.LeaseCandidate, *coordinationv1alpha2.LeaseCandidateList, *v1alpha2.LeaseCandidateApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *leaseCandidatesClient) Create(ctx context.Context, leaseCandidate *coordinationv1alpha2.LeaseCandidate, opts metav1.CreateOptions) (*coordinationv1alpha2.LeaseCandidate, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(leaseCandidatesResource, c.ClusterPath, c.Namespace, leaseCandidate), &coordinationv1alpha2.LeaseCandidate{}) - if obj == nil { - return nil, err - } - return obj.(*coordinationv1alpha2.LeaseCandidate), err -} - -func (c *leaseCandidatesClient) Update(ctx context.Context, leaseCandidate *coordinationv1alpha2.LeaseCandidate, opts metav1.UpdateOptions) (*coordinationv1alpha2.LeaseCandidate, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(leaseCandidatesResource, c.ClusterPath, c.Namespace, leaseCandidate), &coordinationv1alpha2.LeaseCandidate{}) - if obj == nil { - return nil, err - } - return obj.(*coordinationv1alpha2.LeaseCandidate), err -} - -func (c *leaseCandidatesClient) UpdateStatus(ctx context.Context, leaseCandidate *coordinationv1alpha2.LeaseCandidate, opts metav1.UpdateOptions) (*coordinationv1alpha2.LeaseCandidate, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(leaseCandidatesResource, c.ClusterPath, "status", c.Namespace, leaseCandidate), &coordinationv1alpha2.LeaseCandidate{}) - if obj == nil { - return nil, err - } - return obj.(*coordinationv1alpha2.LeaseCandidate), err -} - -func (c *leaseCandidatesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(leaseCandidatesResource, c.ClusterPath, c.Namespace, name, opts), &coordinationv1alpha2.LeaseCandidate{}) - return err -} - -func (c *leaseCandidatesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(leaseCandidatesResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &coordinationv1alpha2.LeaseCandidateList{}) - return err -} - -func (c *leaseCandidatesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*coordinationv1alpha2.LeaseCandidate, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(leaseCandidatesResource, c.ClusterPath, c.Namespace, name), &coordinationv1alpha2.LeaseCandidate{}) - if obj == nil { - return nil, err - } - return obj.(*coordinationv1alpha2.LeaseCandidate), err -} - -// List takes label and field selectors, and returns the list of LeaseCandidates that match those selectors. -func (c *leaseCandidatesClient) List(ctx context.Context, opts metav1.ListOptions) (*coordinationv1alpha2.LeaseCandidateList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(leaseCandidatesResource, leaseCandidatesKind, c.ClusterPath, c.Namespace, opts), &coordinationv1alpha2.LeaseCandidateList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &coordinationv1alpha2.LeaseCandidateList{ListMeta: obj.(*coordinationv1alpha2.LeaseCandidateList).ListMeta} - for _, item := range obj.(*coordinationv1alpha2.LeaseCandidateList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *leaseCandidatesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(leaseCandidatesResource, c.ClusterPath, c.Namespace, opts)) } -func (c *leaseCandidatesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*coordinationv1alpha2.LeaseCandidate, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(leaseCandidatesResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &coordinationv1alpha2.LeaseCandidate{}) - if obj == nil { - return nil, err - } - return obj.(*coordinationv1alpha2.LeaseCandidate), err -} - -func (c *leaseCandidatesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationscoordinationv1alpha2.LeaseCandidateApplyConfiguration, opts metav1.ApplyOptions) (*coordinationv1alpha2.LeaseCandidate, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(leaseCandidatesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &coordinationv1alpha2.LeaseCandidate{}) - if obj == nil { - return nil, err - } - return obj.(*coordinationv1alpha2.LeaseCandidate), err -} - -func (c *leaseCandidatesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationscoordinationv1alpha2.LeaseCandidateApplyConfiguration, opts metav1.ApplyOptions) (*coordinationv1alpha2.LeaseCandidate, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(leaseCandidatesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &coordinationv1alpha2.LeaseCandidate{}) - if obj == nil { - return nil, err +func newFakeLeaseCandidateClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedcoordinationv1alpha2.LeaseCandidateInterface { + return &leaseCandidateScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*coordinationv1alpha2.LeaseCandidate, *coordinationv1alpha2.LeaseCandidateList, *v1alpha2.LeaseCandidateApplyConfiguration]( + fake, + clusterPath, + namespace, + coordinationv1alpha2.SchemeGroupVersion.WithResource("leasecandidates"), + coordinationv1alpha2.SchemeGroupVersion.WithKind("LeaseCandidate"), + func() *coordinationv1alpha2.LeaseCandidate { return &coordinationv1alpha2.LeaseCandidate{} }, + func() *coordinationv1alpha2.LeaseCandidateList { return &coordinationv1alpha2.LeaseCandidateList{} }, + func(dst, src *coordinationv1alpha2.LeaseCandidateList) { dst.ListMeta = src.ListMeta }, + func(list *coordinationv1alpha2.LeaseCandidateList) []*coordinationv1alpha2.LeaseCandidate { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *coordinationv1alpha2.LeaseCandidateList, items []*coordinationv1alpha2.LeaseCandidate) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*coordinationv1alpha2.LeaseCandidate), err } diff --git a/kubernetes/typed/coordination/v1alpha2/generated_expansion.go b/kubernetes/typed/coordination/v1alpha2/generated_expansion.go new file mode 100644 index 000000000..e10ab4e8d --- /dev/null +++ b/kubernetes/typed/coordination/v1alpha2/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1alpha2 + +type LeaseCandidateClusterExpansion interface{} diff --git a/kubernetes/typed/coordination/v1alpha2/leasecandidate.go b/kubernetes/typed/coordination/v1alpha2/leasecandidate.go index 2939a4fc4..e1f50c7ba 100644 --- a/kubernetes/typed/coordination/v1alpha2/leasecandidate.go +++ b/kubernetes/typed/coordination/v1alpha2/leasecandidate.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha2 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" coordinationv1alpha2 "k8s.io/api/coordination/v1alpha2" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - coordinationv1alpha2client "k8s.io/client-go/kubernetes/typed/coordination/v1alpha2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedcoordinationv1alpha2 "k8s.io/client-go/kubernetes/typed/coordination/v1alpha2" ) // LeaseCandidatesClusterGetter has a method to return a LeaseCandidateClusterInterface. @@ -40,12 +40,13 @@ type LeaseCandidatesClusterGetter interface { // or scope down to one cluster and return a LeaseCandidatesNamespacer. type LeaseCandidateClusterInterface interface { Cluster(logicalcluster.Path) LeaseCandidatesNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*coordinationv1alpha2.LeaseCandidateList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*coordinationv1alpha2.LeaseCandidateList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + LeaseCandidateClusterExpansion } type leaseCandidatesClusterInterface struct { - clientCache kcpclient.Cache[*coordinationv1alpha2client.CoordinationV1alpha2Client] + clientCache kcpclient.Cache[*typedcoordinationv1alpha2.CoordinationV1alpha2Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *leaseCandidatesClusterInterface) Cluster(clusterPath logicalcluster.Pat } // List returns the entire collection of all LeaseCandidates across all clusters. -func (c *leaseCandidatesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*coordinationv1alpha2.LeaseCandidateList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).LeaseCandidates(metav1.NamespaceAll).List(ctx, opts) +func (c *leaseCandidatesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*coordinationv1alpha2.LeaseCandidateList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).LeaseCandidates(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all LeaseCandidates across all clusters. -func (c *leaseCandidatesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).LeaseCandidates(metav1.NamespaceAll).Watch(ctx, opts) +func (c *leaseCandidatesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).LeaseCandidates(v1.NamespaceAll).Watch(ctx, opts) } -// LeaseCandidatesNamespacer can scope to objects within a namespace, returning a coordinationv1alpha2client.LeaseCandidateInterface. +// LeaseCandidatesNamespacer can scope to objects within a namespace, returning a typedcoordinationv1alpha2.LeaseCandidateInterface. type LeaseCandidatesNamespacer interface { - Namespace(string) coordinationv1alpha2client.LeaseCandidateInterface + Namespace(string) typedcoordinationv1alpha2.LeaseCandidateInterface } type leaseCandidatesNamespacer struct { - clientCache kcpclient.Cache[*coordinationv1alpha2client.CoordinationV1alpha2Client] + clientCache kcpclient.Cache[*typedcoordinationv1alpha2.CoordinationV1alpha2Client] clusterPath logicalcluster.Path } -func (n *leaseCandidatesNamespacer) Namespace(namespace string) coordinationv1alpha2client.LeaseCandidateInterface { +func (n *leaseCandidatesNamespacer) Namespace(namespace string) typedcoordinationv1alpha2.LeaseCandidateInterface { return n.clientCache.ClusterOrDie(n.clusterPath).LeaseCandidates(namespace) } diff --git a/kubernetes/typed/coordination/v1beta1/coordination_client.go b/kubernetes/typed/coordination/v1beta1/coordination_client.go index 6d91fdf24..ac01148f5 100644 --- a/kubernetes/typed/coordination/v1beta1/coordination_client.go +++ b/kubernetes/typed/coordination/v1beta1/coordination_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apicoordinationv1beta1 "k8s.io/api/coordination/v1beta1" coordinationv1beta1 "k8s.io/client-go/kubernetes/typed/coordination/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type CoordinationV1beta1ClusterInterface interface { @@ -37,6 +40,7 @@ type CoordinationV1beta1ClusterScoper interface { Cluster(logicalcluster.Path) coordinationv1beta1.CoordinationV1beta1Interface } +// CoordinationV1beta1ClusterClient is used to interact with features provided by the coordination.k8s.io group. type CoordinationV1beta1ClusterClient struct { clientCache kcpclient.Cache[*coordinationv1beta1.CoordinationV1beta1Client] } @@ -56,11 +60,13 @@ func (c *CoordinationV1beta1ClusterClient) Leases() LeaseClusterInterface { // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*CoordinationV1beta1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new CoordinationV1beta1ClusterClient for the given config and http client. @@ -72,6 +78,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*CoordinationV1beta1 if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &CoordinationV1beta1ClusterClient{clientCache: cache}, nil } @@ -84,3 +91,14 @@ func NewForConfigOrDie(c *rest.Config) *CoordinationV1beta1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apicoordinationv1beta1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/coordination/v1beta1/doc.go b/kubernetes/typed/coordination/v1beta1/doc.go new file mode 100644 index 000000000..541e9d258 --- /dev/null +++ b/kubernetes/typed/coordination/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1beta1 diff --git a/kubernetes/typed/coordination/v1beta1/fake/coordination_client.go b/kubernetes/typed/coordination/v1beta1/fake/coordination_client.go index 7e191fa13..2d1ea095e 100644 --- a/kubernetes/typed/coordination/v1beta1/fake/coordination_client.go +++ b/kubernetes/typed/coordination/v1beta1/fake/coordination_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" coordinationv1beta1 "k8s.io/client-go/kubernetes/typed/coordination/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpcoordinationv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/coordination/v1beta1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -42,21 +42,21 @@ func (c *CoordinationV1beta1ClusterClient) Cluster(clusterPath logicalcluster.Pa } func (c *CoordinationV1beta1ClusterClient) Leases() kcpcoordinationv1beta1.LeaseClusterInterface { - return &leasesClusterClient{Fake: c.Fake} + return newFakeLeaseClusterClient(c) } -var _ coordinationv1beta1.CoordinationV1beta1Interface = (*CoordinationV1beta1Client)(nil) - type CoordinationV1beta1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } +func (c *CoordinationV1beta1Client) Leases(namespace string) coordinationv1beta1.LeaseInterface { + return newFakeLeaseClient(c.Fake, namespace, c.ClusterPath) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. func (c *CoordinationV1beta1Client) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } - -func (c *CoordinationV1beta1Client) Leases(namespace string) coordinationv1beta1.LeaseInterface { - return &leasesClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} -} diff --git a/kubernetes/typed/coordination/v1beta1/fake/doc.go b/kubernetes/typed/coordination/v1beta1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/coordination/v1beta1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/coordination/v1beta1/fake/lease.go b/kubernetes/typed/coordination/v1beta1/fake/lease.go index 01936217d..dbbc5dd4a 100644 --- a/kubernetes/typed/coordination/v1beta1/fake/lease.go +++ b/kubernetes/typed/coordination/v1beta1/fake/lease.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" coordinationv1beta1 "k8s.io/api/coordination/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationscoordinationv1beta1 "k8s.io/client-go/applyconfigurations/coordination/v1beta1" - coordinationv1beta1client "k8s.io/client-go/kubernetes/typed/coordination/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/coordination/v1beta1" + typedcoordinationv1beta1 "k8s.io/client-go/kubernetes/typed/coordination/v1beta1" - kcpcoordinationv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/coordination/v1beta1" + typedkcpcoordinationv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/coordination/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var leasesResource = schema.GroupVersionResource{Group: "coordination.k8s.io", Version: "v1beta1", Resource: "leases"} -var leasesKind = schema.GroupVersionKind{Group: "coordination.k8s.io", Version: "v1beta1", Kind: "Lease"} - -type leasesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *leasesClusterClient) Cluster(clusterPath logicalcluster.Path) kcpcoordinationv1beta1.LeasesNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &leasesNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// leaseClusterClient implements LeaseClusterInterface +type leaseClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*coordinationv1beta1.Lease, *coordinationv1beta1.LeaseList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of Leases that match those selectors across all clusters. -func (c *leasesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*coordinationv1beta1.LeaseList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(leasesResource, leasesKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &coordinationv1beta1.LeaseList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeLeaseClusterClient(fake *CoordinationV1beta1ClusterClient) typedkcpcoordinationv1beta1.LeaseClusterInterface { + return &leaseClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*coordinationv1beta1.Lease, *coordinationv1beta1.LeaseList]( + fake.Fake, + coordinationv1beta1.SchemeGroupVersion.WithResource("leases"), + coordinationv1beta1.SchemeGroupVersion.WithKind("Lease"), + func() *coordinationv1beta1.Lease { return &coordinationv1beta1.Lease{} }, + func() *coordinationv1beta1.LeaseList { return &coordinationv1beta1.LeaseList{} }, + func(dst, src *coordinationv1beta1.LeaseList) { dst.ListMeta = src.ListMeta }, + func(list *coordinationv1beta1.LeaseList) []*coordinationv1beta1.Lease { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *coordinationv1beta1.LeaseList, items []*coordinationv1beta1.Lease) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &coordinationv1beta1.LeaseList{ListMeta: obj.(*coordinationv1beta1.LeaseList).ListMeta} - for _, item := range obj.(*coordinationv1beta1.LeaseList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested Leases across all clusters. -func (c *leasesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(leasesResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *leaseClusterClient) Cluster(cluster logicalcluster.Path) typedkcpcoordinationv1beta1.LeasesNamespacer { + return &leaseNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type leasesNamespacer struct { +type leaseNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *leasesNamespacer) Namespace(namespace string) coordinationv1beta1client.LeaseInterface { - return &leasesClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *leaseNamespacer) Namespace(namespace string) typedcoordinationv1beta1.LeaseInterface { + return newFakeLeaseClient(n.Fake, namespace, n.ClusterPath) } -type leasesClient struct { - *kcptesting.Fake +// leaseScopedClient implements LeaseInterface +type leaseScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*coordinationv1beta1.Lease, *coordinationv1beta1.LeaseList, *v1beta1.LeaseApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *leasesClient) Create(ctx context.Context, lease *coordinationv1beta1.Lease, opts metav1.CreateOptions) (*coordinationv1beta1.Lease, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(leasesResource, c.ClusterPath, c.Namespace, lease), &coordinationv1beta1.Lease{}) - if obj == nil { - return nil, err - } - return obj.(*coordinationv1beta1.Lease), err -} - -func (c *leasesClient) Update(ctx context.Context, lease *coordinationv1beta1.Lease, opts metav1.UpdateOptions) (*coordinationv1beta1.Lease, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(leasesResource, c.ClusterPath, c.Namespace, lease), &coordinationv1beta1.Lease{}) - if obj == nil { - return nil, err - } - return obj.(*coordinationv1beta1.Lease), err -} - -func (c *leasesClient) UpdateStatus(ctx context.Context, lease *coordinationv1beta1.Lease, opts metav1.UpdateOptions) (*coordinationv1beta1.Lease, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(leasesResource, c.ClusterPath, "status", c.Namespace, lease), &coordinationv1beta1.Lease{}) - if obj == nil { - return nil, err - } - return obj.(*coordinationv1beta1.Lease), err -} - -func (c *leasesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(leasesResource, c.ClusterPath, c.Namespace, name, opts), &coordinationv1beta1.Lease{}) - return err -} - -func (c *leasesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(leasesResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &coordinationv1beta1.LeaseList{}) - return err -} - -func (c *leasesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*coordinationv1beta1.Lease, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(leasesResource, c.ClusterPath, c.Namespace, name), &coordinationv1beta1.Lease{}) - if obj == nil { - return nil, err - } - return obj.(*coordinationv1beta1.Lease), err -} - -// List takes label and field selectors, and returns the list of Leases that match those selectors. -func (c *leasesClient) List(ctx context.Context, opts metav1.ListOptions) (*coordinationv1beta1.LeaseList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(leasesResource, leasesKind, c.ClusterPath, c.Namespace, opts), &coordinationv1beta1.LeaseList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &coordinationv1beta1.LeaseList{ListMeta: obj.(*coordinationv1beta1.LeaseList).ListMeta} - for _, item := range obj.(*coordinationv1beta1.LeaseList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *leasesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(leasesResource, c.ClusterPath, c.Namespace, opts)) } -func (c *leasesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*coordinationv1beta1.Lease, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(leasesResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &coordinationv1beta1.Lease{}) - if obj == nil { - return nil, err - } - return obj.(*coordinationv1beta1.Lease), err -} - -func (c *leasesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationscoordinationv1beta1.LeaseApplyConfiguration, opts metav1.ApplyOptions) (*coordinationv1beta1.Lease, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(leasesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &coordinationv1beta1.Lease{}) - if obj == nil { - return nil, err - } - return obj.(*coordinationv1beta1.Lease), err -} - -func (c *leasesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationscoordinationv1beta1.LeaseApplyConfiguration, opts metav1.ApplyOptions) (*coordinationv1beta1.Lease, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(leasesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &coordinationv1beta1.Lease{}) - if obj == nil { - return nil, err +func newFakeLeaseClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedcoordinationv1beta1.LeaseInterface { + return &leaseScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*coordinationv1beta1.Lease, *coordinationv1beta1.LeaseList, *v1beta1.LeaseApplyConfiguration]( + fake, + clusterPath, + namespace, + coordinationv1beta1.SchemeGroupVersion.WithResource("leases"), + coordinationv1beta1.SchemeGroupVersion.WithKind("Lease"), + func() *coordinationv1beta1.Lease { return &coordinationv1beta1.Lease{} }, + func() *coordinationv1beta1.LeaseList { return &coordinationv1beta1.LeaseList{} }, + func(dst, src *coordinationv1beta1.LeaseList) { dst.ListMeta = src.ListMeta }, + func(list *coordinationv1beta1.LeaseList) []*coordinationv1beta1.Lease { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *coordinationv1beta1.LeaseList, items []*coordinationv1beta1.Lease) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*coordinationv1beta1.Lease), err } diff --git a/kubernetes/typed/coordination/v1beta1/generated_expansion.go b/kubernetes/typed/coordination/v1beta1/generated_expansion.go new file mode 100644 index 000000000..a24ddd8c0 --- /dev/null +++ b/kubernetes/typed/coordination/v1beta1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1beta1 + +type LeaseClusterExpansion interface{} diff --git a/kubernetes/typed/coordination/v1beta1/lease.go b/kubernetes/typed/coordination/v1beta1/lease.go index c60cee1f2..4ff7f8ed6 100644 --- a/kubernetes/typed/coordination/v1beta1/lease.go +++ b/kubernetes/typed/coordination/v1beta1/lease.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" coordinationv1beta1 "k8s.io/api/coordination/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - coordinationv1beta1client "k8s.io/client-go/kubernetes/typed/coordination/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedcoordinationv1beta1 "k8s.io/client-go/kubernetes/typed/coordination/v1beta1" ) // LeasesClusterGetter has a method to return a LeaseClusterInterface. @@ -40,12 +40,13 @@ type LeasesClusterGetter interface { // or scope down to one cluster and return a LeasesNamespacer. type LeaseClusterInterface interface { Cluster(logicalcluster.Path) LeasesNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*coordinationv1beta1.LeaseList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*coordinationv1beta1.LeaseList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + LeaseClusterExpansion } type leasesClusterInterface struct { - clientCache kcpclient.Cache[*coordinationv1beta1client.CoordinationV1beta1Client] + clientCache kcpclient.Cache[*typedcoordinationv1beta1.CoordinationV1beta1Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *leasesClusterInterface) Cluster(clusterPath logicalcluster.Path) Leases } // List returns the entire collection of all Leases across all clusters. -func (c *leasesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*coordinationv1beta1.LeaseList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Leases(metav1.NamespaceAll).List(ctx, opts) +func (c *leasesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*coordinationv1beta1.LeaseList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Leases(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all Leases across all clusters. -func (c *leasesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Leases(metav1.NamespaceAll).Watch(ctx, opts) +func (c *leasesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Leases(v1.NamespaceAll).Watch(ctx, opts) } -// LeasesNamespacer can scope to objects within a namespace, returning a coordinationv1beta1client.LeaseInterface. +// LeasesNamespacer can scope to objects within a namespace, returning a typedcoordinationv1beta1.LeaseInterface. type LeasesNamespacer interface { - Namespace(string) coordinationv1beta1client.LeaseInterface + Namespace(string) typedcoordinationv1beta1.LeaseInterface } type leasesNamespacer struct { - clientCache kcpclient.Cache[*coordinationv1beta1client.CoordinationV1beta1Client] + clientCache kcpclient.Cache[*typedcoordinationv1beta1.CoordinationV1beta1Client] clusterPath logicalcluster.Path } -func (n *leasesNamespacer) Namespace(namespace string) coordinationv1beta1client.LeaseInterface { +func (n *leasesNamespacer) Namespace(namespace string) typedcoordinationv1beta1.LeaseInterface { return n.clientCache.ClusterOrDie(n.clusterPath).Leases(namespace) } diff --git a/kubernetes/typed/core/v1/componentstatus.go b/kubernetes/typed/core/v1/componentstatus.go index 6752cd27c..2d28e88b9 100644 --- a/kubernetes/typed/core/v1/componentstatus.go +++ b/kubernetes/typed/core/v1/componentstatus.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - corev1 "k8s.io/api/core/v1" + apicorev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" + watch "k8s.io/apimachinery/pkg/watch" + corev1 "k8s.io/client-go/kubernetes/typed/core/v1" ) // ComponentStatusesClusterGetter has a method to return a ComponentStatusClusterInterface. @@ -37,19 +37,20 @@ type ComponentStatusesClusterGetter interface { } // ComponentStatusClusterInterface can operate on ComponentStatuses across all clusters, -// or scope down to one cluster and return a corev1client.ComponentStatusInterface. +// or scope down to one cluster and return a corev1.ComponentStatusInterface. type ComponentStatusClusterInterface interface { - Cluster(logicalcluster.Path) corev1client.ComponentStatusInterface - List(ctx context.Context, opts metav1.ListOptions) (*corev1.ComponentStatusList, error) + Cluster(logicalcluster.Path) corev1.ComponentStatusInterface + List(ctx context.Context, opts metav1.ListOptions) (*apicorev1.ComponentStatusList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + ComponentStatusClusterExpansion } type componentStatusesClusterInterface struct { - clientCache kcpclient.Cache[*corev1client.CoreV1Client] + clientCache kcpclient.Cache[*corev1.CoreV1Client] } // Cluster scopes the client down to a particular cluster. -func (c *componentStatusesClusterInterface) Cluster(clusterPath logicalcluster.Path) corev1client.ComponentStatusInterface { +func (c *componentStatusesClusterInterface) Cluster(clusterPath logicalcluster.Path) corev1.ComponentStatusInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,7 +59,7 @@ func (c *componentStatusesClusterInterface) Cluster(clusterPath logicalcluster.P } // List returns the entire collection of all ComponentStatuses across all clusters. -func (c *componentStatusesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*corev1.ComponentStatusList, error) { +func (c *componentStatusesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*apicorev1.ComponentStatusList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ComponentStatuses().List(ctx, opts) } diff --git a/kubernetes/typed/core/v1/configmap.go b/kubernetes/typed/core/v1/configmap.go index f11136ac8..a9f0b4d76 100644 --- a/kubernetes/typed/core/v1/configmap.go +++ b/kubernetes/typed/core/v1/configmap.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" ) // ConfigMapsClusterGetter has a method to return a ConfigMapClusterInterface. @@ -42,10 +42,11 @@ type ConfigMapClusterInterface interface { Cluster(logicalcluster.Path) ConfigMapsNamespacer List(ctx context.Context, opts metav1.ListOptions) (*corev1.ConfigMapList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + ConfigMapClusterExpansion } type configMapsClusterInterface struct { - clientCache kcpclient.Cache[*corev1client.CoreV1Client] + clientCache kcpclient.Cache[*typedcorev1.CoreV1Client] } // Cluster scopes the client down to a particular cluster. @@ -67,16 +68,16 @@ func (c *configMapsClusterInterface) Watch(ctx context.Context, opts metav1.List return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ConfigMaps(metav1.NamespaceAll).Watch(ctx, opts) } -// ConfigMapsNamespacer can scope to objects within a namespace, returning a corev1client.ConfigMapInterface. +// ConfigMapsNamespacer can scope to objects within a namespace, returning a typedcorev1.ConfigMapInterface. type ConfigMapsNamespacer interface { - Namespace(string) corev1client.ConfigMapInterface + Namespace(string) typedcorev1.ConfigMapInterface } type configMapsNamespacer struct { - clientCache kcpclient.Cache[*corev1client.CoreV1Client] + clientCache kcpclient.Cache[*typedcorev1.CoreV1Client] clusterPath logicalcluster.Path } -func (n *configMapsNamespacer) Namespace(namespace string) corev1client.ConfigMapInterface { +func (n *configMapsNamespacer) Namespace(namespace string) typedcorev1.ConfigMapInterface { return n.clientCache.ClusterOrDie(n.clusterPath).ConfigMaps(namespace) } diff --git a/kubernetes/typed/core/v1/core_client.go b/kubernetes/typed/core/v1/core_client.go index d9c15e6ad..c4c5ce003 100644 --- a/kubernetes/typed/core/v1/core_client.go +++ b/kubernetes/typed/core/v1/core_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,44 +14,48 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apicorev1 "k8s.io/api/core/v1" corev1 "k8s.io/client-go/kubernetes/typed/core/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type CoreV1ClusterInterface interface { CoreV1ClusterScoper + ComponentStatusesClusterGetter + ConfigMapsClusterGetter + EndpointsClusterGetter + EventsClusterGetter + LimitRangesClusterGetter + NamespacesClusterGetter + NodesClusterGetter PersistentVolumesClusterGetter PersistentVolumeClaimsClusterGetter PodsClusterGetter PodTemplatesClusterGetter ReplicationControllersClusterGetter - ServicesClusterGetter - ServiceAccountsClusterGetter - EndpointsClusterGetter - NodesClusterGetter - NamespacesClusterGetter - EventsClusterGetter - LimitRangesClusterGetter ResourceQuotasClusterGetter SecretsClusterGetter - ConfigMapsClusterGetter - ComponentStatusesClusterGetter + ServicesClusterGetter + ServiceAccountsClusterGetter } type CoreV1ClusterScoper interface { Cluster(logicalcluster.Path) corev1.CoreV1Interface } +// CoreV1ClusterClient is used to interact with features provided by the group. type CoreV1ClusterClient struct { clientCache kcpclient.Cache[*corev1.CoreV1Client] } @@ -63,52 +67,52 @@ func (c *CoreV1ClusterClient) Cluster(clusterPath logicalcluster.Path) corev1.Co return c.clientCache.ClusterOrDie(clusterPath) } -func (c *CoreV1ClusterClient) PersistentVolumes() PersistentVolumeClusterInterface { - return &persistentVolumesClusterInterface{clientCache: c.clientCache} +func (c *CoreV1ClusterClient) ComponentStatuses() ComponentStatusClusterInterface { + return &componentStatusesClusterInterface{clientCache: c.clientCache} } -func (c *CoreV1ClusterClient) PersistentVolumeClaims() PersistentVolumeClaimClusterInterface { - return &persistentVolumeClaimsClusterInterface{clientCache: c.clientCache} +func (c *CoreV1ClusterClient) ConfigMaps() ConfigMapClusterInterface { + return &configMapsClusterInterface{clientCache: c.clientCache} } -func (c *CoreV1ClusterClient) Pods() PodClusterInterface { - return &podsClusterInterface{clientCache: c.clientCache} +func (c *CoreV1ClusterClient) Endpoints() EndpointsClusterInterface { + return &endpointsClusterInterface{clientCache: c.clientCache} } -func (c *CoreV1ClusterClient) PodTemplates() PodTemplateClusterInterface { - return &podTemplatesClusterInterface{clientCache: c.clientCache} +func (c *CoreV1ClusterClient) Events() EventClusterInterface { + return &eventsClusterInterface{clientCache: c.clientCache} } -func (c *CoreV1ClusterClient) ReplicationControllers() ReplicationControllerClusterInterface { - return &replicationControllersClusterInterface{clientCache: c.clientCache} +func (c *CoreV1ClusterClient) LimitRanges() LimitRangeClusterInterface { + return &limitRangesClusterInterface{clientCache: c.clientCache} } -func (c *CoreV1ClusterClient) Services() ServiceClusterInterface { - return &servicesClusterInterface{clientCache: c.clientCache} +func (c *CoreV1ClusterClient) Namespaces() NamespaceClusterInterface { + return &namespacesClusterInterface{clientCache: c.clientCache} } -func (c *CoreV1ClusterClient) ServiceAccounts() ServiceAccountClusterInterface { - return &serviceAccountsClusterInterface{clientCache: c.clientCache} +func (c *CoreV1ClusterClient) Nodes() NodeClusterInterface { + return &nodesClusterInterface{clientCache: c.clientCache} } -func (c *CoreV1ClusterClient) Endpoints() EndpointsClusterInterface { - return &endpointsClusterInterface{clientCache: c.clientCache} +func (c *CoreV1ClusterClient) PersistentVolumes() PersistentVolumeClusterInterface { + return &persistentVolumesClusterInterface{clientCache: c.clientCache} } -func (c *CoreV1ClusterClient) Nodes() NodeClusterInterface { - return &nodesClusterInterface{clientCache: c.clientCache} +func (c *CoreV1ClusterClient) PersistentVolumeClaims() PersistentVolumeClaimClusterInterface { + return &persistentVolumeClaimsClusterInterface{clientCache: c.clientCache} } -func (c *CoreV1ClusterClient) Namespaces() NamespaceClusterInterface { - return &namespacesClusterInterface{clientCache: c.clientCache} +func (c *CoreV1ClusterClient) Pods() PodClusterInterface { + return &podsClusterInterface{clientCache: c.clientCache} } -func (c *CoreV1ClusterClient) Events() EventClusterInterface { - return &eventsClusterInterface{clientCache: c.clientCache} +func (c *CoreV1ClusterClient) PodTemplates() PodTemplateClusterInterface { + return &podTemplatesClusterInterface{clientCache: c.clientCache} } -func (c *CoreV1ClusterClient) LimitRanges() LimitRangeClusterInterface { - return &limitRangesClusterInterface{clientCache: c.clientCache} +func (c *CoreV1ClusterClient) ReplicationControllers() ReplicationControllerClusterInterface { + return &replicationControllersClusterInterface{clientCache: c.clientCache} } func (c *CoreV1ClusterClient) ResourceQuotas() ResourceQuotaClusterInterface { @@ -119,23 +123,25 @@ func (c *CoreV1ClusterClient) Secrets() SecretClusterInterface { return &secretsClusterInterface{clientCache: c.clientCache} } -func (c *CoreV1ClusterClient) ConfigMaps() ConfigMapClusterInterface { - return &configMapsClusterInterface{clientCache: c.clientCache} +func (c *CoreV1ClusterClient) Services() ServiceClusterInterface { + return &servicesClusterInterface{clientCache: c.clientCache} } -func (c *CoreV1ClusterClient) ComponentStatuses() ComponentStatusClusterInterface { - return &componentStatusesClusterInterface{clientCache: c.clientCache} +func (c *CoreV1ClusterClient) ServiceAccounts() ServiceAccountClusterInterface { + return &serviceAccountsClusterInterface{clientCache: c.clientCache} } // NewForConfig creates a new CoreV1ClusterClient for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*CoreV1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new CoreV1ClusterClient for the given config and http client. @@ -147,6 +153,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*CoreV1ClusterClient if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &CoreV1ClusterClient{clientCache: cache}, nil } @@ -159,3 +166,14 @@ func NewForConfigOrDie(c *rest.Config) *CoreV1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apicorev1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/api" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/core/v1/doc.go b/kubernetes/typed/core/v1/doc.go new file mode 100644 index 000000000..d2f3412ab --- /dev/null +++ b/kubernetes/typed/core/v1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1 diff --git a/kubernetes/typed/core/v1/endpoints.go b/kubernetes/typed/core/v1/endpoints.go index dea4329f0..e98968eed 100644 --- a/kubernetes/typed/core/v1/endpoints.go +++ b/kubernetes/typed/core/v1/endpoints.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" ) // EndpointsClusterGetter has a method to return a EndpointsClusterInterface. @@ -42,10 +42,11 @@ type EndpointsClusterInterface interface { Cluster(logicalcluster.Path) EndpointsNamespacer List(ctx context.Context, opts metav1.ListOptions) (*corev1.EndpointsList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + EndpointsClusterExpansion } type endpointsClusterInterface struct { - clientCache kcpclient.Cache[*corev1client.CoreV1Client] + clientCache kcpclient.Cache[*typedcorev1.CoreV1Client] } // Cluster scopes the client down to a particular cluster. @@ -67,16 +68,16 @@ func (c *endpointsClusterInterface) Watch(ctx context.Context, opts metav1.ListO return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Endpoints(metav1.NamespaceAll).Watch(ctx, opts) } -// EndpointsNamespacer can scope to objects within a namespace, returning a corev1client.EndpointsInterface. +// EndpointsNamespacer can scope to objects within a namespace, returning a typedcorev1.EndpointsInterface. type EndpointsNamespacer interface { - Namespace(string) corev1client.EndpointsInterface + Namespace(string) typedcorev1.EndpointsInterface } type endpointsNamespacer struct { - clientCache kcpclient.Cache[*corev1client.CoreV1Client] + clientCache kcpclient.Cache[*typedcorev1.CoreV1Client] clusterPath logicalcluster.Path } -func (n *endpointsNamespacer) Namespace(namespace string) corev1client.EndpointsInterface { +func (n *endpointsNamespacer) Namespace(namespace string) typedcorev1.EndpointsInterface { return n.clientCache.ClusterOrDie(n.clusterPath).Endpoints(namespace) } diff --git a/kubernetes/typed/core/v1/event.go b/kubernetes/typed/core/v1/event.go index 881da1aa9..2c497a079 100644 --- a/kubernetes/typed/core/v1/event.go +++ b/kubernetes/typed/core/v1/event.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" ) // EventsClusterGetter has a method to return a EventClusterInterface. @@ -42,10 +42,11 @@ type EventClusterInterface interface { Cluster(logicalcluster.Path) EventsNamespacer List(ctx context.Context, opts metav1.ListOptions) (*corev1.EventList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + EventClusterExpansion } type eventsClusterInterface struct { - clientCache kcpclient.Cache[*corev1client.CoreV1Client] + clientCache kcpclient.Cache[*typedcorev1.CoreV1Client] } // Cluster scopes the client down to a particular cluster. @@ -67,16 +68,16 @@ func (c *eventsClusterInterface) Watch(ctx context.Context, opts metav1.ListOpti return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Events(metav1.NamespaceAll).Watch(ctx, opts) } -// EventsNamespacer can scope to objects within a namespace, returning a corev1client.EventInterface. +// EventsNamespacer can scope to objects within a namespace, returning a typedcorev1.EventInterface. type EventsNamespacer interface { - Namespace(string) corev1client.EventInterface + Namespace(string) typedcorev1.EventInterface } type eventsNamespacer struct { - clientCache kcpclient.Cache[*corev1client.CoreV1Client] + clientCache kcpclient.Cache[*typedcorev1.CoreV1Client] clusterPath logicalcluster.Path } -func (n *eventsNamespacer) Namespace(namespace string) corev1client.EventInterface { +func (n *eventsNamespacer) Namespace(namespace string) typedcorev1.EventInterface { return n.clientCache.ClusterOrDie(n.clusterPath).Events(namespace) } diff --git a/kubernetes/typed/core/v1/fake/componentstatus.go b/kubernetes/typed/core/v1/fake/componentstatus.go index 1b9e26028..d6dedf76c 100644 --- a/kubernetes/typed/core/v1/fake/componentstatus.go +++ b/kubernetes/typed/core/v1/fake/componentstatus.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationscorev1 "k8s.io/client-go/applyconfigurations/core/v1" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/core/v1" + typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" + typedkcpcorev1 "github.com/kcp-dev/client-go/kubernetes/typed/core/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var componentStatusesResource = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "componentstatuses"} -var componentStatusesKind = schema.GroupVersionKind{Group: "", Version: "v1", Kind: "ComponentStatus"} - -type componentStatusesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *componentStatusesClusterClient) Cluster(clusterPath logicalcluster.Path) corev1client.ComponentStatusInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &componentStatusesClient{Fake: c.Fake, ClusterPath: clusterPath} +// componentStatusClusterClient implements ComponentStatusClusterInterface +type componentStatusClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*corev1.ComponentStatus, *corev1.ComponentStatusList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of ComponentStatuses that match those selectors across all clusters. -func (c *componentStatusesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*corev1.ComponentStatusList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(componentStatusesResource, componentStatusesKind, logicalcluster.Wildcard, opts), &corev1.ComponentStatusList{}) - if obj == nil { - return nil, err +func newFakeComponentStatusClusterClient(fake *CoreV1ClusterClient) typedkcpcorev1.ComponentStatusClusterInterface { + return &componentStatusClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*corev1.ComponentStatus, *corev1.ComponentStatusList]( + fake.Fake, + corev1.SchemeGroupVersion.WithResource("componentstatuses"), + corev1.SchemeGroupVersion.WithKind("ComponentStatus"), + func() *corev1.ComponentStatus { return &corev1.ComponentStatus{} }, + func() *corev1.ComponentStatusList { return &corev1.ComponentStatusList{} }, + func(dst, src *corev1.ComponentStatusList) { dst.ListMeta = src.ListMeta }, + func(list *corev1.ComponentStatusList) []*corev1.ComponentStatus { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *corev1.ComponentStatusList, items []*corev1.ComponentStatus) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &corev1.ComponentStatusList{ListMeta: obj.(*corev1.ComponentStatusList).ListMeta} - for _, item := range obj.(*corev1.ComponentStatusList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested ComponentStatuses across all clusters. -func (c *componentStatusesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(componentStatusesResource, logicalcluster.Wildcard, opts)) +func (c *componentStatusClusterClient) Cluster(cluster logicalcluster.Path) typedcorev1.ComponentStatusInterface { + return newFakeComponentStatusClient(c.Fake, cluster) } -type componentStatusesClient struct { - *kcptesting.Fake +// componentStatusScopedClient implements ComponentStatusInterface +type componentStatusScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*corev1.ComponentStatus, *corev1.ComponentStatusList, *v1.ComponentStatusApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *componentStatusesClient) Create(ctx context.Context, componentStatus *corev1.ComponentStatus, opts metav1.CreateOptions) (*corev1.ComponentStatus, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(componentStatusesResource, c.ClusterPath, componentStatus), &corev1.ComponentStatus{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.ComponentStatus), err -} - -func (c *componentStatusesClient) Update(ctx context.Context, componentStatus *corev1.ComponentStatus, opts metav1.UpdateOptions) (*corev1.ComponentStatus, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(componentStatusesResource, c.ClusterPath, componentStatus), &corev1.ComponentStatus{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.ComponentStatus), err -} - -func (c *componentStatusesClient) UpdateStatus(ctx context.Context, componentStatus *corev1.ComponentStatus, opts metav1.UpdateOptions) (*corev1.ComponentStatus, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(componentStatusesResource, c.ClusterPath, "status", componentStatus), &corev1.ComponentStatus{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.ComponentStatus), err -} - -func (c *componentStatusesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(componentStatusesResource, c.ClusterPath, name, opts), &corev1.ComponentStatus{}) - return err -} - -func (c *componentStatusesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(componentStatusesResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &corev1.ComponentStatusList{}) - return err -} - -func (c *componentStatusesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*corev1.ComponentStatus, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(componentStatusesResource, c.ClusterPath, name), &corev1.ComponentStatus{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.ComponentStatus), err -} - -// List takes label and field selectors, and returns the list of ComponentStatuses that match those selectors. -func (c *componentStatusesClient) List(ctx context.Context, opts metav1.ListOptions) (*corev1.ComponentStatusList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(componentStatusesResource, componentStatusesKind, c.ClusterPath, opts), &corev1.ComponentStatusList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &corev1.ComponentStatusList{ListMeta: obj.(*corev1.ComponentStatusList).ListMeta} - for _, item := range obj.(*corev1.ComponentStatusList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *componentStatusesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(componentStatusesResource, c.ClusterPath, opts)) -} - -func (c *componentStatusesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*corev1.ComponentStatus, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(componentStatusesResource, c.ClusterPath, name, pt, data, subresources...), &corev1.ComponentStatus{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.ComponentStatus), err -} - -func (c *componentStatusesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationscorev1.ComponentStatusApplyConfiguration, opts metav1.ApplyOptions) (*corev1.ComponentStatus, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(componentStatusesResource, c.ClusterPath, *name, types.ApplyPatchType, data), &corev1.ComponentStatus{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.ComponentStatus), err -} - -func (c *componentStatusesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationscorev1.ComponentStatusApplyConfiguration, opts metav1.ApplyOptions) (*corev1.ComponentStatus, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(componentStatusesResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &corev1.ComponentStatus{}) - if obj == nil { - return nil, err +func newFakeComponentStatusClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedcorev1.ComponentStatusInterface { + return &componentStatusScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*corev1.ComponentStatus, *corev1.ComponentStatusList, *v1.ComponentStatusApplyConfiguration]( + fake, + clusterPath, + "", + corev1.SchemeGroupVersion.WithResource("componentstatuses"), + corev1.SchemeGroupVersion.WithKind("ComponentStatus"), + func() *corev1.ComponentStatus { return &corev1.ComponentStatus{} }, + func() *corev1.ComponentStatusList { return &corev1.ComponentStatusList{} }, + func(dst, src *corev1.ComponentStatusList) { dst.ListMeta = src.ListMeta }, + func(list *corev1.ComponentStatusList) []*corev1.ComponentStatus { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *corev1.ComponentStatusList, items []*corev1.ComponentStatus) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*corev1.ComponentStatus), err } diff --git a/kubernetes/typed/core/v1/fake/configmap.go b/kubernetes/typed/core/v1/fake/configmap.go index 527fcc672..81fbfddca 100644 --- a/kubernetes/typed/core/v1/fake/configmap.go +++ b/kubernetes/typed/core/v1/fake/configmap.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,83 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationscorev1 "k8s.io/client-go/applyconfigurations/core/v1" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/core/v1" + typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" - kcpcorev1 "github.com/kcp-dev/client-go/kubernetes/typed/core/v1" + typedkcpcorev1 "github.com/kcp-dev/client-go/kubernetes/typed/core/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var configMapsResource = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "configmaps"} -var configMapsKind = schema.GroupVersionKind{Group: "", Version: "v1", Kind: "ConfigMap"} - -type configMapsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *configMapsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpcorev1.ConfigMapsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &configMapsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// configMapClusterClient implements ConfigMapClusterInterface +type configMapClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*corev1.ConfigMap, *corev1.ConfigMapList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of ConfigMaps that match those selectors across all clusters. -func (c *configMapsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*corev1.ConfigMapList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(configMapsResource, configMapsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &corev1.ConfigMapList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeConfigMapClusterClient(fake *CoreV1ClusterClient) typedkcpcorev1.ConfigMapClusterInterface { + return &configMapClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*corev1.ConfigMap, *corev1.ConfigMapList]( + fake.Fake, + corev1.SchemeGroupVersion.WithResource("configmaps"), + corev1.SchemeGroupVersion.WithKind("ConfigMap"), + func() *corev1.ConfigMap { return &corev1.ConfigMap{} }, + func() *corev1.ConfigMapList { return &corev1.ConfigMapList{} }, + func(dst, src *corev1.ConfigMapList) { dst.ListMeta = src.ListMeta }, + func(list *corev1.ConfigMapList) []*corev1.ConfigMap { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *corev1.ConfigMapList, items []*corev1.ConfigMap) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &corev1.ConfigMapList{ListMeta: obj.(*corev1.ConfigMapList).ListMeta} - for _, item := range obj.(*corev1.ConfigMapList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested ConfigMaps across all clusters. -func (c *configMapsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(configMapsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *configMapClusterClient) Cluster(cluster logicalcluster.Path) typedkcpcorev1.ConfigMapsNamespacer { + return &configMapNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type configMapsNamespacer struct { +type configMapNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *configMapsNamespacer) Namespace(namespace string) corev1client.ConfigMapInterface { - return &configMapsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *configMapNamespacer) Namespace(namespace string) typedcorev1.ConfigMapInterface { + return newFakeConfigMapClient(n.Fake, namespace, n.ClusterPath) } -type configMapsClient struct { - *kcptesting.Fake +// configMapScopedClient implements ConfigMapInterface +type configMapScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*corev1.ConfigMap, *corev1.ConfigMapList, *v1.ConfigMapApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *configMapsClient) Create(ctx context.Context, configMap *corev1.ConfigMap, opts metav1.CreateOptions) (*corev1.ConfigMap, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(configMapsResource, c.ClusterPath, c.Namespace, configMap), &corev1.ConfigMap{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.ConfigMap), err -} - -func (c *configMapsClient) Update(ctx context.Context, configMap *corev1.ConfigMap, opts metav1.UpdateOptions) (*corev1.ConfigMap, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(configMapsResource, c.ClusterPath, c.Namespace, configMap), &corev1.ConfigMap{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.ConfigMap), err -} - -func (c *configMapsClient) UpdateStatus(ctx context.Context, configMap *corev1.ConfigMap, opts metav1.UpdateOptions) (*corev1.ConfigMap, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(configMapsResource, c.ClusterPath, "status", c.Namespace, configMap), &corev1.ConfigMap{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.ConfigMap), err -} - -func (c *configMapsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(configMapsResource, c.ClusterPath, c.Namespace, name, opts), &corev1.ConfigMap{}) - return err -} - -func (c *configMapsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(configMapsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &corev1.ConfigMapList{}) - return err -} - -func (c *configMapsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*corev1.ConfigMap, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(configMapsResource, c.ClusterPath, c.Namespace, name), &corev1.ConfigMap{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.ConfigMap), err -} - -// List takes label and field selectors, and returns the list of ConfigMaps that match those selectors. -func (c *configMapsClient) List(ctx context.Context, opts metav1.ListOptions) (*corev1.ConfigMapList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(configMapsResource, configMapsKind, c.ClusterPath, c.Namespace, opts), &corev1.ConfigMapList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &corev1.ConfigMapList{ListMeta: obj.(*corev1.ConfigMapList).ListMeta} - for _, item := range obj.(*corev1.ConfigMapList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *configMapsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(configMapsResource, c.ClusterPath, c.Namespace, opts)) } -func (c *configMapsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*corev1.ConfigMap, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(configMapsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &corev1.ConfigMap{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.ConfigMap), err -} - -func (c *configMapsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationscorev1.ConfigMapApplyConfiguration, opts metav1.ApplyOptions) (*corev1.ConfigMap, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(configMapsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &corev1.ConfigMap{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.ConfigMap), err -} - -func (c *configMapsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationscorev1.ConfigMapApplyConfiguration, opts metav1.ApplyOptions) (*corev1.ConfigMap, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(configMapsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &corev1.ConfigMap{}) - if obj == nil { - return nil, err +func newFakeConfigMapClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedcorev1.ConfigMapInterface { + return &configMapScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*corev1.ConfigMap, *corev1.ConfigMapList, *v1.ConfigMapApplyConfiguration]( + fake, + clusterPath, + namespace, + corev1.SchemeGroupVersion.WithResource("configmaps"), + corev1.SchemeGroupVersion.WithKind("ConfigMap"), + func() *corev1.ConfigMap { return &corev1.ConfigMap{} }, + func() *corev1.ConfigMapList { return &corev1.ConfigMapList{} }, + func(dst, src *corev1.ConfigMapList) { dst.ListMeta = src.ListMeta }, + func(list *corev1.ConfigMapList) []*corev1.ConfigMap { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *corev1.ConfigMapList, items []*corev1.ConfigMap) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*corev1.ConfigMap), err } diff --git a/kubernetes/typed/core/v1/fake/core_client.go b/kubernetes/typed/core/v1/fake/core_client.go index f913ac28c..d5ba317b2 100644 --- a/kubernetes/typed/core/v1/fake/core_client.go +++ b/kubernetes/typed/core/v1/fake/core_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/client-go/kubernetes/typed/core/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpcorev1 "github.com/kcp-dev/client-go/kubernetes/typed/core/v1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -41,142 +41,142 @@ func (c *CoreV1ClusterClient) Cluster(clusterPath logicalcluster.Path) corev1.Co return &CoreV1Client{Fake: c.Fake, ClusterPath: clusterPath} } -func (c *CoreV1ClusterClient) PersistentVolumes() kcpcorev1.PersistentVolumeClusterInterface { - return &persistentVolumesClusterClient{Fake: c.Fake} +func (c *CoreV1ClusterClient) ComponentStatuses() kcpcorev1.ComponentStatusClusterInterface { + return newFakeComponentStatusClusterClient(c) } -func (c *CoreV1ClusterClient) PersistentVolumeClaims() kcpcorev1.PersistentVolumeClaimClusterInterface { - return &persistentVolumeClaimsClusterClient{Fake: c.Fake} +func (c *CoreV1ClusterClient) ConfigMaps() kcpcorev1.ConfigMapClusterInterface { + return newFakeConfigMapClusterClient(c) } -func (c *CoreV1ClusterClient) Pods() kcpcorev1.PodClusterInterface { - return &podsClusterClient{Fake: c.Fake} +func (c *CoreV1ClusterClient) Endpoints() kcpcorev1.EndpointsClusterInterface { + return newFakeEndpointsClusterClient(c) } -func (c *CoreV1ClusterClient) PodTemplates() kcpcorev1.PodTemplateClusterInterface { - return &podTemplatesClusterClient{Fake: c.Fake} +func (c *CoreV1ClusterClient) Events() kcpcorev1.EventClusterInterface { + return newFakeEventClusterClient(c) } -func (c *CoreV1ClusterClient) ReplicationControllers() kcpcorev1.ReplicationControllerClusterInterface { - return &replicationControllersClusterClient{Fake: c.Fake} +func (c *CoreV1ClusterClient) LimitRanges() kcpcorev1.LimitRangeClusterInterface { + return newFakeLimitRangeClusterClient(c) } -func (c *CoreV1ClusterClient) Services() kcpcorev1.ServiceClusterInterface { - return &servicesClusterClient{Fake: c.Fake} +func (c *CoreV1ClusterClient) Namespaces() kcpcorev1.NamespaceClusterInterface { + return newFakeNamespaceClusterClient(c) } -func (c *CoreV1ClusterClient) ServiceAccounts() kcpcorev1.ServiceAccountClusterInterface { - return &serviceAccountsClusterClient{Fake: c.Fake} +func (c *CoreV1ClusterClient) Nodes() kcpcorev1.NodeClusterInterface { + return newFakeNodeClusterClient(c) } -func (c *CoreV1ClusterClient) Endpoints() kcpcorev1.EndpointsClusterInterface { - return &endpointsClusterClient{Fake: c.Fake} +func (c *CoreV1ClusterClient) PersistentVolumes() kcpcorev1.PersistentVolumeClusterInterface { + return newFakePersistentVolumeClusterClient(c) } -func (c *CoreV1ClusterClient) Nodes() kcpcorev1.NodeClusterInterface { - return &nodesClusterClient{Fake: c.Fake} +func (c *CoreV1ClusterClient) PersistentVolumeClaims() kcpcorev1.PersistentVolumeClaimClusterInterface { + return newFakePersistentVolumeClaimClusterClient(c) } -func (c *CoreV1ClusterClient) Namespaces() kcpcorev1.NamespaceClusterInterface { - return &namespacesClusterClient{Fake: c.Fake} +func (c *CoreV1ClusterClient) Pods() kcpcorev1.PodClusterInterface { + return newFakePodClusterClient(c) } -func (c *CoreV1ClusterClient) Events() kcpcorev1.EventClusterInterface { - return &eventsClusterClient{Fake: c.Fake} +func (c *CoreV1ClusterClient) PodTemplates() kcpcorev1.PodTemplateClusterInterface { + return newFakePodTemplateClusterClient(c) } -func (c *CoreV1ClusterClient) LimitRanges() kcpcorev1.LimitRangeClusterInterface { - return &limitRangesClusterClient{Fake: c.Fake} +func (c *CoreV1ClusterClient) ReplicationControllers() kcpcorev1.ReplicationControllerClusterInterface { + return newFakeReplicationControllerClusterClient(c) } func (c *CoreV1ClusterClient) ResourceQuotas() kcpcorev1.ResourceQuotaClusterInterface { - return &resourceQuotasClusterClient{Fake: c.Fake} + return newFakeResourceQuotaClusterClient(c) } func (c *CoreV1ClusterClient) Secrets() kcpcorev1.SecretClusterInterface { - return &secretsClusterClient{Fake: c.Fake} + return newFakeSecretClusterClient(c) } -func (c *CoreV1ClusterClient) ConfigMaps() kcpcorev1.ConfigMapClusterInterface { - return &configMapsClusterClient{Fake: c.Fake} +func (c *CoreV1ClusterClient) Services() kcpcorev1.ServiceClusterInterface { + return newFakeServiceClusterClient(c) } -func (c *CoreV1ClusterClient) ComponentStatuses() kcpcorev1.ComponentStatusClusterInterface { - return &componentStatusesClusterClient{Fake: c.Fake} +func (c *CoreV1ClusterClient) ServiceAccounts() kcpcorev1.ServiceAccountClusterInterface { + return newFakeServiceAccountClusterClient(c) } -var _ corev1.CoreV1Interface = (*CoreV1Client)(nil) - type CoreV1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *CoreV1Client) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret -} - -func (c *CoreV1Client) PersistentVolumes() corev1.PersistentVolumeInterface { - return &persistentVolumesClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +func (c *CoreV1Client) ComponentStatuses() corev1.ComponentStatusInterface { + return newFakeComponentStatusClient(c.Fake, c.ClusterPath) } -func (c *CoreV1Client) PersistentVolumeClaims(namespace string) corev1.PersistentVolumeClaimInterface { - return &persistentVolumeClaimsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *CoreV1Client) ConfigMaps(namespace string) corev1.ConfigMapInterface { + return newFakeConfigMapClient(c.Fake, namespace, c.ClusterPath) } -func (c *CoreV1Client) Pods(namespace string) corev1.PodInterface { - return &podsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *CoreV1Client) Endpoints(namespace string) corev1.EndpointsInterface { + return newFakeEndpointsClient(c.Fake, namespace, c.ClusterPath) } -func (c *CoreV1Client) PodTemplates(namespace string) corev1.PodTemplateInterface { - return &podTemplatesClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *CoreV1Client) Events(namespace string) corev1.EventInterface { + return newFakeEventClient(c.Fake, namespace, c.ClusterPath) } -func (c *CoreV1Client) ReplicationControllers(namespace string) corev1.ReplicationControllerInterface { - return &replicationControllersClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *CoreV1Client) LimitRanges(namespace string) corev1.LimitRangeInterface { + return newFakeLimitRangeClient(c.Fake, namespace, c.ClusterPath) } -func (c *CoreV1Client) Services(namespace string) corev1.ServiceInterface { - return &servicesClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *CoreV1Client) Namespaces() corev1.NamespaceInterface { + return newFakeNamespaceClient(c.Fake, c.ClusterPath) } -func (c *CoreV1Client) ServiceAccounts(namespace string) corev1.ServiceAccountInterface { - return &serviceAccountsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *CoreV1Client) Nodes() corev1.NodeInterface { + return newFakeNodeClient(c.Fake, c.ClusterPath) } -func (c *CoreV1Client) Endpoints(namespace string) corev1.EndpointsInterface { - return &endpointsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *CoreV1Client) PersistentVolumes() corev1.PersistentVolumeInterface { + return newFakePersistentVolumeClient(c.Fake, c.ClusterPath) } -func (c *CoreV1Client) Nodes() corev1.NodeInterface { - return &nodesClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +func (c *CoreV1Client) PersistentVolumeClaims(namespace string) corev1.PersistentVolumeClaimInterface { + return newFakePersistentVolumeClaimClient(c.Fake, namespace, c.ClusterPath) } -func (c *CoreV1Client) Namespaces() corev1.NamespaceInterface { - return &namespacesClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +func (c *CoreV1Client) Pods(namespace string) corev1.PodInterface { + return newFakePodClient(c.Fake, namespace, c.ClusterPath) } -func (c *CoreV1Client) Events(namespace string) corev1.EventInterface { - return &eventsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *CoreV1Client) PodTemplates(namespace string) corev1.PodTemplateInterface { + return newFakePodTemplateClient(c.Fake, namespace, c.ClusterPath) } -func (c *CoreV1Client) LimitRanges(namespace string) corev1.LimitRangeInterface { - return &limitRangesClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *CoreV1Client) ReplicationControllers(namespace string) corev1.ReplicationControllerInterface { + return newFakeReplicationControllerClient(c.Fake, namespace, c.ClusterPath) } func (c *CoreV1Client) ResourceQuotas(namespace string) corev1.ResourceQuotaInterface { - return &resourceQuotasClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} + return newFakeResourceQuotaClient(c.Fake, namespace, c.ClusterPath) } func (c *CoreV1Client) Secrets(namespace string) corev1.SecretInterface { - return &secretsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} + return newFakeSecretClient(c.Fake, namespace, c.ClusterPath) } -func (c *CoreV1Client) ConfigMaps(namespace string) corev1.ConfigMapInterface { - return &configMapsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *CoreV1Client) Services(namespace string) corev1.ServiceInterface { + return newFakeServiceClient(c.Fake, namespace, c.ClusterPath) } -func (c *CoreV1Client) ComponentStatuses() corev1.ComponentStatusInterface { - return &componentStatusesClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +func (c *CoreV1Client) ServiceAccounts(namespace string) corev1.ServiceAccountInterface { + return newFakeServiceAccountClient(c.Fake, namespace, c.ClusterPath) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *CoreV1Client) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret } diff --git a/kubernetes/typed/core/v1/fake/doc.go b/kubernetes/typed/core/v1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/core/v1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/core/v1/fake/endpoints.go b/kubernetes/typed/core/v1/fake/endpoints.go index 57e2bc731..8b6041b17 100644 --- a/kubernetes/typed/core/v1/fake/endpoints.go +++ b/kubernetes/typed/core/v1/fake/endpoints.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,70 +14,48 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationscorev1 "k8s.io/client-go/applyconfigurations/core/v1" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/core/v1" + typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" - kcpcorev1 "github.com/kcp-dev/client-go/kubernetes/typed/core/v1" + typedkcpcorev1 "github.com/kcp-dev/client-go/kubernetes/typed/core/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var endpointsResource = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "endpoints"} -var endpointsKind = schema.GroupVersionKind{Group: "", Version: "v1", Kind: "Endpoints"} - +// endpointsClusterClient implements EndpointsClusterInterface type endpointsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *endpointsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpcorev1.EndpointsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &endpointsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} + *kcpgentype.FakeClusterClientWithList[*corev1.Endpoints, *corev1.EndpointsList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of Endpoints that match those selectors across all clusters. -func (c *endpointsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*corev1.EndpointsList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(endpointsResource, endpointsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &corev1.EndpointsList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeEndpointsClusterClient(fake *CoreV1ClusterClient) typedkcpcorev1.EndpointsClusterInterface { + return &endpointsClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*corev1.Endpoints, *corev1.EndpointsList]( + fake.Fake, + corev1.SchemeGroupVersion.WithResource("endpoints"), + corev1.SchemeGroupVersion.WithKind("Endpoints"), + func() *corev1.Endpoints { return &corev1.Endpoints{} }, + func() *corev1.EndpointsList { return &corev1.EndpointsList{} }, + func(dst, src *corev1.EndpointsList) { dst.ListMeta = src.ListMeta }, + func(list *corev1.EndpointsList) []*corev1.Endpoints { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *corev1.EndpointsList, items []*corev1.Endpoints) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &corev1.EndpointsList{ListMeta: obj.(*corev1.EndpointsList).ListMeta} - for _, item := range obj.(*corev1.EndpointsList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested Endpoints across all clusters. -func (c *endpointsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(endpointsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *endpointsClusterClient) Cluster(cluster logicalcluster.Path) typedkcpcorev1.EndpointsNamespacer { + return &endpointsNamespacer{Fake: c.Fake, ClusterPath: cluster} } type endpointsNamespacer struct { @@ -85,126 +63,34 @@ type endpointsNamespacer struct { ClusterPath logicalcluster.Path } -func (n *endpointsNamespacer) Namespace(namespace string) corev1client.EndpointsInterface { - return &endpointsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *endpointsNamespacer) Namespace(namespace string) typedcorev1.EndpointsInterface { + return newFakeEndpointsClient(n.Fake, namespace, n.ClusterPath) } -type endpointsClient struct { - *kcptesting.Fake +// endpointsScopedClient implements EndpointsInterface +type endpointsScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*corev1.Endpoints, *corev1.EndpointsList, *v1.EndpointsApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *endpointsClient) Create(ctx context.Context, endpoints *corev1.Endpoints, opts metav1.CreateOptions) (*corev1.Endpoints, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(endpointsResource, c.ClusterPath, c.Namespace, endpoints), &corev1.Endpoints{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Endpoints), err -} - -func (c *endpointsClient) Update(ctx context.Context, endpoints *corev1.Endpoints, opts metav1.UpdateOptions) (*corev1.Endpoints, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(endpointsResource, c.ClusterPath, c.Namespace, endpoints), &corev1.Endpoints{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Endpoints), err -} - -func (c *endpointsClient) UpdateStatus(ctx context.Context, endpoints *corev1.Endpoints, opts metav1.UpdateOptions) (*corev1.Endpoints, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(endpointsResource, c.ClusterPath, "status", c.Namespace, endpoints), &corev1.Endpoints{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Endpoints), err -} - -func (c *endpointsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(endpointsResource, c.ClusterPath, c.Namespace, name, opts), &corev1.Endpoints{}) - return err -} - -func (c *endpointsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(endpointsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &corev1.EndpointsList{}) - return err -} - -func (c *endpointsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*corev1.Endpoints, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(endpointsResource, c.ClusterPath, c.Namespace, name), &corev1.Endpoints{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Endpoints), err -} - -// List takes label and field selectors, and returns the list of Endpoints that match those selectors. -func (c *endpointsClient) List(ctx context.Context, opts metav1.ListOptions) (*corev1.EndpointsList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(endpointsResource, endpointsKind, c.ClusterPath, c.Namespace, opts), &corev1.EndpointsList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &corev1.EndpointsList{ListMeta: obj.(*corev1.EndpointsList).ListMeta} - for _, item := range obj.(*corev1.EndpointsList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *endpointsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(endpointsResource, c.ClusterPath, c.Namespace, opts)) } -func (c *endpointsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*corev1.Endpoints, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(endpointsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &corev1.Endpoints{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Endpoints), err -} - -func (c *endpointsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationscorev1.EndpointsApplyConfiguration, opts metav1.ApplyOptions) (*corev1.Endpoints, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(endpointsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &corev1.Endpoints{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Endpoints), err -} - -func (c *endpointsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationscorev1.EndpointsApplyConfiguration, opts metav1.ApplyOptions) (*corev1.Endpoints, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(endpointsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &corev1.Endpoints{}) - if obj == nil { - return nil, err +func newFakeEndpointsClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedcorev1.EndpointsInterface { + return &endpointsScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*corev1.Endpoints, *corev1.EndpointsList, *v1.EndpointsApplyConfiguration]( + fake, + clusterPath, + namespace, + corev1.SchemeGroupVersion.WithResource("endpoints"), + corev1.SchemeGroupVersion.WithKind("Endpoints"), + func() *corev1.Endpoints { return &corev1.Endpoints{} }, + func() *corev1.EndpointsList { return &corev1.EndpointsList{} }, + func(dst, src *corev1.EndpointsList) { dst.ListMeta = src.ListMeta }, + func(list *corev1.EndpointsList) []*corev1.Endpoints { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *corev1.EndpointsList, items []*corev1.Endpoints) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*corev1.Endpoints), err } diff --git a/kubernetes/typed/core/v1/fake/event.go b/kubernetes/typed/core/v1/fake/event.go index 88f902952..43cfcf8f4 100644 --- a/kubernetes/typed/core/v1/fake/event.go +++ b/kubernetes/typed/core/v1/fake/event.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationscorev1 "k8s.io/client-go/applyconfigurations/core/v1" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/core/v1" + typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" - kcpcorev1 "github.com/kcp-dev/client-go/kubernetes/typed/core/v1" + typedkcpcorev1 "github.com/kcp-dev/client-go/kubernetes/typed/core/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var eventsResource = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "events"} -var eventsKind = schema.GroupVersionKind{Group: "", Version: "v1", Kind: "Event"} - -type eventsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *eventsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpcorev1.EventsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &eventsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// eventClusterClient implements EventClusterInterface +type eventClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*corev1.Event, *corev1.EventList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of Events that match those selectors across all clusters. -func (c *eventsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*corev1.EventList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(eventsResource, eventsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &corev1.EventList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeEventClusterClient(fake *CoreV1ClusterClient) typedkcpcorev1.EventClusterInterface { + return &eventClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*corev1.Event, *corev1.EventList]( + fake.Fake, + corev1.SchemeGroupVersion.WithResource("events"), + corev1.SchemeGroupVersion.WithKind("Event"), + func() *corev1.Event { return &corev1.Event{} }, + func() *corev1.EventList { return &corev1.EventList{} }, + func(dst, src *corev1.EventList) { dst.ListMeta = src.ListMeta }, + func(list *corev1.EventList) []*corev1.Event { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *corev1.EventList, items []*corev1.Event) { list.Items = kcpgentype.FromPointerSlice(items) }, + ), + fake.Fake, } - list := &corev1.EventList{ListMeta: obj.(*corev1.EventList).ListMeta} - for _, item := range obj.(*corev1.EventList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested Events across all clusters. -func (c *eventsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(eventsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *eventClusterClient) Cluster(cluster logicalcluster.Path) typedkcpcorev1.EventsNamespacer { + return &eventNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type eventsNamespacer struct { +type eventNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *eventsNamespacer) Namespace(namespace string) corev1client.EventInterface { - return &eventsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *eventNamespacer) Namespace(namespace string) typedcorev1.EventInterface { + return newFakeEventClient(n.Fake, namespace, n.ClusterPath) } -type eventsClient struct { - *kcptesting.Fake +// eventScopedClient implements EventInterface +type eventScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*corev1.Event, *corev1.EventList, *v1.EventApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *eventsClient) Create(ctx context.Context, event *corev1.Event, opts metav1.CreateOptions) (*corev1.Event, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(eventsResource, c.ClusterPath, c.Namespace, event), &corev1.Event{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Event), err -} - -func (c *eventsClient) Update(ctx context.Context, event *corev1.Event, opts metav1.UpdateOptions) (*corev1.Event, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(eventsResource, c.ClusterPath, c.Namespace, event), &corev1.Event{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Event), err -} - -func (c *eventsClient) UpdateStatus(ctx context.Context, event *corev1.Event, opts metav1.UpdateOptions) (*corev1.Event, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(eventsResource, c.ClusterPath, "status", c.Namespace, event), &corev1.Event{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Event), err -} - -func (c *eventsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(eventsResource, c.ClusterPath, c.Namespace, name, opts), &corev1.Event{}) - return err -} - -func (c *eventsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(eventsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &corev1.EventList{}) - return err -} - -func (c *eventsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*corev1.Event, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(eventsResource, c.ClusterPath, c.Namespace, name), &corev1.Event{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Event), err -} - -// List takes label and field selectors, and returns the list of Events that match those selectors. -func (c *eventsClient) List(ctx context.Context, opts metav1.ListOptions) (*corev1.EventList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(eventsResource, eventsKind, c.ClusterPath, c.Namespace, opts), &corev1.EventList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &corev1.EventList{ListMeta: obj.(*corev1.EventList).ListMeta} - for _, item := range obj.(*corev1.EventList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *eventsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(eventsResource, c.ClusterPath, c.Namespace, opts)) } -func (c *eventsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*corev1.Event, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(eventsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &corev1.Event{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Event), err -} - -func (c *eventsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationscorev1.EventApplyConfiguration, opts metav1.ApplyOptions) (*corev1.Event, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(eventsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &corev1.Event{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Event), err -} - -func (c *eventsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationscorev1.EventApplyConfiguration, opts metav1.ApplyOptions) (*corev1.Event, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(eventsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &corev1.Event{}) - if obj == nil { - return nil, err +func newFakeEventClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedcorev1.EventInterface { + return &eventScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*corev1.Event, *corev1.EventList, *v1.EventApplyConfiguration]( + fake, + clusterPath, + namespace, + corev1.SchemeGroupVersion.WithResource("events"), + corev1.SchemeGroupVersion.WithKind("Event"), + func() *corev1.Event { return &corev1.Event{} }, + func() *corev1.EventList { return &corev1.EventList{} }, + func(dst, src *corev1.EventList) { dst.ListMeta = src.ListMeta }, + func(list *corev1.EventList) []*corev1.Event { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *corev1.EventList, items []*corev1.Event) { list.Items = kcpgentype.FromPointerSlice(items) }, + ), + fake, + clusterPath, } - return obj.(*corev1.Event), err } diff --git a/kubernetes/typed/core/v1/fake/fake_event_expansion.go b/kubernetes/typed/core/v1/fake/fake_event_expansion.go index 314a0aaf9..a5e10d675 100644 --- a/kubernetes/typed/core/v1/fake/fake_event_expansion.go +++ b/kubernetes/typed/core/v1/fake/fake_event_expansion.go @@ -18,19 +18,23 @@ limitations under the License. package fake import ( - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" core "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -func (c *eventsClient) CreateWithEventNamespace(event *v1.Event) (*v1.Event, error) { +var eventsResource = schema.GroupVersionResource{Group: "events.k8s.io", Version: "v1beta1", Resource: "events"} +var eventsKind = schema.GroupVersionKind{Group: "events.k8s.io", Version: "v1beta1", Kind: "Event"} + +func (c *eventScopedClient) CreateWithEventNamespace(event *v1.Event) (*v1.Event, error) { action := core.NewRootCreateAction(eventsResource, c.ClusterPath, event) - if c.Namespace != "" { - action = core.NewCreateAction(eventsResource, c.ClusterPath, c.Namespace, event) + if c.Namespace() != "" { + action = core.NewCreateAction(eventsResource, c.ClusterPath, c.Namespace(), event) } obj, err := c.Fake.Invokes(action, event) if obj == nil { @@ -41,10 +45,10 @@ func (c *eventsClient) CreateWithEventNamespace(event *v1.Event) (*v1.Event, err } // Update replaces an existing event. Returns the copy of the event the server returns, or an error. -func (c *eventsClient) UpdateWithEventNamespace(event *v1.Event) (*v1.Event, error) { +func (c *eventScopedClient) UpdateWithEventNamespace(event *v1.Event) (*v1.Event, error) { action := core.NewRootUpdateAction(eventsResource, c.ClusterPath, event) - if c.Namespace != "" { - action = core.NewUpdateAction(eventsResource, c.ClusterPath, c.Namespace, event) + if c.Namespace() != "" { + action = core.NewUpdateAction(eventsResource, c.ClusterPath, c.Namespace(), event) } obj, err := c.Fake.Invokes(action, event) if obj == nil { @@ -56,12 +60,12 @@ func (c *eventsClient) UpdateWithEventNamespace(event *v1.Event) (*v1.Event, err // PatchWithEventNamespace patches an existing event. Returns the copy of the event the server returns, or an error. // TODO: Should take a PatchType as an argument probably. -func (c *eventsClient) PatchWithEventNamespace(event *v1.Event, data []byte) (*v1.Event, error) { +func (c *eventScopedClient) PatchWithEventNamespace(event *v1.Event, data []byte) (*v1.Event, error) { // TODO: Should be configurable to support additional patch strategies. pt := types.StrategicMergePatchType action := core.NewRootPatchAction(eventsResource, c.ClusterPath, event.Name, pt, data) - if c.Namespace != "" { - action = core.NewPatchAction(eventsResource, c.ClusterPath, c.Namespace, event.Name, pt, data) + if c.Namespace() != "" { + action = core.NewPatchAction(eventsResource, c.ClusterPath, c.Namespace(), event.Name, pt, data) } obj, err := c.Fake.Invokes(action, event) if obj == nil { @@ -72,10 +76,10 @@ func (c *eventsClient) PatchWithEventNamespace(event *v1.Event, data []byte) (*v } // Search returns a list of events matching the specified object. -func (c *eventsClient) Search(scheme *runtime.Scheme, objOrRef runtime.Object) (*v1.EventList, error) { +func (c *eventScopedClient) Search(scheme *runtime.Scheme, objOrRef runtime.Object) (*v1.EventList, error) { action := core.NewRootListAction(eventsResource, eventsKind, c.ClusterPath, metav1.ListOptions{}) - if c.Namespace != "" { - action = core.NewListAction(eventsResource, eventsKind, c.ClusterPath, c.Namespace, metav1.ListOptions{}) + if c.Namespace() != "" { + action = core.NewListAction(eventsResource, eventsKind, c.ClusterPath, c.Namespace(), metav1.ListOptions{}) } obj, err := c.Fake.Invokes(action, &v1.EventList{}) if obj == nil { @@ -85,7 +89,7 @@ func (c *eventsClient) Search(scheme *runtime.Scheme, objOrRef runtime.Object) ( return obj.(*v1.EventList), err } -func (c *eventsClient) GetFieldSelector(involvedObjectName, involvedObjectNamespace, involvedObjectKind, involvedObjectUID *string) fields.Selector { +func (c *eventScopedClient) GetFieldSelector(involvedObjectName, involvedObjectNamespace, involvedObjectKind, involvedObjectUID *string) fields.Selector { action := core.GenericActionImpl{} action.Verb = "get-field-selector" action.Resource = eventsResource diff --git a/kubernetes/typed/core/v1/fake/fake_namespace_expansion.go b/kubernetes/typed/core/v1/fake/fake_namespace_expansion.go index c785a2fc9..1f14e7aca 100644 --- a/kubernetes/typed/core/v1/fake/fake_namespace_expansion.go +++ b/kubernetes/typed/core/v1/fake/fake_namespace_expansion.go @@ -20,13 +20,16 @@ package fake import ( "context" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" core "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -func (c *namespacesClient) Finalize(ctx context.Context, namespace *v1.Namespace, opts metav1.UpdateOptions) (*v1.Namespace, error) { +var namespacesResource = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "namespaces"} + +func (c *namespaceScopedClient) Finalize(ctx context.Context, namespace *v1.Namespace, opts metav1.UpdateOptions) (*v1.Namespace, error) { action := core.CreateActionImpl{} action.Verb = "create" action.Resource = namespacesResource diff --git a/kubernetes/typed/core/v1/fake/fake_node_expansion.go b/kubernetes/typed/core/v1/fake/fake_node_expansion.go index 2dca4d0d2..b17d6adda 100644 --- a/kubernetes/typed/core/v1/fake/fake_node_expansion.go +++ b/kubernetes/typed/core/v1/fake/fake_node_expansion.go @@ -21,13 +21,16 @@ import ( "context" v1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" core "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) +var nodesResource = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "nodes"} + // TODO: Should take a PatchType as an argument probably. -func (c *nodesClient) PatchStatus(_ context.Context, nodeName string, data []byte) (*v1.Node, error) { +func (c *nodeScopedClient) PatchStatus(_ context.Context, nodeName string, data []byte) (*v1.Node, error) { // TODO: Should be configurable to support additional patch strategies. pt := types.StrategicMergePatchType obj, err := c.Fake.Invokes(core.NewRootPatchSubresourceAction(nodesResource, c.ClusterPath, nodeName, pt, data, "status"), &v1.Node{}) diff --git a/kubernetes/typed/core/v1/fake/fake_pod_expansion.go b/kubernetes/typed/core/v1/fake/fake_pod_expansion.go index e171f1d91..a770334ed 100644 --- a/kubernetes/typed/core/v1/fake/fake_pod_expansion.go +++ b/kubernetes/typed/core/v1/fake/fake_pod_expansion.go @@ -28,6 +28,7 @@ import ( policyv1 "k8s.io/api/policy/v1" policyv1beta1 "k8s.io/api/policy/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/kubernetes/scheme" restclient "k8s.io/client-go/rest" fakerest "k8s.io/client-go/rest/fake" @@ -35,7 +36,10 @@ import ( core "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -func (c *podsClient) Bind(ctx context.Context, binding *v1.Binding, opts metav1.CreateOptions) error { +var podsResource = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "pods"} +var podsKind = schema.GroupVersionKind{Group: "", Version: "v1", Kind: "Pod"} + +func (c *podScopedClient) Bind(ctx context.Context, binding *v1.Binding, opts metav1.CreateOptions) error { action := core.CreateActionImpl{} action.Verb = "create" action.Namespace = binding.Namespace @@ -48,9 +52,9 @@ func (c *podsClient) Bind(ctx context.Context, binding *v1.Binding, opts metav1. return err } -func (c *podsClient) GetBinding(name string) (result *v1.Binding, err error) { +func (c *podScopedClient) GetBinding(name string) (result *v1.Binding, err error) { obj, err := c.Fake. - Invokes(core.NewGetSubresourceAction(podsResource, c.ClusterPath, c.Namespace, "binding", name), &v1.Binding{}) + Invokes(core.NewGetSubresourceAction(podsResource, c.ClusterPath, c.Namespace(), "binding", name), &v1.Binding{}) if obj == nil { return nil, err @@ -58,10 +62,10 @@ func (c *podsClient) GetBinding(name string) (result *v1.Binding, err error) { return obj.(*v1.Binding), err } -func (c *podsClient) GetLogs(name string, opts *v1.PodLogOptions) *restclient.Request { +func (c *podScopedClient) GetLogs(name string, opts *v1.PodLogOptions) *restclient.Request { action := core.GenericActionImpl{} action.Verb = "get" - action.Namespace = c.Namespace + action.Namespace = c.Namespace() action.Resource = podsResource action.Subresource = "log" action.Value = opts @@ -78,19 +82,19 @@ func (c *podsClient) GetLogs(name string, opts *v1.PodLogOptions) *restclient.Re }), NegotiatedSerializer: scheme.Codecs.WithoutConversion(), GroupVersion: podsKind.GroupVersion(), - VersionedAPIPath: fmt.Sprintf("/api/v1/namespaces/%s/pods/%s/log", c.Namespace, name), + VersionedAPIPath: fmt.Sprintf("/api/v1/namespaces/%s/pods/%s/log", c.Namespace(), name), } return fakeClient.Request() } -func (c *podsClient) Evict(ctx context.Context, eviction *policyv1beta1.Eviction) error { +func (c *podScopedClient) Evict(ctx context.Context, eviction *policyv1beta1.Eviction) error { return c.EvictV1beta1(ctx, eviction) } -func (c *podsClient) EvictV1(ctx context.Context, eviction *policyv1.Eviction) error { +func (c *podScopedClient) EvictV1(ctx context.Context, eviction *policyv1.Eviction) error { action := core.CreateActionImpl{} action.Verb = "create" - action.Namespace = c.Namespace + action.Namespace = c.Namespace() action.Resource = podsResource action.Subresource = "eviction" action.Object = eviction @@ -100,10 +104,10 @@ func (c *podsClient) EvictV1(ctx context.Context, eviction *policyv1.Eviction) e return err } -func (c *podsClient) EvictV1beta1(ctx context.Context, eviction *policyv1beta1.Eviction) error { +func (c *podScopedClient) EvictV1beta1(ctx context.Context, eviction *policyv1beta1.Eviction) error { action := core.CreateActionImpl{} action.Verb = "create" - action.Namespace = c.Namespace + action.Namespace = c.Namespace() action.Resource = podsResource action.Subresource = "eviction" action.Object = eviction @@ -113,6 +117,6 @@ func (c *podsClient) EvictV1beta1(ctx context.Context, eviction *policyv1beta1.E return err } -func (c *podsClient) ProxyGet(scheme, name, port, path string, params map[string]string) restclient.ResponseWrapper { - return c.Fake.InvokesProxy(core.NewProxyGetAction(podsResource, c.ClusterPath, c.Namespace, scheme, name, port, path, params)) +func (c *podScopedClient) ProxyGet(scheme, name, port, path string, params map[string]string) restclient.ResponseWrapper { + return c.Fake.InvokesProxy(core.NewProxyGetAction(podsResource, c.ClusterPath, c.Namespace(), scheme, name, port, path, params)) } diff --git a/kubernetes/typed/core/v1/fake/fake_service_expansion.go b/kubernetes/typed/core/v1/fake/fake_service_expansion.go index d59af2eba..506c30bfe 100644 --- a/kubernetes/typed/core/v1/fake/fake_service_expansion.go +++ b/kubernetes/typed/core/v1/fake/fake_service_expansion.go @@ -18,11 +18,14 @@ limitations under the License. package fake import ( + "k8s.io/apimachinery/pkg/runtime/schema" restclient "k8s.io/client-go/rest" core "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -func (c *servicesClient) ProxyGet(scheme, name, port, path string, params map[string]string) restclient.ResponseWrapper { - return c.Fake.InvokesProxy(core.NewProxyGetAction(servicesResource, c.ClusterPath, c.Namespace, scheme, name, port, path, params)) +var servicesResource = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "services"} + +func (c *serviceScopedClient) ProxyGet(scheme, name, port, path string, params map[string]string) restclient.ResponseWrapper { + return c.Fake.InvokesProxy(core.NewProxyGetAction(servicesResource, c.ClusterPath, c.Namespace(), scheme, name, port, path, params)) } diff --git a/kubernetes/typed/core/v1/fake/limitrange.go b/kubernetes/typed/core/v1/fake/limitrange.go index 4e80eba4f..a8cd9154e 100644 --- a/kubernetes/typed/core/v1/fake/limitrange.go +++ b/kubernetes/typed/core/v1/fake/limitrange.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,83 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationscorev1 "k8s.io/client-go/applyconfigurations/core/v1" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/core/v1" + typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" - kcpcorev1 "github.com/kcp-dev/client-go/kubernetes/typed/core/v1" + typedkcpcorev1 "github.com/kcp-dev/client-go/kubernetes/typed/core/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var limitRangesResource = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "limitranges"} -var limitRangesKind = schema.GroupVersionKind{Group: "", Version: "v1", Kind: "LimitRange"} - -type limitRangesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *limitRangesClusterClient) Cluster(clusterPath logicalcluster.Path) kcpcorev1.LimitRangesNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &limitRangesNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// limitRangeClusterClient implements LimitRangeClusterInterface +type limitRangeClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*corev1.LimitRange, *corev1.LimitRangeList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of LimitRanges that match those selectors across all clusters. -func (c *limitRangesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*corev1.LimitRangeList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(limitRangesResource, limitRangesKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &corev1.LimitRangeList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeLimitRangeClusterClient(fake *CoreV1ClusterClient) typedkcpcorev1.LimitRangeClusterInterface { + return &limitRangeClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*corev1.LimitRange, *corev1.LimitRangeList]( + fake.Fake, + corev1.SchemeGroupVersion.WithResource("limitranges"), + corev1.SchemeGroupVersion.WithKind("LimitRange"), + func() *corev1.LimitRange { return &corev1.LimitRange{} }, + func() *corev1.LimitRangeList { return &corev1.LimitRangeList{} }, + func(dst, src *corev1.LimitRangeList) { dst.ListMeta = src.ListMeta }, + func(list *corev1.LimitRangeList) []*corev1.LimitRange { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *corev1.LimitRangeList, items []*corev1.LimitRange) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &corev1.LimitRangeList{ListMeta: obj.(*corev1.LimitRangeList).ListMeta} - for _, item := range obj.(*corev1.LimitRangeList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested LimitRanges across all clusters. -func (c *limitRangesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(limitRangesResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *limitRangeClusterClient) Cluster(cluster logicalcluster.Path) typedkcpcorev1.LimitRangesNamespacer { + return &limitRangeNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type limitRangesNamespacer struct { +type limitRangeNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *limitRangesNamespacer) Namespace(namespace string) corev1client.LimitRangeInterface { - return &limitRangesClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *limitRangeNamespacer) Namespace(namespace string) typedcorev1.LimitRangeInterface { + return newFakeLimitRangeClient(n.Fake, namespace, n.ClusterPath) } -type limitRangesClient struct { - *kcptesting.Fake +// limitRangeScopedClient implements LimitRangeInterface +type limitRangeScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*corev1.LimitRange, *corev1.LimitRangeList, *v1.LimitRangeApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *limitRangesClient) Create(ctx context.Context, limitRange *corev1.LimitRange, opts metav1.CreateOptions) (*corev1.LimitRange, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(limitRangesResource, c.ClusterPath, c.Namespace, limitRange), &corev1.LimitRange{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.LimitRange), err -} - -func (c *limitRangesClient) Update(ctx context.Context, limitRange *corev1.LimitRange, opts metav1.UpdateOptions) (*corev1.LimitRange, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(limitRangesResource, c.ClusterPath, c.Namespace, limitRange), &corev1.LimitRange{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.LimitRange), err -} - -func (c *limitRangesClient) UpdateStatus(ctx context.Context, limitRange *corev1.LimitRange, opts metav1.UpdateOptions) (*corev1.LimitRange, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(limitRangesResource, c.ClusterPath, "status", c.Namespace, limitRange), &corev1.LimitRange{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.LimitRange), err -} - -func (c *limitRangesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(limitRangesResource, c.ClusterPath, c.Namespace, name, opts), &corev1.LimitRange{}) - return err -} - -func (c *limitRangesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(limitRangesResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &corev1.LimitRangeList{}) - return err -} - -func (c *limitRangesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*corev1.LimitRange, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(limitRangesResource, c.ClusterPath, c.Namespace, name), &corev1.LimitRange{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.LimitRange), err -} - -// List takes label and field selectors, and returns the list of LimitRanges that match those selectors. -func (c *limitRangesClient) List(ctx context.Context, opts metav1.ListOptions) (*corev1.LimitRangeList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(limitRangesResource, limitRangesKind, c.ClusterPath, c.Namespace, opts), &corev1.LimitRangeList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &corev1.LimitRangeList{ListMeta: obj.(*corev1.LimitRangeList).ListMeta} - for _, item := range obj.(*corev1.LimitRangeList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *limitRangesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(limitRangesResource, c.ClusterPath, c.Namespace, opts)) } -func (c *limitRangesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*corev1.LimitRange, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(limitRangesResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &corev1.LimitRange{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.LimitRange), err -} - -func (c *limitRangesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationscorev1.LimitRangeApplyConfiguration, opts metav1.ApplyOptions) (*corev1.LimitRange, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(limitRangesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &corev1.LimitRange{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.LimitRange), err -} - -func (c *limitRangesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationscorev1.LimitRangeApplyConfiguration, opts metav1.ApplyOptions) (*corev1.LimitRange, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(limitRangesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &corev1.LimitRange{}) - if obj == nil { - return nil, err +func newFakeLimitRangeClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedcorev1.LimitRangeInterface { + return &limitRangeScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*corev1.LimitRange, *corev1.LimitRangeList, *v1.LimitRangeApplyConfiguration]( + fake, + clusterPath, + namespace, + corev1.SchemeGroupVersion.WithResource("limitranges"), + corev1.SchemeGroupVersion.WithKind("LimitRange"), + func() *corev1.LimitRange { return &corev1.LimitRange{} }, + func() *corev1.LimitRangeList { return &corev1.LimitRangeList{} }, + func(dst, src *corev1.LimitRangeList) { dst.ListMeta = src.ListMeta }, + func(list *corev1.LimitRangeList) []*corev1.LimitRange { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *corev1.LimitRangeList, items []*corev1.LimitRange) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*corev1.LimitRange), err } diff --git a/kubernetes/typed/core/v1/fake/namespace.go b/kubernetes/typed/core/v1/fake/namespace.go index 2380aa351..e249b59a7 100644 --- a/kubernetes/typed/core/v1/fake/namespace.go +++ b/kubernetes/typed/core/v1/fake/namespace.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,179 +14,74 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationscorev1 "k8s.io/client-go/applyconfigurations/core/v1" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/core/v1" + typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" + typedkcpcorev1 "github.com/kcp-dev/client-go/kubernetes/typed/core/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var namespacesResource = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "namespaces"} -var namespacesKind = schema.GroupVersionKind{Group: "", Version: "v1", Kind: "Namespace"} - -type namespacesClusterClient struct { - *kcptesting.Fake +// namespaceClusterClient implements NamespaceClusterInterface +type namespaceClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*corev1.Namespace, *corev1.NamespaceList] + Fake *kcptesting.Fake } -// Cluster scopes the client down to a particular cluster. -func (c *namespacesClusterClient) Cluster(clusterPath logicalcluster.Path) corev1client.NamespaceInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") +func newFakeNamespaceClusterClient(fake *CoreV1ClusterClient) typedkcpcorev1.NamespaceClusterInterface { + return &namespaceClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*corev1.Namespace, *corev1.NamespaceList]( + fake.Fake, + corev1.SchemeGroupVersion.WithResource("namespaces"), + corev1.SchemeGroupVersion.WithKind("Namespace"), + func() *corev1.Namespace { return &corev1.Namespace{} }, + func() *corev1.NamespaceList { return &corev1.NamespaceList{} }, + func(dst, src *corev1.NamespaceList) { dst.ListMeta = src.ListMeta }, + func(list *corev1.NamespaceList) []*corev1.Namespace { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *corev1.NamespaceList, items []*corev1.Namespace) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - return &namespacesClient{Fake: c.Fake, ClusterPath: clusterPath} } -// List takes label and field selectors, and returns the list of Namespaces that match those selectors across all clusters. -func (c *namespacesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*corev1.NamespaceList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(namespacesResource, namespacesKind, logicalcluster.Wildcard, opts), &corev1.NamespaceList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &corev1.NamespaceList{ListMeta: obj.(*corev1.NamespaceList).ListMeta} - for _, item := range obj.(*corev1.NamespaceList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested Namespaces across all clusters. -func (c *namespacesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(namespacesResource, logicalcluster.Wildcard, opts)) +func (c *namespaceClusterClient) Cluster(cluster logicalcluster.Path) typedcorev1.NamespaceInterface { + return newFakeNamespaceClient(c.Fake, cluster) } -type namespacesClient struct { - *kcptesting.Fake +// namespaceScopedClient implements NamespaceInterface +type namespaceScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*corev1.Namespace, *corev1.NamespaceList, *v1.NamespaceApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *namespacesClient) Create(ctx context.Context, namespace *corev1.Namespace, opts metav1.CreateOptions) (*corev1.Namespace, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(namespacesResource, c.ClusterPath, namespace), &corev1.Namespace{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Namespace), err -} - -func (c *namespacesClient) Update(ctx context.Context, namespace *corev1.Namespace, opts metav1.UpdateOptions) (*corev1.Namespace, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(namespacesResource, c.ClusterPath, namespace), &corev1.Namespace{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Namespace), err -} - -func (c *namespacesClient) UpdateStatus(ctx context.Context, namespace *corev1.Namespace, opts metav1.UpdateOptions) (*corev1.Namespace, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(namespacesResource, c.ClusterPath, "status", namespace), &corev1.Namespace{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Namespace), err -} - -func (c *namespacesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(namespacesResource, c.ClusterPath, name, opts), &corev1.Namespace{}) - return err -} - -func (c *namespacesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*corev1.Namespace, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(namespacesResource, c.ClusterPath, name), &corev1.Namespace{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Namespace), err -} - -// List takes label and field selectors, and returns the list of Namespaces that match those selectors. -func (c *namespacesClient) List(ctx context.Context, opts metav1.ListOptions) (*corev1.NamespaceList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(namespacesResource, namespacesKind, c.ClusterPath, opts), &corev1.NamespaceList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &corev1.NamespaceList{ListMeta: obj.(*corev1.NamespaceList).ListMeta} - for _, item := range obj.(*corev1.NamespaceList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *namespacesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(namespacesResource, c.ClusterPath, opts)) -} - -func (c *namespacesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*corev1.Namespace, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(namespacesResource, c.ClusterPath, name, pt, data, subresources...), &corev1.Namespace{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Namespace), err -} - -func (c *namespacesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationscorev1.NamespaceApplyConfiguration, opts metav1.ApplyOptions) (*corev1.Namespace, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(namespacesResource, c.ClusterPath, *name, types.ApplyPatchType, data), &corev1.Namespace{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Namespace), err -} - -func (c *namespacesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationscorev1.NamespaceApplyConfiguration, opts metav1.ApplyOptions) (*corev1.Namespace, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(namespacesResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &corev1.Namespace{}) - if obj == nil { - return nil, err +func newFakeNamespaceClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedcorev1.NamespaceInterface { + return &namespaceScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*corev1.Namespace, *corev1.NamespaceList, *v1.NamespaceApplyConfiguration]( + fake, + clusterPath, + "", + corev1.SchemeGroupVersion.WithResource("namespaces"), + corev1.SchemeGroupVersion.WithKind("Namespace"), + func() *corev1.Namespace { return &corev1.Namespace{} }, + func() *corev1.NamespaceList { return &corev1.NamespaceList{} }, + func(dst, src *corev1.NamespaceList) { dst.ListMeta = src.ListMeta }, + func(list *corev1.NamespaceList) []*corev1.Namespace { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *corev1.NamespaceList, items []*corev1.Namespace) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*corev1.Namespace), err } diff --git a/kubernetes/typed/core/v1/fake/node.go b/kubernetes/typed/core/v1/fake/node.go index aef3be2e1..cedf1775a 100644 --- a/kubernetes/typed/core/v1/fake/node.go +++ b/kubernetes/typed/core/v1/fake/node.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,70 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationscorev1 "k8s.io/client-go/applyconfigurations/core/v1" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/core/v1" + typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" + typedkcpcorev1 "github.com/kcp-dev/client-go/kubernetes/typed/core/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var nodesResource = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "nodes"} -var nodesKind = schema.GroupVersionKind{Group: "", Version: "v1", Kind: "Node"} - -type nodesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *nodesClusterClient) Cluster(clusterPath logicalcluster.Path) corev1client.NodeInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &nodesClient{Fake: c.Fake, ClusterPath: clusterPath} +// nodeClusterClient implements NodeClusterInterface +type nodeClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*corev1.Node, *corev1.NodeList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of Nodes that match those selectors across all clusters. -func (c *nodesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*corev1.NodeList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(nodesResource, nodesKind, logicalcluster.Wildcard, opts), &corev1.NodeList{}) - if obj == nil { - return nil, err +func newFakeNodeClusterClient(fake *CoreV1ClusterClient) typedkcpcorev1.NodeClusterInterface { + return &nodeClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*corev1.Node, *corev1.NodeList]( + fake.Fake, + corev1.SchemeGroupVersion.WithResource("nodes"), + corev1.SchemeGroupVersion.WithKind("Node"), + func() *corev1.Node { return &corev1.Node{} }, + func() *corev1.NodeList { return &corev1.NodeList{} }, + func(dst, src *corev1.NodeList) { dst.ListMeta = src.ListMeta }, + func(list *corev1.NodeList) []*corev1.Node { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *corev1.NodeList, items []*corev1.Node) { list.Items = kcpgentype.FromPointerSlice(items) }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &corev1.NodeList{ListMeta: obj.(*corev1.NodeList).ListMeta} - for _, item := range obj.(*corev1.NodeList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested Nodes across all clusters. -func (c *nodesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(nodesResource, logicalcluster.Wildcard, opts)) +func (c *nodeClusterClient) Cluster(cluster logicalcluster.Path) typedcorev1.NodeInterface { + return newFakeNodeClient(c.Fake, cluster) } -type nodesClient struct { - *kcptesting.Fake +// nodeScopedClient implements NodeInterface +type nodeScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*corev1.Node, *corev1.NodeList, *v1.NodeApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *nodesClient) Create(ctx context.Context, node *corev1.Node, opts metav1.CreateOptions) (*corev1.Node, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(nodesResource, c.ClusterPath, node), &corev1.Node{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Node), err -} - -func (c *nodesClient) Update(ctx context.Context, node *corev1.Node, opts metav1.UpdateOptions) (*corev1.Node, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(nodesResource, c.ClusterPath, node), &corev1.Node{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Node), err -} - -func (c *nodesClient) UpdateStatus(ctx context.Context, node *corev1.Node, opts metav1.UpdateOptions) (*corev1.Node, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(nodesResource, c.ClusterPath, "status", node), &corev1.Node{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Node), err -} - -func (c *nodesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(nodesResource, c.ClusterPath, name, opts), &corev1.Node{}) - return err -} - -func (c *nodesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(nodesResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &corev1.NodeList{}) - return err -} - -func (c *nodesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*corev1.Node, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(nodesResource, c.ClusterPath, name), &corev1.Node{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Node), err -} - -// List takes label and field selectors, and returns the list of Nodes that match those selectors. -func (c *nodesClient) List(ctx context.Context, opts metav1.ListOptions) (*corev1.NodeList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(nodesResource, nodesKind, c.ClusterPath, opts), &corev1.NodeList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &corev1.NodeList{ListMeta: obj.(*corev1.NodeList).ListMeta} - for _, item := range obj.(*corev1.NodeList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *nodesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(nodesResource, c.ClusterPath, opts)) -} - -func (c *nodesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*corev1.Node, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(nodesResource, c.ClusterPath, name, pt, data, subresources...), &corev1.Node{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Node), err -} - -func (c *nodesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationscorev1.NodeApplyConfiguration, opts metav1.ApplyOptions) (*corev1.Node, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(nodesResource, c.ClusterPath, *name, types.ApplyPatchType, data), &corev1.Node{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Node), err -} - -func (c *nodesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationscorev1.NodeApplyConfiguration, opts metav1.ApplyOptions) (*corev1.Node, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(nodesResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &corev1.Node{}) - if obj == nil { - return nil, err +func newFakeNodeClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedcorev1.NodeInterface { + return &nodeScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*corev1.Node, *corev1.NodeList, *v1.NodeApplyConfiguration]( + fake, + clusterPath, + "", + corev1.SchemeGroupVersion.WithResource("nodes"), + corev1.SchemeGroupVersion.WithKind("Node"), + func() *corev1.Node { return &corev1.Node{} }, + func() *corev1.NodeList { return &corev1.NodeList{} }, + func(dst, src *corev1.NodeList) { dst.ListMeta = src.ListMeta }, + func(list *corev1.NodeList) []*corev1.Node { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *corev1.NodeList, items []*corev1.Node) { list.Items = kcpgentype.FromPointerSlice(items) }, + ), + fake, + clusterPath, } - return obj.(*corev1.Node), err } diff --git a/kubernetes/typed/core/v1/fake/persistentvolume.go b/kubernetes/typed/core/v1/fake/persistentvolume.go index a4f26351c..2d72adb9c 100644 --- a/kubernetes/typed/core/v1/fake/persistentvolume.go +++ b/kubernetes/typed/core/v1/fake/persistentvolume.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationscorev1 "k8s.io/client-go/applyconfigurations/core/v1" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/core/v1" + typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" + typedkcpcorev1 "github.com/kcp-dev/client-go/kubernetes/typed/core/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var persistentVolumesResource = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "persistentvolumes"} -var persistentVolumesKind = schema.GroupVersionKind{Group: "", Version: "v1", Kind: "PersistentVolume"} - -type persistentVolumesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *persistentVolumesClusterClient) Cluster(clusterPath logicalcluster.Path) corev1client.PersistentVolumeInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &persistentVolumesClient{Fake: c.Fake, ClusterPath: clusterPath} +// persistentVolumeClusterClient implements PersistentVolumeClusterInterface +type persistentVolumeClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*corev1.PersistentVolume, *corev1.PersistentVolumeList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of PersistentVolumes that match those selectors across all clusters. -func (c *persistentVolumesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*corev1.PersistentVolumeList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(persistentVolumesResource, persistentVolumesKind, logicalcluster.Wildcard, opts), &corev1.PersistentVolumeList{}) - if obj == nil { - return nil, err +func newFakePersistentVolumeClusterClient(fake *CoreV1ClusterClient) typedkcpcorev1.PersistentVolumeClusterInterface { + return &persistentVolumeClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*corev1.PersistentVolume, *corev1.PersistentVolumeList]( + fake.Fake, + corev1.SchemeGroupVersion.WithResource("persistentvolumes"), + corev1.SchemeGroupVersion.WithKind("PersistentVolume"), + func() *corev1.PersistentVolume { return &corev1.PersistentVolume{} }, + func() *corev1.PersistentVolumeList { return &corev1.PersistentVolumeList{} }, + func(dst, src *corev1.PersistentVolumeList) { dst.ListMeta = src.ListMeta }, + func(list *corev1.PersistentVolumeList) []*corev1.PersistentVolume { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *corev1.PersistentVolumeList, items []*corev1.PersistentVolume) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &corev1.PersistentVolumeList{ListMeta: obj.(*corev1.PersistentVolumeList).ListMeta} - for _, item := range obj.(*corev1.PersistentVolumeList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested PersistentVolumes across all clusters. -func (c *persistentVolumesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(persistentVolumesResource, logicalcluster.Wildcard, opts)) +func (c *persistentVolumeClusterClient) Cluster(cluster logicalcluster.Path) typedcorev1.PersistentVolumeInterface { + return newFakePersistentVolumeClient(c.Fake, cluster) } -type persistentVolumesClient struct { - *kcptesting.Fake +// persistentVolumeScopedClient implements PersistentVolumeInterface +type persistentVolumeScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*corev1.PersistentVolume, *corev1.PersistentVolumeList, *v1.PersistentVolumeApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *persistentVolumesClient) Create(ctx context.Context, persistentVolume *corev1.PersistentVolume, opts metav1.CreateOptions) (*corev1.PersistentVolume, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(persistentVolumesResource, c.ClusterPath, persistentVolume), &corev1.PersistentVolume{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.PersistentVolume), err -} - -func (c *persistentVolumesClient) Update(ctx context.Context, persistentVolume *corev1.PersistentVolume, opts metav1.UpdateOptions) (*corev1.PersistentVolume, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(persistentVolumesResource, c.ClusterPath, persistentVolume), &corev1.PersistentVolume{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.PersistentVolume), err -} - -func (c *persistentVolumesClient) UpdateStatus(ctx context.Context, persistentVolume *corev1.PersistentVolume, opts metav1.UpdateOptions) (*corev1.PersistentVolume, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(persistentVolumesResource, c.ClusterPath, "status", persistentVolume), &corev1.PersistentVolume{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.PersistentVolume), err -} - -func (c *persistentVolumesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(persistentVolumesResource, c.ClusterPath, name, opts), &corev1.PersistentVolume{}) - return err -} - -func (c *persistentVolumesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(persistentVolumesResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &corev1.PersistentVolumeList{}) - return err -} - -func (c *persistentVolumesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*corev1.PersistentVolume, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(persistentVolumesResource, c.ClusterPath, name), &corev1.PersistentVolume{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.PersistentVolume), err -} - -// List takes label and field selectors, and returns the list of PersistentVolumes that match those selectors. -func (c *persistentVolumesClient) List(ctx context.Context, opts metav1.ListOptions) (*corev1.PersistentVolumeList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(persistentVolumesResource, persistentVolumesKind, c.ClusterPath, opts), &corev1.PersistentVolumeList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &corev1.PersistentVolumeList{ListMeta: obj.(*corev1.PersistentVolumeList).ListMeta} - for _, item := range obj.(*corev1.PersistentVolumeList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *persistentVolumesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(persistentVolumesResource, c.ClusterPath, opts)) -} - -func (c *persistentVolumesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*corev1.PersistentVolume, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(persistentVolumesResource, c.ClusterPath, name, pt, data, subresources...), &corev1.PersistentVolume{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.PersistentVolume), err -} - -func (c *persistentVolumesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationscorev1.PersistentVolumeApplyConfiguration, opts metav1.ApplyOptions) (*corev1.PersistentVolume, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(persistentVolumesResource, c.ClusterPath, *name, types.ApplyPatchType, data), &corev1.PersistentVolume{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.PersistentVolume), err -} - -func (c *persistentVolumesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationscorev1.PersistentVolumeApplyConfiguration, opts metav1.ApplyOptions) (*corev1.PersistentVolume, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(persistentVolumesResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &corev1.PersistentVolume{}) - if obj == nil { - return nil, err +func newFakePersistentVolumeClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedcorev1.PersistentVolumeInterface { + return &persistentVolumeScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*corev1.PersistentVolume, *corev1.PersistentVolumeList, *v1.PersistentVolumeApplyConfiguration]( + fake, + clusterPath, + "", + corev1.SchemeGroupVersion.WithResource("persistentvolumes"), + corev1.SchemeGroupVersion.WithKind("PersistentVolume"), + func() *corev1.PersistentVolume { return &corev1.PersistentVolume{} }, + func() *corev1.PersistentVolumeList { return &corev1.PersistentVolumeList{} }, + func(dst, src *corev1.PersistentVolumeList) { dst.ListMeta = src.ListMeta }, + func(list *corev1.PersistentVolumeList) []*corev1.PersistentVolume { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *corev1.PersistentVolumeList, items []*corev1.PersistentVolume) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*corev1.PersistentVolume), err } diff --git a/kubernetes/typed/core/v1/fake/persistentvolumeclaim.go b/kubernetes/typed/core/v1/fake/persistentvolumeclaim.go index 5390cdf40..14ac69bc4 100644 --- a/kubernetes/typed/core/v1/fake/persistentvolumeclaim.go +++ b/kubernetes/typed/core/v1/fake/persistentvolumeclaim.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationscorev1 "k8s.io/client-go/applyconfigurations/core/v1" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/core/v1" + typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" - kcpcorev1 "github.com/kcp-dev/client-go/kubernetes/typed/core/v1" + typedkcpcorev1 "github.com/kcp-dev/client-go/kubernetes/typed/core/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var persistentVolumeClaimsResource = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "persistentvolumeclaims"} -var persistentVolumeClaimsKind = schema.GroupVersionKind{Group: "", Version: "v1", Kind: "PersistentVolumeClaim"} - -type persistentVolumeClaimsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *persistentVolumeClaimsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpcorev1.PersistentVolumeClaimsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &persistentVolumeClaimsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// persistentVolumeClaimClusterClient implements PersistentVolumeClaimClusterInterface +type persistentVolumeClaimClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*corev1.PersistentVolumeClaim, *corev1.PersistentVolumeClaimList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of PersistentVolumeClaims that match those selectors across all clusters. -func (c *persistentVolumeClaimsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*corev1.PersistentVolumeClaimList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(persistentVolumeClaimsResource, persistentVolumeClaimsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &corev1.PersistentVolumeClaimList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakePersistentVolumeClaimClusterClient(fake *CoreV1ClusterClient) typedkcpcorev1.PersistentVolumeClaimClusterInterface { + return &persistentVolumeClaimClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*corev1.PersistentVolumeClaim, *corev1.PersistentVolumeClaimList]( + fake.Fake, + corev1.SchemeGroupVersion.WithResource("persistentvolumeclaims"), + corev1.SchemeGroupVersion.WithKind("PersistentVolumeClaim"), + func() *corev1.PersistentVolumeClaim { return &corev1.PersistentVolumeClaim{} }, + func() *corev1.PersistentVolumeClaimList { return &corev1.PersistentVolumeClaimList{} }, + func(dst, src *corev1.PersistentVolumeClaimList) { dst.ListMeta = src.ListMeta }, + func(list *corev1.PersistentVolumeClaimList) []*corev1.PersistentVolumeClaim { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *corev1.PersistentVolumeClaimList, items []*corev1.PersistentVolumeClaim) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &corev1.PersistentVolumeClaimList{ListMeta: obj.(*corev1.PersistentVolumeClaimList).ListMeta} - for _, item := range obj.(*corev1.PersistentVolumeClaimList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested PersistentVolumeClaims across all clusters. -func (c *persistentVolumeClaimsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(persistentVolumeClaimsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *persistentVolumeClaimClusterClient) Cluster(cluster logicalcluster.Path) typedkcpcorev1.PersistentVolumeClaimsNamespacer { + return &persistentVolumeClaimNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type persistentVolumeClaimsNamespacer struct { +type persistentVolumeClaimNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *persistentVolumeClaimsNamespacer) Namespace(namespace string) corev1client.PersistentVolumeClaimInterface { - return &persistentVolumeClaimsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *persistentVolumeClaimNamespacer) Namespace(namespace string) typedcorev1.PersistentVolumeClaimInterface { + return newFakePersistentVolumeClaimClient(n.Fake, namespace, n.ClusterPath) } -type persistentVolumeClaimsClient struct { - *kcptesting.Fake +// persistentVolumeClaimScopedClient implements PersistentVolumeClaimInterface +type persistentVolumeClaimScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*corev1.PersistentVolumeClaim, *corev1.PersistentVolumeClaimList, *v1.PersistentVolumeClaimApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *persistentVolumeClaimsClient) Create(ctx context.Context, persistentVolumeClaim *corev1.PersistentVolumeClaim, opts metav1.CreateOptions) (*corev1.PersistentVolumeClaim, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(persistentVolumeClaimsResource, c.ClusterPath, c.Namespace, persistentVolumeClaim), &corev1.PersistentVolumeClaim{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.PersistentVolumeClaim), err -} - -func (c *persistentVolumeClaimsClient) Update(ctx context.Context, persistentVolumeClaim *corev1.PersistentVolumeClaim, opts metav1.UpdateOptions) (*corev1.PersistentVolumeClaim, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(persistentVolumeClaimsResource, c.ClusterPath, c.Namespace, persistentVolumeClaim), &corev1.PersistentVolumeClaim{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.PersistentVolumeClaim), err -} - -func (c *persistentVolumeClaimsClient) UpdateStatus(ctx context.Context, persistentVolumeClaim *corev1.PersistentVolumeClaim, opts metav1.UpdateOptions) (*corev1.PersistentVolumeClaim, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(persistentVolumeClaimsResource, c.ClusterPath, "status", c.Namespace, persistentVolumeClaim), &corev1.PersistentVolumeClaim{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.PersistentVolumeClaim), err -} - -func (c *persistentVolumeClaimsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(persistentVolumeClaimsResource, c.ClusterPath, c.Namespace, name, opts), &corev1.PersistentVolumeClaim{}) - return err -} - -func (c *persistentVolumeClaimsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(persistentVolumeClaimsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &corev1.PersistentVolumeClaimList{}) - return err -} - -func (c *persistentVolumeClaimsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*corev1.PersistentVolumeClaim, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(persistentVolumeClaimsResource, c.ClusterPath, c.Namespace, name), &corev1.PersistentVolumeClaim{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.PersistentVolumeClaim), err -} - -// List takes label and field selectors, and returns the list of PersistentVolumeClaims that match those selectors. -func (c *persistentVolumeClaimsClient) List(ctx context.Context, opts metav1.ListOptions) (*corev1.PersistentVolumeClaimList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(persistentVolumeClaimsResource, persistentVolumeClaimsKind, c.ClusterPath, c.Namespace, opts), &corev1.PersistentVolumeClaimList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &corev1.PersistentVolumeClaimList{ListMeta: obj.(*corev1.PersistentVolumeClaimList).ListMeta} - for _, item := range obj.(*corev1.PersistentVolumeClaimList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *persistentVolumeClaimsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(persistentVolumeClaimsResource, c.ClusterPath, c.Namespace, opts)) } -func (c *persistentVolumeClaimsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*corev1.PersistentVolumeClaim, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(persistentVolumeClaimsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &corev1.PersistentVolumeClaim{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.PersistentVolumeClaim), err -} - -func (c *persistentVolumeClaimsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationscorev1.PersistentVolumeClaimApplyConfiguration, opts metav1.ApplyOptions) (*corev1.PersistentVolumeClaim, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(persistentVolumeClaimsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &corev1.PersistentVolumeClaim{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.PersistentVolumeClaim), err -} - -func (c *persistentVolumeClaimsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationscorev1.PersistentVolumeClaimApplyConfiguration, opts metav1.ApplyOptions) (*corev1.PersistentVolumeClaim, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(persistentVolumeClaimsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &corev1.PersistentVolumeClaim{}) - if obj == nil { - return nil, err +func newFakePersistentVolumeClaimClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedcorev1.PersistentVolumeClaimInterface { + return &persistentVolumeClaimScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*corev1.PersistentVolumeClaim, *corev1.PersistentVolumeClaimList, *v1.PersistentVolumeClaimApplyConfiguration]( + fake, + clusterPath, + namespace, + corev1.SchemeGroupVersion.WithResource("persistentvolumeclaims"), + corev1.SchemeGroupVersion.WithKind("PersistentVolumeClaim"), + func() *corev1.PersistentVolumeClaim { return &corev1.PersistentVolumeClaim{} }, + func() *corev1.PersistentVolumeClaimList { return &corev1.PersistentVolumeClaimList{} }, + func(dst, src *corev1.PersistentVolumeClaimList) { dst.ListMeta = src.ListMeta }, + func(list *corev1.PersistentVolumeClaimList) []*corev1.PersistentVolumeClaim { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *corev1.PersistentVolumeClaimList, items []*corev1.PersistentVolumeClaim) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*corev1.PersistentVolumeClaim), err } diff --git a/kubernetes/typed/core/v1/fake/pod.go b/kubernetes/typed/core/v1/fake/pod.go index edb818887..71c2dee69 100644 --- a/kubernetes/typed/core/v1/fake/pod.go +++ b/kubernetes/typed/core/v1/fake/pod.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,213 +14,102 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" + context "context" "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationscorev1 "k8s.io/client-go/applyconfigurations/core/v1" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" - "k8s.io/client-go/testing" - - kcpcorev1 "github.com/kcp-dev/client-go/kubernetes/typed/core/v1" + v1 "k8s.io/client-go/applyconfigurations/core/v1" + typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" + + typedkcpcorev1 "github.com/kcp-dev/client-go/kubernetes/typed/core/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var podsResource = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "pods"} -var podsKind = schema.GroupVersionKind{Group: "", Version: "v1", Kind: "Pod"} - -type podsClusterClient struct { - *kcptesting.Fake +// podClusterClient implements PodClusterInterface +type podClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*corev1.Pod, *corev1.PodList] + Fake *kcptesting.Fake } -// Cluster scopes the client down to a particular cluster. -func (c *podsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpcorev1.PodsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") +func newFakePodClusterClient(fake *CoreV1ClusterClient) typedkcpcorev1.PodClusterInterface { + return &podClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*corev1.Pod, *corev1.PodList]( + fake.Fake, + corev1.SchemeGroupVersion.WithResource("pods"), + corev1.SchemeGroupVersion.WithKind("Pod"), + func() *corev1.Pod { return &corev1.Pod{} }, + func() *corev1.PodList { return &corev1.PodList{} }, + func(dst, src *corev1.PodList) { dst.ListMeta = src.ListMeta }, + func(list *corev1.PodList) []*corev1.Pod { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *corev1.PodList, items []*corev1.Pod) { list.Items = kcpgentype.FromPointerSlice(items) }, + ), + fake.Fake, } - - return &podsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} } -// List takes label and field selectors, and returns the list of Pods that match those selectors across all clusters. -func (c *podsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*corev1.PodList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(podsResource, podsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &corev1.PodList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &corev1.PodList{ListMeta: obj.(*corev1.PodList).ListMeta} - for _, item := range obj.(*corev1.PodList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err +func (c *podClusterClient) Cluster(cluster logicalcluster.Path) typedkcpcorev1.PodsNamespacer { + return &podNamespacer{Fake: c.Fake, ClusterPath: cluster} } -// Watch returns a watch.Interface that watches the requested Pods across all clusters. -func (c *podsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(podsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) -} - -type podsNamespacer struct { +type podNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *podsNamespacer) Namespace(namespace string) corev1client.PodInterface { - return &podsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *podNamespacer) Namespace(namespace string) typedcorev1.PodInterface { + return newFakePodClient(n.Fake, namespace, n.ClusterPath) } -type podsClient struct { - *kcptesting.Fake +// podScopedClient implements PodInterface +type podScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*corev1.Pod, *corev1.PodList, *v1.PodApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *podsClient) Create(ctx context.Context, pod *corev1.Pod, opts metav1.CreateOptions) (*corev1.Pod, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(podsResource, c.ClusterPath, c.Namespace, pod), &corev1.Pod{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Pod), err -} - -func (c *podsClient) Update(ctx context.Context, pod *corev1.Pod, opts metav1.UpdateOptions) (*corev1.Pod, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(podsResource, c.ClusterPath, c.Namespace, pod), &corev1.Pod{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Pod), err -} - -func (c *podsClient) UpdateStatus(ctx context.Context, pod *corev1.Pod, opts metav1.UpdateOptions) (*corev1.Pod, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(podsResource, c.ClusterPath, "status", c.Namespace, pod), &corev1.Pod{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Pod), err -} - -func (c *podsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(podsResource, c.ClusterPath, c.Namespace, name, opts), &corev1.Pod{}) - return err -} - -func (c *podsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(podsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &corev1.PodList{}) - return err -} - -func (c *podsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*corev1.Pod, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(podsResource, c.ClusterPath, c.Namespace, name), &corev1.Pod{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Pod), err -} - -// List takes label and field selectors, and returns the list of Pods that match those selectors. -func (c *podsClient) List(ctx context.Context, opts metav1.ListOptions) (*corev1.PodList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(podsResource, podsKind, c.ClusterPath, c.Namespace, opts), &corev1.PodList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &corev1.PodList{ListMeta: obj.(*corev1.PodList).ListMeta} - for _, item := range obj.(*corev1.PodList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *podsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(podsResource, c.ClusterPath, c.Namespace, opts)) -} - -func (c *podsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*corev1.Pod, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(podsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &corev1.Pod{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Pod), err -} - -func (c *podsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationscorev1.PodApplyConfiguration, opts metav1.ApplyOptions) (*corev1.Pod, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(podsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &corev1.Pod{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Pod), err -} - -func (c *podsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationscorev1.PodApplyConfiguration, opts metav1.ApplyOptions) (*corev1.Pod, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(podsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &corev1.Pod{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Pod), err } -func (c *podsClient) UpdateEphemeralContainers(ctx context.Context, podName string, pod *corev1.Pod, opts metav1.UpdateOptions) (*corev1.Pod, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(podsResource, c.ClusterPath, "ephemeralcontainers", c.Namespace, pod), &corev1.Pod{}) +func newFakePodClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedcorev1.PodInterface { + return &podScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*corev1.Pod, *corev1.PodList, *v1.PodApplyConfiguration]( + fake, + clusterPath, + namespace, + corev1.SchemeGroupVersion.WithResource("pods"), + corev1.SchemeGroupVersion.WithKind("Pod"), + func() *corev1.Pod { return &corev1.Pod{} }, + func() *corev1.PodList { return &corev1.PodList{} }, + func(dst, src *corev1.PodList) { dst.ListMeta = src.ListMeta }, + func(list *corev1.PodList) []*corev1.Pod { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *corev1.PodList, items []*corev1.Pod) { list.Items = kcpgentype.FromPointerSlice(items) }, + ), + fake, + clusterPath, + } +} + +// UpdateEphemeralContainers takes the representation of a pod and updates it. Returns the server's representation of the pod, and an error, if there is any. +func (c *podScopedClient) UpdateEphemeralContainers(ctx context.Context, podName string, pod *corev1.Pod, _ metav1.UpdateOptions) (result *corev1.Pod, err error) { + emptyResult := &corev1.Pod{} + obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(c.Resource(), c.ClusterPath, "ephemeralcontainers", c.Namespace(), pod), &corev1.Pod{}) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*corev1.Pod), err } -func (c *podsClient) UpdateResize(ctx context.Context, podName string, pod *corev1.Pod, opts metav1.UpdateOptions) (*corev1.Pod, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(podsResource, c.ClusterPath, "resize", c.Namespace, pod), &corev1.Pod{}) +// UpdateResize takes the representation of a pod and updates it. Returns the server's representation of the pod, and an error, if there is any. +func (c *podScopedClient) UpdateResize(ctx context.Context, podName string, pod *corev1.Pod, _ metav1.UpdateOptions) (result *corev1.Pod, err error) { + emptyResult := &corev1.Pod{} + obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(c.Resource(), c.ClusterPath, "resize", c.Namespace(), pod), &corev1.Pod{}) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*corev1.Pod), err } diff --git a/kubernetes/typed/core/v1/fake/podtemplate.go b/kubernetes/typed/core/v1/fake/podtemplate.go index 82ffdaff1..91971656e 100644 --- a/kubernetes/typed/core/v1/fake/podtemplate.go +++ b/kubernetes/typed/core/v1/fake/podtemplate.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,83 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationscorev1 "k8s.io/client-go/applyconfigurations/core/v1" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/core/v1" + typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" - kcpcorev1 "github.com/kcp-dev/client-go/kubernetes/typed/core/v1" + typedkcpcorev1 "github.com/kcp-dev/client-go/kubernetes/typed/core/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var podTemplatesResource = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "podtemplates"} -var podTemplatesKind = schema.GroupVersionKind{Group: "", Version: "v1", Kind: "PodTemplate"} - -type podTemplatesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *podTemplatesClusterClient) Cluster(clusterPath logicalcluster.Path) kcpcorev1.PodTemplatesNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &podTemplatesNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// podTemplateClusterClient implements PodTemplateClusterInterface +type podTemplateClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*corev1.PodTemplate, *corev1.PodTemplateList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of PodTemplates that match those selectors across all clusters. -func (c *podTemplatesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*corev1.PodTemplateList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(podTemplatesResource, podTemplatesKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &corev1.PodTemplateList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakePodTemplateClusterClient(fake *CoreV1ClusterClient) typedkcpcorev1.PodTemplateClusterInterface { + return &podTemplateClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*corev1.PodTemplate, *corev1.PodTemplateList]( + fake.Fake, + corev1.SchemeGroupVersion.WithResource("podtemplates"), + corev1.SchemeGroupVersion.WithKind("PodTemplate"), + func() *corev1.PodTemplate { return &corev1.PodTemplate{} }, + func() *corev1.PodTemplateList { return &corev1.PodTemplateList{} }, + func(dst, src *corev1.PodTemplateList) { dst.ListMeta = src.ListMeta }, + func(list *corev1.PodTemplateList) []*corev1.PodTemplate { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *corev1.PodTemplateList, items []*corev1.PodTemplate) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &corev1.PodTemplateList{ListMeta: obj.(*corev1.PodTemplateList).ListMeta} - for _, item := range obj.(*corev1.PodTemplateList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested PodTemplates across all clusters. -func (c *podTemplatesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(podTemplatesResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *podTemplateClusterClient) Cluster(cluster logicalcluster.Path) typedkcpcorev1.PodTemplatesNamespacer { + return &podTemplateNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type podTemplatesNamespacer struct { +type podTemplateNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *podTemplatesNamespacer) Namespace(namespace string) corev1client.PodTemplateInterface { - return &podTemplatesClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *podTemplateNamespacer) Namespace(namespace string) typedcorev1.PodTemplateInterface { + return newFakePodTemplateClient(n.Fake, namespace, n.ClusterPath) } -type podTemplatesClient struct { - *kcptesting.Fake +// podTemplateScopedClient implements PodTemplateInterface +type podTemplateScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*corev1.PodTemplate, *corev1.PodTemplateList, *v1.PodTemplateApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *podTemplatesClient) Create(ctx context.Context, podTemplate *corev1.PodTemplate, opts metav1.CreateOptions) (*corev1.PodTemplate, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(podTemplatesResource, c.ClusterPath, c.Namespace, podTemplate), &corev1.PodTemplate{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.PodTemplate), err -} - -func (c *podTemplatesClient) Update(ctx context.Context, podTemplate *corev1.PodTemplate, opts metav1.UpdateOptions) (*corev1.PodTemplate, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(podTemplatesResource, c.ClusterPath, c.Namespace, podTemplate), &corev1.PodTemplate{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.PodTemplate), err -} - -func (c *podTemplatesClient) UpdateStatus(ctx context.Context, podTemplate *corev1.PodTemplate, opts metav1.UpdateOptions) (*corev1.PodTemplate, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(podTemplatesResource, c.ClusterPath, "status", c.Namespace, podTemplate), &corev1.PodTemplate{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.PodTemplate), err -} - -func (c *podTemplatesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(podTemplatesResource, c.ClusterPath, c.Namespace, name, opts), &corev1.PodTemplate{}) - return err -} - -func (c *podTemplatesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(podTemplatesResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &corev1.PodTemplateList{}) - return err -} - -func (c *podTemplatesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*corev1.PodTemplate, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(podTemplatesResource, c.ClusterPath, c.Namespace, name), &corev1.PodTemplate{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.PodTemplate), err -} - -// List takes label and field selectors, and returns the list of PodTemplates that match those selectors. -func (c *podTemplatesClient) List(ctx context.Context, opts metav1.ListOptions) (*corev1.PodTemplateList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(podTemplatesResource, podTemplatesKind, c.ClusterPath, c.Namespace, opts), &corev1.PodTemplateList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &corev1.PodTemplateList{ListMeta: obj.(*corev1.PodTemplateList).ListMeta} - for _, item := range obj.(*corev1.PodTemplateList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *podTemplatesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(podTemplatesResource, c.ClusterPath, c.Namespace, opts)) } -func (c *podTemplatesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*corev1.PodTemplate, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(podTemplatesResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &corev1.PodTemplate{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.PodTemplate), err -} - -func (c *podTemplatesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationscorev1.PodTemplateApplyConfiguration, opts metav1.ApplyOptions) (*corev1.PodTemplate, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(podTemplatesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &corev1.PodTemplate{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.PodTemplate), err -} - -func (c *podTemplatesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationscorev1.PodTemplateApplyConfiguration, opts metav1.ApplyOptions) (*corev1.PodTemplate, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(podTemplatesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &corev1.PodTemplate{}) - if obj == nil { - return nil, err +func newFakePodTemplateClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedcorev1.PodTemplateInterface { + return &podTemplateScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*corev1.PodTemplate, *corev1.PodTemplateList, *v1.PodTemplateApplyConfiguration]( + fake, + clusterPath, + namespace, + corev1.SchemeGroupVersion.WithResource("podtemplates"), + corev1.SchemeGroupVersion.WithKind("PodTemplate"), + func() *corev1.PodTemplate { return &corev1.PodTemplate{} }, + func() *corev1.PodTemplateList { return &corev1.PodTemplateList{} }, + func(dst, src *corev1.PodTemplateList) { dst.ListMeta = src.ListMeta }, + func(list *corev1.PodTemplateList) []*corev1.PodTemplate { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *corev1.PodTemplateList, items []*corev1.PodTemplate) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*corev1.PodTemplate), err } diff --git a/kubernetes/typed/core/v1/fake/replicationcontroller.go b/kubernetes/typed/core/v1/fake/replicationcontroller.go index 5d97c9dd9..82405ebcd 100644 --- a/kubernetes/typed/core/v1/fake/replicationcontroller.go +++ b/kubernetes/typed/core/v1/fake/replicationcontroller.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,214 +14,111 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" + context "context" "github.com/kcp-dev/logicalcluster/v3" autoscalingv1 "k8s.io/api/autoscaling/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationscorev1 "k8s.io/client-go/applyconfigurations/core/v1" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" - "k8s.io/client-go/testing" - - kcpcorev1 "github.com/kcp-dev/client-go/kubernetes/typed/core/v1" + v1 "k8s.io/client-go/applyconfigurations/core/v1" + typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" + + typedkcpcorev1 "github.com/kcp-dev/client-go/kubernetes/typed/core/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var replicationControllersResource = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "replicationcontrollers"} -var replicationControllersKind = schema.GroupVersionKind{Group: "", Version: "v1", Kind: "ReplicationController"} - -type replicationControllersClusterClient struct { - *kcptesting.Fake +// replicationControllerClusterClient implements ReplicationControllerClusterInterface +type replicationControllerClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*corev1.ReplicationController, *corev1.ReplicationControllerList] + Fake *kcptesting.Fake } -// Cluster scopes the client down to a particular cluster. -func (c *replicationControllersClusterClient) Cluster(clusterPath logicalcluster.Path) kcpcorev1.ReplicationControllersNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") +func newFakeReplicationControllerClusterClient(fake *CoreV1ClusterClient) typedkcpcorev1.ReplicationControllerClusterInterface { + return &replicationControllerClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*corev1.ReplicationController, *corev1.ReplicationControllerList]( + fake.Fake, + corev1.SchemeGroupVersion.WithResource("replicationcontrollers"), + corev1.SchemeGroupVersion.WithKind("ReplicationController"), + func() *corev1.ReplicationController { return &corev1.ReplicationController{} }, + func() *corev1.ReplicationControllerList { return &corev1.ReplicationControllerList{} }, + func(dst, src *corev1.ReplicationControllerList) { dst.ListMeta = src.ListMeta }, + func(list *corev1.ReplicationControllerList) []*corev1.ReplicationController { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *corev1.ReplicationControllerList, items []*corev1.ReplicationController) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - return &replicationControllersNamespacer{Fake: c.Fake, ClusterPath: clusterPath} } -// List takes label and field selectors, and returns the list of ReplicationControllers that match those selectors across all clusters. -func (c *replicationControllersClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*corev1.ReplicationControllerList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(replicationControllersResource, replicationControllersKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &corev1.ReplicationControllerList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &corev1.ReplicationControllerList{ListMeta: obj.(*corev1.ReplicationControllerList).ListMeta} - for _, item := range obj.(*corev1.ReplicationControllerList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested ReplicationControllers across all clusters. -func (c *replicationControllersClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(replicationControllersResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *replicationControllerClusterClient) Cluster(cluster logicalcluster.Path) typedkcpcorev1.ReplicationControllersNamespacer { + return &replicationControllerNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type replicationControllersNamespacer struct { +type replicationControllerNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *replicationControllersNamespacer) Namespace(namespace string) corev1client.ReplicationControllerInterface { - return &replicationControllersClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *replicationControllerNamespacer) Namespace(namespace string) typedcorev1.ReplicationControllerInterface { + return newFakeReplicationControllerClient(n.Fake, namespace, n.ClusterPath) } -type replicationControllersClient struct { - *kcptesting.Fake +// replicationControllerScopedClient implements ReplicationControllerInterface +type replicationControllerScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*corev1.ReplicationController, *corev1.ReplicationControllerList, *v1.ReplicationControllerApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *replicationControllersClient) Create(ctx context.Context, replicationController *corev1.ReplicationController, opts metav1.CreateOptions) (*corev1.ReplicationController, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(replicationControllersResource, c.ClusterPath, c.Namespace, replicationController), &corev1.ReplicationController{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.ReplicationController), err -} - -func (c *replicationControllersClient) Update(ctx context.Context, replicationController *corev1.ReplicationController, opts metav1.UpdateOptions) (*corev1.ReplicationController, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(replicationControllersResource, c.ClusterPath, c.Namespace, replicationController), &corev1.ReplicationController{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.ReplicationController), err -} - -func (c *replicationControllersClient) UpdateStatus(ctx context.Context, replicationController *corev1.ReplicationController, opts metav1.UpdateOptions) (*corev1.ReplicationController, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(replicationControllersResource, c.ClusterPath, "status", c.Namespace, replicationController), &corev1.ReplicationController{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.ReplicationController), err -} - -func (c *replicationControllersClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(replicationControllersResource, c.ClusterPath, c.Namespace, name, opts), &corev1.ReplicationController{}) - return err -} - -func (c *replicationControllersClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(replicationControllersResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &corev1.ReplicationControllerList{}) - return err -} - -func (c *replicationControllersClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*corev1.ReplicationController, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(replicationControllersResource, c.ClusterPath, c.Namespace, name), &corev1.ReplicationController{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.ReplicationController), err -} - -// List takes label and field selectors, and returns the list of ReplicationControllers that match those selectors. -func (c *replicationControllersClient) List(ctx context.Context, opts metav1.ListOptions) (*corev1.ReplicationControllerList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(replicationControllersResource, replicationControllersKind, c.ClusterPath, c.Namespace, opts), &corev1.ReplicationControllerList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &corev1.ReplicationControllerList{ListMeta: obj.(*corev1.ReplicationControllerList).ListMeta} - for _, item := range obj.(*corev1.ReplicationControllerList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *replicationControllersClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(replicationControllersResource, c.ClusterPath, c.Namespace, opts)) -} - -func (c *replicationControllersClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*corev1.ReplicationController, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(replicationControllersResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &corev1.ReplicationController{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.ReplicationController), err -} - -func (c *replicationControllersClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationscorev1.ReplicationControllerApplyConfiguration, opts metav1.ApplyOptions) (*corev1.ReplicationController, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(replicationControllersResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &corev1.ReplicationController{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.ReplicationController), err -} - -func (c *replicationControllersClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationscorev1.ReplicationControllerApplyConfiguration, opts metav1.ApplyOptions) (*corev1.ReplicationController, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(replicationControllersResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &corev1.ReplicationController{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.ReplicationController), err } -func (c *replicationControllersClient) GetScale(ctx context.Context, replicationControllerName string, options metav1.GetOptions) (*autoscalingv1.Scale, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetSubresourceAction(replicationControllersResource, c.ClusterPath, "scale", c.Namespace, replicationControllerName), &autoscalingv1.Scale{}) +func newFakeReplicationControllerClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedcorev1.ReplicationControllerInterface { + return &replicationControllerScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*corev1.ReplicationController, *corev1.ReplicationControllerList, *v1.ReplicationControllerApplyConfiguration]( + fake, + clusterPath, + namespace, + corev1.SchemeGroupVersion.WithResource("replicationcontrollers"), + corev1.SchemeGroupVersion.WithKind("ReplicationController"), + func() *corev1.ReplicationController { return &corev1.ReplicationController{} }, + func() *corev1.ReplicationControllerList { return &corev1.ReplicationControllerList{} }, + func(dst, src *corev1.ReplicationControllerList) { dst.ListMeta = src.ListMeta }, + func(list *corev1.ReplicationControllerList) []*corev1.ReplicationController { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *corev1.ReplicationControllerList, items []*corev1.ReplicationController) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, + } +} + +// GetScale takes name of the replicationController, and returns the corresponding scale object, and an error if there is any. +func (c *replicationControllerScopedClient) GetScale(ctx context.Context, replicationControllerName string, _ metav1.GetOptions) (result *autoscalingv1.Scale, err error) { + emptyResult := &autoscalingv1.Scale{} + obj, err := c.Fake.Invokes(kcptesting.NewGetSubresourceAction(c.Resource(), c.ClusterPath, c.Namespace(), "scale", replicationControllerName), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*autoscalingv1.Scale), err } -func (c *replicationControllersClient) UpdateScale(ctx context.Context, replicationControllerName string, scale *autoscalingv1.Scale, opts metav1.UpdateOptions) (*autoscalingv1.Scale, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(replicationControllersResource, c.ClusterPath, "scale", c.Namespace, scale), &autoscalingv1.Scale{}) +// UpdateScale takes the representation of a scale and updates it. Returns the server's representation of the scale, and an error, if there is any. +func (c *replicationControllerScopedClient) UpdateScale(ctx context.Context, replicationControllerName string, scale *autoscalingv1.Scale, _ metav1.UpdateOptions) (result *autoscalingv1.Scale, err error) { + emptyResult := &autoscalingv1.Scale{} + obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(c.Resource(), c.ClusterPath, "scale", c.Namespace(), scale), &autoscalingv1.Scale{}) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*autoscalingv1.Scale), err } diff --git a/kubernetes/typed/core/v1/fake/resourcequota.go b/kubernetes/typed/core/v1/fake/resourcequota.go index 52a653c6f..5c5095fa9 100644 --- a/kubernetes/typed/core/v1/fake/resourcequota.go +++ b/kubernetes/typed/core/v1/fake/resourcequota.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationscorev1 "k8s.io/client-go/applyconfigurations/core/v1" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/core/v1" + typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" - kcpcorev1 "github.com/kcp-dev/client-go/kubernetes/typed/core/v1" + typedkcpcorev1 "github.com/kcp-dev/client-go/kubernetes/typed/core/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var resourceQuotasResource = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "resourcequotas"} -var resourceQuotasKind = schema.GroupVersionKind{Group: "", Version: "v1", Kind: "ResourceQuota"} - -type resourceQuotasClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *resourceQuotasClusterClient) Cluster(clusterPath logicalcluster.Path) kcpcorev1.ResourceQuotasNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &resourceQuotasNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// resourceQuotaClusterClient implements ResourceQuotaClusterInterface +type resourceQuotaClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*corev1.ResourceQuota, *corev1.ResourceQuotaList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of ResourceQuotas that match those selectors across all clusters. -func (c *resourceQuotasClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*corev1.ResourceQuotaList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(resourceQuotasResource, resourceQuotasKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &corev1.ResourceQuotaList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeResourceQuotaClusterClient(fake *CoreV1ClusterClient) typedkcpcorev1.ResourceQuotaClusterInterface { + return &resourceQuotaClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*corev1.ResourceQuota, *corev1.ResourceQuotaList]( + fake.Fake, + corev1.SchemeGroupVersion.WithResource("resourcequotas"), + corev1.SchemeGroupVersion.WithKind("ResourceQuota"), + func() *corev1.ResourceQuota { return &corev1.ResourceQuota{} }, + func() *corev1.ResourceQuotaList { return &corev1.ResourceQuotaList{} }, + func(dst, src *corev1.ResourceQuotaList) { dst.ListMeta = src.ListMeta }, + func(list *corev1.ResourceQuotaList) []*corev1.ResourceQuota { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *corev1.ResourceQuotaList, items []*corev1.ResourceQuota) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &corev1.ResourceQuotaList{ListMeta: obj.(*corev1.ResourceQuotaList).ListMeta} - for _, item := range obj.(*corev1.ResourceQuotaList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested ResourceQuotas across all clusters. -func (c *resourceQuotasClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(resourceQuotasResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *resourceQuotaClusterClient) Cluster(cluster logicalcluster.Path) typedkcpcorev1.ResourceQuotasNamespacer { + return &resourceQuotaNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type resourceQuotasNamespacer struct { +type resourceQuotaNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *resourceQuotasNamespacer) Namespace(namespace string) corev1client.ResourceQuotaInterface { - return &resourceQuotasClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *resourceQuotaNamespacer) Namespace(namespace string) typedcorev1.ResourceQuotaInterface { + return newFakeResourceQuotaClient(n.Fake, namespace, n.ClusterPath) } -type resourceQuotasClient struct { - *kcptesting.Fake +// resourceQuotaScopedClient implements ResourceQuotaInterface +type resourceQuotaScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*corev1.ResourceQuota, *corev1.ResourceQuotaList, *v1.ResourceQuotaApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *resourceQuotasClient) Create(ctx context.Context, resourceQuota *corev1.ResourceQuota, opts metav1.CreateOptions) (*corev1.ResourceQuota, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(resourceQuotasResource, c.ClusterPath, c.Namespace, resourceQuota), &corev1.ResourceQuota{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.ResourceQuota), err -} - -func (c *resourceQuotasClient) Update(ctx context.Context, resourceQuota *corev1.ResourceQuota, opts metav1.UpdateOptions) (*corev1.ResourceQuota, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(resourceQuotasResource, c.ClusterPath, c.Namespace, resourceQuota), &corev1.ResourceQuota{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.ResourceQuota), err -} - -func (c *resourceQuotasClient) UpdateStatus(ctx context.Context, resourceQuota *corev1.ResourceQuota, opts metav1.UpdateOptions) (*corev1.ResourceQuota, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(resourceQuotasResource, c.ClusterPath, "status", c.Namespace, resourceQuota), &corev1.ResourceQuota{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.ResourceQuota), err -} - -func (c *resourceQuotasClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(resourceQuotasResource, c.ClusterPath, c.Namespace, name, opts), &corev1.ResourceQuota{}) - return err -} - -func (c *resourceQuotasClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(resourceQuotasResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &corev1.ResourceQuotaList{}) - return err -} - -func (c *resourceQuotasClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*corev1.ResourceQuota, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(resourceQuotasResource, c.ClusterPath, c.Namespace, name), &corev1.ResourceQuota{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.ResourceQuota), err -} - -// List takes label and field selectors, and returns the list of ResourceQuotas that match those selectors. -func (c *resourceQuotasClient) List(ctx context.Context, opts metav1.ListOptions) (*corev1.ResourceQuotaList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(resourceQuotasResource, resourceQuotasKind, c.ClusterPath, c.Namespace, opts), &corev1.ResourceQuotaList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &corev1.ResourceQuotaList{ListMeta: obj.(*corev1.ResourceQuotaList).ListMeta} - for _, item := range obj.(*corev1.ResourceQuotaList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *resourceQuotasClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(resourceQuotasResource, c.ClusterPath, c.Namespace, opts)) } -func (c *resourceQuotasClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*corev1.ResourceQuota, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(resourceQuotasResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &corev1.ResourceQuota{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.ResourceQuota), err -} - -func (c *resourceQuotasClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationscorev1.ResourceQuotaApplyConfiguration, opts metav1.ApplyOptions) (*corev1.ResourceQuota, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(resourceQuotasResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &corev1.ResourceQuota{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.ResourceQuota), err -} - -func (c *resourceQuotasClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationscorev1.ResourceQuotaApplyConfiguration, opts metav1.ApplyOptions) (*corev1.ResourceQuota, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(resourceQuotasResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &corev1.ResourceQuota{}) - if obj == nil { - return nil, err +func newFakeResourceQuotaClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedcorev1.ResourceQuotaInterface { + return &resourceQuotaScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*corev1.ResourceQuota, *corev1.ResourceQuotaList, *v1.ResourceQuotaApplyConfiguration]( + fake, + clusterPath, + namespace, + corev1.SchemeGroupVersion.WithResource("resourcequotas"), + corev1.SchemeGroupVersion.WithKind("ResourceQuota"), + func() *corev1.ResourceQuota { return &corev1.ResourceQuota{} }, + func() *corev1.ResourceQuotaList { return &corev1.ResourceQuotaList{} }, + func(dst, src *corev1.ResourceQuotaList) { dst.ListMeta = src.ListMeta }, + func(list *corev1.ResourceQuotaList) []*corev1.ResourceQuota { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *corev1.ResourceQuotaList, items []*corev1.ResourceQuota) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*corev1.ResourceQuota), err } diff --git a/kubernetes/typed/core/v1/fake/secret.go b/kubernetes/typed/core/v1/fake/secret.go index 137d9f899..a602590b8 100644 --- a/kubernetes/typed/core/v1/fake/secret.go +++ b/kubernetes/typed/core/v1/fake/secret.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationscorev1 "k8s.io/client-go/applyconfigurations/core/v1" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/core/v1" + typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" - kcpcorev1 "github.com/kcp-dev/client-go/kubernetes/typed/core/v1" + typedkcpcorev1 "github.com/kcp-dev/client-go/kubernetes/typed/core/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var secretsResource = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "secrets"} -var secretsKind = schema.GroupVersionKind{Group: "", Version: "v1", Kind: "Secret"} - -type secretsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *secretsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpcorev1.SecretsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &secretsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// secretClusterClient implements SecretClusterInterface +type secretClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*corev1.Secret, *corev1.SecretList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of Secrets that match those selectors across all clusters. -func (c *secretsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*corev1.SecretList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(secretsResource, secretsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &corev1.SecretList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeSecretClusterClient(fake *CoreV1ClusterClient) typedkcpcorev1.SecretClusterInterface { + return &secretClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*corev1.Secret, *corev1.SecretList]( + fake.Fake, + corev1.SchemeGroupVersion.WithResource("secrets"), + corev1.SchemeGroupVersion.WithKind("Secret"), + func() *corev1.Secret { return &corev1.Secret{} }, + func() *corev1.SecretList { return &corev1.SecretList{} }, + func(dst, src *corev1.SecretList) { dst.ListMeta = src.ListMeta }, + func(list *corev1.SecretList) []*corev1.Secret { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *corev1.SecretList, items []*corev1.Secret) { list.Items = kcpgentype.FromPointerSlice(items) }, + ), + fake.Fake, } - list := &corev1.SecretList{ListMeta: obj.(*corev1.SecretList).ListMeta} - for _, item := range obj.(*corev1.SecretList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested Secrets across all clusters. -func (c *secretsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(secretsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *secretClusterClient) Cluster(cluster logicalcluster.Path) typedkcpcorev1.SecretsNamespacer { + return &secretNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type secretsNamespacer struct { +type secretNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *secretsNamespacer) Namespace(namespace string) corev1client.SecretInterface { - return &secretsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *secretNamespacer) Namespace(namespace string) typedcorev1.SecretInterface { + return newFakeSecretClient(n.Fake, namespace, n.ClusterPath) } -type secretsClient struct { - *kcptesting.Fake +// secretScopedClient implements SecretInterface +type secretScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*corev1.Secret, *corev1.SecretList, *v1.SecretApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *secretsClient) Create(ctx context.Context, secret *corev1.Secret, opts metav1.CreateOptions) (*corev1.Secret, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(secretsResource, c.ClusterPath, c.Namespace, secret), &corev1.Secret{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Secret), err -} - -func (c *secretsClient) Update(ctx context.Context, secret *corev1.Secret, opts metav1.UpdateOptions) (*corev1.Secret, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(secretsResource, c.ClusterPath, c.Namespace, secret), &corev1.Secret{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Secret), err -} - -func (c *secretsClient) UpdateStatus(ctx context.Context, secret *corev1.Secret, opts metav1.UpdateOptions) (*corev1.Secret, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(secretsResource, c.ClusterPath, "status", c.Namespace, secret), &corev1.Secret{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Secret), err -} - -func (c *secretsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(secretsResource, c.ClusterPath, c.Namespace, name, opts), &corev1.Secret{}) - return err -} - -func (c *secretsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(secretsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &corev1.SecretList{}) - return err -} - -func (c *secretsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*corev1.Secret, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(secretsResource, c.ClusterPath, c.Namespace, name), &corev1.Secret{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Secret), err -} - -// List takes label and field selectors, and returns the list of Secrets that match those selectors. -func (c *secretsClient) List(ctx context.Context, opts metav1.ListOptions) (*corev1.SecretList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(secretsResource, secretsKind, c.ClusterPath, c.Namespace, opts), &corev1.SecretList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &corev1.SecretList{ListMeta: obj.(*corev1.SecretList).ListMeta} - for _, item := range obj.(*corev1.SecretList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *secretsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(secretsResource, c.ClusterPath, c.Namespace, opts)) } -func (c *secretsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*corev1.Secret, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(secretsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &corev1.Secret{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Secret), err -} - -func (c *secretsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationscorev1.SecretApplyConfiguration, opts metav1.ApplyOptions) (*corev1.Secret, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(secretsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &corev1.Secret{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Secret), err -} - -func (c *secretsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationscorev1.SecretApplyConfiguration, opts metav1.ApplyOptions) (*corev1.Secret, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(secretsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &corev1.Secret{}) - if obj == nil { - return nil, err +func newFakeSecretClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedcorev1.SecretInterface { + return &secretScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*corev1.Secret, *corev1.SecretList, *v1.SecretApplyConfiguration]( + fake, + clusterPath, + namespace, + corev1.SchemeGroupVersion.WithResource("secrets"), + corev1.SchemeGroupVersion.WithKind("Secret"), + func() *corev1.Secret { return &corev1.Secret{} }, + func() *corev1.SecretList { return &corev1.SecretList{} }, + func(dst, src *corev1.SecretList) { dst.ListMeta = src.ListMeta }, + func(list *corev1.SecretList) []*corev1.Secret { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *corev1.SecretList, items []*corev1.Secret) { list.Items = kcpgentype.FromPointerSlice(items) }, + ), + fake, + clusterPath, } - return obj.(*corev1.Secret), err } diff --git a/kubernetes/typed/core/v1/fake/service.go b/kubernetes/typed/core/v1/fake/service.go index 412361ba5..2d3d8f6aa 100644 --- a/kubernetes/typed/core/v1/fake/service.go +++ b/kubernetes/typed/core/v1/fake/service.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,190 +14,83 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationscorev1 "k8s.io/client-go/applyconfigurations/core/v1" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/core/v1" + typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" - kcpcorev1 "github.com/kcp-dev/client-go/kubernetes/typed/core/v1" + typedkcpcorev1 "github.com/kcp-dev/client-go/kubernetes/typed/core/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var servicesResource = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "services"} -var servicesKind = schema.GroupVersionKind{Group: "", Version: "v1", Kind: "Service"} - -type servicesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *servicesClusterClient) Cluster(clusterPath logicalcluster.Path) kcpcorev1.ServicesNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &servicesNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// serviceClusterClient implements ServiceClusterInterface +type serviceClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*corev1.Service, *corev1.ServiceList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of Services that match those selectors across all clusters. -func (c *servicesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*corev1.ServiceList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(servicesResource, servicesKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &corev1.ServiceList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeServiceClusterClient(fake *CoreV1ClusterClient) typedkcpcorev1.ServiceClusterInterface { + return &serviceClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*corev1.Service, *corev1.ServiceList]( + fake.Fake, + corev1.SchemeGroupVersion.WithResource("services"), + corev1.SchemeGroupVersion.WithKind("Service"), + func() *corev1.Service { return &corev1.Service{} }, + func() *corev1.ServiceList { return &corev1.ServiceList{} }, + func(dst, src *corev1.ServiceList) { dst.ListMeta = src.ListMeta }, + func(list *corev1.ServiceList) []*corev1.Service { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *corev1.ServiceList, items []*corev1.Service) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &corev1.ServiceList{ListMeta: obj.(*corev1.ServiceList).ListMeta} - for _, item := range obj.(*corev1.ServiceList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested Services across all clusters. -func (c *servicesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(servicesResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *serviceClusterClient) Cluster(cluster logicalcluster.Path) typedkcpcorev1.ServicesNamespacer { + return &serviceNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type servicesNamespacer struct { +type serviceNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *servicesNamespacer) Namespace(namespace string) corev1client.ServiceInterface { - return &servicesClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *serviceNamespacer) Namespace(namespace string) typedcorev1.ServiceInterface { + return newFakeServiceClient(n.Fake, namespace, n.ClusterPath) } -type servicesClient struct { - *kcptesting.Fake +// serviceScopedClient implements ServiceInterface +type serviceScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*corev1.Service, *corev1.ServiceList, *v1.ServiceApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string } -func (c *servicesClient) Create(ctx context.Context, service *corev1.Service, opts metav1.CreateOptions) (*corev1.Service, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(servicesResource, c.ClusterPath, c.Namespace, service), &corev1.Service{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Service), err -} - -func (c *servicesClient) Update(ctx context.Context, service *corev1.Service, opts metav1.UpdateOptions) (*corev1.Service, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(servicesResource, c.ClusterPath, c.Namespace, service), &corev1.Service{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Service), err -} - -func (c *servicesClient) UpdateStatus(ctx context.Context, service *corev1.Service, opts metav1.UpdateOptions) (*corev1.Service, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(servicesResource, c.ClusterPath, "status", c.Namespace, service), &corev1.Service{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Service), err -} - -func (c *servicesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(servicesResource, c.ClusterPath, c.Namespace, name, opts), &corev1.Service{}) - return err -} - -func (c *servicesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*corev1.Service, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(servicesResource, c.ClusterPath, c.Namespace, name), &corev1.Service{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Service), err -} - -// List takes label and field selectors, and returns the list of Services that match those selectors. -func (c *servicesClient) List(ctx context.Context, opts metav1.ListOptions) (*corev1.ServiceList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(servicesResource, servicesKind, c.ClusterPath, c.Namespace, opts), &corev1.ServiceList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &corev1.ServiceList{ListMeta: obj.(*corev1.ServiceList).ListMeta} - for _, item := range obj.(*corev1.ServiceList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *servicesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(servicesResource, c.ClusterPath, c.Namespace, opts)) -} - -func (c *servicesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*corev1.Service, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(servicesResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &corev1.Service{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Service), err -} - -func (c *servicesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationscorev1.ServiceApplyConfiguration, opts metav1.ApplyOptions) (*corev1.Service, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(servicesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &corev1.Service{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.Service), err -} - -func (c *servicesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationscorev1.ServiceApplyConfiguration, opts metav1.ApplyOptions) (*corev1.Service, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(servicesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &corev1.Service{}) - if obj == nil { - return nil, err +func newFakeServiceClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedcorev1.ServiceInterface { + return &serviceScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*corev1.Service, *corev1.ServiceList, *v1.ServiceApplyConfiguration]( + fake, + clusterPath, + namespace, + corev1.SchemeGroupVersion.WithResource("services"), + corev1.SchemeGroupVersion.WithKind("Service"), + func() *corev1.Service { return &corev1.Service{} }, + func() *corev1.ServiceList { return &corev1.ServiceList{} }, + func(dst, src *corev1.ServiceList) { dst.ListMeta = src.ListMeta }, + func(list *corev1.ServiceList) []*corev1.Service { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *corev1.ServiceList, items []*corev1.Service) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*corev1.Service), err } diff --git a/kubernetes/typed/core/v1/fake/serviceaccount.go b/kubernetes/typed/core/v1/fake/serviceaccount.go index f08a9a6d2..59b478605 100644 --- a/kubernetes/typed/core/v1/fake/serviceaccount.go +++ b/kubernetes/typed/core/v1/fake/serviceaccount.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,206 +14,101 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" + context "context" "github.com/kcp-dev/logicalcluster/v3" authenticationv1 "k8s.io/api/authentication/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationscorev1 "k8s.io/client-go/applyconfigurations/core/v1" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" - "k8s.io/client-go/testing" - - kcpcorev1 "github.com/kcp-dev/client-go/kubernetes/typed/core/v1" + v1 "k8s.io/client-go/applyconfigurations/core/v1" + typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" + + typedkcpcorev1 "github.com/kcp-dev/client-go/kubernetes/typed/core/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var serviceAccountsResource = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "serviceaccounts"} -var serviceAccountsKind = schema.GroupVersionKind{Group: "", Version: "v1", Kind: "ServiceAccount"} - -type serviceAccountsClusterClient struct { - *kcptesting.Fake +// serviceAccountClusterClient implements ServiceAccountClusterInterface +type serviceAccountClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*corev1.ServiceAccount, *corev1.ServiceAccountList] + Fake *kcptesting.Fake } -// Cluster scopes the client down to a particular cluster. -func (c *serviceAccountsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpcorev1.ServiceAccountsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") +func newFakeServiceAccountClusterClient(fake *CoreV1ClusterClient) typedkcpcorev1.ServiceAccountClusterInterface { + return &serviceAccountClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*corev1.ServiceAccount, *corev1.ServiceAccountList]( + fake.Fake, + corev1.SchemeGroupVersion.WithResource("serviceaccounts"), + corev1.SchemeGroupVersion.WithKind("ServiceAccount"), + func() *corev1.ServiceAccount { return &corev1.ServiceAccount{} }, + func() *corev1.ServiceAccountList { return &corev1.ServiceAccountList{} }, + func(dst, src *corev1.ServiceAccountList) { dst.ListMeta = src.ListMeta }, + func(list *corev1.ServiceAccountList) []*corev1.ServiceAccount { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *corev1.ServiceAccountList, items []*corev1.ServiceAccount) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - return &serviceAccountsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} } -// List takes label and field selectors, and returns the list of ServiceAccounts that match those selectors across all clusters. -func (c *serviceAccountsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*corev1.ServiceAccountList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(serviceAccountsResource, serviceAccountsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &corev1.ServiceAccountList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &corev1.ServiceAccountList{ListMeta: obj.(*corev1.ServiceAccountList).ListMeta} - for _, item := range obj.(*corev1.ServiceAccountList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested ServiceAccounts across all clusters. -func (c *serviceAccountsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(serviceAccountsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *serviceAccountClusterClient) Cluster(cluster logicalcluster.Path) typedkcpcorev1.ServiceAccountsNamespacer { + return &serviceAccountNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type serviceAccountsNamespacer struct { +type serviceAccountNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *serviceAccountsNamespacer) Namespace(namespace string) corev1client.ServiceAccountInterface { - return &serviceAccountsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *serviceAccountNamespacer) Namespace(namespace string) typedcorev1.ServiceAccountInterface { + return newFakeServiceAccountClient(n.Fake, namespace, n.ClusterPath) } -type serviceAccountsClient struct { - *kcptesting.Fake +// serviceAccountScopedClient implements ServiceAccountInterface +type serviceAccountScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*corev1.ServiceAccount, *corev1.ServiceAccountList, *v1.ServiceAccountApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *serviceAccountsClient) Create(ctx context.Context, serviceAccount *corev1.ServiceAccount, opts metav1.CreateOptions) (*corev1.ServiceAccount, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(serviceAccountsResource, c.ClusterPath, c.Namespace, serviceAccount), &corev1.ServiceAccount{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.ServiceAccount), err -} - -func (c *serviceAccountsClient) Update(ctx context.Context, serviceAccount *corev1.ServiceAccount, opts metav1.UpdateOptions) (*corev1.ServiceAccount, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(serviceAccountsResource, c.ClusterPath, c.Namespace, serviceAccount), &corev1.ServiceAccount{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.ServiceAccount), err -} - -func (c *serviceAccountsClient) UpdateStatus(ctx context.Context, serviceAccount *corev1.ServiceAccount, opts metav1.UpdateOptions) (*corev1.ServiceAccount, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(serviceAccountsResource, c.ClusterPath, "status", c.Namespace, serviceAccount), &corev1.ServiceAccount{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.ServiceAccount), err -} - -func (c *serviceAccountsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(serviceAccountsResource, c.ClusterPath, c.Namespace, name, opts), &corev1.ServiceAccount{}) - return err -} - -func (c *serviceAccountsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(serviceAccountsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &corev1.ServiceAccountList{}) - return err -} - -func (c *serviceAccountsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*corev1.ServiceAccount, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(serviceAccountsResource, c.ClusterPath, c.Namespace, name), &corev1.ServiceAccount{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.ServiceAccount), err -} - -// List takes label and field selectors, and returns the list of ServiceAccounts that match those selectors. -func (c *serviceAccountsClient) List(ctx context.Context, opts metav1.ListOptions) (*corev1.ServiceAccountList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(serviceAccountsResource, serviceAccountsKind, c.ClusterPath, c.Namespace, opts), &corev1.ServiceAccountList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &corev1.ServiceAccountList{ListMeta: obj.(*corev1.ServiceAccountList).ListMeta} - for _, item := range obj.(*corev1.ServiceAccountList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *serviceAccountsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(serviceAccountsResource, c.ClusterPath, c.Namespace, opts)) -} - -func (c *serviceAccountsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*corev1.ServiceAccount, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(serviceAccountsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &corev1.ServiceAccount{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.ServiceAccount), err -} - -func (c *serviceAccountsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationscorev1.ServiceAccountApplyConfiguration, opts metav1.ApplyOptions) (*corev1.ServiceAccount, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(serviceAccountsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &corev1.ServiceAccount{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.ServiceAccount), err -} - -func (c *serviceAccountsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationscorev1.ServiceAccountApplyConfiguration, opts metav1.ApplyOptions) (*corev1.ServiceAccount, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(serviceAccountsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &corev1.ServiceAccount{}) - if obj == nil { - return nil, err - } - return obj.(*corev1.ServiceAccount), err } -func (c *serviceAccountsClient) CreateToken(ctx context.Context, serviceAccountName string, tokenRequest *authenticationv1.TokenRequest, opts metav1.CreateOptions) (*authenticationv1.TokenRequest, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateSubresourceAction(serviceAccountsResource, c.ClusterPath, serviceAccountName, "token", c.Namespace, tokenRequest), &authenticationv1.TokenRequest{}) +func newFakeServiceAccountClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedcorev1.ServiceAccountInterface { + return &serviceAccountScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*corev1.ServiceAccount, *corev1.ServiceAccountList, *v1.ServiceAccountApplyConfiguration]( + fake, + clusterPath, + namespace, + corev1.SchemeGroupVersion.WithResource("serviceaccounts"), + corev1.SchemeGroupVersion.WithKind("ServiceAccount"), + func() *corev1.ServiceAccount { return &corev1.ServiceAccount{} }, + func() *corev1.ServiceAccountList { return &corev1.ServiceAccountList{} }, + func(dst, src *corev1.ServiceAccountList) { dst.ListMeta = src.ListMeta }, + func(list *corev1.ServiceAccountList) []*corev1.ServiceAccount { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *corev1.ServiceAccountList, items []*corev1.ServiceAccount) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, + } +} + +// CreateToken takes the representation of a tokenRequest and creates it. Returns the server's representation of the tokenRequest, and an error, if there is any. +func (c *serviceAccountScopedClient) CreateToken(ctx context.Context, serviceAccountName string, tokenRequest *authenticationv1.TokenRequest, _ metav1.CreateOptions) (result *authenticationv1.TokenRequest, err error) { + emptyResult := &authenticationv1.TokenRequest{} + obj, err := c.Fake.Invokes(kcptesting.NewCreateSubresourceAction(c.Resource(), c.ClusterPath, serviceAccountName, "token", c.Namespace(), tokenRequest), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*authenticationv1.TokenRequest), err } diff --git a/kubernetes/typed/core/v1/generated_expansion.go b/kubernetes/typed/core/v1/generated_expansion.go new file mode 100644 index 000000000..a7e4f03d6 --- /dev/null +++ b/kubernetes/typed/core/v1/generated_expansion.go @@ -0,0 +1,51 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1 + +type ComponentStatusClusterExpansion interface{} + +type ConfigMapClusterExpansion interface{} + +type EndpointsClusterExpansion interface{} + +type EventClusterExpansion interface{} + +type LimitRangeClusterExpansion interface{} + +type NamespaceClusterExpansion interface{} + +type NodeClusterExpansion interface{} + +type PersistentVolumeClusterExpansion interface{} + +type PersistentVolumeClaimClusterExpansion interface{} + +type PodClusterExpansion interface{} + +type PodTemplateClusterExpansion interface{} + +type ReplicationControllerClusterExpansion interface{} + +type ResourceQuotaClusterExpansion interface{} + +type SecretClusterExpansion interface{} + +type ServiceClusterExpansion interface{} + +type ServiceAccountClusterExpansion interface{} diff --git a/kubernetes/typed/core/v1/limitrange.go b/kubernetes/typed/core/v1/limitrange.go index 14bc3d214..6dc4f893c 100644 --- a/kubernetes/typed/core/v1/limitrange.go +++ b/kubernetes/typed/core/v1/limitrange.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" ) // LimitRangesClusterGetter has a method to return a LimitRangeClusterInterface. @@ -42,10 +42,11 @@ type LimitRangeClusterInterface interface { Cluster(logicalcluster.Path) LimitRangesNamespacer List(ctx context.Context, opts metav1.ListOptions) (*corev1.LimitRangeList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + LimitRangeClusterExpansion } type limitRangesClusterInterface struct { - clientCache kcpclient.Cache[*corev1client.CoreV1Client] + clientCache kcpclient.Cache[*typedcorev1.CoreV1Client] } // Cluster scopes the client down to a particular cluster. @@ -67,16 +68,16 @@ func (c *limitRangesClusterInterface) Watch(ctx context.Context, opts metav1.Lis return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).LimitRanges(metav1.NamespaceAll).Watch(ctx, opts) } -// LimitRangesNamespacer can scope to objects within a namespace, returning a corev1client.LimitRangeInterface. +// LimitRangesNamespacer can scope to objects within a namespace, returning a typedcorev1.LimitRangeInterface. type LimitRangesNamespacer interface { - Namespace(string) corev1client.LimitRangeInterface + Namespace(string) typedcorev1.LimitRangeInterface } type limitRangesNamespacer struct { - clientCache kcpclient.Cache[*corev1client.CoreV1Client] + clientCache kcpclient.Cache[*typedcorev1.CoreV1Client] clusterPath logicalcluster.Path } -func (n *limitRangesNamespacer) Namespace(namespace string) corev1client.LimitRangeInterface { +func (n *limitRangesNamespacer) Namespace(namespace string) typedcorev1.LimitRangeInterface { return n.clientCache.ClusterOrDie(n.clusterPath).LimitRanges(namespace) } diff --git a/kubernetes/typed/core/v1/namespace.go b/kubernetes/typed/core/v1/namespace.go index 9d79d777c..7c8d37ddc 100644 --- a/kubernetes/typed/core/v1/namespace.go +++ b/kubernetes/typed/core/v1/namespace.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - corev1 "k8s.io/api/core/v1" + apicorev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" + watch "k8s.io/apimachinery/pkg/watch" + corev1 "k8s.io/client-go/kubernetes/typed/core/v1" ) // NamespacesClusterGetter has a method to return a NamespaceClusterInterface. @@ -37,19 +37,20 @@ type NamespacesClusterGetter interface { } // NamespaceClusterInterface can operate on Namespaces across all clusters, -// or scope down to one cluster and return a corev1client.NamespaceInterface. +// or scope down to one cluster and return a corev1.NamespaceInterface. type NamespaceClusterInterface interface { - Cluster(logicalcluster.Path) corev1client.NamespaceInterface - List(ctx context.Context, opts metav1.ListOptions) (*corev1.NamespaceList, error) + Cluster(logicalcluster.Path) corev1.NamespaceInterface + List(ctx context.Context, opts metav1.ListOptions) (*apicorev1.NamespaceList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + NamespaceClusterExpansion } type namespacesClusterInterface struct { - clientCache kcpclient.Cache[*corev1client.CoreV1Client] + clientCache kcpclient.Cache[*corev1.CoreV1Client] } // Cluster scopes the client down to a particular cluster. -func (c *namespacesClusterInterface) Cluster(clusterPath logicalcluster.Path) corev1client.NamespaceInterface { +func (c *namespacesClusterInterface) Cluster(clusterPath logicalcluster.Path) corev1.NamespaceInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,7 +59,7 @@ func (c *namespacesClusterInterface) Cluster(clusterPath logicalcluster.Path) co } // List returns the entire collection of all Namespaces across all clusters. -func (c *namespacesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*corev1.NamespaceList, error) { +func (c *namespacesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*apicorev1.NamespaceList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Namespaces().List(ctx, opts) } diff --git a/kubernetes/typed/core/v1/node.go b/kubernetes/typed/core/v1/node.go index 29eafbd54..fc2a9f37f 100644 --- a/kubernetes/typed/core/v1/node.go +++ b/kubernetes/typed/core/v1/node.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - corev1 "k8s.io/api/core/v1" + apicorev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" + watch "k8s.io/apimachinery/pkg/watch" + corev1 "k8s.io/client-go/kubernetes/typed/core/v1" ) // NodesClusterGetter has a method to return a NodeClusterInterface. @@ -37,19 +37,20 @@ type NodesClusterGetter interface { } // NodeClusterInterface can operate on Nodes across all clusters, -// or scope down to one cluster and return a corev1client.NodeInterface. +// or scope down to one cluster and return a corev1.NodeInterface. type NodeClusterInterface interface { - Cluster(logicalcluster.Path) corev1client.NodeInterface - List(ctx context.Context, opts metav1.ListOptions) (*corev1.NodeList, error) + Cluster(logicalcluster.Path) corev1.NodeInterface + List(ctx context.Context, opts metav1.ListOptions) (*apicorev1.NodeList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + NodeClusterExpansion } type nodesClusterInterface struct { - clientCache kcpclient.Cache[*corev1client.CoreV1Client] + clientCache kcpclient.Cache[*corev1.CoreV1Client] } // Cluster scopes the client down to a particular cluster. -func (c *nodesClusterInterface) Cluster(clusterPath logicalcluster.Path) corev1client.NodeInterface { +func (c *nodesClusterInterface) Cluster(clusterPath logicalcluster.Path) corev1.NodeInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,7 +59,7 @@ func (c *nodesClusterInterface) Cluster(clusterPath logicalcluster.Path) corev1c } // List returns the entire collection of all Nodes across all clusters. -func (c *nodesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*corev1.NodeList, error) { +func (c *nodesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*apicorev1.NodeList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Nodes().List(ctx, opts) } diff --git a/kubernetes/typed/core/v1/persistentvolume.go b/kubernetes/typed/core/v1/persistentvolume.go index 57550d2a9..dfb24e104 100644 --- a/kubernetes/typed/core/v1/persistentvolume.go +++ b/kubernetes/typed/core/v1/persistentvolume.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - corev1 "k8s.io/api/core/v1" + apicorev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" + watch "k8s.io/apimachinery/pkg/watch" + corev1 "k8s.io/client-go/kubernetes/typed/core/v1" ) // PersistentVolumesClusterGetter has a method to return a PersistentVolumeClusterInterface. @@ -37,19 +37,20 @@ type PersistentVolumesClusterGetter interface { } // PersistentVolumeClusterInterface can operate on PersistentVolumes across all clusters, -// or scope down to one cluster and return a corev1client.PersistentVolumeInterface. +// or scope down to one cluster and return a corev1.PersistentVolumeInterface. type PersistentVolumeClusterInterface interface { - Cluster(logicalcluster.Path) corev1client.PersistentVolumeInterface - List(ctx context.Context, opts metav1.ListOptions) (*corev1.PersistentVolumeList, error) + Cluster(logicalcluster.Path) corev1.PersistentVolumeInterface + List(ctx context.Context, opts metav1.ListOptions) (*apicorev1.PersistentVolumeList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + PersistentVolumeClusterExpansion } type persistentVolumesClusterInterface struct { - clientCache kcpclient.Cache[*corev1client.CoreV1Client] + clientCache kcpclient.Cache[*corev1.CoreV1Client] } // Cluster scopes the client down to a particular cluster. -func (c *persistentVolumesClusterInterface) Cluster(clusterPath logicalcluster.Path) corev1client.PersistentVolumeInterface { +func (c *persistentVolumesClusterInterface) Cluster(clusterPath logicalcluster.Path) corev1.PersistentVolumeInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,7 +59,7 @@ func (c *persistentVolumesClusterInterface) Cluster(clusterPath logicalcluster.P } // List returns the entire collection of all PersistentVolumes across all clusters. -func (c *persistentVolumesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*corev1.PersistentVolumeList, error) { +func (c *persistentVolumesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*apicorev1.PersistentVolumeList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).PersistentVolumes().List(ctx, opts) } diff --git a/kubernetes/typed/core/v1/persistentvolumeclaim.go b/kubernetes/typed/core/v1/persistentvolumeclaim.go index 02dc94274..3cd21cc1c 100644 --- a/kubernetes/typed/core/v1/persistentvolumeclaim.go +++ b/kubernetes/typed/core/v1/persistentvolumeclaim.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" ) // PersistentVolumeClaimsClusterGetter has a method to return a PersistentVolumeClaimClusterInterface. @@ -42,10 +42,11 @@ type PersistentVolumeClaimClusterInterface interface { Cluster(logicalcluster.Path) PersistentVolumeClaimsNamespacer List(ctx context.Context, opts metav1.ListOptions) (*corev1.PersistentVolumeClaimList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + PersistentVolumeClaimClusterExpansion } type persistentVolumeClaimsClusterInterface struct { - clientCache kcpclient.Cache[*corev1client.CoreV1Client] + clientCache kcpclient.Cache[*typedcorev1.CoreV1Client] } // Cluster scopes the client down to a particular cluster. @@ -67,16 +68,16 @@ func (c *persistentVolumeClaimsClusterInterface) Watch(ctx context.Context, opts return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).PersistentVolumeClaims(metav1.NamespaceAll).Watch(ctx, opts) } -// PersistentVolumeClaimsNamespacer can scope to objects within a namespace, returning a corev1client.PersistentVolumeClaimInterface. +// PersistentVolumeClaimsNamespacer can scope to objects within a namespace, returning a typedcorev1.PersistentVolumeClaimInterface. type PersistentVolumeClaimsNamespacer interface { - Namespace(string) corev1client.PersistentVolumeClaimInterface + Namespace(string) typedcorev1.PersistentVolumeClaimInterface } type persistentVolumeClaimsNamespacer struct { - clientCache kcpclient.Cache[*corev1client.CoreV1Client] + clientCache kcpclient.Cache[*typedcorev1.CoreV1Client] clusterPath logicalcluster.Path } -func (n *persistentVolumeClaimsNamespacer) Namespace(namespace string) corev1client.PersistentVolumeClaimInterface { +func (n *persistentVolumeClaimsNamespacer) Namespace(namespace string) typedcorev1.PersistentVolumeClaimInterface { return n.clientCache.ClusterOrDie(n.clusterPath).PersistentVolumeClaims(namespace) } diff --git a/kubernetes/typed/core/v1/pod.go b/kubernetes/typed/core/v1/pod.go index 7274a56ad..05fc7855d 100644 --- a/kubernetes/typed/core/v1/pod.go +++ b/kubernetes/typed/core/v1/pod.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" ) // PodsClusterGetter has a method to return a PodClusterInterface. @@ -42,10 +42,11 @@ type PodClusterInterface interface { Cluster(logicalcluster.Path) PodsNamespacer List(ctx context.Context, opts metav1.ListOptions) (*corev1.PodList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + PodClusterExpansion } type podsClusterInterface struct { - clientCache kcpclient.Cache[*corev1client.CoreV1Client] + clientCache kcpclient.Cache[*typedcorev1.CoreV1Client] } // Cluster scopes the client down to a particular cluster. @@ -67,16 +68,16 @@ func (c *podsClusterInterface) Watch(ctx context.Context, opts metav1.ListOption return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Pods(metav1.NamespaceAll).Watch(ctx, opts) } -// PodsNamespacer can scope to objects within a namespace, returning a corev1client.PodInterface. +// PodsNamespacer can scope to objects within a namespace, returning a typedcorev1.PodInterface. type PodsNamespacer interface { - Namespace(string) corev1client.PodInterface + Namespace(string) typedcorev1.PodInterface } type podsNamespacer struct { - clientCache kcpclient.Cache[*corev1client.CoreV1Client] + clientCache kcpclient.Cache[*typedcorev1.CoreV1Client] clusterPath logicalcluster.Path } -func (n *podsNamespacer) Namespace(namespace string) corev1client.PodInterface { +func (n *podsNamespacer) Namespace(namespace string) typedcorev1.PodInterface { return n.clientCache.ClusterOrDie(n.clusterPath).Pods(namespace) } diff --git a/kubernetes/typed/core/v1/podtemplate.go b/kubernetes/typed/core/v1/podtemplate.go index 387354f55..792b263d4 100644 --- a/kubernetes/typed/core/v1/podtemplate.go +++ b/kubernetes/typed/core/v1/podtemplate.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" ) // PodTemplatesClusterGetter has a method to return a PodTemplateClusterInterface. @@ -42,10 +42,11 @@ type PodTemplateClusterInterface interface { Cluster(logicalcluster.Path) PodTemplatesNamespacer List(ctx context.Context, opts metav1.ListOptions) (*corev1.PodTemplateList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + PodTemplateClusterExpansion } type podTemplatesClusterInterface struct { - clientCache kcpclient.Cache[*corev1client.CoreV1Client] + clientCache kcpclient.Cache[*typedcorev1.CoreV1Client] } // Cluster scopes the client down to a particular cluster. @@ -67,16 +68,16 @@ func (c *podTemplatesClusterInterface) Watch(ctx context.Context, opts metav1.Li return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).PodTemplates(metav1.NamespaceAll).Watch(ctx, opts) } -// PodTemplatesNamespacer can scope to objects within a namespace, returning a corev1client.PodTemplateInterface. +// PodTemplatesNamespacer can scope to objects within a namespace, returning a typedcorev1.PodTemplateInterface. type PodTemplatesNamespacer interface { - Namespace(string) corev1client.PodTemplateInterface + Namespace(string) typedcorev1.PodTemplateInterface } type podTemplatesNamespacer struct { - clientCache kcpclient.Cache[*corev1client.CoreV1Client] + clientCache kcpclient.Cache[*typedcorev1.CoreV1Client] clusterPath logicalcluster.Path } -func (n *podTemplatesNamespacer) Namespace(namespace string) corev1client.PodTemplateInterface { +func (n *podTemplatesNamespacer) Namespace(namespace string) typedcorev1.PodTemplateInterface { return n.clientCache.ClusterOrDie(n.clusterPath).PodTemplates(namespace) } diff --git a/kubernetes/typed/core/v1/replicationcontroller.go b/kubernetes/typed/core/v1/replicationcontroller.go index 0b917bb94..bd34eaf19 100644 --- a/kubernetes/typed/core/v1/replicationcontroller.go +++ b/kubernetes/typed/core/v1/replicationcontroller.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" ) // ReplicationControllersClusterGetter has a method to return a ReplicationControllerClusterInterface. @@ -42,10 +42,11 @@ type ReplicationControllerClusterInterface interface { Cluster(logicalcluster.Path) ReplicationControllersNamespacer List(ctx context.Context, opts metav1.ListOptions) (*corev1.ReplicationControllerList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + ReplicationControllerClusterExpansion } type replicationControllersClusterInterface struct { - clientCache kcpclient.Cache[*corev1client.CoreV1Client] + clientCache kcpclient.Cache[*typedcorev1.CoreV1Client] } // Cluster scopes the client down to a particular cluster. @@ -67,16 +68,16 @@ func (c *replicationControllersClusterInterface) Watch(ctx context.Context, opts return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ReplicationControllers(metav1.NamespaceAll).Watch(ctx, opts) } -// ReplicationControllersNamespacer can scope to objects within a namespace, returning a corev1client.ReplicationControllerInterface. +// ReplicationControllersNamespacer can scope to objects within a namespace, returning a typedcorev1.ReplicationControllerInterface. type ReplicationControllersNamespacer interface { - Namespace(string) corev1client.ReplicationControllerInterface + Namespace(string) typedcorev1.ReplicationControllerInterface } type replicationControllersNamespacer struct { - clientCache kcpclient.Cache[*corev1client.CoreV1Client] + clientCache kcpclient.Cache[*typedcorev1.CoreV1Client] clusterPath logicalcluster.Path } -func (n *replicationControllersNamespacer) Namespace(namespace string) corev1client.ReplicationControllerInterface { +func (n *replicationControllersNamespacer) Namespace(namespace string) typedcorev1.ReplicationControllerInterface { return n.clientCache.ClusterOrDie(n.clusterPath).ReplicationControllers(namespace) } diff --git a/kubernetes/typed/core/v1/resourcequota.go b/kubernetes/typed/core/v1/resourcequota.go index 5c61c2d10..4f6faeaf3 100644 --- a/kubernetes/typed/core/v1/resourcequota.go +++ b/kubernetes/typed/core/v1/resourcequota.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" ) // ResourceQuotasClusterGetter has a method to return a ResourceQuotaClusterInterface. @@ -42,10 +42,11 @@ type ResourceQuotaClusterInterface interface { Cluster(logicalcluster.Path) ResourceQuotasNamespacer List(ctx context.Context, opts metav1.ListOptions) (*corev1.ResourceQuotaList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + ResourceQuotaClusterExpansion } type resourceQuotasClusterInterface struct { - clientCache kcpclient.Cache[*corev1client.CoreV1Client] + clientCache kcpclient.Cache[*typedcorev1.CoreV1Client] } // Cluster scopes the client down to a particular cluster. @@ -67,16 +68,16 @@ func (c *resourceQuotasClusterInterface) Watch(ctx context.Context, opts metav1. return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ResourceQuotas(metav1.NamespaceAll).Watch(ctx, opts) } -// ResourceQuotasNamespacer can scope to objects within a namespace, returning a corev1client.ResourceQuotaInterface. +// ResourceQuotasNamespacer can scope to objects within a namespace, returning a typedcorev1.ResourceQuotaInterface. type ResourceQuotasNamespacer interface { - Namespace(string) corev1client.ResourceQuotaInterface + Namespace(string) typedcorev1.ResourceQuotaInterface } type resourceQuotasNamespacer struct { - clientCache kcpclient.Cache[*corev1client.CoreV1Client] + clientCache kcpclient.Cache[*typedcorev1.CoreV1Client] clusterPath logicalcluster.Path } -func (n *resourceQuotasNamespacer) Namespace(namespace string) corev1client.ResourceQuotaInterface { +func (n *resourceQuotasNamespacer) Namespace(namespace string) typedcorev1.ResourceQuotaInterface { return n.clientCache.ClusterOrDie(n.clusterPath).ResourceQuotas(namespace) } diff --git a/kubernetes/typed/core/v1/secret.go b/kubernetes/typed/core/v1/secret.go index 4bcf22ca9..de482719f 100644 --- a/kubernetes/typed/core/v1/secret.go +++ b/kubernetes/typed/core/v1/secret.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" ) // SecretsClusterGetter has a method to return a SecretClusterInterface. @@ -42,10 +42,11 @@ type SecretClusterInterface interface { Cluster(logicalcluster.Path) SecretsNamespacer List(ctx context.Context, opts metav1.ListOptions) (*corev1.SecretList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + SecretClusterExpansion } type secretsClusterInterface struct { - clientCache kcpclient.Cache[*corev1client.CoreV1Client] + clientCache kcpclient.Cache[*typedcorev1.CoreV1Client] } // Cluster scopes the client down to a particular cluster. @@ -67,16 +68,16 @@ func (c *secretsClusterInterface) Watch(ctx context.Context, opts metav1.ListOpt return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Secrets(metav1.NamespaceAll).Watch(ctx, opts) } -// SecretsNamespacer can scope to objects within a namespace, returning a corev1client.SecretInterface. +// SecretsNamespacer can scope to objects within a namespace, returning a typedcorev1.SecretInterface. type SecretsNamespacer interface { - Namespace(string) corev1client.SecretInterface + Namespace(string) typedcorev1.SecretInterface } type secretsNamespacer struct { - clientCache kcpclient.Cache[*corev1client.CoreV1Client] + clientCache kcpclient.Cache[*typedcorev1.CoreV1Client] clusterPath logicalcluster.Path } -func (n *secretsNamespacer) Namespace(namespace string) corev1client.SecretInterface { +func (n *secretsNamespacer) Namespace(namespace string) typedcorev1.SecretInterface { return n.clientCache.ClusterOrDie(n.clusterPath).Secrets(namespace) } diff --git a/kubernetes/typed/core/v1/service.go b/kubernetes/typed/core/v1/service.go index f51a5eeae..a4a1ccabc 100644 --- a/kubernetes/typed/core/v1/service.go +++ b/kubernetes/typed/core/v1/service.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" ) // ServicesClusterGetter has a method to return a ServiceClusterInterface. @@ -42,10 +42,11 @@ type ServiceClusterInterface interface { Cluster(logicalcluster.Path) ServicesNamespacer List(ctx context.Context, opts metav1.ListOptions) (*corev1.ServiceList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + ServiceClusterExpansion } type servicesClusterInterface struct { - clientCache kcpclient.Cache[*corev1client.CoreV1Client] + clientCache kcpclient.Cache[*typedcorev1.CoreV1Client] } // Cluster scopes the client down to a particular cluster. @@ -67,16 +68,16 @@ func (c *servicesClusterInterface) Watch(ctx context.Context, opts metav1.ListOp return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Services(metav1.NamespaceAll).Watch(ctx, opts) } -// ServicesNamespacer can scope to objects within a namespace, returning a corev1client.ServiceInterface. +// ServicesNamespacer can scope to objects within a namespace, returning a typedcorev1.ServiceInterface. type ServicesNamespacer interface { - Namespace(string) corev1client.ServiceInterface + Namespace(string) typedcorev1.ServiceInterface } type servicesNamespacer struct { - clientCache kcpclient.Cache[*corev1client.CoreV1Client] + clientCache kcpclient.Cache[*typedcorev1.CoreV1Client] clusterPath logicalcluster.Path } -func (n *servicesNamespacer) Namespace(namespace string) corev1client.ServiceInterface { +func (n *servicesNamespacer) Namespace(namespace string) typedcorev1.ServiceInterface { return n.clientCache.ClusterOrDie(n.clusterPath).Services(namespace) } diff --git a/kubernetes/typed/core/v1/serviceaccount.go b/kubernetes/typed/core/v1/serviceaccount.go index 828a7f2bd..1c936914a 100644 --- a/kubernetes/typed/core/v1/serviceaccount.go +++ b/kubernetes/typed/core/v1/serviceaccount.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" ) // ServiceAccountsClusterGetter has a method to return a ServiceAccountClusterInterface. @@ -42,10 +42,11 @@ type ServiceAccountClusterInterface interface { Cluster(logicalcluster.Path) ServiceAccountsNamespacer List(ctx context.Context, opts metav1.ListOptions) (*corev1.ServiceAccountList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + ServiceAccountClusterExpansion } type serviceAccountsClusterInterface struct { - clientCache kcpclient.Cache[*corev1client.CoreV1Client] + clientCache kcpclient.Cache[*typedcorev1.CoreV1Client] } // Cluster scopes the client down to a particular cluster. @@ -67,16 +68,16 @@ func (c *serviceAccountsClusterInterface) Watch(ctx context.Context, opts metav1 return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ServiceAccounts(metav1.NamespaceAll).Watch(ctx, opts) } -// ServiceAccountsNamespacer can scope to objects within a namespace, returning a corev1client.ServiceAccountInterface. +// ServiceAccountsNamespacer can scope to objects within a namespace, returning a typedcorev1.ServiceAccountInterface. type ServiceAccountsNamespacer interface { - Namespace(string) corev1client.ServiceAccountInterface + Namespace(string) typedcorev1.ServiceAccountInterface } type serviceAccountsNamespacer struct { - clientCache kcpclient.Cache[*corev1client.CoreV1Client] + clientCache kcpclient.Cache[*typedcorev1.CoreV1Client] clusterPath logicalcluster.Path } -func (n *serviceAccountsNamespacer) Namespace(namespace string) corev1client.ServiceAccountInterface { +func (n *serviceAccountsNamespacer) Namespace(namespace string) typedcorev1.ServiceAccountInterface { return n.clientCache.ClusterOrDie(n.clusterPath).ServiceAccounts(namespace) } diff --git a/kubernetes/typed/discovery/v1/discovery_client.go b/kubernetes/typed/discovery/v1/discovery_client.go index 5c0581f48..4d0fa8e73 100644 --- a/kubernetes/typed/discovery/v1/discovery_client.go +++ b/kubernetes/typed/discovery/v1/discovery_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apidiscoveryv1 "k8s.io/api/discovery/v1" discoveryv1 "k8s.io/client-go/kubernetes/typed/discovery/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type DiscoveryV1ClusterInterface interface { @@ -37,6 +40,7 @@ type DiscoveryV1ClusterScoper interface { Cluster(logicalcluster.Path) discoveryv1.DiscoveryV1Interface } +// DiscoveryV1ClusterClient is used to interact with features provided by the discovery.k8s.io group. type DiscoveryV1ClusterClient struct { clientCache kcpclient.Cache[*discoveryv1.DiscoveryV1Client] } @@ -56,11 +60,13 @@ func (c *DiscoveryV1ClusterClient) EndpointSlices() EndpointSliceClusterInterfac // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*DiscoveryV1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new DiscoveryV1ClusterClient for the given config and http client. @@ -72,6 +78,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*DiscoveryV1ClusterC if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &DiscoveryV1ClusterClient{clientCache: cache}, nil } @@ -84,3 +91,14 @@ func NewForConfigOrDie(c *rest.Config) *DiscoveryV1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apidiscoveryv1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/discovery/v1/doc.go b/kubernetes/typed/discovery/v1/doc.go new file mode 100644 index 000000000..d2f3412ab --- /dev/null +++ b/kubernetes/typed/discovery/v1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1 diff --git a/kubernetes/typed/discovery/v1/endpointslice.go b/kubernetes/typed/discovery/v1/endpointslice.go index cfeba98be..8347ff48e 100644 --- a/kubernetes/typed/discovery/v1/endpointslice.go +++ b/kubernetes/typed/discovery/v1/endpointslice.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" discoveryv1 "k8s.io/api/discovery/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - discoveryv1client "k8s.io/client-go/kubernetes/typed/discovery/v1" + watch "k8s.io/apimachinery/pkg/watch" + typeddiscoveryv1 "k8s.io/client-go/kubernetes/typed/discovery/v1" ) // EndpointSlicesClusterGetter has a method to return a EndpointSliceClusterInterface. @@ -42,10 +42,11 @@ type EndpointSliceClusterInterface interface { Cluster(logicalcluster.Path) EndpointSlicesNamespacer List(ctx context.Context, opts metav1.ListOptions) (*discoveryv1.EndpointSliceList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + EndpointSliceClusterExpansion } type endpointSlicesClusterInterface struct { - clientCache kcpclient.Cache[*discoveryv1client.DiscoveryV1Client] + clientCache kcpclient.Cache[*typeddiscoveryv1.DiscoveryV1Client] } // Cluster scopes the client down to a particular cluster. @@ -67,16 +68,16 @@ func (c *endpointSlicesClusterInterface) Watch(ctx context.Context, opts metav1. return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).EndpointSlices(metav1.NamespaceAll).Watch(ctx, opts) } -// EndpointSlicesNamespacer can scope to objects within a namespace, returning a discoveryv1client.EndpointSliceInterface. +// EndpointSlicesNamespacer can scope to objects within a namespace, returning a typeddiscoveryv1.EndpointSliceInterface. type EndpointSlicesNamespacer interface { - Namespace(string) discoveryv1client.EndpointSliceInterface + Namespace(string) typeddiscoveryv1.EndpointSliceInterface } type endpointSlicesNamespacer struct { - clientCache kcpclient.Cache[*discoveryv1client.DiscoveryV1Client] + clientCache kcpclient.Cache[*typeddiscoveryv1.DiscoveryV1Client] clusterPath logicalcluster.Path } -func (n *endpointSlicesNamespacer) Namespace(namespace string) discoveryv1client.EndpointSliceInterface { +func (n *endpointSlicesNamespacer) Namespace(namespace string) typeddiscoveryv1.EndpointSliceInterface { return n.clientCache.ClusterOrDie(n.clusterPath).EndpointSlices(namespace) } diff --git a/kubernetes/typed/discovery/v1/fake/discovery_client.go b/kubernetes/typed/discovery/v1/fake/discovery_client.go index fdd1eb5e3..d8990e61d 100644 --- a/kubernetes/typed/discovery/v1/fake/discovery_client.go +++ b/kubernetes/typed/discovery/v1/fake/discovery_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" discoveryv1 "k8s.io/client-go/kubernetes/typed/discovery/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpdiscoveryv1 "github.com/kcp-dev/client-go/kubernetes/typed/discovery/v1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -42,21 +42,21 @@ func (c *DiscoveryV1ClusterClient) Cluster(clusterPath logicalcluster.Path) disc } func (c *DiscoveryV1ClusterClient) EndpointSlices() kcpdiscoveryv1.EndpointSliceClusterInterface { - return &endpointSlicesClusterClient{Fake: c.Fake} + return newFakeEndpointSliceClusterClient(c) } -var _ discoveryv1.DiscoveryV1Interface = (*DiscoveryV1Client)(nil) - type DiscoveryV1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } +func (c *DiscoveryV1Client) EndpointSlices(namespace string) discoveryv1.EndpointSliceInterface { + return newFakeEndpointSliceClient(c.Fake, namespace, c.ClusterPath) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. func (c *DiscoveryV1Client) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } - -func (c *DiscoveryV1Client) EndpointSlices(namespace string) discoveryv1.EndpointSliceInterface { - return &endpointSlicesClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} -} diff --git a/kubernetes/typed/discovery/v1/fake/doc.go b/kubernetes/typed/discovery/v1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/discovery/v1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/discovery/v1/fake/endpointslice.go b/kubernetes/typed/discovery/v1/fake/endpointslice.go index e8ecba992..b110095cc 100644 --- a/kubernetes/typed/discovery/v1/fake/endpointslice.go +++ b/kubernetes/typed/discovery/v1/fake/endpointslice.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" discoveryv1 "k8s.io/api/discovery/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsdiscoveryv1 "k8s.io/client-go/applyconfigurations/discovery/v1" - discoveryv1client "k8s.io/client-go/kubernetes/typed/discovery/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/discovery/v1" + typeddiscoveryv1 "k8s.io/client-go/kubernetes/typed/discovery/v1" - kcpdiscoveryv1 "github.com/kcp-dev/client-go/kubernetes/typed/discovery/v1" + typedkcpdiscoveryv1 "github.com/kcp-dev/client-go/kubernetes/typed/discovery/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var endpointSlicesResource = schema.GroupVersionResource{Group: "discovery.k8s.io", Version: "v1", Resource: "endpointslices"} -var endpointSlicesKind = schema.GroupVersionKind{Group: "discovery.k8s.io", Version: "v1", Kind: "EndpointSlice"} - -type endpointSlicesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *endpointSlicesClusterClient) Cluster(clusterPath logicalcluster.Path) kcpdiscoveryv1.EndpointSlicesNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &endpointSlicesNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// endpointSliceClusterClient implements EndpointSliceClusterInterface +type endpointSliceClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*discoveryv1.EndpointSlice, *discoveryv1.EndpointSliceList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of EndpointSlices that match those selectors across all clusters. -func (c *endpointSlicesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*discoveryv1.EndpointSliceList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(endpointSlicesResource, endpointSlicesKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &discoveryv1.EndpointSliceList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeEndpointSliceClusterClient(fake *DiscoveryV1ClusterClient) typedkcpdiscoveryv1.EndpointSliceClusterInterface { + return &endpointSliceClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*discoveryv1.EndpointSlice, *discoveryv1.EndpointSliceList]( + fake.Fake, + discoveryv1.SchemeGroupVersion.WithResource("endpointslices"), + discoveryv1.SchemeGroupVersion.WithKind("EndpointSlice"), + func() *discoveryv1.EndpointSlice { return &discoveryv1.EndpointSlice{} }, + func() *discoveryv1.EndpointSliceList { return &discoveryv1.EndpointSliceList{} }, + func(dst, src *discoveryv1.EndpointSliceList) { dst.ListMeta = src.ListMeta }, + func(list *discoveryv1.EndpointSliceList) []*discoveryv1.EndpointSlice { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *discoveryv1.EndpointSliceList, items []*discoveryv1.EndpointSlice) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &discoveryv1.EndpointSliceList{ListMeta: obj.(*discoveryv1.EndpointSliceList).ListMeta} - for _, item := range obj.(*discoveryv1.EndpointSliceList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested EndpointSlices across all clusters. -func (c *endpointSlicesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(endpointSlicesResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *endpointSliceClusterClient) Cluster(cluster logicalcluster.Path) typedkcpdiscoveryv1.EndpointSlicesNamespacer { + return &endpointSliceNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type endpointSlicesNamespacer struct { +type endpointSliceNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *endpointSlicesNamespacer) Namespace(namespace string) discoveryv1client.EndpointSliceInterface { - return &endpointSlicesClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *endpointSliceNamespacer) Namespace(namespace string) typeddiscoveryv1.EndpointSliceInterface { + return newFakeEndpointSliceClient(n.Fake, namespace, n.ClusterPath) } -type endpointSlicesClient struct { - *kcptesting.Fake +// endpointSliceScopedClient implements EndpointSliceInterface +type endpointSliceScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*discoveryv1.EndpointSlice, *discoveryv1.EndpointSliceList, *v1.EndpointSliceApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *endpointSlicesClient) Create(ctx context.Context, endpointSlice *discoveryv1.EndpointSlice, opts metav1.CreateOptions) (*discoveryv1.EndpointSlice, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(endpointSlicesResource, c.ClusterPath, c.Namespace, endpointSlice), &discoveryv1.EndpointSlice{}) - if obj == nil { - return nil, err - } - return obj.(*discoveryv1.EndpointSlice), err -} - -func (c *endpointSlicesClient) Update(ctx context.Context, endpointSlice *discoveryv1.EndpointSlice, opts metav1.UpdateOptions) (*discoveryv1.EndpointSlice, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(endpointSlicesResource, c.ClusterPath, c.Namespace, endpointSlice), &discoveryv1.EndpointSlice{}) - if obj == nil { - return nil, err - } - return obj.(*discoveryv1.EndpointSlice), err -} - -func (c *endpointSlicesClient) UpdateStatus(ctx context.Context, endpointSlice *discoveryv1.EndpointSlice, opts metav1.UpdateOptions) (*discoveryv1.EndpointSlice, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(endpointSlicesResource, c.ClusterPath, "status", c.Namespace, endpointSlice), &discoveryv1.EndpointSlice{}) - if obj == nil { - return nil, err - } - return obj.(*discoveryv1.EndpointSlice), err -} - -func (c *endpointSlicesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(endpointSlicesResource, c.ClusterPath, c.Namespace, name, opts), &discoveryv1.EndpointSlice{}) - return err -} - -func (c *endpointSlicesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(endpointSlicesResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &discoveryv1.EndpointSliceList{}) - return err -} - -func (c *endpointSlicesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*discoveryv1.EndpointSlice, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(endpointSlicesResource, c.ClusterPath, c.Namespace, name), &discoveryv1.EndpointSlice{}) - if obj == nil { - return nil, err - } - return obj.(*discoveryv1.EndpointSlice), err -} - -// List takes label and field selectors, and returns the list of EndpointSlices that match those selectors. -func (c *endpointSlicesClient) List(ctx context.Context, opts metav1.ListOptions) (*discoveryv1.EndpointSliceList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(endpointSlicesResource, endpointSlicesKind, c.ClusterPath, c.Namespace, opts), &discoveryv1.EndpointSliceList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &discoveryv1.EndpointSliceList{ListMeta: obj.(*discoveryv1.EndpointSliceList).ListMeta} - for _, item := range obj.(*discoveryv1.EndpointSliceList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *endpointSlicesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(endpointSlicesResource, c.ClusterPath, c.Namespace, opts)) } -func (c *endpointSlicesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*discoveryv1.EndpointSlice, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(endpointSlicesResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &discoveryv1.EndpointSlice{}) - if obj == nil { - return nil, err - } - return obj.(*discoveryv1.EndpointSlice), err -} - -func (c *endpointSlicesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsdiscoveryv1.EndpointSliceApplyConfiguration, opts metav1.ApplyOptions) (*discoveryv1.EndpointSlice, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(endpointSlicesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &discoveryv1.EndpointSlice{}) - if obj == nil { - return nil, err - } - return obj.(*discoveryv1.EndpointSlice), err -} - -func (c *endpointSlicesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsdiscoveryv1.EndpointSliceApplyConfiguration, opts metav1.ApplyOptions) (*discoveryv1.EndpointSlice, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(endpointSlicesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &discoveryv1.EndpointSlice{}) - if obj == nil { - return nil, err +func newFakeEndpointSliceClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typeddiscoveryv1.EndpointSliceInterface { + return &endpointSliceScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*discoveryv1.EndpointSlice, *discoveryv1.EndpointSliceList, *v1.EndpointSliceApplyConfiguration]( + fake, + clusterPath, + namespace, + discoveryv1.SchemeGroupVersion.WithResource("endpointslices"), + discoveryv1.SchemeGroupVersion.WithKind("EndpointSlice"), + func() *discoveryv1.EndpointSlice { return &discoveryv1.EndpointSlice{} }, + func() *discoveryv1.EndpointSliceList { return &discoveryv1.EndpointSliceList{} }, + func(dst, src *discoveryv1.EndpointSliceList) { dst.ListMeta = src.ListMeta }, + func(list *discoveryv1.EndpointSliceList) []*discoveryv1.EndpointSlice { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *discoveryv1.EndpointSliceList, items []*discoveryv1.EndpointSlice) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*discoveryv1.EndpointSlice), err } diff --git a/kubernetes/typed/discovery/v1/generated_expansion.go b/kubernetes/typed/discovery/v1/generated_expansion.go new file mode 100644 index 000000000..24479f340 --- /dev/null +++ b/kubernetes/typed/discovery/v1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1 + +type EndpointSliceClusterExpansion interface{} diff --git a/kubernetes/typed/discovery/v1beta1/discovery_client.go b/kubernetes/typed/discovery/v1beta1/discovery_client.go index 6414b873e..f6cbc56a9 100644 --- a/kubernetes/typed/discovery/v1beta1/discovery_client.go +++ b/kubernetes/typed/discovery/v1beta1/discovery_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apidiscoveryv1beta1 "k8s.io/api/discovery/v1beta1" discoveryv1beta1 "k8s.io/client-go/kubernetes/typed/discovery/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type DiscoveryV1beta1ClusterInterface interface { @@ -37,6 +40,7 @@ type DiscoveryV1beta1ClusterScoper interface { Cluster(logicalcluster.Path) discoveryv1beta1.DiscoveryV1beta1Interface } +// DiscoveryV1beta1ClusterClient is used to interact with features provided by the discovery.k8s.io group. type DiscoveryV1beta1ClusterClient struct { clientCache kcpclient.Cache[*discoveryv1beta1.DiscoveryV1beta1Client] } @@ -56,11 +60,13 @@ func (c *DiscoveryV1beta1ClusterClient) EndpointSlices() EndpointSliceClusterInt // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*DiscoveryV1beta1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new DiscoveryV1beta1ClusterClient for the given config and http client. @@ -72,6 +78,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*DiscoveryV1beta1Clu if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &DiscoveryV1beta1ClusterClient{clientCache: cache}, nil } @@ -84,3 +91,14 @@ func NewForConfigOrDie(c *rest.Config) *DiscoveryV1beta1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apidiscoveryv1beta1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/discovery/v1beta1/doc.go b/kubernetes/typed/discovery/v1beta1/doc.go new file mode 100644 index 000000000..541e9d258 --- /dev/null +++ b/kubernetes/typed/discovery/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1beta1 diff --git a/kubernetes/typed/discovery/v1beta1/endpointslice.go b/kubernetes/typed/discovery/v1beta1/endpointslice.go index 1d2ed4f63..6c45f70f9 100644 --- a/kubernetes/typed/discovery/v1beta1/endpointslice.go +++ b/kubernetes/typed/discovery/v1beta1/endpointslice.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" discoveryv1beta1 "k8s.io/api/discovery/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - discoveryv1beta1client "k8s.io/client-go/kubernetes/typed/discovery/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typeddiscoveryv1beta1 "k8s.io/client-go/kubernetes/typed/discovery/v1beta1" ) // EndpointSlicesClusterGetter has a method to return a EndpointSliceClusterInterface. @@ -40,12 +40,13 @@ type EndpointSlicesClusterGetter interface { // or scope down to one cluster and return a EndpointSlicesNamespacer. type EndpointSliceClusterInterface interface { Cluster(logicalcluster.Path) EndpointSlicesNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*discoveryv1beta1.EndpointSliceList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*discoveryv1beta1.EndpointSliceList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + EndpointSliceClusterExpansion } type endpointSlicesClusterInterface struct { - clientCache kcpclient.Cache[*discoveryv1beta1client.DiscoveryV1beta1Client] + clientCache kcpclient.Cache[*typeddiscoveryv1beta1.DiscoveryV1beta1Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *endpointSlicesClusterInterface) Cluster(clusterPath logicalcluster.Path } // List returns the entire collection of all EndpointSlices across all clusters. -func (c *endpointSlicesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*discoveryv1beta1.EndpointSliceList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).EndpointSlices(metav1.NamespaceAll).List(ctx, opts) +func (c *endpointSlicesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*discoveryv1beta1.EndpointSliceList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).EndpointSlices(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all EndpointSlices across all clusters. -func (c *endpointSlicesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).EndpointSlices(metav1.NamespaceAll).Watch(ctx, opts) +func (c *endpointSlicesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).EndpointSlices(v1.NamespaceAll).Watch(ctx, opts) } -// EndpointSlicesNamespacer can scope to objects within a namespace, returning a discoveryv1beta1client.EndpointSliceInterface. +// EndpointSlicesNamespacer can scope to objects within a namespace, returning a typeddiscoveryv1beta1.EndpointSliceInterface. type EndpointSlicesNamespacer interface { - Namespace(string) discoveryv1beta1client.EndpointSliceInterface + Namespace(string) typeddiscoveryv1beta1.EndpointSliceInterface } type endpointSlicesNamespacer struct { - clientCache kcpclient.Cache[*discoveryv1beta1client.DiscoveryV1beta1Client] + clientCache kcpclient.Cache[*typeddiscoveryv1beta1.DiscoveryV1beta1Client] clusterPath logicalcluster.Path } -func (n *endpointSlicesNamespacer) Namespace(namespace string) discoveryv1beta1client.EndpointSliceInterface { +func (n *endpointSlicesNamespacer) Namespace(namespace string) typeddiscoveryv1beta1.EndpointSliceInterface { return n.clientCache.ClusterOrDie(n.clusterPath).EndpointSlices(namespace) } diff --git a/kubernetes/typed/discovery/v1beta1/fake/discovery_client.go b/kubernetes/typed/discovery/v1beta1/fake/discovery_client.go index 48959b24b..170948d97 100644 --- a/kubernetes/typed/discovery/v1beta1/fake/discovery_client.go +++ b/kubernetes/typed/discovery/v1beta1/fake/discovery_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" discoveryv1beta1 "k8s.io/client-go/kubernetes/typed/discovery/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpdiscoveryv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/discovery/v1beta1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -42,21 +42,21 @@ func (c *DiscoveryV1beta1ClusterClient) Cluster(clusterPath logicalcluster.Path) } func (c *DiscoveryV1beta1ClusterClient) EndpointSlices() kcpdiscoveryv1beta1.EndpointSliceClusterInterface { - return &endpointSlicesClusterClient{Fake: c.Fake} + return newFakeEndpointSliceClusterClient(c) } -var _ discoveryv1beta1.DiscoveryV1beta1Interface = (*DiscoveryV1beta1Client)(nil) - type DiscoveryV1beta1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } +func (c *DiscoveryV1beta1Client) EndpointSlices(namespace string) discoveryv1beta1.EndpointSliceInterface { + return newFakeEndpointSliceClient(c.Fake, namespace, c.ClusterPath) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. func (c *DiscoveryV1beta1Client) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } - -func (c *DiscoveryV1beta1Client) EndpointSlices(namespace string) discoveryv1beta1.EndpointSliceInterface { - return &endpointSlicesClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} -} diff --git a/kubernetes/typed/discovery/v1beta1/fake/doc.go b/kubernetes/typed/discovery/v1beta1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/discovery/v1beta1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/discovery/v1beta1/fake/endpointslice.go b/kubernetes/typed/discovery/v1beta1/fake/endpointslice.go index 278a86855..68bf2f343 100644 --- a/kubernetes/typed/discovery/v1beta1/fake/endpointslice.go +++ b/kubernetes/typed/discovery/v1beta1/fake/endpointslice.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" discoveryv1beta1 "k8s.io/api/discovery/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsdiscoveryv1beta1 "k8s.io/client-go/applyconfigurations/discovery/v1beta1" - discoveryv1beta1client "k8s.io/client-go/kubernetes/typed/discovery/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/discovery/v1beta1" + typeddiscoveryv1beta1 "k8s.io/client-go/kubernetes/typed/discovery/v1beta1" - kcpdiscoveryv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/discovery/v1beta1" + typedkcpdiscoveryv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/discovery/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var endpointSlicesResource = schema.GroupVersionResource{Group: "discovery.k8s.io", Version: "v1beta1", Resource: "endpointslices"} -var endpointSlicesKind = schema.GroupVersionKind{Group: "discovery.k8s.io", Version: "v1beta1", Kind: "EndpointSlice"} - -type endpointSlicesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *endpointSlicesClusterClient) Cluster(clusterPath logicalcluster.Path) kcpdiscoveryv1beta1.EndpointSlicesNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &endpointSlicesNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// endpointSliceClusterClient implements EndpointSliceClusterInterface +type endpointSliceClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*discoveryv1beta1.EndpointSlice, *discoveryv1beta1.EndpointSliceList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of EndpointSlices that match those selectors across all clusters. -func (c *endpointSlicesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*discoveryv1beta1.EndpointSliceList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(endpointSlicesResource, endpointSlicesKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &discoveryv1beta1.EndpointSliceList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeEndpointSliceClusterClient(fake *DiscoveryV1beta1ClusterClient) typedkcpdiscoveryv1beta1.EndpointSliceClusterInterface { + return &endpointSliceClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*discoveryv1beta1.EndpointSlice, *discoveryv1beta1.EndpointSliceList]( + fake.Fake, + discoveryv1beta1.SchemeGroupVersion.WithResource("endpointslices"), + discoveryv1beta1.SchemeGroupVersion.WithKind("EndpointSlice"), + func() *discoveryv1beta1.EndpointSlice { return &discoveryv1beta1.EndpointSlice{} }, + func() *discoveryv1beta1.EndpointSliceList { return &discoveryv1beta1.EndpointSliceList{} }, + func(dst, src *discoveryv1beta1.EndpointSliceList) { dst.ListMeta = src.ListMeta }, + func(list *discoveryv1beta1.EndpointSliceList) []*discoveryv1beta1.EndpointSlice { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *discoveryv1beta1.EndpointSliceList, items []*discoveryv1beta1.EndpointSlice) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &discoveryv1beta1.EndpointSliceList{ListMeta: obj.(*discoveryv1beta1.EndpointSliceList).ListMeta} - for _, item := range obj.(*discoveryv1beta1.EndpointSliceList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested EndpointSlices across all clusters. -func (c *endpointSlicesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(endpointSlicesResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *endpointSliceClusterClient) Cluster(cluster logicalcluster.Path) typedkcpdiscoveryv1beta1.EndpointSlicesNamespacer { + return &endpointSliceNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type endpointSlicesNamespacer struct { +type endpointSliceNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *endpointSlicesNamespacer) Namespace(namespace string) discoveryv1beta1client.EndpointSliceInterface { - return &endpointSlicesClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *endpointSliceNamespacer) Namespace(namespace string) typeddiscoveryv1beta1.EndpointSliceInterface { + return newFakeEndpointSliceClient(n.Fake, namespace, n.ClusterPath) } -type endpointSlicesClient struct { - *kcptesting.Fake +// endpointSliceScopedClient implements EndpointSliceInterface +type endpointSliceScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*discoveryv1beta1.EndpointSlice, *discoveryv1beta1.EndpointSliceList, *v1beta1.EndpointSliceApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *endpointSlicesClient) Create(ctx context.Context, endpointSlice *discoveryv1beta1.EndpointSlice, opts metav1.CreateOptions) (*discoveryv1beta1.EndpointSlice, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(endpointSlicesResource, c.ClusterPath, c.Namespace, endpointSlice), &discoveryv1beta1.EndpointSlice{}) - if obj == nil { - return nil, err - } - return obj.(*discoveryv1beta1.EndpointSlice), err -} - -func (c *endpointSlicesClient) Update(ctx context.Context, endpointSlice *discoveryv1beta1.EndpointSlice, opts metav1.UpdateOptions) (*discoveryv1beta1.EndpointSlice, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(endpointSlicesResource, c.ClusterPath, c.Namespace, endpointSlice), &discoveryv1beta1.EndpointSlice{}) - if obj == nil { - return nil, err - } - return obj.(*discoveryv1beta1.EndpointSlice), err -} - -func (c *endpointSlicesClient) UpdateStatus(ctx context.Context, endpointSlice *discoveryv1beta1.EndpointSlice, opts metav1.UpdateOptions) (*discoveryv1beta1.EndpointSlice, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(endpointSlicesResource, c.ClusterPath, "status", c.Namespace, endpointSlice), &discoveryv1beta1.EndpointSlice{}) - if obj == nil { - return nil, err - } - return obj.(*discoveryv1beta1.EndpointSlice), err -} - -func (c *endpointSlicesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(endpointSlicesResource, c.ClusterPath, c.Namespace, name, opts), &discoveryv1beta1.EndpointSlice{}) - return err -} - -func (c *endpointSlicesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(endpointSlicesResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &discoveryv1beta1.EndpointSliceList{}) - return err -} - -func (c *endpointSlicesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*discoveryv1beta1.EndpointSlice, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(endpointSlicesResource, c.ClusterPath, c.Namespace, name), &discoveryv1beta1.EndpointSlice{}) - if obj == nil { - return nil, err - } - return obj.(*discoveryv1beta1.EndpointSlice), err -} - -// List takes label and field selectors, and returns the list of EndpointSlices that match those selectors. -func (c *endpointSlicesClient) List(ctx context.Context, opts metav1.ListOptions) (*discoveryv1beta1.EndpointSliceList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(endpointSlicesResource, endpointSlicesKind, c.ClusterPath, c.Namespace, opts), &discoveryv1beta1.EndpointSliceList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &discoveryv1beta1.EndpointSliceList{ListMeta: obj.(*discoveryv1beta1.EndpointSliceList).ListMeta} - for _, item := range obj.(*discoveryv1beta1.EndpointSliceList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *endpointSlicesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(endpointSlicesResource, c.ClusterPath, c.Namespace, opts)) } -func (c *endpointSlicesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*discoveryv1beta1.EndpointSlice, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(endpointSlicesResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &discoveryv1beta1.EndpointSlice{}) - if obj == nil { - return nil, err - } - return obj.(*discoveryv1beta1.EndpointSlice), err -} - -func (c *endpointSlicesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsdiscoveryv1beta1.EndpointSliceApplyConfiguration, opts metav1.ApplyOptions) (*discoveryv1beta1.EndpointSlice, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(endpointSlicesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &discoveryv1beta1.EndpointSlice{}) - if obj == nil { - return nil, err - } - return obj.(*discoveryv1beta1.EndpointSlice), err -} - -func (c *endpointSlicesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsdiscoveryv1beta1.EndpointSliceApplyConfiguration, opts metav1.ApplyOptions) (*discoveryv1beta1.EndpointSlice, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(endpointSlicesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &discoveryv1beta1.EndpointSlice{}) - if obj == nil { - return nil, err +func newFakeEndpointSliceClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typeddiscoveryv1beta1.EndpointSliceInterface { + return &endpointSliceScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*discoveryv1beta1.EndpointSlice, *discoveryv1beta1.EndpointSliceList, *v1beta1.EndpointSliceApplyConfiguration]( + fake, + clusterPath, + namespace, + discoveryv1beta1.SchemeGroupVersion.WithResource("endpointslices"), + discoveryv1beta1.SchemeGroupVersion.WithKind("EndpointSlice"), + func() *discoveryv1beta1.EndpointSlice { return &discoveryv1beta1.EndpointSlice{} }, + func() *discoveryv1beta1.EndpointSliceList { return &discoveryv1beta1.EndpointSliceList{} }, + func(dst, src *discoveryv1beta1.EndpointSliceList) { dst.ListMeta = src.ListMeta }, + func(list *discoveryv1beta1.EndpointSliceList) []*discoveryv1beta1.EndpointSlice { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *discoveryv1beta1.EndpointSliceList, items []*discoveryv1beta1.EndpointSlice) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*discoveryv1beta1.EndpointSlice), err } diff --git a/kubernetes/typed/discovery/v1beta1/generated_expansion.go b/kubernetes/typed/discovery/v1beta1/generated_expansion.go new file mode 100644 index 000000000..f3043d806 --- /dev/null +++ b/kubernetes/typed/discovery/v1beta1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1beta1 + +type EndpointSliceClusterExpansion interface{} diff --git a/kubernetes/typed/events/v1/doc.go b/kubernetes/typed/events/v1/doc.go new file mode 100644 index 000000000..d2f3412ab --- /dev/null +++ b/kubernetes/typed/events/v1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1 diff --git a/kubernetes/typed/events/v1/event.go b/kubernetes/typed/events/v1/event.go index fcbe5a60c..c4c28df08 100644 --- a/kubernetes/typed/events/v1/event.go +++ b/kubernetes/typed/events/v1/event.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" eventsv1 "k8s.io/api/events/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - eventsv1client "k8s.io/client-go/kubernetes/typed/events/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedeventsv1 "k8s.io/client-go/kubernetes/typed/events/v1" ) // EventsClusterGetter has a method to return a EventClusterInterface. @@ -42,10 +42,11 @@ type EventClusterInterface interface { Cluster(logicalcluster.Path) EventsNamespacer List(ctx context.Context, opts metav1.ListOptions) (*eventsv1.EventList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + EventClusterExpansion } type eventsClusterInterface struct { - clientCache kcpclient.Cache[*eventsv1client.EventsV1Client] + clientCache kcpclient.Cache[*typedeventsv1.EventsV1Client] } // Cluster scopes the client down to a particular cluster. @@ -67,16 +68,16 @@ func (c *eventsClusterInterface) Watch(ctx context.Context, opts metav1.ListOpti return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Events(metav1.NamespaceAll).Watch(ctx, opts) } -// EventsNamespacer can scope to objects within a namespace, returning a eventsv1client.EventInterface. +// EventsNamespacer can scope to objects within a namespace, returning a typedeventsv1.EventInterface. type EventsNamespacer interface { - Namespace(string) eventsv1client.EventInterface + Namespace(string) typedeventsv1.EventInterface } type eventsNamespacer struct { - clientCache kcpclient.Cache[*eventsv1client.EventsV1Client] + clientCache kcpclient.Cache[*typedeventsv1.EventsV1Client] clusterPath logicalcluster.Path } -func (n *eventsNamespacer) Namespace(namespace string) eventsv1client.EventInterface { +func (n *eventsNamespacer) Namespace(namespace string) typedeventsv1.EventInterface { return n.clientCache.ClusterOrDie(n.clusterPath).Events(namespace) } diff --git a/kubernetes/typed/events/v1/events_client.go b/kubernetes/typed/events/v1/events_client.go index 7daf93cf7..24ba54e03 100644 --- a/kubernetes/typed/events/v1/events_client.go +++ b/kubernetes/typed/events/v1/events_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apieventsv1 "k8s.io/api/events/v1" eventsv1 "k8s.io/client-go/kubernetes/typed/events/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type EventsV1ClusterInterface interface { @@ -37,6 +40,7 @@ type EventsV1ClusterScoper interface { Cluster(logicalcluster.Path) eventsv1.EventsV1Interface } +// EventsV1ClusterClient is used to interact with features provided by the events.k8s.io group. type EventsV1ClusterClient struct { clientCache kcpclient.Cache[*eventsv1.EventsV1Client] } @@ -56,11 +60,13 @@ func (c *EventsV1ClusterClient) Events() EventClusterInterface { // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*EventsV1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new EventsV1ClusterClient for the given config and http client. @@ -72,6 +78,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*EventsV1ClusterClie if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &EventsV1ClusterClient{clientCache: cache}, nil } @@ -84,3 +91,14 @@ func NewForConfigOrDie(c *rest.Config) *EventsV1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apieventsv1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/events/v1/fake/doc.go b/kubernetes/typed/events/v1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/events/v1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/events/v1/fake/event.go b/kubernetes/typed/events/v1/fake/event.go index c6358737f..c3ae2922c 100644 --- a/kubernetes/typed/events/v1/fake/event.go +++ b/kubernetes/typed/events/v1/fake/event.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,83 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" eventsv1 "k8s.io/api/events/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationseventsv1 "k8s.io/client-go/applyconfigurations/events/v1" - eventsv1client "k8s.io/client-go/kubernetes/typed/events/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/events/v1" + typedeventsv1 "k8s.io/client-go/kubernetes/typed/events/v1" - kcpeventsv1 "github.com/kcp-dev/client-go/kubernetes/typed/events/v1" + typedkcpeventsv1 "github.com/kcp-dev/client-go/kubernetes/typed/events/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var eventsResource = schema.GroupVersionResource{Group: "events.k8s.io", Version: "v1", Resource: "events"} -var eventsKind = schema.GroupVersionKind{Group: "events.k8s.io", Version: "v1", Kind: "Event"} - -type eventsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *eventsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpeventsv1.EventsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &eventsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// eventClusterClient implements EventClusterInterface +type eventClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*eventsv1.Event, *eventsv1.EventList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of Events that match those selectors across all clusters. -func (c *eventsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*eventsv1.EventList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(eventsResource, eventsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &eventsv1.EventList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeEventClusterClient(fake *EventsV1ClusterClient) typedkcpeventsv1.EventClusterInterface { + return &eventClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*eventsv1.Event, *eventsv1.EventList]( + fake.Fake, + eventsv1.SchemeGroupVersion.WithResource("events"), + eventsv1.SchemeGroupVersion.WithKind("Event"), + func() *eventsv1.Event { return &eventsv1.Event{} }, + func() *eventsv1.EventList { return &eventsv1.EventList{} }, + func(dst, src *eventsv1.EventList) { dst.ListMeta = src.ListMeta }, + func(list *eventsv1.EventList) []*eventsv1.Event { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *eventsv1.EventList, items []*eventsv1.Event) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &eventsv1.EventList{ListMeta: obj.(*eventsv1.EventList).ListMeta} - for _, item := range obj.(*eventsv1.EventList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested Events across all clusters. -func (c *eventsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(eventsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *eventClusterClient) Cluster(cluster logicalcluster.Path) typedkcpeventsv1.EventsNamespacer { + return &eventNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type eventsNamespacer struct { +type eventNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *eventsNamespacer) Namespace(namespace string) eventsv1client.EventInterface { - return &eventsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *eventNamespacer) Namespace(namespace string) typedeventsv1.EventInterface { + return newFakeEventClient(n.Fake, namespace, n.ClusterPath) } -type eventsClient struct { - *kcptesting.Fake +// eventScopedClient implements EventInterface +type eventScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*eventsv1.Event, *eventsv1.EventList, *v1.EventApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *eventsClient) Create(ctx context.Context, event *eventsv1.Event, opts metav1.CreateOptions) (*eventsv1.Event, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(eventsResource, c.ClusterPath, c.Namespace, event), &eventsv1.Event{}) - if obj == nil { - return nil, err - } - return obj.(*eventsv1.Event), err -} - -func (c *eventsClient) Update(ctx context.Context, event *eventsv1.Event, opts metav1.UpdateOptions) (*eventsv1.Event, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(eventsResource, c.ClusterPath, c.Namespace, event), &eventsv1.Event{}) - if obj == nil { - return nil, err - } - return obj.(*eventsv1.Event), err -} - -func (c *eventsClient) UpdateStatus(ctx context.Context, event *eventsv1.Event, opts metav1.UpdateOptions) (*eventsv1.Event, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(eventsResource, c.ClusterPath, "status", c.Namespace, event), &eventsv1.Event{}) - if obj == nil { - return nil, err - } - return obj.(*eventsv1.Event), err -} - -func (c *eventsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(eventsResource, c.ClusterPath, c.Namespace, name, opts), &eventsv1.Event{}) - return err -} - -func (c *eventsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(eventsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &eventsv1.EventList{}) - return err -} - -func (c *eventsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*eventsv1.Event, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(eventsResource, c.ClusterPath, c.Namespace, name), &eventsv1.Event{}) - if obj == nil { - return nil, err - } - return obj.(*eventsv1.Event), err -} - -// List takes label and field selectors, and returns the list of Events that match those selectors. -func (c *eventsClient) List(ctx context.Context, opts metav1.ListOptions) (*eventsv1.EventList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(eventsResource, eventsKind, c.ClusterPath, c.Namespace, opts), &eventsv1.EventList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &eventsv1.EventList{ListMeta: obj.(*eventsv1.EventList).ListMeta} - for _, item := range obj.(*eventsv1.EventList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *eventsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(eventsResource, c.ClusterPath, c.Namespace, opts)) } -func (c *eventsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*eventsv1.Event, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(eventsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &eventsv1.Event{}) - if obj == nil { - return nil, err - } - return obj.(*eventsv1.Event), err -} - -func (c *eventsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationseventsv1.EventApplyConfiguration, opts metav1.ApplyOptions) (*eventsv1.Event, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(eventsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &eventsv1.Event{}) - if obj == nil { - return nil, err - } - return obj.(*eventsv1.Event), err -} - -func (c *eventsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationseventsv1.EventApplyConfiguration, opts metav1.ApplyOptions) (*eventsv1.Event, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(eventsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &eventsv1.Event{}) - if obj == nil { - return nil, err +func newFakeEventClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedeventsv1.EventInterface { + return &eventScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*eventsv1.Event, *eventsv1.EventList, *v1.EventApplyConfiguration]( + fake, + clusterPath, + namespace, + eventsv1.SchemeGroupVersion.WithResource("events"), + eventsv1.SchemeGroupVersion.WithKind("Event"), + func() *eventsv1.Event { return &eventsv1.Event{} }, + func() *eventsv1.EventList { return &eventsv1.EventList{} }, + func(dst, src *eventsv1.EventList) { dst.ListMeta = src.ListMeta }, + func(list *eventsv1.EventList) []*eventsv1.Event { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *eventsv1.EventList, items []*eventsv1.Event) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*eventsv1.Event), err } diff --git a/kubernetes/typed/events/v1/fake/events_client.go b/kubernetes/typed/events/v1/fake/events_client.go index 67683a308..864f0fa3a 100644 --- a/kubernetes/typed/events/v1/fake/events_client.go +++ b/kubernetes/typed/events/v1/fake/events_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" eventsv1 "k8s.io/client-go/kubernetes/typed/events/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpeventsv1 "github.com/kcp-dev/client-go/kubernetes/typed/events/v1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -42,21 +42,21 @@ func (c *EventsV1ClusterClient) Cluster(clusterPath logicalcluster.Path) eventsv } func (c *EventsV1ClusterClient) Events() kcpeventsv1.EventClusterInterface { - return &eventsClusterClient{Fake: c.Fake} + return newFakeEventClusterClient(c) } -var _ eventsv1.EventsV1Interface = (*EventsV1Client)(nil) - type EventsV1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } +func (c *EventsV1Client) Events(namespace string) eventsv1.EventInterface { + return newFakeEventClient(c.Fake, namespace, c.ClusterPath) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. func (c *EventsV1Client) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } - -func (c *EventsV1Client) Events(namespace string) eventsv1.EventInterface { - return &eventsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} -} diff --git a/kubernetes/typed/events/v1/generated_expansion.go b/kubernetes/typed/events/v1/generated_expansion.go new file mode 100644 index 000000000..ca565e18f --- /dev/null +++ b/kubernetes/typed/events/v1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1 + +type EventClusterExpansion interface{} diff --git a/kubernetes/typed/events/v1beta1/doc.go b/kubernetes/typed/events/v1beta1/doc.go new file mode 100644 index 000000000..541e9d258 --- /dev/null +++ b/kubernetes/typed/events/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1beta1 diff --git a/kubernetes/typed/events/v1beta1/event.go b/kubernetes/typed/events/v1beta1/event.go index 6e7d1275a..78cd0738e 100644 --- a/kubernetes/typed/events/v1beta1/event.go +++ b/kubernetes/typed/events/v1beta1/event.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" eventsv1beta1 "k8s.io/api/events/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - eventsv1beta1client "k8s.io/client-go/kubernetes/typed/events/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedeventsv1beta1 "k8s.io/client-go/kubernetes/typed/events/v1beta1" ) // EventsClusterGetter has a method to return a EventClusterInterface. @@ -40,12 +40,13 @@ type EventsClusterGetter interface { // or scope down to one cluster and return a EventsNamespacer. type EventClusterInterface interface { Cluster(logicalcluster.Path) EventsNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*eventsv1beta1.EventList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*eventsv1beta1.EventList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + EventClusterExpansion } type eventsClusterInterface struct { - clientCache kcpclient.Cache[*eventsv1beta1client.EventsV1beta1Client] + clientCache kcpclient.Cache[*typedeventsv1beta1.EventsV1beta1Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *eventsClusterInterface) Cluster(clusterPath logicalcluster.Path) Events } // List returns the entire collection of all Events across all clusters. -func (c *eventsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*eventsv1beta1.EventList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Events(metav1.NamespaceAll).List(ctx, opts) +func (c *eventsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*eventsv1beta1.EventList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Events(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all Events across all clusters. -func (c *eventsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Events(metav1.NamespaceAll).Watch(ctx, opts) +func (c *eventsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Events(v1.NamespaceAll).Watch(ctx, opts) } -// EventsNamespacer can scope to objects within a namespace, returning a eventsv1beta1client.EventInterface. +// EventsNamespacer can scope to objects within a namespace, returning a typedeventsv1beta1.EventInterface. type EventsNamespacer interface { - Namespace(string) eventsv1beta1client.EventInterface + Namespace(string) typedeventsv1beta1.EventInterface } type eventsNamespacer struct { - clientCache kcpclient.Cache[*eventsv1beta1client.EventsV1beta1Client] + clientCache kcpclient.Cache[*typedeventsv1beta1.EventsV1beta1Client] clusterPath logicalcluster.Path } -func (n *eventsNamespacer) Namespace(namespace string) eventsv1beta1client.EventInterface { +func (n *eventsNamespacer) Namespace(namespace string) typedeventsv1beta1.EventInterface { return n.clientCache.ClusterOrDie(n.clusterPath).Events(namespace) } diff --git a/kubernetes/typed/events/v1beta1/events_client.go b/kubernetes/typed/events/v1beta1/events_client.go index b50c3ec48..78f2b8576 100644 --- a/kubernetes/typed/events/v1beta1/events_client.go +++ b/kubernetes/typed/events/v1beta1/events_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apieventsv1beta1 "k8s.io/api/events/v1beta1" eventsv1beta1 "k8s.io/client-go/kubernetes/typed/events/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type EventsV1beta1ClusterInterface interface { @@ -37,6 +40,7 @@ type EventsV1beta1ClusterScoper interface { Cluster(logicalcluster.Path) eventsv1beta1.EventsV1beta1Interface } +// EventsV1beta1ClusterClient is used to interact with features provided by the events.k8s.io group. type EventsV1beta1ClusterClient struct { clientCache kcpclient.Cache[*eventsv1beta1.EventsV1beta1Client] } @@ -56,11 +60,13 @@ func (c *EventsV1beta1ClusterClient) Events() EventClusterInterface { // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*EventsV1beta1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new EventsV1beta1ClusterClient for the given config and http client. @@ -72,6 +78,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*EventsV1beta1Cluste if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &EventsV1beta1ClusterClient{clientCache: cache}, nil } @@ -84,3 +91,14 @@ func NewForConfigOrDie(c *rest.Config) *EventsV1beta1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apieventsv1beta1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/events/v1beta1/fake/doc.go b/kubernetes/typed/events/v1beta1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/events/v1beta1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/events/v1beta1/fake/event.go b/kubernetes/typed/events/v1beta1/fake/event.go index 1fdff0748..f8b0518c4 100644 --- a/kubernetes/typed/events/v1beta1/fake/event.go +++ b/kubernetes/typed/events/v1beta1/fake/event.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" eventsv1beta1 "k8s.io/api/events/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationseventsv1beta1 "k8s.io/client-go/applyconfigurations/events/v1beta1" - eventsv1beta1client "k8s.io/client-go/kubernetes/typed/events/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/events/v1beta1" + typedeventsv1beta1 "k8s.io/client-go/kubernetes/typed/events/v1beta1" - kcpeventsv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/events/v1beta1" + typedkcpeventsv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/events/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var eventsResource = schema.GroupVersionResource{Group: "events.k8s.io", Version: "v1beta1", Resource: "events"} -var eventsKind = schema.GroupVersionKind{Group: "events.k8s.io", Version: "v1beta1", Kind: "Event"} - -type eventsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *eventsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpeventsv1beta1.EventsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &eventsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// eventClusterClient implements EventClusterInterface +type eventClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*eventsv1beta1.Event, *eventsv1beta1.EventList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of Events that match those selectors across all clusters. -func (c *eventsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*eventsv1beta1.EventList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(eventsResource, eventsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &eventsv1beta1.EventList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeEventClusterClient(fake *EventsV1beta1ClusterClient) typedkcpeventsv1beta1.EventClusterInterface { + return &eventClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*eventsv1beta1.Event, *eventsv1beta1.EventList]( + fake.Fake, + eventsv1beta1.SchemeGroupVersion.WithResource("events"), + eventsv1beta1.SchemeGroupVersion.WithKind("Event"), + func() *eventsv1beta1.Event { return &eventsv1beta1.Event{} }, + func() *eventsv1beta1.EventList { return &eventsv1beta1.EventList{} }, + func(dst, src *eventsv1beta1.EventList) { dst.ListMeta = src.ListMeta }, + func(list *eventsv1beta1.EventList) []*eventsv1beta1.Event { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *eventsv1beta1.EventList, items []*eventsv1beta1.Event) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &eventsv1beta1.EventList{ListMeta: obj.(*eventsv1beta1.EventList).ListMeta} - for _, item := range obj.(*eventsv1beta1.EventList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested Events across all clusters. -func (c *eventsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(eventsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *eventClusterClient) Cluster(cluster logicalcluster.Path) typedkcpeventsv1beta1.EventsNamespacer { + return &eventNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type eventsNamespacer struct { +type eventNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *eventsNamespacer) Namespace(namespace string) eventsv1beta1client.EventInterface { - return &eventsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *eventNamespacer) Namespace(namespace string) typedeventsv1beta1.EventInterface { + return newFakeEventClient(n.Fake, namespace, n.ClusterPath) } -type eventsClient struct { - *kcptesting.Fake +// eventScopedClient implements EventInterface +type eventScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*eventsv1beta1.Event, *eventsv1beta1.EventList, *v1beta1.EventApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *eventsClient) Create(ctx context.Context, event *eventsv1beta1.Event, opts metav1.CreateOptions) (*eventsv1beta1.Event, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(eventsResource, c.ClusterPath, c.Namespace, event), &eventsv1beta1.Event{}) - if obj == nil { - return nil, err - } - return obj.(*eventsv1beta1.Event), err -} - -func (c *eventsClient) Update(ctx context.Context, event *eventsv1beta1.Event, opts metav1.UpdateOptions) (*eventsv1beta1.Event, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(eventsResource, c.ClusterPath, c.Namespace, event), &eventsv1beta1.Event{}) - if obj == nil { - return nil, err - } - return obj.(*eventsv1beta1.Event), err -} - -func (c *eventsClient) UpdateStatus(ctx context.Context, event *eventsv1beta1.Event, opts metav1.UpdateOptions) (*eventsv1beta1.Event, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(eventsResource, c.ClusterPath, "status", c.Namespace, event), &eventsv1beta1.Event{}) - if obj == nil { - return nil, err - } - return obj.(*eventsv1beta1.Event), err -} - -func (c *eventsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(eventsResource, c.ClusterPath, c.Namespace, name, opts), &eventsv1beta1.Event{}) - return err -} - -func (c *eventsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(eventsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &eventsv1beta1.EventList{}) - return err -} - -func (c *eventsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*eventsv1beta1.Event, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(eventsResource, c.ClusterPath, c.Namespace, name), &eventsv1beta1.Event{}) - if obj == nil { - return nil, err - } - return obj.(*eventsv1beta1.Event), err -} - -// List takes label and field selectors, and returns the list of Events that match those selectors. -func (c *eventsClient) List(ctx context.Context, opts metav1.ListOptions) (*eventsv1beta1.EventList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(eventsResource, eventsKind, c.ClusterPath, c.Namespace, opts), &eventsv1beta1.EventList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &eventsv1beta1.EventList{ListMeta: obj.(*eventsv1beta1.EventList).ListMeta} - for _, item := range obj.(*eventsv1beta1.EventList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *eventsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(eventsResource, c.ClusterPath, c.Namespace, opts)) } -func (c *eventsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*eventsv1beta1.Event, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(eventsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &eventsv1beta1.Event{}) - if obj == nil { - return nil, err - } - return obj.(*eventsv1beta1.Event), err -} - -func (c *eventsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationseventsv1beta1.EventApplyConfiguration, opts metav1.ApplyOptions) (*eventsv1beta1.Event, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(eventsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &eventsv1beta1.Event{}) - if obj == nil { - return nil, err - } - return obj.(*eventsv1beta1.Event), err -} - -func (c *eventsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationseventsv1beta1.EventApplyConfiguration, opts metav1.ApplyOptions) (*eventsv1beta1.Event, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(eventsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &eventsv1beta1.Event{}) - if obj == nil { - return nil, err +func newFakeEventClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedeventsv1beta1.EventInterface { + return &eventScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*eventsv1beta1.Event, *eventsv1beta1.EventList, *v1beta1.EventApplyConfiguration]( + fake, + clusterPath, + namespace, + eventsv1beta1.SchemeGroupVersion.WithResource("events"), + eventsv1beta1.SchemeGroupVersion.WithKind("Event"), + func() *eventsv1beta1.Event { return &eventsv1beta1.Event{} }, + func() *eventsv1beta1.EventList { return &eventsv1beta1.EventList{} }, + func(dst, src *eventsv1beta1.EventList) { dst.ListMeta = src.ListMeta }, + func(list *eventsv1beta1.EventList) []*eventsv1beta1.Event { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *eventsv1beta1.EventList, items []*eventsv1beta1.Event) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*eventsv1beta1.Event), err } diff --git a/kubernetes/typed/events/v1beta1/fake/events_client.go b/kubernetes/typed/events/v1beta1/fake/events_client.go index 2d3ef00d7..644f3e85b 100644 --- a/kubernetes/typed/events/v1beta1/fake/events_client.go +++ b/kubernetes/typed/events/v1beta1/fake/events_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" eventsv1beta1 "k8s.io/client-go/kubernetes/typed/events/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpeventsv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/events/v1beta1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -42,21 +42,21 @@ func (c *EventsV1beta1ClusterClient) Cluster(clusterPath logicalcluster.Path) ev } func (c *EventsV1beta1ClusterClient) Events() kcpeventsv1beta1.EventClusterInterface { - return &eventsClusterClient{Fake: c.Fake} + return newFakeEventClusterClient(c) } -var _ eventsv1beta1.EventsV1beta1Interface = (*EventsV1beta1Client)(nil) - type EventsV1beta1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } +func (c *EventsV1beta1Client) Events(namespace string) eventsv1beta1.EventInterface { + return newFakeEventClient(c.Fake, namespace, c.ClusterPath) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. func (c *EventsV1beta1Client) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } - -func (c *EventsV1beta1Client) Events(namespace string) eventsv1beta1.EventInterface { - return &eventsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} -} diff --git a/kubernetes/typed/events/v1beta1/fake/fake_event_expansion.go b/kubernetes/typed/events/v1beta1/fake/fake_event_expansion.go index d26830a57..0fd675530 100644 --- a/kubernetes/typed/events/v1beta1/fake/fake_event_expansion.go +++ b/kubernetes/typed/events/v1beta1/fake/fake_event_expansion.go @@ -19,16 +19,19 @@ package fake import ( "k8s.io/api/events/v1beta1" + "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" core "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) +var eventsResource = schema.GroupVersionResource{Group: "events.k8s.io", Version: "v1beta1", Resource: "events"} + // CreateWithEventNamespace creats a new event. Returns the copy of the event the server returns, or an error. -func (c *eventsClient) CreateWithEventNamespace(event *v1beta1.Event) (*v1beta1.Event, error) { +func (c *eventScopedClient) CreateWithEventNamespace(event *v1beta1.Event) (*v1beta1.Event, error) { action := core.NewRootCreateAction(eventsResource, c.ClusterPath, event) - if c.Namespace != "" { - action = core.NewCreateAction(eventsResource, c.ClusterPath, c.Namespace, event) + if c.Namespace() != "" { + action = core.NewCreateAction(eventsResource, c.ClusterPath, c.Namespace(), event) } obj, err := c.Fake.Invokes(action, event) if obj == nil { @@ -39,10 +42,10 @@ func (c *eventsClient) CreateWithEventNamespace(event *v1beta1.Event) (*v1beta1. } // UpdateWithEventNamespace replaces an existing event. Returns the copy of the event the server returns, or an error. -func (c *eventsClient) UpdateWithEventNamespace(event *v1beta1.Event) (*v1beta1.Event, error) { +func (c *eventScopedClient) UpdateWithEventNamespace(event *v1beta1.Event) (*v1beta1.Event, error) { action := core.NewRootUpdateAction(eventsResource, c.ClusterPath, event) - if c.Namespace != "" { - action = core.NewUpdateAction(eventsResource, c.ClusterPath, c.Namespace, event) + if c.Namespace() != "" { + action = core.NewUpdateAction(eventsResource, c.ClusterPath, c.Namespace(), event) } obj, err := c.Fake.Invokes(action, event) if obj == nil { @@ -53,11 +56,11 @@ func (c *eventsClient) UpdateWithEventNamespace(event *v1beta1.Event) (*v1beta1. } // PatchWithEventNamespace patches an existing event. Returns the copy of the event the server returns, or an error. -func (c *eventsClient) PatchWithEventNamespace(event *v1beta1.Event, data []byte) (*v1beta1.Event, error) { +func (c *eventScopedClient) PatchWithEventNamespace(event *v1beta1.Event, data []byte) (*v1beta1.Event, error) { pt := types.StrategicMergePatchType action := core.NewRootPatchAction(eventsResource, c.ClusterPath, event.Name, pt, data) - if c.Namespace != "" { - action = core.NewPatchAction(eventsResource, c.ClusterPath, c.Namespace, event.Name, pt, data) + if c.Namespace() != "" { + action = core.NewPatchAction(eventsResource, c.ClusterPath, c.Namespace(), event.Name, pt, data) } obj, err := c.Fake.Invokes(action, event) if obj == nil { diff --git a/kubernetes/typed/events/v1beta1/generated_expansion.go b/kubernetes/typed/events/v1beta1/generated_expansion.go new file mode 100644 index 000000000..37c6f1072 --- /dev/null +++ b/kubernetes/typed/events/v1beta1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1beta1 + +type EventClusterExpansion interface{} diff --git a/kubernetes/typed/extensions/v1beta1/daemonset.go b/kubernetes/typed/extensions/v1beta1/daemonset.go index 79568bd73..039981819 100644 --- a/kubernetes/typed/extensions/v1beta1/daemonset.go +++ b/kubernetes/typed/extensions/v1beta1/daemonset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" extensionsv1beta1 "k8s.io/api/extensions/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - extensionsv1beta1client "k8s.io/client-go/kubernetes/typed/extensions/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedextensionsv1beta1 "k8s.io/client-go/kubernetes/typed/extensions/v1beta1" ) // DaemonSetsClusterGetter has a method to return a DaemonSetClusterInterface. @@ -40,12 +40,13 @@ type DaemonSetsClusterGetter interface { // or scope down to one cluster and return a DaemonSetsNamespacer. type DaemonSetClusterInterface interface { Cluster(logicalcluster.Path) DaemonSetsNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*extensionsv1beta1.DaemonSetList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*extensionsv1beta1.DaemonSetList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + DaemonSetClusterExpansion } type daemonSetsClusterInterface struct { - clientCache kcpclient.Cache[*extensionsv1beta1client.ExtensionsV1beta1Client] + clientCache kcpclient.Cache[*typedextensionsv1beta1.ExtensionsV1beta1Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *daemonSetsClusterInterface) Cluster(clusterPath logicalcluster.Path) Da } // List returns the entire collection of all DaemonSets across all clusters. -func (c *daemonSetsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*extensionsv1beta1.DaemonSetList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).DaemonSets(metav1.NamespaceAll).List(ctx, opts) +func (c *daemonSetsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*extensionsv1beta1.DaemonSetList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).DaemonSets(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all DaemonSets across all clusters. -func (c *daemonSetsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).DaemonSets(metav1.NamespaceAll).Watch(ctx, opts) +func (c *daemonSetsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).DaemonSets(v1.NamespaceAll).Watch(ctx, opts) } -// DaemonSetsNamespacer can scope to objects within a namespace, returning a extensionsv1beta1client.DaemonSetInterface. +// DaemonSetsNamespacer can scope to objects within a namespace, returning a typedextensionsv1beta1.DaemonSetInterface. type DaemonSetsNamespacer interface { - Namespace(string) extensionsv1beta1client.DaemonSetInterface + Namespace(string) typedextensionsv1beta1.DaemonSetInterface } type daemonSetsNamespacer struct { - clientCache kcpclient.Cache[*extensionsv1beta1client.ExtensionsV1beta1Client] + clientCache kcpclient.Cache[*typedextensionsv1beta1.ExtensionsV1beta1Client] clusterPath logicalcluster.Path } -func (n *daemonSetsNamespacer) Namespace(namespace string) extensionsv1beta1client.DaemonSetInterface { +func (n *daemonSetsNamespacer) Namespace(namespace string) typedextensionsv1beta1.DaemonSetInterface { return n.clientCache.ClusterOrDie(n.clusterPath).DaemonSets(namespace) } diff --git a/kubernetes/typed/extensions/v1beta1/deployment.go b/kubernetes/typed/extensions/v1beta1/deployment.go index 77a8bf49c..03ef88cb4 100644 --- a/kubernetes/typed/extensions/v1beta1/deployment.go +++ b/kubernetes/typed/extensions/v1beta1/deployment.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" extensionsv1beta1 "k8s.io/api/extensions/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - extensionsv1beta1client "k8s.io/client-go/kubernetes/typed/extensions/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedextensionsv1beta1 "k8s.io/client-go/kubernetes/typed/extensions/v1beta1" ) // DeploymentsClusterGetter has a method to return a DeploymentClusterInterface. @@ -40,12 +40,13 @@ type DeploymentsClusterGetter interface { // or scope down to one cluster and return a DeploymentsNamespacer. type DeploymentClusterInterface interface { Cluster(logicalcluster.Path) DeploymentsNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*extensionsv1beta1.DeploymentList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*extensionsv1beta1.DeploymentList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + DeploymentClusterExpansion } type deploymentsClusterInterface struct { - clientCache kcpclient.Cache[*extensionsv1beta1client.ExtensionsV1beta1Client] + clientCache kcpclient.Cache[*typedextensionsv1beta1.ExtensionsV1beta1Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *deploymentsClusterInterface) Cluster(clusterPath logicalcluster.Path) D } // List returns the entire collection of all Deployments across all clusters. -func (c *deploymentsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*extensionsv1beta1.DeploymentList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Deployments(metav1.NamespaceAll).List(ctx, opts) +func (c *deploymentsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*extensionsv1beta1.DeploymentList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Deployments(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all Deployments across all clusters. -func (c *deploymentsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Deployments(metav1.NamespaceAll).Watch(ctx, opts) +func (c *deploymentsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Deployments(v1.NamespaceAll).Watch(ctx, opts) } -// DeploymentsNamespacer can scope to objects within a namespace, returning a extensionsv1beta1client.DeploymentInterface. +// DeploymentsNamespacer can scope to objects within a namespace, returning a typedextensionsv1beta1.DeploymentInterface. type DeploymentsNamespacer interface { - Namespace(string) extensionsv1beta1client.DeploymentInterface + Namespace(string) typedextensionsv1beta1.DeploymentInterface } type deploymentsNamespacer struct { - clientCache kcpclient.Cache[*extensionsv1beta1client.ExtensionsV1beta1Client] + clientCache kcpclient.Cache[*typedextensionsv1beta1.ExtensionsV1beta1Client] clusterPath logicalcluster.Path } -func (n *deploymentsNamespacer) Namespace(namespace string) extensionsv1beta1client.DeploymentInterface { +func (n *deploymentsNamespacer) Namespace(namespace string) typedextensionsv1beta1.DeploymentInterface { return n.clientCache.ClusterOrDie(n.clusterPath).Deployments(namespace) } diff --git a/kubernetes/typed/extensions/v1beta1/doc.go b/kubernetes/typed/extensions/v1beta1/doc.go new file mode 100644 index 000000000..541e9d258 --- /dev/null +++ b/kubernetes/typed/extensions/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1beta1 diff --git a/kubernetes/typed/extensions/v1beta1/extensions_client.go b/kubernetes/typed/extensions/v1beta1/extensions_client.go index f3741cd79..50d402fef 100644 --- a/kubernetes/typed/extensions/v1beta1/extensions_client.go +++ b/kubernetes/typed/extensions/v1beta1/extensions_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,33 +14,37 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apiextensionsv1beta1 "k8s.io/api/extensions/v1beta1" extensionsv1beta1 "k8s.io/client-go/kubernetes/typed/extensions/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type ExtensionsV1beta1ClusterInterface interface { ExtensionsV1beta1ClusterScoper - DeploymentsClusterGetter DaemonSetsClusterGetter + DeploymentsClusterGetter IngressesClusterGetter - ReplicaSetsClusterGetter NetworkPoliciesClusterGetter + ReplicaSetsClusterGetter } type ExtensionsV1beta1ClusterScoper interface { Cluster(logicalcluster.Path) extensionsv1beta1.ExtensionsV1beta1Interface } +// ExtensionsV1beta1ClusterClient is used to interact with features provided by the extensions group. type ExtensionsV1beta1ClusterClient struct { clientCache kcpclient.Cache[*extensionsv1beta1.ExtensionsV1beta1Client] } @@ -52,35 +56,37 @@ func (c *ExtensionsV1beta1ClusterClient) Cluster(clusterPath logicalcluster.Path return c.clientCache.ClusterOrDie(clusterPath) } -func (c *ExtensionsV1beta1ClusterClient) Deployments() DeploymentClusterInterface { - return &deploymentsClusterInterface{clientCache: c.clientCache} -} - func (c *ExtensionsV1beta1ClusterClient) DaemonSets() DaemonSetClusterInterface { return &daemonSetsClusterInterface{clientCache: c.clientCache} } -func (c *ExtensionsV1beta1ClusterClient) Ingresses() IngressClusterInterface { - return &ingressesClusterInterface{clientCache: c.clientCache} +func (c *ExtensionsV1beta1ClusterClient) Deployments() DeploymentClusterInterface { + return &deploymentsClusterInterface{clientCache: c.clientCache} } -func (c *ExtensionsV1beta1ClusterClient) ReplicaSets() ReplicaSetClusterInterface { - return &replicaSetsClusterInterface{clientCache: c.clientCache} +func (c *ExtensionsV1beta1ClusterClient) Ingresses() IngressClusterInterface { + return &ingressesClusterInterface{clientCache: c.clientCache} } func (c *ExtensionsV1beta1ClusterClient) NetworkPolicies() NetworkPolicyClusterInterface { return &networkPoliciesClusterInterface{clientCache: c.clientCache} } +func (c *ExtensionsV1beta1ClusterClient) ReplicaSets() ReplicaSetClusterInterface { + return &replicaSetsClusterInterface{clientCache: c.clientCache} +} + // NewForConfig creates a new ExtensionsV1beta1ClusterClient for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*ExtensionsV1beta1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new ExtensionsV1beta1ClusterClient for the given config and http client. @@ -92,6 +98,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*ExtensionsV1beta1Cl if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &ExtensionsV1beta1ClusterClient{clientCache: cache}, nil } @@ -104,3 +111,14 @@ func NewForConfigOrDie(c *rest.Config) *ExtensionsV1beta1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apiextensionsv1beta1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/extensions/v1beta1/fake/daemonset.go b/kubernetes/typed/extensions/v1beta1/fake/daemonset.go index 1423e0202..e911bda07 100644 --- a/kubernetes/typed/extensions/v1beta1/fake/daemonset.go +++ b/kubernetes/typed/extensions/v1beta1/fake/daemonset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" extensionsv1beta1 "k8s.io/api/extensions/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsextensionsv1beta1 "k8s.io/client-go/applyconfigurations/extensions/v1beta1" - extensionsv1beta1client "k8s.io/client-go/kubernetes/typed/extensions/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/extensions/v1beta1" + typedextensionsv1beta1 "k8s.io/client-go/kubernetes/typed/extensions/v1beta1" - kcpextensionsv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/extensions/v1beta1" + typedkcpextensionsv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/extensions/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var daemonSetsResource = schema.GroupVersionResource{Group: "extensions", Version: "v1beta1", Resource: "daemonsets"} -var daemonSetsKind = schema.GroupVersionKind{Group: "extensions", Version: "v1beta1", Kind: "DaemonSet"} - -type daemonSetsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *daemonSetsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpextensionsv1beta1.DaemonSetsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &daemonSetsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// daemonSetClusterClient implements DaemonSetClusterInterface +type daemonSetClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*extensionsv1beta1.DaemonSet, *extensionsv1beta1.DaemonSetList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of DaemonSets that match those selectors across all clusters. -func (c *daemonSetsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*extensionsv1beta1.DaemonSetList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(daemonSetsResource, daemonSetsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &extensionsv1beta1.DaemonSetList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeDaemonSetClusterClient(fake *ExtensionsV1beta1ClusterClient) typedkcpextensionsv1beta1.DaemonSetClusterInterface { + return &daemonSetClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*extensionsv1beta1.DaemonSet, *extensionsv1beta1.DaemonSetList]( + fake.Fake, + extensionsv1beta1.SchemeGroupVersion.WithResource("daemonsets"), + extensionsv1beta1.SchemeGroupVersion.WithKind("DaemonSet"), + func() *extensionsv1beta1.DaemonSet { return &extensionsv1beta1.DaemonSet{} }, + func() *extensionsv1beta1.DaemonSetList { return &extensionsv1beta1.DaemonSetList{} }, + func(dst, src *extensionsv1beta1.DaemonSetList) { dst.ListMeta = src.ListMeta }, + func(list *extensionsv1beta1.DaemonSetList) []*extensionsv1beta1.DaemonSet { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *extensionsv1beta1.DaemonSetList, items []*extensionsv1beta1.DaemonSet) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &extensionsv1beta1.DaemonSetList{ListMeta: obj.(*extensionsv1beta1.DaemonSetList).ListMeta} - for _, item := range obj.(*extensionsv1beta1.DaemonSetList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested DaemonSets across all clusters. -func (c *daemonSetsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(daemonSetsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *daemonSetClusterClient) Cluster(cluster logicalcluster.Path) typedkcpextensionsv1beta1.DaemonSetsNamespacer { + return &daemonSetNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type daemonSetsNamespacer struct { +type daemonSetNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *daemonSetsNamespacer) Namespace(namespace string) extensionsv1beta1client.DaemonSetInterface { - return &daemonSetsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *daemonSetNamespacer) Namespace(namespace string) typedextensionsv1beta1.DaemonSetInterface { + return newFakeDaemonSetClient(n.Fake, namespace, n.ClusterPath) } -type daemonSetsClient struct { - *kcptesting.Fake +// daemonSetScopedClient implements DaemonSetInterface +type daemonSetScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*extensionsv1beta1.DaemonSet, *extensionsv1beta1.DaemonSetList, *v1beta1.DaemonSetApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *daemonSetsClient) Create(ctx context.Context, daemonSet *extensionsv1beta1.DaemonSet, opts metav1.CreateOptions) (*extensionsv1beta1.DaemonSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(daemonSetsResource, c.ClusterPath, c.Namespace, daemonSet), &extensionsv1beta1.DaemonSet{}) - if obj == nil { - return nil, err - } - return obj.(*extensionsv1beta1.DaemonSet), err -} - -func (c *daemonSetsClient) Update(ctx context.Context, daemonSet *extensionsv1beta1.DaemonSet, opts metav1.UpdateOptions) (*extensionsv1beta1.DaemonSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(daemonSetsResource, c.ClusterPath, c.Namespace, daemonSet), &extensionsv1beta1.DaemonSet{}) - if obj == nil { - return nil, err - } - return obj.(*extensionsv1beta1.DaemonSet), err -} - -func (c *daemonSetsClient) UpdateStatus(ctx context.Context, daemonSet *extensionsv1beta1.DaemonSet, opts metav1.UpdateOptions) (*extensionsv1beta1.DaemonSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(daemonSetsResource, c.ClusterPath, "status", c.Namespace, daemonSet), &extensionsv1beta1.DaemonSet{}) - if obj == nil { - return nil, err - } - return obj.(*extensionsv1beta1.DaemonSet), err -} - -func (c *daemonSetsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(daemonSetsResource, c.ClusterPath, c.Namespace, name, opts), &extensionsv1beta1.DaemonSet{}) - return err -} - -func (c *daemonSetsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(daemonSetsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &extensionsv1beta1.DaemonSetList{}) - return err -} - -func (c *daemonSetsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*extensionsv1beta1.DaemonSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(daemonSetsResource, c.ClusterPath, c.Namespace, name), &extensionsv1beta1.DaemonSet{}) - if obj == nil { - return nil, err - } - return obj.(*extensionsv1beta1.DaemonSet), err -} - -// List takes label and field selectors, and returns the list of DaemonSets that match those selectors. -func (c *daemonSetsClient) List(ctx context.Context, opts metav1.ListOptions) (*extensionsv1beta1.DaemonSetList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(daemonSetsResource, daemonSetsKind, c.ClusterPath, c.Namespace, opts), &extensionsv1beta1.DaemonSetList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &extensionsv1beta1.DaemonSetList{ListMeta: obj.(*extensionsv1beta1.DaemonSetList).ListMeta} - for _, item := range obj.(*extensionsv1beta1.DaemonSetList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *daemonSetsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(daemonSetsResource, c.ClusterPath, c.Namespace, opts)) } -func (c *daemonSetsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*extensionsv1beta1.DaemonSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(daemonSetsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &extensionsv1beta1.DaemonSet{}) - if obj == nil { - return nil, err - } - return obj.(*extensionsv1beta1.DaemonSet), err -} - -func (c *daemonSetsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsextensionsv1beta1.DaemonSetApplyConfiguration, opts metav1.ApplyOptions) (*extensionsv1beta1.DaemonSet, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(daemonSetsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &extensionsv1beta1.DaemonSet{}) - if obj == nil { - return nil, err - } - return obj.(*extensionsv1beta1.DaemonSet), err -} - -func (c *daemonSetsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsextensionsv1beta1.DaemonSetApplyConfiguration, opts metav1.ApplyOptions) (*extensionsv1beta1.DaemonSet, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(daemonSetsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &extensionsv1beta1.DaemonSet{}) - if obj == nil { - return nil, err +func newFakeDaemonSetClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedextensionsv1beta1.DaemonSetInterface { + return &daemonSetScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*extensionsv1beta1.DaemonSet, *extensionsv1beta1.DaemonSetList, *v1beta1.DaemonSetApplyConfiguration]( + fake, + clusterPath, + namespace, + extensionsv1beta1.SchemeGroupVersion.WithResource("daemonsets"), + extensionsv1beta1.SchemeGroupVersion.WithKind("DaemonSet"), + func() *extensionsv1beta1.DaemonSet { return &extensionsv1beta1.DaemonSet{} }, + func() *extensionsv1beta1.DaemonSetList { return &extensionsv1beta1.DaemonSetList{} }, + func(dst, src *extensionsv1beta1.DaemonSetList) { dst.ListMeta = src.ListMeta }, + func(list *extensionsv1beta1.DaemonSetList) []*extensionsv1beta1.DaemonSet { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *extensionsv1beta1.DaemonSetList, items []*extensionsv1beta1.DaemonSet) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*extensionsv1beta1.DaemonSet), err } diff --git a/kubernetes/typed/extensions/v1beta1/fake/deployment.go b/kubernetes/typed/extensions/v1beta1/fake/deployment.go index 4e448da87..163eb8a65 100644 --- a/kubernetes/typed/extensions/v1beta1/fake/deployment.go +++ b/kubernetes/typed/extensions/v1beta1/fake/deployment.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,232 +14,131 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" + context "context" + json "encoding/json" + fmt "fmt" "github.com/kcp-dev/logicalcluster/v3" extensionsv1beta1 "k8s.io/api/extensions/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsextensionsv1beta1 "k8s.io/client-go/applyconfigurations/extensions/v1beta1" - extensionsv1beta1client "k8s.io/client-go/kubernetes/typed/extensions/v1beta1" - "k8s.io/client-go/testing" - - kcpextensionsv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/extensions/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + v1beta1 "k8s.io/client-go/applyconfigurations/extensions/v1beta1" + typedextensionsv1beta1 "k8s.io/client-go/kubernetes/typed/extensions/v1beta1" + + typedkcpextensionsv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/extensions/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var deploymentsResource = schema.GroupVersionResource{Group: "extensions", Version: "v1beta1", Resource: "deployments"} -var deploymentsKind = schema.GroupVersionKind{Group: "extensions", Version: "v1beta1", Kind: "Deployment"} - -type deploymentsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *deploymentsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpextensionsv1beta1.DeploymentsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &deploymentsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// deploymentClusterClient implements DeploymentClusterInterface +type deploymentClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*extensionsv1beta1.Deployment, *extensionsv1beta1.DeploymentList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of Deployments that match those selectors across all clusters. -func (c *deploymentsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*extensionsv1beta1.DeploymentList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(deploymentsResource, deploymentsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &extensionsv1beta1.DeploymentList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &extensionsv1beta1.DeploymentList{ListMeta: obj.(*extensionsv1beta1.DeploymentList).ListMeta} - for _, item := range obj.(*extensionsv1beta1.DeploymentList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } +func newFakeDeploymentClusterClient(fake *ExtensionsV1beta1ClusterClient) typedkcpextensionsv1beta1.DeploymentClusterInterface { + return &deploymentClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*extensionsv1beta1.Deployment, *extensionsv1beta1.DeploymentList]( + fake.Fake, + extensionsv1beta1.SchemeGroupVersion.WithResource("deployments"), + extensionsv1beta1.SchemeGroupVersion.WithKind("Deployment"), + func() *extensionsv1beta1.Deployment { return &extensionsv1beta1.Deployment{} }, + func() *extensionsv1beta1.DeploymentList { return &extensionsv1beta1.DeploymentList{} }, + func(dst, src *extensionsv1beta1.DeploymentList) { dst.ListMeta = src.ListMeta }, + func(list *extensionsv1beta1.DeploymentList) []*extensionsv1beta1.Deployment { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *extensionsv1beta1.DeploymentList, items []*extensionsv1beta1.Deployment) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - return list, err } -// Watch returns a watch.Interface that watches the requested Deployments across all clusters. -func (c *deploymentsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(deploymentsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *deploymentClusterClient) Cluster(cluster logicalcluster.Path) typedkcpextensionsv1beta1.DeploymentsNamespacer { + return &deploymentNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type deploymentsNamespacer struct { +type deploymentNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *deploymentsNamespacer) Namespace(namespace string) extensionsv1beta1client.DeploymentInterface { - return &deploymentsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *deploymentNamespacer) Namespace(namespace string) typedextensionsv1beta1.DeploymentInterface { + return newFakeDeploymentClient(n.Fake, namespace, n.ClusterPath) } -type deploymentsClient struct { - *kcptesting.Fake +// deploymentScopedClient implements DeploymentInterface +type deploymentScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*extensionsv1beta1.Deployment, *extensionsv1beta1.DeploymentList, *v1beta1.DeploymentApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *deploymentsClient) Create(ctx context.Context, deployment *extensionsv1beta1.Deployment, opts metav1.CreateOptions) (*extensionsv1beta1.Deployment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(deploymentsResource, c.ClusterPath, c.Namespace, deployment), &extensionsv1beta1.Deployment{}) - if obj == nil { - return nil, err - } - return obj.(*extensionsv1beta1.Deployment), err } -func (c *deploymentsClient) Update(ctx context.Context, deployment *extensionsv1beta1.Deployment, opts metav1.UpdateOptions) (*extensionsv1beta1.Deployment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(deploymentsResource, c.ClusterPath, c.Namespace, deployment), &extensionsv1beta1.Deployment{}) +func newFakeDeploymentClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedextensionsv1beta1.DeploymentInterface { + return &deploymentScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*extensionsv1beta1.Deployment, *extensionsv1beta1.DeploymentList, *v1beta1.DeploymentApplyConfiguration]( + fake, + clusterPath, + namespace, + extensionsv1beta1.SchemeGroupVersion.WithResource("deployments"), + extensionsv1beta1.SchemeGroupVersion.WithKind("Deployment"), + func() *extensionsv1beta1.Deployment { return &extensionsv1beta1.Deployment{} }, + func() *extensionsv1beta1.DeploymentList { return &extensionsv1beta1.DeploymentList{} }, + func(dst, src *extensionsv1beta1.DeploymentList) { dst.ListMeta = src.ListMeta }, + func(list *extensionsv1beta1.DeploymentList) []*extensionsv1beta1.Deployment { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *extensionsv1beta1.DeploymentList, items []*extensionsv1beta1.Deployment) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, + } +} + +// GetScale takes name of the deployment, and returns the corresponding scale object, and an error if there is any. +func (c *deploymentScopedClient) GetScale(ctx context.Context, deploymentName string, _ v1.GetOptions) (result *extensionsv1beta1.Scale, err error) { + emptyResult := &extensionsv1beta1.Scale{} + obj, err := c.Fake.Invokes(kcptesting.NewGetSubresourceAction(c.Resource(), c.ClusterPath, c.Namespace(), "scale", deploymentName), emptyResult) if obj == nil { - return nil, err - } - return obj.(*extensionsv1beta1.Deployment), err -} - -func (c *deploymentsClient) UpdateStatus(ctx context.Context, deployment *extensionsv1beta1.Deployment, opts metav1.UpdateOptions) (*extensionsv1beta1.Deployment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(deploymentsResource, c.ClusterPath, "status", c.Namespace, deployment), &extensionsv1beta1.Deployment{}) - if obj == nil { - return nil, err - } - return obj.(*extensionsv1beta1.Deployment), err -} - -func (c *deploymentsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(deploymentsResource, c.ClusterPath, c.Namespace, name, opts), &extensionsv1beta1.Deployment{}) - return err -} - -func (c *deploymentsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(deploymentsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &extensionsv1beta1.DeploymentList{}) - return err -} - -func (c *deploymentsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*extensionsv1beta1.Deployment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(deploymentsResource, c.ClusterPath, c.Namespace, name), &extensionsv1beta1.Deployment{}) - if obj == nil { - return nil, err - } - return obj.(*extensionsv1beta1.Deployment), err -} - -// List takes label and field selectors, and returns the list of Deployments that match those selectors. -func (c *deploymentsClient) List(ctx context.Context, opts metav1.ListOptions) (*extensionsv1beta1.DeploymentList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(deploymentsResource, deploymentsKind, c.ClusterPath, c.Namespace, opts), &extensionsv1beta1.DeploymentList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &extensionsv1beta1.DeploymentList{ListMeta: obj.(*extensionsv1beta1.DeploymentList).ListMeta} - for _, item := range obj.(*extensionsv1beta1.DeploymentList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *deploymentsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(deploymentsResource, c.ClusterPath, c.Namespace, opts)) -} - -func (c *deploymentsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*extensionsv1beta1.Deployment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(deploymentsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &extensionsv1beta1.Deployment{}) - if obj == nil { - return nil, err - } - return obj.(*extensionsv1beta1.Deployment), err -} - -func (c *deploymentsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsextensionsv1beta1.DeploymentApplyConfiguration, opts metav1.ApplyOptions) (*extensionsv1beta1.Deployment, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(deploymentsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &extensionsv1beta1.Deployment{}) - if obj == nil { - return nil, err - } - return obj.(*extensionsv1beta1.Deployment), err -} - -func (c *deploymentsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsextensionsv1beta1.DeploymentApplyConfiguration, opts metav1.ApplyOptions) (*extensionsv1beta1.Deployment, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(deploymentsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &extensionsv1beta1.Deployment{}) - if obj == nil { - return nil, err - } - return obj.(*extensionsv1beta1.Deployment), err -} - -func (c *deploymentsClient) GetScale(ctx context.Context, deploymentName string, options metav1.GetOptions) (*extensionsv1beta1.Scale, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetSubresourceAction(deploymentsResource, c.ClusterPath, "scale", c.Namespace, deploymentName), &extensionsv1beta1.Scale{}) - if obj == nil { - return nil, err + return emptyResult, err } return obj.(*extensionsv1beta1.Scale), err } -func (c *deploymentsClient) UpdateScale(ctx context.Context, deploymentName string, scale *extensionsv1beta1.Scale, opts metav1.UpdateOptions) (*extensionsv1beta1.Scale, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(deploymentsResource, c.ClusterPath, "scale", c.Namespace, scale), &extensionsv1beta1.Scale{}) +// UpdateScale takes the representation of a scale and updates it. Returns the server's representation of the scale, and an error, if there is any. +func (c *deploymentScopedClient) UpdateScale(ctx context.Context, deploymentName string, scale *extensionsv1beta1.Scale, _ v1.UpdateOptions) (result *extensionsv1beta1.Scale, err error) { + emptyResult := &extensionsv1beta1.Scale{} + obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(c.Resource(), c.ClusterPath, "scale", c.Namespace(), scale), &extensionsv1beta1.Scale{}) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*extensionsv1beta1.Scale), err } -func (c *deploymentsClient) ApplyScale(ctx context.Context, deploymentName string, applyConfiguration *applyconfigurationsextensionsv1beta1.ScaleApplyConfiguration, opts metav1.ApplyOptions) (*extensionsv1beta1.Scale, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") +// ApplyScale takes top resource name and the apply declarative configuration for scale, +// applies it and returns the applied scale, and an error, if there is any. +func (c *deploymentScopedClient) ApplyScale(ctx context.Context, deploymentName string, scale *v1beta1.ScaleApplyConfiguration, _ v1.ApplyOptions) (result *extensionsv1beta1.Scale, err error) { + if scale == nil { + return nil, fmt.Errorf("scale provided to ApplyScale must not be nil") } - data, err := json.Marshal(applyConfiguration) + data, err := json.Marshal(scale) if err != nil { return nil, err } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(deploymentsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &extensionsv1beta1.Scale{}) + emptyResult := &extensionsv1beta1.Scale{} + obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(c.Resource(), c.ClusterPath, c.Namespace(), deploymentName, types.ApplyPatchType, data, "scale"), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*extensionsv1beta1.Scale), err } diff --git a/kubernetes/typed/extensions/v1beta1/fake/doc.go b/kubernetes/typed/extensions/v1beta1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/extensions/v1beta1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/extensions/v1beta1/fake/extensions_client.go b/kubernetes/typed/extensions/v1beta1/fake/extensions_client.go index 13a8a3af8..f0d1ec51a 100644 --- a/kubernetes/typed/extensions/v1beta1/fake/extensions_client.go +++ b/kubernetes/typed/extensions/v1beta1/fake/extensions_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" extensionsv1beta1 "k8s.io/client-go/kubernetes/typed/extensions/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpextensionsv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/extensions/v1beta1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -41,54 +41,54 @@ func (c *ExtensionsV1beta1ClusterClient) Cluster(clusterPath logicalcluster.Path return &ExtensionsV1beta1Client{Fake: c.Fake, ClusterPath: clusterPath} } -func (c *ExtensionsV1beta1ClusterClient) Deployments() kcpextensionsv1beta1.DeploymentClusterInterface { - return &deploymentsClusterClient{Fake: c.Fake} -} - func (c *ExtensionsV1beta1ClusterClient) DaemonSets() kcpextensionsv1beta1.DaemonSetClusterInterface { - return &daemonSetsClusterClient{Fake: c.Fake} + return newFakeDaemonSetClusterClient(c) } -func (c *ExtensionsV1beta1ClusterClient) Ingresses() kcpextensionsv1beta1.IngressClusterInterface { - return &ingressesClusterClient{Fake: c.Fake} +func (c *ExtensionsV1beta1ClusterClient) Deployments() kcpextensionsv1beta1.DeploymentClusterInterface { + return newFakeDeploymentClusterClient(c) } -func (c *ExtensionsV1beta1ClusterClient) ReplicaSets() kcpextensionsv1beta1.ReplicaSetClusterInterface { - return &replicaSetsClusterClient{Fake: c.Fake} +func (c *ExtensionsV1beta1ClusterClient) Ingresses() kcpextensionsv1beta1.IngressClusterInterface { + return newFakeIngressClusterClient(c) } func (c *ExtensionsV1beta1ClusterClient) NetworkPolicies() kcpextensionsv1beta1.NetworkPolicyClusterInterface { - return &networkPoliciesClusterClient{Fake: c.Fake} + return newFakeNetworkPolicyClusterClient(c) } -var _ extensionsv1beta1.ExtensionsV1beta1Interface = (*ExtensionsV1beta1Client)(nil) +func (c *ExtensionsV1beta1ClusterClient) ReplicaSets() kcpextensionsv1beta1.ReplicaSetClusterInterface { + return newFakeReplicaSetClusterClient(c) +} type ExtensionsV1beta1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *ExtensionsV1beta1Client) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret +func (c *ExtensionsV1beta1Client) DaemonSets(namespace string) extensionsv1beta1.DaemonSetInterface { + return newFakeDaemonSetClient(c.Fake, namespace, c.ClusterPath) } func (c *ExtensionsV1beta1Client) Deployments(namespace string) extensionsv1beta1.DeploymentInterface { - return &deploymentsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} + return newFakeDeploymentClient(c.Fake, namespace, c.ClusterPath) } -func (c *ExtensionsV1beta1Client) DaemonSets(namespace string) extensionsv1beta1.DaemonSetInterface { - return &daemonSetsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *ExtensionsV1beta1Client) Ingresses(namespace string) extensionsv1beta1.IngressInterface { + return newFakeIngressClient(c.Fake, namespace, c.ClusterPath) } -func (c *ExtensionsV1beta1Client) Ingresses(namespace string) extensionsv1beta1.IngressInterface { - return &ingressesClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *ExtensionsV1beta1Client) NetworkPolicies(namespace string) extensionsv1beta1.NetworkPolicyInterface { + return newFakeNetworkPolicyClient(c.Fake, namespace, c.ClusterPath) } func (c *ExtensionsV1beta1Client) ReplicaSets(namespace string) extensionsv1beta1.ReplicaSetInterface { - return &replicaSetsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} + return newFakeReplicaSetClient(c.Fake, namespace, c.ClusterPath) } -func (c *ExtensionsV1beta1Client) NetworkPolicies(namespace string) extensionsv1beta1.NetworkPolicyInterface { - return &networkPoliciesClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *ExtensionsV1beta1Client) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret } diff --git a/kubernetes/typed/extensions/v1beta1/fake/fake_deployment_expansion.go b/kubernetes/typed/extensions/v1beta1/fake/fake_deployment_expansion.go index 1246e4df6..2bc06dcc4 100644 --- a/kubernetes/typed/extensions/v1beta1/fake/fake_deployment_expansion.go +++ b/kubernetes/typed/extensions/v1beta1/fake/fake_deployment_expansion.go @@ -22,11 +22,15 @@ import ( "k8s.io/api/extensions/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" core "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -func (c *deploymentsClient) Rollback(ctx context.Context, deploymentRollback *v1beta1.DeploymentRollback, opts metav1.CreateOptions) error { +var deploymentsResource = schema.GroupVersionResource{Group: "extensions", Version: "v1beta1", Resource: "deployments"} +var deploymentsKind = schema.GroupVersionKind{Group: "extensions", Version: "v1beta1", Kind: "Deployment"} + +func (c *deploymentScopedClient) Rollback(ctx context.Context, deploymentRollback *v1beta1.DeploymentRollback, opts metav1.CreateOptions) error { action := core.CreateActionImpl{} action.Verb = "create" action.Resource = deploymentsResource diff --git a/kubernetes/typed/extensions/v1beta1/fake/ingress.go b/kubernetes/typed/extensions/v1beta1/fake/ingress.go index c583a0cec..7ebb4a550 100644 --- a/kubernetes/typed/extensions/v1beta1/fake/ingress.go +++ b/kubernetes/typed/extensions/v1beta1/fake/ingress.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" extensionsv1beta1 "k8s.io/api/extensions/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsextensionsv1beta1 "k8s.io/client-go/applyconfigurations/extensions/v1beta1" - extensionsv1beta1client "k8s.io/client-go/kubernetes/typed/extensions/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/extensions/v1beta1" + typedextensionsv1beta1 "k8s.io/client-go/kubernetes/typed/extensions/v1beta1" - kcpextensionsv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/extensions/v1beta1" + typedkcpextensionsv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/extensions/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var ingressesResource = schema.GroupVersionResource{Group: "extensions", Version: "v1beta1", Resource: "ingresses"} -var ingressesKind = schema.GroupVersionKind{Group: "extensions", Version: "v1beta1", Kind: "Ingress"} - -type ingressesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *ingressesClusterClient) Cluster(clusterPath logicalcluster.Path) kcpextensionsv1beta1.IngressesNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &ingressesNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// ingressClusterClient implements IngressClusterInterface +type ingressClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*extensionsv1beta1.Ingress, *extensionsv1beta1.IngressList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of Ingresses that match those selectors across all clusters. -func (c *ingressesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*extensionsv1beta1.IngressList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(ingressesResource, ingressesKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &extensionsv1beta1.IngressList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeIngressClusterClient(fake *ExtensionsV1beta1ClusterClient) typedkcpextensionsv1beta1.IngressClusterInterface { + return &ingressClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*extensionsv1beta1.Ingress, *extensionsv1beta1.IngressList]( + fake.Fake, + extensionsv1beta1.SchemeGroupVersion.WithResource("ingresses"), + extensionsv1beta1.SchemeGroupVersion.WithKind("Ingress"), + func() *extensionsv1beta1.Ingress { return &extensionsv1beta1.Ingress{} }, + func() *extensionsv1beta1.IngressList { return &extensionsv1beta1.IngressList{} }, + func(dst, src *extensionsv1beta1.IngressList) { dst.ListMeta = src.ListMeta }, + func(list *extensionsv1beta1.IngressList) []*extensionsv1beta1.Ingress { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *extensionsv1beta1.IngressList, items []*extensionsv1beta1.Ingress) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &extensionsv1beta1.IngressList{ListMeta: obj.(*extensionsv1beta1.IngressList).ListMeta} - for _, item := range obj.(*extensionsv1beta1.IngressList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested Ingresses across all clusters. -func (c *ingressesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(ingressesResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *ingressClusterClient) Cluster(cluster logicalcluster.Path) typedkcpextensionsv1beta1.IngressesNamespacer { + return &ingressNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type ingressesNamespacer struct { +type ingressNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *ingressesNamespacer) Namespace(namespace string) extensionsv1beta1client.IngressInterface { - return &ingressesClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *ingressNamespacer) Namespace(namespace string) typedextensionsv1beta1.IngressInterface { + return newFakeIngressClient(n.Fake, namespace, n.ClusterPath) } -type ingressesClient struct { - *kcptesting.Fake +// ingressScopedClient implements IngressInterface +type ingressScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*extensionsv1beta1.Ingress, *extensionsv1beta1.IngressList, *v1beta1.IngressApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *ingressesClient) Create(ctx context.Context, ingress *extensionsv1beta1.Ingress, opts metav1.CreateOptions) (*extensionsv1beta1.Ingress, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(ingressesResource, c.ClusterPath, c.Namespace, ingress), &extensionsv1beta1.Ingress{}) - if obj == nil { - return nil, err - } - return obj.(*extensionsv1beta1.Ingress), err -} - -func (c *ingressesClient) Update(ctx context.Context, ingress *extensionsv1beta1.Ingress, opts metav1.UpdateOptions) (*extensionsv1beta1.Ingress, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(ingressesResource, c.ClusterPath, c.Namespace, ingress), &extensionsv1beta1.Ingress{}) - if obj == nil { - return nil, err - } - return obj.(*extensionsv1beta1.Ingress), err -} - -func (c *ingressesClient) UpdateStatus(ctx context.Context, ingress *extensionsv1beta1.Ingress, opts metav1.UpdateOptions) (*extensionsv1beta1.Ingress, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(ingressesResource, c.ClusterPath, "status", c.Namespace, ingress), &extensionsv1beta1.Ingress{}) - if obj == nil { - return nil, err - } - return obj.(*extensionsv1beta1.Ingress), err -} - -func (c *ingressesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(ingressesResource, c.ClusterPath, c.Namespace, name, opts), &extensionsv1beta1.Ingress{}) - return err -} - -func (c *ingressesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(ingressesResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &extensionsv1beta1.IngressList{}) - return err -} - -func (c *ingressesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*extensionsv1beta1.Ingress, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(ingressesResource, c.ClusterPath, c.Namespace, name), &extensionsv1beta1.Ingress{}) - if obj == nil { - return nil, err - } - return obj.(*extensionsv1beta1.Ingress), err -} - -// List takes label and field selectors, and returns the list of Ingresses that match those selectors. -func (c *ingressesClient) List(ctx context.Context, opts metav1.ListOptions) (*extensionsv1beta1.IngressList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(ingressesResource, ingressesKind, c.ClusterPath, c.Namespace, opts), &extensionsv1beta1.IngressList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &extensionsv1beta1.IngressList{ListMeta: obj.(*extensionsv1beta1.IngressList).ListMeta} - for _, item := range obj.(*extensionsv1beta1.IngressList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *ingressesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(ingressesResource, c.ClusterPath, c.Namespace, opts)) } -func (c *ingressesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*extensionsv1beta1.Ingress, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(ingressesResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &extensionsv1beta1.Ingress{}) - if obj == nil { - return nil, err - } - return obj.(*extensionsv1beta1.Ingress), err -} - -func (c *ingressesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsextensionsv1beta1.IngressApplyConfiguration, opts metav1.ApplyOptions) (*extensionsv1beta1.Ingress, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(ingressesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &extensionsv1beta1.Ingress{}) - if obj == nil { - return nil, err - } - return obj.(*extensionsv1beta1.Ingress), err -} - -func (c *ingressesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsextensionsv1beta1.IngressApplyConfiguration, opts metav1.ApplyOptions) (*extensionsv1beta1.Ingress, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(ingressesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &extensionsv1beta1.Ingress{}) - if obj == nil { - return nil, err +func newFakeIngressClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedextensionsv1beta1.IngressInterface { + return &ingressScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*extensionsv1beta1.Ingress, *extensionsv1beta1.IngressList, *v1beta1.IngressApplyConfiguration]( + fake, + clusterPath, + namespace, + extensionsv1beta1.SchemeGroupVersion.WithResource("ingresses"), + extensionsv1beta1.SchemeGroupVersion.WithKind("Ingress"), + func() *extensionsv1beta1.Ingress { return &extensionsv1beta1.Ingress{} }, + func() *extensionsv1beta1.IngressList { return &extensionsv1beta1.IngressList{} }, + func(dst, src *extensionsv1beta1.IngressList) { dst.ListMeta = src.ListMeta }, + func(list *extensionsv1beta1.IngressList) []*extensionsv1beta1.Ingress { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *extensionsv1beta1.IngressList, items []*extensionsv1beta1.Ingress) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*extensionsv1beta1.Ingress), err } diff --git a/kubernetes/typed/extensions/v1beta1/fake/networkpolicy.go b/kubernetes/typed/extensions/v1beta1/fake/networkpolicy.go index 6eccb0e2b..6c32cccd8 100644 --- a/kubernetes/typed/extensions/v1beta1/fake/networkpolicy.go +++ b/kubernetes/typed/extensions/v1beta1/fake/networkpolicy.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" extensionsv1beta1 "k8s.io/api/extensions/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsextensionsv1beta1 "k8s.io/client-go/applyconfigurations/extensions/v1beta1" - extensionsv1beta1client "k8s.io/client-go/kubernetes/typed/extensions/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/extensions/v1beta1" + typedextensionsv1beta1 "k8s.io/client-go/kubernetes/typed/extensions/v1beta1" - kcpextensionsv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/extensions/v1beta1" + typedkcpextensionsv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/extensions/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var networkPoliciesResource = schema.GroupVersionResource{Group: "extensions", Version: "v1beta1", Resource: "networkpolicies"} -var networkPoliciesKind = schema.GroupVersionKind{Group: "extensions", Version: "v1beta1", Kind: "NetworkPolicy"} - -type networkPoliciesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *networkPoliciesClusterClient) Cluster(clusterPath logicalcluster.Path) kcpextensionsv1beta1.NetworkPoliciesNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &networkPoliciesNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// networkPolicyClusterClient implements NetworkPolicyClusterInterface +type networkPolicyClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*extensionsv1beta1.NetworkPolicy, *extensionsv1beta1.NetworkPolicyList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of NetworkPolicies that match those selectors across all clusters. -func (c *networkPoliciesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*extensionsv1beta1.NetworkPolicyList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(networkPoliciesResource, networkPoliciesKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &extensionsv1beta1.NetworkPolicyList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeNetworkPolicyClusterClient(fake *ExtensionsV1beta1ClusterClient) typedkcpextensionsv1beta1.NetworkPolicyClusterInterface { + return &networkPolicyClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*extensionsv1beta1.NetworkPolicy, *extensionsv1beta1.NetworkPolicyList]( + fake.Fake, + extensionsv1beta1.SchemeGroupVersion.WithResource("networkpolicies"), + extensionsv1beta1.SchemeGroupVersion.WithKind("NetworkPolicy"), + func() *extensionsv1beta1.NetworkPolicy { return &extensionsv1beta1.NetworkPolicy{} }, + func() *extensionsv1beta1.NetworkPolicyList { return &extensionsv1beta1.NetworkPolicyList{} }, + func(dst, src *extensionsv1beta1.NetworkPolicyList) { dst.ListMeta = src.ListMeta }, + func(list *extensionsv1beta1.NetworkPolicyList) []*extensionsv1beta1.NetworkPolicy { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *extensionsv1beta1.NetworkPolicyList, items []*extensionsv1beta1.NetworkPolicy) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &extensionsv1beta1.NetworkPolicyList{ListMeta: obj.(*extensionsv1beta1.NetworkPolicyList).ListMeta} - for _, item := range obj.(*extensionsv1beta1.NetworkPolicyList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested NetworkPolicies across all clusters. -func (c *networkPoliciesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(networkPoliciesResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *networkPolicyClusterClient) Cluster(cluster logicalcluster.Path) typedkcpextensionsv1beta1.NetworkPoliciesNamespacer { + return &networkPolicyNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type networkPoliciesNamespacer struct { +type networkPolicyNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *networkPoliciesNamespacer) Namespace(namespace string) extensionsv1beta1client.NetworkPolicyInterface { - return &networkPoliciesClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *networkPolicyNamespacer) Namespace(namespace string) typedextensionsv1beta1.NetworkPolicyInterface { + return newFakeNetworkPolicyClient(n.Fake, namespace, n.ClusterPath) } -type networkPoliciesClient struct { - *kcptesting.Fake +// networkPolicyScopedClient implements NetworkPolicyInterface +type networkPolicyScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*extensionsv1beta1.NetworkPolicy, *extensionsv1beta1.NetworkPolicyList, *v1beta1.NetworkPolicyApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *networkPoliciesClient) Create(ctx context.Context, networkPolicy *extensionsv1beta1.NetworkPolicy, opts metav1.CreateOptions) (*extensionsv1beta1.NetworkPolicy, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(networkPoliciesResource, c.ClusterPath, c.Namespace, networkPolicy), &extensionsv1beta1.NetworkPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*extensionsv1beta1.NetworkPolicy), err -} - -func (c *networkPoliciesClient) Update(ctx context.Context, networkPolicy *extensionsv1beta1.NetworkPolicy, opts metav1.UpdateOptions) (*extensionsv1beta1.NetworkPolicy, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(networkPoliciesResource, c.ClusterPath, c.Namespace, networkPolicy), &extensionsv1beta1.NetworkPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*extensionsv1beta1.NetworkPolicy), err -} - -func (c *networkPoliciesClient) UpdateStatus(ctx context.Context, networkPolicy *extensionsv1beta1.NetworkPolicy, opts metav1.UpdateOptions) (*extensionsv1beta1.NetworkPolicy, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(networkPoliciesResource, c.ClusterPath, "status", c.Namespace, networkPolicy), &extensionsv1beta1.NetworkPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*extensionsv1beta1.NetworkPolicy), err -} - -func (c *networkPoliciesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(networkPoliciesResource, c.ClusterPath, c.Namespace, name, opts), &extensionsv1beta1.NetworkPolicy{}) - return err -} - -func (c *networkPoliciesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(networkPoliciesResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &extensionsv1beta1.NetworkPolicyList{}) - return err -} - -func (c *networkPoliciesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*extensionsv1beta1.NetworkPolicy, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(networkPoliciesResource, c.ClusterPath, c.Namespace, name), &extensionsv1beta1.NetworkPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*extensionsv1beta1.NetworkPolicy), err -} - -// List takes label and field selectors, and returns the list of NetworkPolicies that match those selectors. -func (c *networkPoliciesClient) List(ctx context.Context, opts metav1.ListOptions) (*extensionsv1beta1.NetworkPolicyList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(networkPoliciesResource, networkPoliciesKind, c.ClusterPath, c.Namespace, opts), &extensionsv1beta1.NetworkPolicyList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &extensionsv1beta1.NetworkPolicyList{ListMeta: obj.(*extensionsv1beta1.NetworkPolicyList).ListMeta} - for _, item := range obj.(*extensionsv1beta1.NetworkPolicyList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *networkPoliciesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(networkPoliciesResource, c.ClusterPath, c.Namespace, opts)) } -func (c *networkPoliciesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*extensionsv1beta1.NetworkPolicy, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(networkPoliciesResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &extensionsv1beta1.NetworkPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*extensionsv1beta1.NetworkPolicy), err -} - -func (c *networkPoliciesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsextensionsv1beta1.NetworkPolicyApplyConfiguration, opts metav1.ApplyOptions) (*extensionsv1beta1.NetworkPolicy, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(networkPoliciesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &extensionsv1beta1.NetworkPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*extensionsv1beta1.NetworkPolicy), err -} - -func (c *networkPoliciesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsextensionsv1beta1.NetworkPolicyApplyConfiguration, opts metav1.ApplyOptions) (*extensionsv1beta1.NetworkPolicy, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(networkPoliciesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &extensionsv1beta1.NetworkPolicy{}) - if obj == nil { - return nil, err +func newFakeNetworkPolicyClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedextensionsv1beta1.NetworkPolicyInterface { + return &networkPolicyScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*extensionsv1beta1.NetworkPolicy, *extensionsv1beta1.NetworkPolicyList, *v1beta1.NetworkPolicyApplyConfiguration]( + fake, + clusterPath, + namespace, + extensionsv1beta1.SchemeGroupVersion.WithResource("networkpolicies"), + extensionsv1beta1.SchemeGroupVersion.WithKind("NetworkPolicy"), + func() *extensionsv1beta1.NetworkPolicy { return &extensionsv1beta1.NetworkPolicy{} }, + func() *extensionsv1beta1.NetworkPolicyList { return &extensionsv1beta1.NetworkPolicyList{} }, + func(dst, src *extensionsv1beta1.NetworkPolicyList) { dst.ListMeta = src.ListMeta }, + func(list *extensionsv1beta1.NetworkPolicyList) []*extensionsv1beta1.NetworkPolicy { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *extensionsv1beta1.NetworkPolicyList, items []*extensionsv1beta1.NetworkPolicy) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*extensionsv1beta1.NetworkPolicy), err } diff --git a/kubernetes/typed/extensions/v1beta1/fake/replicaset.go b/kubernetes/typed/extensions/v1beta1/fake/replicaset.go index 0a2712532..ab61c5a7c 100644 --- a/kubernetes/typed/extensions/v1beta1/fake/replicaset.go +++ b/kubernetes/typed/extensions/v1beta1/fake/replicaset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,232 +14,131 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" + context "context" + json "encoding/json" + fmt "fmt" "github.com/kcp-dev/logicalcluster/v3" extensionsv1beta1 "k8s.io/api/extensions/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsextensionsv1beta1 "k8s.io/client-go/applyconfigurations/extensions/v1beta1" - extensionsv1beta1client "k8s.io/client-go/kubernetes/typed/extensions/v1beta1" - "k8s.io/client-go/testing" - - kcpextensionsv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/extensions/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + v1beta1 "k8s.io/client-go/applyconfigurations/extensions/v1beta1" + typedextensionsv1beta1 "k8s.io/client-go/kubernetes/typed/extensions/v1beta1" + + typedkcpextensionsv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/extensions/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var replicaSetsResource = schema.GroupVersionResource{Group: "extensions", Version: "v1beta1", Resource: "replicasets"} -var replicaSetsKind = schema.GroupVersionKind{Group: "extensions", Version: "v1beta1", Kind: "ReplicaSet"} - -type replicaSetsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *replicaSetsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpextensionsv1beta1.ReplicaSetsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &replicaSetsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// replicaSetClusterClient implements ReplicaSetClusterInterface +type replicaSetClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*extensionsv1beta1.ReplicaSet, *extensionsv1beta1.ReplicaSetList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of ReplicaSets that match those selectors across all clusters. -func (c *replicaSetsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*extensionsv1beta1.ReplicaSetList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(replicaSetsResource, replicaSetsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &extensionsv1beta1.ReplicaSetList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &extensionsv1beta1.ReplicaSetList{ListMeta: obj.(*extensionsv1beta1.ReplicaSetList).ListMeta} - for _, item := range obj.(*extensionsv1beta1.ReplicaSetList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } +func newFakeReplicaSetClusterClient(fake *ExtensionsV1beta1ClusterClient) typedkcpextensionsv1beta1.ReplicaSetClusterInterface { + return &replicaSetClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*extensionsv1beta1.ReplicaSet, *extensionsv1beta1.ReplicaSetList]( + fake.Fake, + extensionsv1beta1.SchemeGroupVersion.WithResource("replicasets"), + extensionsv1beta1.SchemeGroupVersion.WithKind("ReplicaSet"), + func() *extensionsv1beta1.ReplicaSet { return &extensionsv1beta1.ReplicaSet{} }, + func() *extensionsv1beta1.ReplicaSetList { return &extensionsv1beta1.ReplicaSetList{} }, + func(dst, src *extensionsv1beta1.ReplicaSetList) { dst.ListMeta = src.ListMeta }, + func(list *extensionsv1beta1.ReplicaSetList) []*extensionsv1beta1.ReplicaSet { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *extensionsv1beta1.ReplicaSetList, items []*extensionsv1beta1.ReplicaSet) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - return list, err } -// Watch returns a watch.Interface that watches the requested ReplicaSets across all clusters. -func (c *replicaSetsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(replicaSetsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *replicaSetClusterClient) Cluster(cluster logicalcluster.Path) typedkcpextensionsv1beta1.ReplicaSetsNamespacer { + return &replicaSetNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type replicaSetsNamespacer struct { +type replicaSetNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *replicaSetsNamespacer) Namespace(namespace string) extensionsv1beta1client.ReplicaSetInterface { - return &replicaSetsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *replicaSetNamespacer) Namespace(namespace string) typedextensionsv1beta1.ReplicaSetInterface { + return newFakeReplicaSetClient(n.Fake, namespace, n.ClusterPath) } -type replicaSetsClient struct { - *kcptesting.Fake +// replicaSetScopedClient implements ReplicaSetInterface +type replicaSetScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*extensionsv1beta1.ReplicaSet, *extensionsv1beta1.ReplicaSetList, *v1beta1.ReplicaSetApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *replicaSetsClient) Create(ctx context.Context, replicaSet *extensionsv1beta1.ReplicaSet, opts metav1.CreateOptions) (*extensionsv1beta1.ReplicaSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(replicaSetsResource, c.ClusterPath, c.Namespace, replicaSet), &extensionsv1beta1.ReplicaSet{}) - if obj == nil { - return nil, err - } - return obj.(*extensionsv1beta1.ReplicaSet), err } -func (c *replicaSetsClient) Update(ctx context.Context, replicaSet *extensionsv1beta1.ReplicaSet, opts metav1.UpdateOptions) (*extensionsv1beta1.ReplicaSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(replicaSetsResource, c.ClusterPath, c.Namespace, replicaSet), &extensionsv1beta1.ReplicaSet{}) +func newFakeReplicaSetClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedextensionsv1beta1.ReplicaSetInterface { + return &replicaSetScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*extensionsv1beta1.ReplicaSet, *extensionsv1beta1.ReplicaSetList, *v1beta1.ReplicaSetApplyConfiguration]( + fake, + clusterPath, + namespace, + extensionsv1beta1.SchemeGroupVersion.WithResource("replicasets"), + extensionsv1beta1.SchemeGroupVersion.WithKind("ReplicaSet"), + func() *extensionsv1beta1.ReplicaSet { return &extensionsv1beta1.ReplicaSet{} }, + func() *extensionsv1beta1.ReplicaSetList { return &extensionsv1beta1.ReplicaSetList{} }, + func(dst, src *extensionsv1beta1.ReplicaSetList) { dst.ListMeta = src.ListMeta }, + func(list *extensionsv1beta1.ReplicaSetList) []*extensionsv1beta1.ReplicaSet { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *extensionsv1beta1.ReplicaSetList, items []*extensionsv1beta1.ReplicaSet) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, + } +} + +// GetScale takes name of the replicaSet, and returns the corresponding scale object, and an error if there is any. +func (c *replicaSetScopedClient) GetScale(ctx context.Context, replicaSetName string, _ v1.GetOptions) (result *extensionsv1beta1.Scale, err error) { + emptyResult := &extensionsv1beta1.Scale{} + obj, err := c.Fake.Invokes(kcptesting.NewGetSubresourceAction(c.Resource(), c.ClusterPath, c.Namespace(), "scale", replicaSetName), emptyResult) if obj == nil { - return nil, err - } - return obj.(*extensionsv1beta1.ReplicaSet), err -} - -func (c *replicaSetsClient) UpdateStatus(ctx context.Context, replicaSet *extensionsv1beta1.ReplicaSet, opts metav1.UpdateOptions) (*extensionsv1beta1.ReplicaSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(replicaSetsResource, c.ClusterPath, "status", c.Namespace, replicaSet), &extensionsv1beta1.ReplicaSet{}) - if obj == nil { - return nil, err - } - return obj.(*extensionsv1beta1.ReplicaSet), err -} - -func (c *replicaSetsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(replicaSetsResource, c.ClusterPath, c.Namespace, name, opts), &extensionsv1beta1.ReplicaSet{}) - return err -} - -func (c *replicaSetsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(replicaSetsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &extensionsv1beta1.ReplicaSetList{}) - return err -} - -func (c *replicaSetsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*extensionsv1beta1.ReplicaSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(replicaSetsResource, c.ClusterPath, c.Namespace, name), &extensionsv1beta1.ReplicaSet{}) - if obj == nil { - return nil, err - } - return obj.(*extensionsv1beta1.ReplicaSet), err -} - -// List takes label and field selectors, and returns the list of ReplicaSets that match those selectors. -func (c *replicaSetsClient) List(ctx context.Context, opts metav1.ListOptions) (*extensionsv1beta1.ReplicaSetList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(replicaSetsResource, replicaSetsKind, c.ClusterPath, c.Namespace, opts), &extensionsv1beta1.ReplicaSetList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &extensionsv1beta1.ReplicaSetList{ListMeta: obj.(*extensionsv1beta1.ReplicaSetList).ListMeta} - for _, item := range obj.(*extensionsv1beta1.ReplicaSetList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *replicaSetsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(replicaSetsResource, c.ClusterPath, c.Namespace, opts)) -} - -func (c *replicaSetsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*extensionsv1beta1.ReplicaSet, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(replicaSetsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &extensionsv1beta1.ReplicaSet{}) - if obj == nil { - return nil, err - } - return obj.(*extensionsv1beta1.ReplicaSet), err -} - -func (c *replicaSetsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsextensionsv1beta1.ReplicaSetApplyConfiguration, opts metav1.ApplyOptions) (*extensionsv1beta1.ReplicaSet, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(replicaSetsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &extensionsv1beta1.ReplicaSet{}) - if obj == nil { - return nil, err - } - return obj.(*extensionsv1beta1.ReplicaSet), err -} - -func (c *replicaSetsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsextensionsv1beta1.ReplicaSetApplyConfiguration, opts metav1.ApplyOptions) (*extensionsv1beta1.ReplicaSet, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(replicaSetsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &extensionsv1beta1.ReplicaSet{}) - if obj == nil { - return nil, err - } - return obj.(*extensionsv1beta1.ReplicaSet), err -} - -func (c *replicaSetsClient) GetScale(ctx context.Context, replicaSetName string, options metav1.GetOptions) (*extensionsv1beta1.Scale, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetSubresourceAction(replicaSetsResource, c.ClusterPath, "scale", c.Namespace, replicaSetName), &extensionsv1beta1.Scale{}) - if obj == nil { - return nil, err + return emptyResult, err } return obj.(*extensionsv1beta1.Scale), err } -func (c *replicaSetsClient) UpdateScale(ctx context.Context, replicaSetName string, scale *extensionsv1beta1.Scale, opts metav1.UpdateOptions) (*extensionsv1beta1.Scale, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(replicaSetsResource, c.ClusterPath, "scale", c.Namespace, scale), &extensionsv1beta1.Scale{}) +// UpdateScale takes the representation of a scale and updates it. Returns the server's representation of the scale, and an error, if there is any. +func (c *replicaSetScopedClient) UpdateScale(ctx context.Context, replicaSetName string, scale *extensionsv1beta1.Scale, _ v1.UpdateOptions) (result *extensionsv1beta1.Scale, err error) { + emptyResult := &extensionsv1beta1.Scale{} + obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(c.Resource(), c.ClusterPath, "scale", c.Namespace(), scale), &extensionsv1beta1.Scale{}) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*extensionsv1beta1.Scale), err } -func (c *replicaSetsClient) ApplyScale(ctx context.Context, replicaSetName string, applyConfiguration *applyconfigurationsextensionsv1beta1.ScaleApplyConfiguration, opts metav1.ApplyOptions) (*extensionsv1beta1.Scale, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") +// ApplyScale takes top resource name and the apply declarative configuration for scale, +// applies it and returns the applied scale, and an error, if there is any. +func (c *replicaSetScopedClient) ApplyScale(ctx context.Context, replicaSetName string, scale *v1beta1.ScaleApplyConfiguration, _ v1.ApplyOptions) (result *extensionsv1beta1.Scale, err error) { + if scale == nil { + return nil, fmt.Errorf("scale provided to ApplyScale must not be nil") } - data, err := json.Marshal(applyConfiguration) + data, err := json.Marshal(scale) if err != nil { return nil, err } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(replicaSetsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &extensionsv1beta1.Scale{}) + emptyResult := &extensionsv1beta1.Scale{} + obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(c.Resource(), c.ClusterPath, c.Namespace(), replicaSetName, types.ApplyPatchType, data, "scale"), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*extensionsv1beta1.Scale), err } diff --git a/kubernetes/typed/extensions/v1beta1/generated_expansion.go b/kubernetes/typed/extensions/v1beta1/generated_expansion.go new file mode 100644 index 000000000..a151e1cd4 --- /dev/null +++ b/kubernetes/typed/extensions/v1beta1/generated_expansion.go @@ -0,0 +1,29 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1beta1 + +type DaemonSetClusterExpansion interface{} + +type DeploymentClusterExpansion interface{} + +type IngressClusterExpansion interface{} + +type NetworkPolicyClusterExpansion interface{} + +type ReplicaSetClusterExpansion interface{} diff --git a/kubernetes/typed/extensions/v1beta1/ingress.go b/kubernetes/typed/extensions/v1beta1/ingress.go index d55ef291e..e82b6b04c 100644 --- a/kubernetes/typed/extensions/v1beta1/ingress.go +++ b/kubernetes/typed/extensions/v1beta1/ingress.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" extensionsv1beta1 "k8s.io/api/extensions/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - extensionsv1beta1client "k8s.io/client-go/kubernetes/typed/extensions/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedextensionsv1beta1 "k8s.io/client-go/kubernetes/typed/extensions/v1beta1" ) // IngressesClusterGetter has a method to return a IngressClusterInterface. @@ -40,12 +40,13 @@ type IngressesClusterGetter interface { // or scope down to one cluster and return a IngressesNamespacer. type IngressClusterInterface interface { Cluster(logicalcluster.Path) IngressesNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*extensionsv1beta1.IngressList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*extensionsv1beta1.IngressList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + IngressClusterExpansion } type ingressesClusterInterface struct { - clientCache kcpclient.Cache[*extensionsv1beta1client.ExtensionsV1beta1Client] + clientCache kcpclient.Cache[*typedextensionsv1beta1.ExtensionsV1beta1Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *ingressesClusterInterface) Cluster(clusterPath logicalcluster.Path) Ing } // List returns the entire collection of all Ingresses across all clusters. -func (c *ingressesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*extensionsv1beta1.IngressList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Ingresses(metav1.NamespaceAll).List(ctx, opts) +func (c *ingressesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*extensionsv1beta1.IngressList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Ingresses(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all Ingresses across all clusters. -func (c *ingressesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Ingresses(metav1.NamespaceAll).Watch(ctx, opts) +func (c *ingressesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Ingresses(v1.NamespaceAll).Watch(ctx, opts) } -// IngressesNamespacer can scope to objects within a namespace, returning a extensionsv1beta1client.IngressInterface. +// IngressesNamespacer can scope to objects within a namespace, returning a typedextensionsv1beta1.IngressInterface. type IngressesNamespacer interface { - Namespace(string) extensionsv1beta1client.IngressInterface + Namespace(string) typedextensionsv1beta1.IngressInterface } type ingressesNamespacer struct { - clientCache kcpclient.Cache[*extensionsv1beta1client.ExtensionsV1beta1Client] + clientCache kcpclient.Cache[*typedextensionsv1beta1.ExtensionsV1beta1Client] clusterPath logicalcluster.Path } -func (n *ingressesNamespacer) Namespace(namespace string) extensionsv1beta1client.IngressInterface { +func (n *ingressesNamespacer) Namespace(namespace string) typedextensionsv1beta1.IngressInterface { return n.clientCache.ClusterOrDie(n.clusterPath).Ingresses(namespace) } diff --git a/kubernetes/typed/extensions/v1beta1/networkpolicy.go b/kubernetes/typed/extensions/v1beta1/networkpolicy.go index ecbd8bb2a..23985088e 100644 --- a/kubernetes/typed/extensions/v1beta1/networkpolicy.go +++ b/kubernetes/typed/extensions/v1beta1/networkpolicy.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" extensionsv1beta1 "k8s.io/api/extensions/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - extensionsv1beta1client "k8s.io/client-go/kubernetes/typed/extensions/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedextensionsv1beta1 "k8s.io/client-go/kubernetes/typed/extensions/v1beta1" ) // NetworkPoliciesClusterGetter has a method to return a NetworkPolicyClusterInterface. @@ -40,12 +40,13 @@ type NetworkPoliciesClusterGetter interface { // or scope down to one cluster and return a NetworkPoliciesNamespacer. type NetworkPolicyClusterInterface interface { Cluster(logicalcluster.Path) NetworkPoliciesNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*extensionsv1beta1.NetworkPolicyList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*extensionsv1beta1.NetworkPolicyList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + NetworkPolicyClusterExpansion } type networkPoliciesClusterInterface struct { - clientCache kcpclient.Cache[*extensionsv1beta1client.ExtensionsV1beta1Client] + clientCache kcpclient.Cache[*typedextensionsv1beta1.ExtensionsV1beta1Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *networkPoliciesClusterInterface) Cluster(clusterPath logicalcluster.Pat } // List returns the entire collection of all NetworkPolicies across all clusters. -func (c *networkPoliciesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*extensionsv1beta1.NetworkPolicyList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).NetworkPolicies(metav1.NamespaceAll).List(ctx, opts) +func (c *networkPoliciesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*extensionsv1beta1.NetworkPolicyList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).NetworkPolicies(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all NetworkPolicies across all clusters. -func (c *networkPoliciesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).NetworkPolicies(metav1.NamespaceAll).Watch(ctx, opts) +func (c *networkPoliciesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).NetworkPolicies(v1.NamespaceAll).Watch(ctx, opts) } -// NetworkPoliciesNamespacer can scope to objects within a namespace, returning a extensionsv1beta1client.NetworkPolicyInterface. +// NetworkPoliciesNamespacer can scope to objects within a namespace, returning a typedextensionsv1beta1.NetworkPolicyInterface. type NetworkPoliciesNamespacer interface { - Namespace(string) extensionsv1beta1client.NetworkPolicyInterface + Namespace(string) typedextensionsv1beta1.NetworkPolicyInterface } type networkPoliciesNamespacer struct { - clientCache kcpclient.Cache[*extensionsv1beta1client.ExtensionsV1beta1Client] + clientCache kcpclient.Cache[*typedextensionsv1beta1.ExtensionsV1beta1Client] clusterPath logicalcluster.Path } -func (n *networkPoliciesNamespacer) Namespace(namespace string) extensionsv1beta1client.NetworkPolicyInterface { +func (n *networkPoliciesNamespacer) Namespace(namespace string) typedextensionsv1beta1.NetworkPolicyInterface { return n.clientCache.ClusterOrDie(n.clusterPath).NetworkPolicies(namespace) } diff --git a/kubernetes/typed/extensions/v1beta1/replicaset.go b/kubernetes/typed/extensions/v1beta1/replicaset.go index 54764c8fe..66e52106f 100644 --- a/kubernetes/typed/extensions/v1beta1/replicaset.go +++ b/kubernetes/typed/extensions/v1beta1/replicaset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" extensionsv1beta1 "k8s.io/api/extensions/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - extensionsv1beta1client "k8s.io/client-go/kubernetes/typed/extensions/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedextensionsv1beta1 "k8s.io/client-go/kubernetes/typed/extensions/v1beta1" ) // ReplicaSetsClusterGetter has a method to return a ReplicaSetClusterInterface. @@ -40,12 +40,13 @@ type ReplicaSetsClusterGetter interface { // or scope down to one cluster and return a ReplicaSetsNamespacer. type ReplicaSetClusterInterface interface { Cluster(logicalcluster.Path) ReplicaSetsNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*extensionsv1beta1.ReplicaSetList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*extensionsv1beta1.ReplicaSetList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + ReplicaSetClusterExpansion } type replicaSetsClusterInterface struct { - clientCache kcpclient.Cache[*extensionsv1beta1client.ExtensionsV1beta1Client] + clientCache kcpclient.Cache[*typedextensionsv1beta1.ExtensionsV1beta1Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *replicaSetsClusterInterface) Cluster(clusterPath logicalcluster.Path) R } // List returns the entire collection of all ReplicaSets across all clusters. -func (c *replicaSetsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*extensionsv1beta1.ReplicaSetList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ReplicaSets(metav1.NamespaceAll).List(ctx, opts) +func (c *replicaSetsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*extensionsv1beta1.ReplicaSetList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ReplicaSets(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all ReplicaSets across all clusters. -func (c *replicaSetsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ReplicaSets(metav1.NamespaceAll).Watch(ctx, opts) +func (c *replicaSetsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ReplicaSets(v1.NamespaceAll).Watch(ctx, opts) } -// ReplicaSetsNamespacer can scope to objects within a namespace, returning a extensionsv1beta1client.ReplicaSetInterface. +// ReplicaSetsNamespacer can scope to objects within a namespace, returning a typedextensionsv1beta1.ReplicaSetInterface. type ReplicaSetsNamespacer interface { - Namespace(string) extensionsv1beta1client.ReplicaSetInterface + Namespace(string) typedextensionsv1beta1.ReplicaSetInterface } type replicaSetsNamespacer struct { - clientCache kcpclient.Cache[*extensionsv1beta1client.ExtensionsV1beta1Client] + clientCache kcpclient.Cache[*typedextensionsv1beta1.ExtensionsV1beta1Client] clusterPath logicalcluster.Path } -func (n *replicaSetsNamespacer) Namespace(namespace string) extensionsv1beta1client.ReplicaSetInterface { +func (n *replicaSetsNamespacer) Namespace(namespace string) typedextensionsv1beta1.ReplicaSetInterface { return n.clientCache.ClusterOrDie(n.clusterPath).ReplicaSets(namespace) } diff --git a/kubernetes/typed/flowcontrol/v1/doc.go b/kubernetes/typed/flowcontrol/v1/doc.go new file mode 100644 index 000000000..d2f3412ab --- /dev/null +++ b/kubernetes/typed/flowcontrol/v1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1 diff --git a/kubernetes/typed/flowcontrol/v1/fake/doc.go b/kubernetes/typed/flowcontrol/v1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/flowcontrol/v1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/flowcontrol/v1/fake/flowcontrol_client.go b/kubernetes/typed/flowcontrol/v1/fake/flowcontrol_client.go index 2a92522d1..21ba80a5d 100644 --- a/kubernetes/typed/flowcontrol/v1/fake/flowcontrol_client.go +++ b/kubernetes/typed/flowcontrol/v1/fake/flowcontrol_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" flowcontrolv1 "k8s.io/client-go/kubernetes/typed/flowcontrol/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpflowcontrolv1 "github.com/kcp-dev/client-go/kubernetes/typed/flowcontrol/v1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -42,29 +42,29 @@ func (c *FlowcontrolV1ClusterClient) Cluster(clusterPath logicalcluster.Path) fl } func (c *FlowcontrolV1ClusterClient) FlowSchemas() kcpflowcontrolv1.FlowSchemaClusterInterface { - return &flowSchemasClusterClient{Fake: c.Fake} + return newFakeFlowSchemaClusterClient(c) } func (c *FlowcontrolV1ClusterClient) PriorityLevelConfigurations() kcpflowcontrolv1.PriorityLevelConfigurationClusterInterface { - return &priorityLevelConfigurationsClusterClient{Fake: c.Fake} + return newFakePriorityLevelConfigurationClusterClient(c) } -var _ flowcontrolv1.FlowcontrolV1Interface = (*FlowcontrolV1Client)(nil) - type FlowcontrolV1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *FlowcontrolV1Client) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret -} - func (c *FlowcontrolV1Client) FlowSchemas() flowcontrolv1.FlowSchemaInterface { - return &flowSchemasClient{Fake: c.Fake, ClusterPath: c.ClusterPath} + return newFakeFlowSchemaClient(c.Fake, c.ClusterPath) } func (c *FlowcontrolV1Client) PriorityLevelConfigurations() flowcontrolv1.PriorityLevelConfigurationInterface { - return &priorityLevelConfigurationsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} + return newFakePriorityLevelConfigurationClient(c.Fake, c.ClusterPath) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FlowcontrolV1Client) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret } diff --git a/kubernetes/typed/flowcontrol/v1/fake/flowschema.go b/kubernetes/typed/flowcontrol/v1/fake/flowschema.go index 1ce52344c..5aaa449e2 100644 --- a/kubernetes/typed/flowcontrol/v1/fake/flowschema.go +++ b/kubernetes/typed/flowcontrol/v1/fake/flowschema.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" flowcontrolv1 "k8s.io/api/flowcontrol/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsflowcontrolv1 "k8s.io/client-go/applyconfigurations/flowcontrol/v1" - flowcontrolv1client "k8s.io/client-go/kubernetes/typed/flowcontrol/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/flowcontrol/v1" + typedflowcontrolv1 "k8s.io/client-go/kubernetes/typed/flowcontrol/v1" + typedkcpflowcontrolv1 "github.com/kcp-dev/client-go/kubernetes/typed/flowcontrol/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var flowSchemasResource = schema.GroupVersionResource{Group: "flowcontrol.apiserver.k8s.io", Version: "v1", Resource: "flowschemas"} -var flowSchemasKind = schema.GroupVersionKind{Group: "flowcontrol.apiserver.k8s.io", Version: "v1", Kind: "FlowSchema"} - -type flowSchemasClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *flowSchemasClusterClient) Cluster(clusterPath logicalcluster.Path) flowcontrolv1client.FlowSchemaInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &flowSchemasClient{Fake: c.Fake, ClusterPath: clusterPath} +// flowSchemaClusterClient implements FlowSchemaClusterInterface +type flowSchemaClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*flowcontrolv1.FlowSchema, *flowcontrolv1.FlowSchemaList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of FlowSchemas that match those selectors across all clusters. -func (c *flowSchemasClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*flowcontrolv1.FlowSchemaList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(flowSchemasResource, flowSchemasKind, logicalcluster.Wildcard, opts), &flowcontrolv1.FlowSchemaList{}) - if obj == nil { - return nil, err +func newFakeFlowSchemaClusterClient(fake *FlowcontrolV1ClusterClient) typedkcpflowcontrolv1.FlowSchemaClusterInterface { + return &flowSchemaClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*flowcontrolv1.FlowSchema, *flowcontrolv1.FlowSchemaList]( + fake.Fake, + flowcontrolv1.SchemeGroupVersion.WithResource("flowschemas"), + flowcontrolv1.SchemeGroupVersion.WithKind("FlowSchema"), + func() *flowcontrolv1.FlowSchema { return &flowcontrolv1.FlowSchema{} }, + func() *flowcontrolv1.FlowSchemaList { return &flowcontrolv1.FlowSchemaList{} }, + func(dst, src *flowcontrolv1.FlowSchemaList) { dst.ListMeta = src.ListMeta }, + func(list *flowcontrolv1.FlowSchemaList) []*flowcontrolv1.FlowSchema { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *flowcontrolv1.FlowSchemaList, items []*flowcontrolv1.FlowSchema) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &flowcontrolv1.FlowSchemaList{ListMeta: obj.(*flowcontrolv1.FlowSchemaList).ListMeta} - for _, item := range obj.(*flowcontrolv1.FlowSchemaList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested FlowSchemas across all clusters. -func (c *flowSchemasClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(flowSchemasResource, logicalcluster.Wildcard, opts)) +func (c *flowSchemaClusterClient) Cluster(cluster logicalcluster.Path) typedflowcontrolv1.FlowSchemaInterface { + return newFakeFlowSchemaClient(c.Fake, cluster) } -type flowSchemasClient struct { - *kcptesting.Fake +// flowSchemaScopedClient implements FlowSchemaInterface +type flowSchemaScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*flowcontrolv1.FlowSchema, *flowcontrolv1.FlowSchemaList, *v1.FlowSchemaApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *flowSchemasClient) Create(ctx context.Context, flowSchema *flowcontrolv1.FlowSchema, opts metav1.CreateOptions) (*flowcontrolv1.FlowSchema, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(flowSchemasResource, c.ClusterPath, flowSchema), &flowcontrolv1.FlowSchema{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1.FlowSchema), err -} - -func (c *flowSchemasClient) Update(ctx context.Context, flowSchema *flowcontrolv1.FlowSchema, opts metav1.UpdateOptions) (*flowcontrolv1.FlowSchema, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(flowSchemasResource, c.ClusterPath, flowSchema), &flowcontrolv1.FlowSchema{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1.FlowSchema), err -} - -func (c *flowSchemasClient) UpdateStatus(ctx context.Context, flowSchema *flowcontrolv1.FlowSchema, opts metav1.UpdateOptions) (*flowcontrolv1.FlowSchema, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(flowSchemasResource, c.ClusterPath, "status", flowSchema), &flowcontrolv1.FlowSchema{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1.FlowSchema), err -} - -func (c *flowSchemasClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(flowSchemasResource, c.ClusterPath, name, opts), &flowcontrolv1.FlowSchema{}) - return err -} - -func (c *flowSchemasClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(flowSchemasResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &flowcontrolv1.FlowSchemaList{}) - return err -} - -func (c *flowSchemasClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*flowcontrolv1.FlowSchema, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(flowSchemasResource, c.ClusterPath, name), &flowcontrolv1.FlowSchema{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1.FlowSchema), err -} - -// List takes label and field selectors, and returns the list of FlowSchemas that match those selectors. -func (c *flowSchemasClient) List(ctx context.Context, opts metav1.ListOptions) (*flowcontrolv1.FlowSchemaList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(flowSchemasResource, flowSchemasKind, c.ClusterPath, opts), &flowcontrolv1.FlowSchemaList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &flowcontrolv1.FlowSchemaList{ListMeta: obj.(*flowcontrolv1.FlowSchemaList).ListMeta} - for _, item := range obj.(*flowcontrolv1.FlowSchemaList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *flowSchemasClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(flowSchemasResource, c.ClusterPath, opts)) -} - -func (c *flowSchemasClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*flowcontrolv1.FlowSchema, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(flowSchemasResource, c.ClusterPath, name, pt, data, subresources...), &flowcontrolv1.FlowSchema{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1.FlowSchema), err -} - -func (c *flowSchemasClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsflowcontrolv1.FlowSchemaApplyConfiguration, opts metav1.ApplyOptions) (*flowcontrolv1.FlowSchema, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(flowSchemasResource, c.ClusterPath, *name, types.ApplyPatchType, data), &flowcontrolv1.FlowSchema{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1.FlowSchema), err -} - -func (c *flowSchemasClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsflowcontrolv1.FlowSchemaApplyConfiguration, opts metav1.ApplyOptions) (*flowcontrolv1.FlowSchema, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(flowSchemasResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &flowcontrolv1.FlowSchema{}) - if obj == nil { - return nil, err +func newFakeFlowSchemaClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedflowcontrolv1.FlowSchemaInterface { + return &flowSchemaScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*flowcontrolv1.FlowSchema, *flowcontrolv1.FlowSchemaList, *v1.FlowSchemaApplyConfiguration]( + fake, + clusterPath, + "", + flowcontrolv1.SchemeGroupVersion.WithResource("flowschemas"), + flowcontrolv1.SchemeGroupVersion.WithKind("FlowSchema"), + func() *flowcontrolv1.FlowSchema { return &flowcontrolv1.FlowSchema{} }, + func() *flowcontrolv1.FlowSchemaList { return &flowcontrolv1.FlowSchemaList{} }, + func(dst, src *flowcontrolv1.FlowSchemaList) { dst.ListMeta = src.ListMeta }, + func(list *flowcontrolv1.FlowSchemaList) []*flowcontrolv1.FlowSchema { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *flowcontrolv1.FlowSchemaList, items []*flowcontrolv1.FlowSchema) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*flowcontrolv1.FlowSchema), err } diff --git a/kubernetes/typed/flowcontrol/v1/fake/prioritylevelconfiguration.go b/kubernetes/typed/flowcontrol/v1/fake/prioritylevelconfiguration.go index a265a0ac2..ee7d21250 100644 --- a/kubernetes/typed/flowcontrol/v1/fake/prioritylevelconfiguration.go +++ b/kubernetes/typed/flowcontrol/v1/fake/prioritylevelconfiguration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,82 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" flowcontrolv1 "k8s.io/api/flowcontrol/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsflowcontrolv1 "k8s.io/client-go/applyconfigurations/flowcontrol/v1" - flowcontrolv1client "k8s.io/client-go/kubernetes/typed/flowcontrol/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/flowcontrol/v1" + typedflowcontrolv1 "k8s.io/client-go/kubernetes/typed/flowcontrol/v1" + typedkcpflowcontrolv1 "github.com/kcp-dev/client-go/kubernetes/typed/flowcontrol/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var priorityLevelConfigurationsResource = schema.GroupVersionResource{Group: "flowcontrol.apiserver.k8s.io", Version: "v1", Resource: "prioritylevelconfigurations"} -var priorityLevelConfigurationsKind = schema.GroupVersionKind{Group: "flowcontrol.apiserver.k8s.io", Version: "v1", Kind: "PriorityLevelConfiguration"} - -type priorityLevelConfigurationsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *priorityLevelConfigurationsClusterClient) Cluster(clusterPath logicalcluster.Path) flowcontrolv1client.PriorityLevelConfigurationInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &priorityLevelConfigurationsClient{Fake: c.Fake, ClusterPath: clusterPath} -} - -// List takes label and field selectors, and returns the list of PriorityLevelConfigurations that match those selectors across all clusters. -func (c *priorityLevelConfigurationsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*flowcontrolv1.PriorityLevelConfigurationList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(priorityLevelConfigurationsResource, priorityLevelConfigurationsKind, logicalcluster.Wildcard, opts), &flowcontrolv1.PriorityLevelConfigurationList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &flowcontrolv1.PriorityLevelConfigurationList{ListMeta: obj.(*flowcontrolv1.PriorityLevelConfigurationList).ListMeta} - for _, item := range obj.(*flowcontrolv1.PriorityLevelConfigurationList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested PriorityLevelConfigurations across all clusters. -func (c *priorityLevelConfigurationsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(priorityLevelConfigurationsResource, logicalcluster.Wildcard, opts)) -} - -type priorityLevelConfigurationsClient struct { - *kcptesting.Fake +// priorityLevelConfigurationClusterClient implements PriorityLevelConfigurationClusterInterface +type priorityLevelConfigurationClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*flowcontrolv1.PriorityLevelConfiguration, *flowcontrolv1.PriorityLevelConfigurationList] + Fake *kcptesting.Fake +} + +func newFakePriorityLevelConfigurationClusterClient(fake *FlowcontrolV1ClusterClient) typedkcpflowcontrolv1.PriorityLevelConfigurationClusterInterface { + return &priorityLevelConfigurationClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*flowcontrolv1.PriorityLevelConfiguration, *flowcontrolv1.PriorityLevelConfigurationList]( + fake.Fake, + flowcontrolv1.SchemeGroupVersion.WithResource("prioritylevelconfigurations"), + flowcontrolv1.SchemeGroupVersion.WithKind("PriorityLevelConfiguration"), + func() *flowcontrolv1.PriorityLevelConfiguration { return &flowcontrolv1.PriorityLevelConfiguration{} }, + func() *flowcontrolv1.PriorityLevelConfigurationList { + return &flowcontrolv1.PriorityLevelConfigurationList{} + }, + func(dst, src *flowcontrolv1.PriorityLevelConfigurationList) { dst.ListMeta = src.ListMeta }, + func(list *flowcontrolv1.PriorityLevelConfigurationList) []*flowcontrolv1.PriorityLevelConfiguration { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *flowcontrolv1.PriorityLevelConfigurationList, items []*flowcontrolv1.PriorityLevelConfiguration) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, + } +} + +func (c *priorityLevelConfigurationClusterClient) Cluster(cluster logicalcluster.Path) typedflowcontrolv1.PriorityLevelConfigurationInterface { + return newFakePriorityLevelConfigurationClient(c.Fake, cluster) +} + +// priorityLevelConfigurationScopedClient implements PriorityLevelConfigurationInterface +type priorityLevelConfigurationScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*flowcontrolv1.PriorityLevelConfiguration, *flowcontrolv1.PriorityLevelConfigurationList, *v1.PriorityLevelConfigurationApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *priorityLevelConfigurationsClient) Create(ctx context.Context, priorityLevelConfiguration *flowcontrolv1.PriorityLevelConfiguration, opts metav1.CreateOptions) (*flowcontrolv1.PriorityLevelConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(priorityLevelConfigurationsResource, c.ClusterPath, priorityLevelConfiguration), &flowcontrolv1.PriorityLevelConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1.PriorityLevelConfiguration), err -} - -func (c *priorityLevelConfigurationsClient) Update(ctx context.Context, priorityLevelConfiguration *flowcontrolv1.PriorityLevelConfiguration, opts metav1.UpdateOptions) (*flowcontrolv1.PriorityLevelConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(priorityLevelConfigurationsResource, c.ClusterPath, priorityLevelConfiguration), &flowcontrolv1.PriorityLevelConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1.PriorityLevelConfiguration), err -} - -func (c *priorityLevelConfigurationsClient) UpdateStatus(ctx context.Context, priorityLevelConfiguration *flowcontrolv1.PriorityLevelConfiguration, opts metav1.UpdateOptions) (*flowcontrolv1.PriorityLevelConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(priorityLevelConfigurationsResource, c.ClusterPath, "status", priorityLevelConfiguration), &flowcontrolv1.PriorityLevelConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1.PriorityLevelConfiguration), err -} - -func (c *priorityLevelConfigurationsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(priorityLevelConfigurationsResource, c.ClusterPath, name, opts), &flowcontrolv1.PriorityLevelConfiguration{}) - return err -} - -func (c *priorityLevelConfigurationsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(priorityLevelConfigurationsResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &flowcontrolv1.PriorityLevelConfigurationList{}) - return err -} - -func (c *priorityLevelConfigurationsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*flowcontrolv1.PriorityLevelConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(priorityLevelConfigurationsResource, c.ClusterPath, name), &flowcontrolv1.PriorityLevelConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1.PriorityLevelConfiguration), err -} - -// List takes label and field selectors, and returns the list of PriorityLevelConfigurations that match those selectors. -func (c *priorityLevelConfigurationsClient) List(ctx context.Context, opts metav1.ListOptions) (*flowcontrolv1.PriorityLevelConfigurationList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(priorityLevelConfigurationsResource, priorityLevelConfigurationsKind, c.ClusterPath, opts), &flowcontrolv1.PriorityLevelConfigurationList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &flowcontrolv1.PriorityLevelConfigurationList{ListMeta: obj.(*flowcontrolv1.PriorityLevelConfigurationList).ListMeta} - for _, item := range obj.(*flowcontrolv1.PriorityLevelConfigurationList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *priorityLevelConfigurationsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(priorityLevelConfigurationsResource, c.ClusterPath, opts)) -} - -func (c *priorityLevelConfigurationsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*flowcontrolv1.PriorityLevelConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(priorityLevelConfigurationsResource, c.ClusterPath, name, pt, data, subresources...), &flowcontrolv1.PriorityLevelConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1.PriorityLevelConfiguration), err -} - -func (c *priorityLevelConfigurationsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsflowcontrolv1.PriorityLevelConfigurationApplyConfiguration, opts metav1.ApplyOptions) (*flowcontrolv1.PriorityLevelConfiguration, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(priorityLevelConfigurationsResource, c.ClusterPath, *name, types.ApplyPatchType, data), &flowcontrolv1.PriorityLevelConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1.PriorityLevelConfiguration), err -} - -func (c *priorityLevelConfigurationsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsflowcontrolv1.PriorityLevelConfigurationApplyConfiguration, opts metav1.ApplyOptions) (*flowcontrolv1.PriorityLevelConfiguration, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(priorityLevelConfigurationsResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &flowcontrolv1.PriorityLevelConfiguration{}) - if obj == nil { - return nil, err +func newFakePriorityLevelConfigurationClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedflowcontrolv1.PriorityLevelConfigurationInterface { + return &priorityLevelConfigurationScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*flowcontrolv1.PriorityLevelConfiguration, *flowcontrolv1.PriorityLevelConfigurationList, *v1.PriorityLevelConfigurationApplyConfiguration]( + fake, + clusterPath, + "", + flowcontrolv1.SchemeGroupVersion.WithResource("prioritylevelconfigurations"), + flowcontrolv1.SchemeGroupVersion.WithKind("PriorityLevelConfiguration"), + func() *flowcontrolv1.PriorityLevelConfiguration { return &flowcontrolv1.PriorityLevelConfiguration{} }, + func() *flowcontrolv1.PriorityLevelConfigurationList { + return &flowcontrolv1.PriorityLevelConfigurationList{} + }, + func(dst, src *flowcontrolv1.PriorityLevelConfigurationList) { dst.ListMeta = src.ListMeta }, + func(list *flowcontrolv1.PriorityLevelConfigurationList) []*flowcontrolv1.PriorityLevelConfiguration { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *flowcontrolv1.PriorityLevelConfigurationList, items []*flowcontrolv1.PriorityLevelConfiguration) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*flowcontrolv1.PriorityLevelConfiguration), err } diff --git a/kubernetes/typed/flowcontrol/v1/flowcontrol_client.go b/kubernetes/typed/flowcontrol/v1/flowcontrol_client.go index 55e534390..8295271f8 100644 --- a/kubernetes/typed/flowcontrol/v1/flowcontrol_client.go +++ b/kubernetes/typed/flowcontrol/v1/flowcontrol_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apiflowcontrolv1 "k8s.io/api/flowcontrol/v1" flowcontrolv1 "k8s.io/client-go/kubernetes/typed/flowcontrol/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type FlowcontrolV1ClusterInterface interface { @@ -38,6 +41,7 @@ type FlowcontrolV1ClusterScoper interface { Cluster(logicalcluster.Path) flowcontrolv1.FlowcontrolV1Interface } +// FlowcontrolV1ClusterClient is used to interact with features provided by the flowcontrol.apiserver.k8s.io group. type FlowcontrolV1ClusterClient struct { clientCache kcpclient.Cache[*flowcontrolv1.FlowcontrolV1Client] } @@ -61,11 +65,13 @@ func (c *FlowcontrolV1ClusterClient) PriorityLevelConfigurations() PriorityLevel // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*FlowcontrolV1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new FlowcontrolV1ClusterClient for the given config and http client. @@ -77,6 +83,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*FlowcontrolV1Cluste if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &FlowcontrolV1ClusterClient{clientCache: cache}, nil } @@ -89,3 +96,14 @@ func NewForConfigOrDie(c *rest.Config) *FlowcontrolV1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apiflowcontrolv1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/flowcontrol/v1/flowschema.go b/kubernetes/typed/flowcontrol/v1/flowschema.go index 2e3516abb..f54adcc39 100644 --- a/kubernetes/typed/flowcontrol/v1/flowschema.go +++ b/kubernetes/typed/flowcontrol/v1/flowschema.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - flowcontrolv1 "k8s.io/api/flowcontrol/v1" + apiflowcontrolv1 "k8s.io/api/flowcontrol/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - flowcontrolv1client "k8s.io/client-go/kubernetes/typed/flowcontrol/v1" + watch "k8s.io/apimachinery/pkg/watch" + flowcontrolv1 "k8s.io/client-go/kubernetes/typed/flowcontrol/v1" ) // FlowSchemasClusterGetter has a method to return a FlowSchemaClusterInterface. @@ -37,19 +37,20 @@ type FlowSchemasClusterGetter interface { } // FlowSchemaClusterInterface can operate on FlowSchemas across all clusters, -// or scope down to one cluster and return a flowcontrolv1client.FlowSchemaInterface. +// or scope down to one cluster and return a flowcontrolv1.FlowSchemaInterface. type FlowSchemaClusterInterface interface { - Cluster(logicalcluster.Path) flowcontrolv1client.FlowSchemaInterface - List(ctx context.Context, opts metav1.ListOptions) (*flowcontrolv1.FlowSchemaList, error) + Cluster(logicalcluster.Path) flowcontrolv1.FlowSchemaInterface + List(ctx context.Context, opts metav1.ListOptions) (*apiflowcontrolv1.FlowSchemaList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + FlowSchemaClusterExpansion } type flowSchemasClusterInterface struct { - clientCache kcpclient.Cache[*flowcontrolv1client.FlowcontrolV1Client] + clientCache kcpclient.Cache[*flowcontrolv1.FlowcontrolV1Client] } // Cluster scopes the client down to a particular cluster. -func (c *flowSchemasClusterInterface) Cluster(clusterPath logicalcluster.Path) flowcontrolv1client.FlowSchemaInterface { +func (c *flowSchemasClusterInterface) Cluster(clusterPath logicalcluster.Path) flowcontrolv1.FlowSchemaInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,7 +59,7 @@ func (c *flowSchemasClusterInterface) Cluster(clusterPath logicalcluster.Path) f } // List returns the entire collection of all FlowSchemas across all clusters. -func (c *flowSchemasClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*flowcontrolv1.FlowSchemaList, error) { +func (c *flowSchemasClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*apiflowcontrolv1.FlowSchemaList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).FlowSchemas().List(ctx, opts) } diff --git a/kubernetes/typed/flowcontrol/v1/generated_expansion.go b/kubernetes/typed/flowcontrol/v1/generated_expansion.go new file mode 100644 index 000000000..12f89237d --- /dev/null +++ b/kubernetes/typed/flowcontrol/v1/generated_expansion.go @@ -0,0 +1,23 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1 + +type FlowSchemaClusterExpansion interface{} + +type PriorityLevelConfigurationClusterExpansion interface{} diff --git a/kubernetes/typed/flowcontrol/v1/prioritylevelconfiguration.go b/kubernetes/typed/flowcontrol/v1/prioritylevelconfiguration.go index 2ffda7328..6af6da5e8 100644 --- a/kubernetes/typed/flowcontrol/v1/prioritylevelconfiguration.go +++ b/kubernetes/typed/flowcontrol/v1/prioritylevelconfiguration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - flowcontrolv1 "k8s.io/api/flowcontrol/v1" + apiflowcontrolv1 "k8s.io/api/flowcontrol/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - flowcontrolv1client "k8s.io/client-go/kubernetes/typed/flowcontrol/v1" + watch "k8s.io/apimachinery/pkg/watch" + flowcontrolv1 "k8s.io/client-go/kubernetes/typed/flowcontrol/v1" ) // PriorityLevelConfigurationsClusterGetter has a method to return a PriorityLevelConfigurationClusterInterface. @@ -37,19 +37,20 @@ type PriorityLevelConfigurationsClusterGetter interface { } // PriorityLevelConfigurationClusterInterface can operate on PriorityLevelConfigurations across all clusters, -// or scope down to one cluster and return a flowcontrolv1client.PriorityLevelConfigurationInterface. +// or scope down to one cluster and return a flowcontrolv1.PriorityLevelConfigurationInterface. type PriorityLevelConfigurationClusterInterface interface { - Cluster(logicalcluster.Path) flowcontrolv1client.PriorityLevelConfigurationInterface - List(ctx context.Context, opts metav1.ListOptions) (*flowcontrolv1.PriorityLevelConfigurationList, error) + Cluster(logicalcluster.Path) flowcontrolv1.PriorityLevelConfigurationInterface + List(ctx context.Context, opts metav1.ListOptions) (*apiflowcontrolv1.PriorityLevelConfigurationList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + PriorityLevelConfigurationClusterExpansion } type priorityLevelConfigurationsClusterInterface struct { - clientCache kcpclient.Cache[*flowcontrolv1client.FlowcontrolV1Client] + clientCache kcpclient.Cache[*flowcontrolv1.FlowcontrolV1Client] } // Cluster scopes the client down to a particular cluster. -func (c *priorityLevelConfigurationsClusterInterface) Cluster(clusterPath logicalcluster.Path) flowcontrolv1client.PriorityLevelConfigurationInterface { +func (c *priorityLevelConfigurationsClusterInterface) Cluster(clusterPath logicalcluster.Path) flowcontrolv1.PriorityLevelConfigurationInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,7 +59,7 @@ func (c *priorityLevelConfigurationsClusterInterface) Cluster(clusterPath logica } // List returns the entire collection of all PriorityLevelConfigurations across all clusters. -func (c *priorityLevelConfigurationsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*flowcontrolv1.PriorityLevelConfigurationList, error) { +func (c *priorityLevelConfigurationsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*apiflowcontrolv1.PriorityLevelConfigurationList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).PriorityLevelConfigurations().List(ctx, opts) } diff --git a/kubernetes/typed/flowcontrol/v1beta1/doc.go b/kubernetes/typed/flowcontrol/v1beta1/doc.go new file mode 100644 index 000000000..541e9d258 --- /dev/null +++ b/kubernetes/typed/flowcontrol/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1beta1 diff --git a/kubernetes/typed/flowcontrol/v1beta1/fake/doc.go b/kubernetes/typed/flowcontrol/v1beta1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/flowcontrol/v1beta1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/flowcontrol/v1beta1/fake/flowcontrol_client.go b/kubernetes/typed/flowcontrol/v1beta1/fake/flowcontrol_client.go index 7f56f2d74..d8e375be7 100644 --- a/kubernetes/typed/flowcontrol/v1beta1/fake/flowcontrol_client.go +++ b/kubernetes/typed/flowcontrol/v1beta1/fake/flowcontrol_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" flowcontrolv1beta1 "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpflowcontrolv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/flowcontrol/v1beta1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -42,29 +42,29 @@ func (c *FlowcontrolV1beta1ClusterClient) Cluster(clusterPath logicalcluster.Pat } func (c *FlowcontrolV1beta1ClusterClient) FlowSchemas() kcpflowcontrolv1beta1.FlowSchemaClusterInterface { - return &flowSchemasClusterClient{Fake: c.Fake} + return newFakeFlowSchemaClusterClient(c) } func (c *FlowcontrolV1beta1ClusterClient) PriorityLevelConfigurations() kcpflowcontrolv1beta1.PriorityLevelConfigurationClusterInterface { - return &priorityLevelConfigurationsClusterClient{Fake: c.Fake} + return newFakePriorityLevelConfigurationClusterClient(c) } -var _ flowcontrolv1beta1.FlowcontrolV1beta1Interface = (*FlowcontrolV1beta1Client)(nil) - type FlowcontrolV1beta1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *FlowcontrolV1beta1Client) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret -} - func (c *FlowcontrolV1beta1Client) FlowSchemas() flowcontrolv1beta1.FlowSchemaInterface { - return &flowSchemasClient{Fake: c.Fake, ClusterPath: c.ClusterPath} + return newFakeFlowSchemaClient(c.Fake, c.ClusterPath) } func (c *FlowcontrolV1beta1Client) PriorityLevelConfigurations() flowcontrolv1beta1.PriorityLevelConfigurationInterface { - return &priorityLevelConfigurationsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} + return newFakePriorityLevelConfigurationClient(c.Fake, c.ClusterPath) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FlowcontrolV1beta1Client) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret } diff --git a/kubernetes/typed/flowcontrol/v1beta1/fake/flowschema.go b/kubernetes/typed/flowcontrol/v1beta1/fake/flowschema.go index b6fd0a3b3..9fa916a14 100644 --- a/kubernetes/typed/flowcontrol/v1beta1/fake/flowschema.go +++ b/kubernetes/typed/flowcontrol/v1beta1/fake/flowschema.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" flowcontrolv1beta1 "k8s.io/api/flowcontrol/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsflowcontrolv1beta1 "k8s.io/client-go/applyconfigurations/flowcontrol/v1beta1" - flowcontrolv1beta1client "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/flowcontrol/v1beta1" + typedflowcontrolv1beta1 "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta1" + typedkcpflowcontrolv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/flowcontrol/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var flowSchemasResource = schema.GroupVersionResource{Group: "flowcontrol.apiserver.k8s.io", Version: "v1beta1", Resource: "flowschemas"} -var flowSchemasKind = schema.GroupVersionKind{Group: "flowcontrol.apiserver.k8s.io", Version: "v1beta1", Kind: "FlowSchema"} - -type flowSchemasClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *flowSchemasClusterClient) Cluster(clusterPath logicalcluster.Path) flowcontrolv1beta1client.FlowSchemaInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &flowSchemasClient{Fake: c.Fake, ClusterPath: clusterPath} +// flowSchemaClusterClient implements FlowSchemaClusterInterface +type flowSchemaClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*flowcontrolv1beta1.FlowSchema, *flowcontrolv1beta1.FlowSchemaList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of FlowSchemas that match those selectors across all clusters. -func (c *flowSchemasClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*flowcontrolv1beta1.FlowSchemaList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(flowSchemasResource, flowSchemasKind, logicalcluster.Wildcard, opts), &flowcontrolv1beta1.FlowSchemaList{}) - if obj == nil { - return nil, err +func newFakeFlowSchemaClusterClient(fake *FlowcontrolV1beta1ClusterClient) typedkcpflowcontrolv1beta1.FlowSchemaClusterInterface { + return &flowSchemaClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*flowcontrolv1beta1.FlowSchema, *flowcontrolv1beta1.FlowSchemaList]( + fake.Fake, + flowcontrolv1beta1.SchemeGroupVersion.WithResource("flowschemas"), + flowcontrolv1beta1.SchemeGroupVersion.WithKind("FlowSchema"), + func() *flowcontrolv1beta1.FlowSchema { return &flowcontrolv1beta1.FlowSchema{} }, + func() *flowcontrolv1beta1.FlowSchemaList { return &flowcontrolv1beta1.FlowSchemaList{} }, + func(dst, src *flowcontrolv1beta1.FlowSchemaList) { dst.ListMeta = src.ListMeta }, + func(list *flowcontrolv1beta1.FlowSchemaList) []*flowcontrolv1beta1.FlowSchema { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *flowcontrolv1beta1.FlowSchemaList, items []*flowcontrolv1beta1.FlowSchema) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &flowcontrolv1beta1.FlowSchemaList{ListMeta: obj.(*flowcontrolv1beta1.FlowSchemaList).ListMeta} - for _, item := range obj.(*flowcontrolv1beta1.FlowSchemaList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested FlowSchemas across all clusters. -func (c *flowSchemasClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(flowSchemasResource, logicalcluster.Wildcard, opts)) +func (c *flowSchemaClusterClient) Cluster(cluster logicalcluster.Path) typedflowcontrolv1beta1.FlowSchemaInterface { + return newFakeFlowSchemaClient(c.Fake, cluster) } -type flowSchemasClient struct { - *kcptesting.Fake +// flowSchemaScopedClient implements FlowSchemaInterface +type flowSchemaScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*flowcontrolv1beta1.FlowSchema, *flowcontrolv1beta1.FlowSchemaList, *v1beta1.FlowSchemaApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *flowSchemasClient) Create(ctx context.Context, flowSchema *flowcontrolv1beta1.FlowSchema, opts metav1.CreateOptions) (*flowcontrolv1beta1.FlowSchema, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(flowSchemasResource, c.ClusterPath, flowSchema), &flowcontrolv1beta1.FlowSchema{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta1.FlowSchema), err -} - -func (c *flowSchemasClient) Update(ctx context.Context, flowSchema *flowcontrolv1beta1.FlowSchema, opts metav1.UpdateOptions) (*flowcontrolv1beta1.FlowSchema, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(flowSchemasResource, c.ClusterPath, flowSchema), &flowcontrolv1beta1.FlowSchema{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta1.FlowSchema), err -} - -func (c *flowSchemasClient) UpdateStatus(ctx context.Context, flowSchema *flowcontrolv1beta1.FlowSchema, opts metav1.UpdateOptions) (*flowcontrolv1beta1.FlowSchema, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(flowSchemasResource, c.ClusterPath, "status", flowSchema), &flowcontrolv1beta1.FlowSchema{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta1.FlowSchema), err -} - -func (c *flowSchemasClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(flowSchemasResource, c.ClusterPath, name, opts), &flowcontrolv1beta1.FlowSchema{}) - return err -} - -func (c *flowSchemasClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(flowSchemasResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &flowcontrolv1beta1.FlowSchemaList{}) - return err -} - -func (c *flowSchemasClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*flowcontrolv1beta1.FlowSchema, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(flowSchemasResource, c.ClusterPath, name), &flowcontrolv1beta1.FlowSchema{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta1.FlowSchema), err -} - -// List takes label and field selectors, and returns the list of FlowSchemas that match those selectors. -func (c *flowSchemasClient) List(ctx context.Context, opts metav1.ListOptions) (*flowcontrolv1beta1.FlowSchemaList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(flowSchemasResource, flowSchemasKind, c.ClusterPath, opts), &flowcontrolv1beta1.FlowSchemaList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &flowcontrolv1beta1.FlowSchemaList{ListMeta: obj.(*flowcontrolv1beta1.FlowSchemaList).ListMeta} - for _, item := range obj.(*flowcontrolv1beta1.FlowSchemaList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *flowSchemasClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(flowSchemasResource, c.ClusterPath, opts)) -} - -func (c *flowSchemasClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*flowcontrolv1beta1.FlowSchema, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(flowSchemasResource, c.ClusterPath, name, pt, data, subresources...), &flowcontrolv1beta1.FlowSchema{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta1.FlowSchema), err -} - -func (c *flowSchemasClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsflowcontrolv1beta1.FlowSchemaApplyConfiguration, opts metav1.ApplyOptions) (*flowcontrolv1beta1.FlowSchema, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(flowSchemasResource, c.ClusterPath, *name, types.ApplyPatchType, data), &flowcontrolv1beta1.FlowSchema{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta1.FlowSchema), err -} - -func (c *flowSchemasClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsflowcontrolv1beta1.FlowSchemaApplyConfiguration, opts metav1.ApplyOptions) (*flowcontrolv1beta1.FlowSchema, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(flowSchemasResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &flowcontrolv1beta1.FlowSchema{}) - if obj == nil { - return nil, err +func newFakeFlowSchemaClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedflowcontrolv1beta1.FlowSchemaInterface { + return &flowSchemaScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*flowcontrolv1beta1.FlowSchema, *flowcontrolv1beta1.FlowSchemaList, *v1beta1.FlowSchemaApplyConfiguration]( + fake, + clusterPath, + "", + flowcontrolv1beta1.SchemeGroupVersion.WithResource("flowschemas"), + flowcontrolv1beta1.SchemeGroupVersion.WithKind("FlowSchema"), + func() *flowcontrolv1beta1.FlowSchema { return &flowcontrolv1beta1.FlowSchema{} }, + func() *flowcontrolv1beta1.FlowSchemaList { return &flowcontrolv1beta1.FlowSchemaList{} }, + func(dst, src *flowcontrolv1beta1.FlowSchemaList) { dst.ListMeta = src.ListMeta }, + func(list *flowcontrolv1beta1.FlowSchemaList) []*flowcontrolv1beta1.FlowSchema { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *flowcontrolv1beta1.FlowSchemaList, items []*flowcontrolv1beta1.FlowSchema) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*flowcontrolv1beta1.FlowSchema), err } diff --git a/kubernetes/typed/flowcontrol/v1beta1/fake/prioritylevelconfiguration.go b/kubernetes/typed/flowcontrol/v1beta1/fake/prioritylevelconfiguration.go index 7948f8b47..61abe1895 100644 --- a/kubernetes/typed/flowcontrol/v1beta1/fake/prioritylevelconfiguration.go +++ b/kubernetes/typed/flowcontrol/v1beta1/fake/prioritylevelconfiguration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,86 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" flowcontrolv1beta1 "k8s.io/api/flowcontrol/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsflowcontrolv1beta1 "k8s.io/client-go/applyconfigurations/flowcontrol/v1beta1" - flowcontrolv1beta1client "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/flowcontrol/v1beta1" + typedflowcontrolv1beta1 "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta1" + typedkcpflowcontrolv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/flowcontrol/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var priorityLevelConfigurationsResource = schema.GroupVersionResource{Group: "flowcontrol.apiserver.k8s.io", Version: "v1beta1", Resource: "prioritylevelconfigurations"} -var priorityLevelConfigurationsKind = schema.GroupVersionKind{Group: "flowcontrol.apiserver.k8s.io", Version: "v1beta1", Kind: "PriorityLevelConfiguration"} - -type priorityLevelConfigurationsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *priorityLevelConfigurationsClusterClient) Cluster(clusterPath logicalcluster.Path) flowcontrolv1beta1client.PriorityLevelConfigurationInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &priorityLevelConfigurationsClient{Fake: c.Fake, ClusterPath: clusterPath} -} - -// List takes label and field selectors, and returns the list of PriorityLevelConfigurations that match those selectors across all clusters. -func (c *priorityLevelConfigurationsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*flowcontrolv1beta1.PriorityLevelConfigurationList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(priorityLevelConfigurationsResource, priorityLevelConfigurationsKind, logicalcluster.Wildcard, opts), &flowcontrolv1beta1.PriorityLevelConfigurationList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &flowcontrolv1beta1.PriorityLevelConfigurationList{ListMeta: obj.(*flowcontrolv1beta1.PriorityLevelConfigurationList).ListMeta} - for _, item := range obj.(*flowcontrolv1beta1.PriorityLevelConfigurationList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested PriorityLevelConfigurations across all clusters. -func (c *priorityLevelConfigurationsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(priorityLevelConfigurationsResource, logicalcluster.Wildcard, opts)) -} - -type priorityLevelConfigurationsClient struct { - *kcptesting.Fake +// priorityLevelConfigurationClusterClient implements PriorityLevelConfigurationClusterInterface +type priorityLevelConfigurationClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*flowcontrolv1beta1.PriorityLevelConfiguration, *flowcontrolv1beta1.PriorityLevelConfigurationList] + Fake *kcptesting.Fake +} + +func newFakePriorityLevelConfigurationClusterClient(fake *FlowcontrolV1beta1ClusterClient) typedkcpflowcontrolv1beta1.PriorityLevelConfigurationClusterInterface { + return &priorityLevelConfigurationClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*flowcontrolv1beta1.PriorityLevelConfiguration, *flowcontrolv1beta1.PriorityLevelConfigurationList]( + fake.Fake, + flowcontrolv1beta1.SchemeGroupVersion.WithResource("prioritylevelconfigurations"), + flowcontrolv1beta1.SchemeGroupVersion.WithKind("PriorityLevelConfiguration"), + func() *flowcontrolv1beta1.PriorityLevelConfiguration { + return &flowcontrolv1beta1.PriorityLevelConfiguration{} + }, + func() *flowcontrolv1beta1.PriorityLevelConfigurationList { + return &flowcontrolv1beta1.PriorityLevelConfigurationList{} + }, + func(dst, src *flowcontrolv1beta1.PriorityLevelConfigurationList) { dst.ListMeta = src.ListMeta }, + func(list *flowcontrolv1beta1.PriorityLevelConfigurationList) []*flowcontrolv1beta1.PriorityLevelConfiguration { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *flowcontrolv1beta1.PriorityLevelConfigurationList, items []*flowcontrolv1beta1.PriorityLevelConfiguration) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, + } +} + +func (c *priorityLevelConfigurationClusterClient) Cluster(cluster logicalcluster.Path) typedflowcontrolv1beta1.PriorityLevelConfigurationInterface { + return newFakePriorityLevelConfigurationClient(c.Fake, cluster) +} + +// priorityLevelConfigurationScopedClient implements PriorityLevelConfigurationInterface +type priorityLevelConfigurationScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*flowcontrolv1beta1.PriorityLevelConfiguration, *flowcontrolv1beta1.PriorityLevelConfigurationList, *v1beta1.PriorityLevelConfigurationApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *priorityLevelConfigurationsClient) Create(ctx context.Context, priorityLevelConfiguration *flowcontrolv1beta1.PriorityLevelConfiguration, opts metav1.CreateOptions) (*flowcontrolv1beta1.PriorityLevelConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(priorityLevelConfigurationsResource, c.ClusterPath, priorityLevelConfiguration), &flowcontrolv1beta1.PriorityLevelConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta1.PriorityLevelConfiguration), err -} - -func (c *priorityLevelConfigurationsClient) Update(ctx context.Context, priorityLevelConfiguration *flowcontrolv1beta1.PriorityLevelConfiguration, opts metav1.UpdateOptions) (*flowcontrolv1beta1.PriorityLevelConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(priorityLevelConfigurationsResource, c.ClusterPath, priorityLevelConfiguration), &flowcontrolv1beta1.PriorityLevelConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta1.PriorityLevelConfiguration), err -} - -func (c *priorityLevelConfigurationsClient) UpdateStatus(ctx context.Context, priorityLevelConfiguration *flowcontrolv1beta1.PriorityLevelConfiguration, opts metav1.UpdateOptions) (*flowcontrolv1beta1.PriorityLevelConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(priorityLevelConfigurationsResource, c.ClusterPath, "status", priorityLevelConfiguration), &flowcontrolv1beta1.PriorityLevelConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta1.PriorityLevelConfiguration), err -} - -func (c *priorityLevelConfigurationsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(priorityLevelConfigurationsResource, c.ClusterPath, name, opts), &flowcontrolv1beta1.PriorityLevelConfiguration{}) - return err -} - -func (c *priorityLevelConfigurationsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(priorityLevelConfigurationsResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &flowcontrolv1beta1.PriorityLevelConfigurationList{}) - return err -} - -func (c *priorityLevelConfigurationsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*flowcontrolv1beta1.PriorityLevelConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(priorityLevelConfigurationsResource, c.ClusterPath, name), &flowcontrolv1beta1.PriorityLevelConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta1.PriorityLevelConfiguration), err -} - -// List takes label and field selectors, and returns the list of PriorityLevelConfigurations that match those selectors. -func (c *priorityLevelConfigurationsClient) List(ctx context.Context, opts metav1.ListOptions) (*flowcontrolv1beta1.PriorityLevelConfigurationList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(priorityLevelConfigurationsResource, priorityLevelConfigurationsKind, c.ClusterPath, opts), &flowcontrolv1beta1.PriorityLevelConfigurationList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &flowcontrolv1beta1.PriorityLevelConfigurationList{ListMeta: obj.(*flowcontrolv1beta1.PriorityLevelConfigurationList).ListMeta} - for _, item := range obj.(*flowcontrolv1beta1.PriorityLevelConfigurationList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *priorityLevelConfigurationsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(priorityLevelConfigurationsResource, c.ClusterPath, opts)) -} - -func (c *priorityLevelConfigurationsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*flowcontrolv1beta1.PriorityLevelConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(priorityLevelConfigurationsResource, c.ClusterPath, name, pt, data, subresources...), &flowcontrolv1beta1.PriorityLevelConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta1.PriorityLevelConfiguration), err -} - -func (c *priorityLevelConfigurationsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsflowcontrolv1beta1.PriorityLevelConfigurationApplyConfiguration, opts metav1.ApplyOptions) (*flowcontrolv1beta1.PriorityLevelConfiguration, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(priorityLevelConfigurationsResource, c.ClusterPath, *name, types.ApplyPatchType, data), &flowcontrolv1beta1.PriorityLevelConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta1.PriorityLevelConfiguration), err -} - -func (c *priorityLevelConfigurationsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsflowcontrolv1beta1.PriorityLevelConfigurationApplyConfiguration, opts metav1.ApplyOptions) (*flowcontrolv1beta1.PriorityLevelConfiguration, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(priorityLevelConfigurationsResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &flowcontrolv1beta1.PriorityLevelConfiguration{}) - if obj == nil { - return nil, err +func newFakePriorityLevelConfigurationClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedflowcontrolv1beta1.PriorityLevelConfigurationInterface { + return &priorityLevelConfigurationScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*flowcontrolv1beta1.PriorityLevelConfiguration, *flowcontrolv1beta1.PriorityLevelConfigurationList, *v1beta1.PriorityLevelConfigurationApplyConfiguration]( + fake, + clusterPath, + "", + flowcontrolv1beta1.SchemeGroupVersion.WithResource("prioritylevelconfigurations"), + flowcontrolv1beta1.SchemeGroupVersion.WithKind("PriorityLevelConfiguration"), + func() *flowcontrolv1beta1.PriorityLevelConfiguration { + return &flowcontrolv1beta1.PriorityLevelConfiguration{} + }, + func() *flowcontrolv1beta1.PriorityLevelConfigurationList { + return &flowcontrolv1beta1.PriorityLevelConfigurationList{} + }, + func(dst, src *flowcontrolv1beta1.PriorityLevelConfigurationList) { dst.ListMeta = src.ListMeta }, + func(list *flowcontrolv1beta1.PriorityLevelConfigurationList) []*flowcontrolv1beta1.PriorityLevelConfiguration { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *flowcontrolv1beta1.PriorityLevelConfigurationList, items []*flowcontrolv1beta1.PriorityLevelConfiguration) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*flowcontrolv1beta1.PriorityLevelConfiguration), err } diff --git a/kubernetes/typed/flowcontrol/v1beta1/flowcontrol_client.go b/kubernetes/typed/flowcontrol/v1beta1/flowcontrol_client.go index 9f6c57fc4..bd475f124 100644 --- a/kubernetes/typed/flowcontrol/v1beta1/flowcontrol_client.go +++ b/kubernetes/typed/flowcontrol/v1beta1/flowcontrol_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apiflowcontrolv1beta1 "k8s.io/api/flowcontrol/v1beta1" flowcontrolv1beta1 "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type FlowcontrolV1beta1ClusterInterface interface { @@ -38,6 +41,7 @@ type FlowcontrolV1beta1ClusterScoper interface { Cluster(logicalcluster.Path) flowcontrolv1beta1.FlowcontrolV1beta1Interface } +// FlowcontrolV1beta1ClusterClient is used to interact with features provided by the flowcontrol.apiserver.k8s.io group. type FlowcontrolV1beta1ClusterClient struct { clientCache kcpclient.Cache[*flowcontrolv1beta1.FlowcontrolV1beta1Client] } @@ -61,11 +65,13 @@ func (c *FlowcontrolV1beta1ClusterClient) PriorityLevelConfigurations() Priority // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*FlowcontrolV1beta1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new FlowcontrolV1beta1ClusterClient for the given config and http client. @@ -77,6 +83,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*FlowcontrolV1beta1C if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &FlowcontrolV1beta1ClusterClient{clientCache: cache}, nil } @@ -89,3 +96,14 @@ func NewForConfigOrDie(c *rest.Config) *FlowcontrolV1beta1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apiflowcontrolv1beta1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/flowcontrol/v1beta1/flowschema.go b/kubernetes/typed/flowcontrol/v1beta1/flowschema.go index 44e3bf18b..98aa374c2 100644 --- a/kubernetes/typed/flowcontrol/v1beta1/flowschema.go +++ b/kubernetes/typed/flowcontrol/v1beta1/flowschema.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - flowcontrolv1beta1 "k8s.io/api/flowcontrol/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - flowcontrolv1beta1client "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta1" + apiflowcontrolv1beta1 "k8s.io/api/flowcontrol/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + flowcontrolv1beta1 "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta1" ) // FlowSchemasClusterGetter has a method to return a FlowSchemaClusterInterface. @@ -37,19 +37,20 @@ type FlowSchemasClusterGetter interface { } // FlowSchemaClusterInterface can operate on FlowSchemas across all clusters, -// or scope down to one cluster and return a flowcontrolv1beta1client.FlowSchemaInterface. +// or scope down to one cluster and return a flowcontrolv1beta1.FlowSchemaInterface. type FlowSchemaClusterInterface interface { - Cluster(logicalcluster.Path) flowcontrolv1beta1client.FlowSchemaInterface - List(ctx context.Context, opts metav1.ListOptions) (*flowcontrolv1beta1.FlowSchemaList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) flowcontrolv1beta1.FlowSchemaInterface + List(ctx context.Context, opts v1.ListOptions) (*apiflowcontrolv1beta1.FlowSchemaList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + FlowSchemaClusterExpansion } type flowSchemasClusterInterface struct { - clientCache kcpclient.Cache[*flowcontrolv1beta1client.FlowcontrolV1beta1Client] + clientCache kcpclient.Cache[*flowcontrolv1beta1.FlowcontrolV1beta1Client] } // Cluster scopes the client down to a particular cluster. -func (c *flowSchemasClusterInterface) Cluster(clusterPath logicalcluster.Path) flowcontrolv1beta1client.FlowSchemaInterface { +func (c *flowSchemasClusterInterface) Cluster(clusterPath logicalcluster.Path) flowcontrolv1beta1.FlowSchemaInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *flowSchemasClusterInterface) Cluster(clusterPath logicalcluster.Path) f } // List returns the entire collection of all FlowSchemas across all clusters. -func (c *flowSchemasClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*flowcontrolv1beta1.FlowSchemaList, error) { +func (c *flowSchemasClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apiflowcontrolv1beta1.FlowSchemaList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).FlowSchemas().List(ctx, opts) } // Watch begins to watch all FlowSchemas across all clusters. -func (c *flowSchemasClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *flowSchemasClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).FlowSchemas().Watch(ctx, opts) } diff --git a/kubernetes/typed/flowcontrol/v1beta1/generated_expansion.go b/kubernetes/typed/flowcontrol/v1beta1/generated_expansion.go new file mode 100644 index 000000000..44a436261 --- /dev/null +++ b/kubernetes/typed/flowcontrol/v1beta1/generated_expansion.go @@ -0,0 +1,23 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1beta1 + +type FlowSchemaClusterExpansion interface{} + +type PriorityLevelConfigurationClusterExpansion interface{} diff --git a/kubernetes/typed/flowcontrol/v1beta1/prioritylevelconfiguration.go b/kubernetes/typed/flowcontrol/v1beta1/prioritylevelconfiguration.go index 99d3e3101..cecd17c9b 100644 --- a/kubernetes/typed/flowcontrol/v1beta1/prioritylevelconfiguration.go +++ b/kubernetes/typed/flowcontrol/v1beta1/prioritylevelconfiguration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - flowcontrolv1beta1 "k8s.io/api/flowcontrol/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - flowcontrolv1beta1client "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta1" + apiflowcontrolv1beta1 "k8s.io/api/flowcontrol/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + flowcontrolv1beta1 "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta1" ) // PriorityLevelConfigurationsClusterGetter has a method to return a PriorityLevelConfigurationClusterInterface. @@ -37,19 +37,20 @@ type PriorityLevelConfigurationsClusterGetter interface { } // PriorityLevelConfigurationClusterInterface can operate on PriorityLevelConfigurations across all clusters, -// or scope down to one cluster and return a flowcontrolv1beta1client.PriorityLevelConfigurationInterface. +// or scope down to one cluster and return a flowcontrolv1beta1.PriorityLevelConfigurationInterface. type PriorityLevelConfigurationClusterInterface interface { - Cluster(logicalcluster.Path) flowcontrolv1beta1client.PriorityLevelConfigurationInterface - List(ctx context.Context, opts metav1.ListOptions) (*flowcontrolv1beta1.PriorityLevelConfigurationList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) flowcontrolv1beta1.PriorityLevelConfigurationInterface + List(ctx context.Context, opts v1.ListOptions) (*apiflowcontrolv1beta1.PriorityLevelConfigurationList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + PriorityLevelConfigurationClusterExpansion } type priorityLevelConfigurationsClusterInterface struct { - clientCache kcpclient.Cache[*flowcontrolv1beta1client.FlowcontrolV1beta1Client] + clientCache kcpclient.Cache[*flowcontrolv1beta1.FlowcontrolV1beta1Client] } // Cluster scopes the client down to a particular cluster. -func (c *priorityLevelConfigurationsClusterInterface) Cluster(clusterPath logicalcluster.Path) flowcontrolv1beta1client.PriorityLevelConfigurationInterface { +func (c *priorityLevelConfigurationsClusterInterface) Cluster(clusterPath logicalcluster.Path) flowcontrolv1beta1.PriorityLevelConfigurationInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *priorityLevelConfigurationsClusterInterface) Cluster(clusterPath logica } // List returns the entire collection of all PriorityLevelConfigurations across all clusters. -func (c *priorityLevelConfigurationsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*flowcontrolv1beta1.PriorityLevelConfigurationList, error) { +func (c *priorityLevelConfigurationsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apiflowcontrolv1beta1.PriorityLevelConfigurationList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).PriorityLevelConfigurations().List(ctx, opts) } // Watch begins to watch all PriorityLevelConfigurations across all clusters. -func (c *priorityLevelConfigurationsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *priorityLevelConfigurationsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).PriorityLevelConfigurations().Watch(ctx, opts) } diff --git a/kubernetes/typed/flowcontrol/v1beta2/doc.go b/kubernetes/typed/flowcontrol/v1beta2/doc.go new file mode 100644 index 000000000..3f0720c40 --- /dev/null +++ b/kubernetes/typed/flowcontrol/v1beta2/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1beta2 diff --git a/kubernetes/typed/flowcontrol/v1beta2/fake/doc.go b/kubernetes/typed/flowcontrol/v1beta2/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/flowcontrol/v1beta2/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/flowcontrol/v1beta2/fake/flowcontrol_client.go b/kubernetes/typed/flowcontrol/v1beta2/fake/flowcontrol_client.go index 34ddb5a9e..f03d1ca8b 100644 --- a/kubernetes/typed/flowcontrol/v1beta2/fake/flowcontrol_client.go +++ b/kubernetes/typed/flowcontrol/v1beta2/fake/flowcontrol_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" flowcontrolv1beta2 "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpflowcontrolv1beta2 "github.com/kcp-dev/client-go/kubernetes/typed/flowcontrol/v1beta2" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -42,29 +42,29 @@ func (c *FlowcontrolV1beta2ClusterClient) Cluster(clusterPath logicalcluster.Pat } func (c *FlowcontrolV1beta2ClusterClient) FlowSchemas() kcpflowcontrolv1beta2.FlowSchemaClusterInterface { - return &flowSchemasClusterClient{Fake: c.Fake} + return newFakeFlowSchemaClusterClient(c) } func (c *FlowcontrolV1beta2ClusterClient) PriorityLevelConfigurations() kcpflowcontrolv1beta2.PriorityLevelConfigurationClusterInterface { - return &priorityLevelConfigurationsClusterClient{Fake: c.Fake} + return newFakePriorityLevelConfigurationClusterClient(c) } -var _ flowcontrolv1beta2.FlowcontrolV1beta2Interface = (*FlowcontrolV1beta2Client)(nil) - type FlowcontrolV1beta2Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *FlowcontrolV1beta2Client) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret -} - func (c *FlowcontrolV1beta2Client) FlowSchemas() flowcontrolv1beta2.FlowSchemaInterface { - return &flowSchemasClient{Fake: c.Fake, ClusterPath: c.ClusterPath} + return newFakeFlowSchemaClient(c.Fake, c.ClusterPath) } func (c *FlowcontrolV1beta2Client) PriorityLevelConfigurations() flowcontrolv1beta2.PriorityLevelConfigurationInterface { - return &priorityLevelConfigurationsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} + return newFakePriorityLevelConfigurationClient(c.Fake, c.ClusterPath) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FlowcontrolV1beta2Client) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret } diff --git a/kubernetes/typed/flowcontrol/v1beta2/fake/flowschema.go b/kubernetes/typed/flowcontrol/v1beta2/fake/flowschema.go index 057c47594..1e510e3fd 100644 --- a/kubernetes/typed/flowcontrol/v1beta2/fake/flowschema.go +++ b/kubernetes/typed/flowcontrol/v1beta2/fake/flowschema.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" flowcontrolv1beta2 "k8s.io/api/flowcontrol/v1beta2" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsflowcontrolv1beta2 "k8s.io/client-go/applyconfigurations/flowcontrol/v1beta2" - flowcontrolv1beta2client "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2" - "k8s.io/client-go/testing" + v1beta2 "k8s.io/client-go/applyconfigurations/flowcontrol/v1beta2" + typedflowcontrolv1beta2 "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2" + typedkcpflowcontrolv1beta2 "github.com/kcp-dev/client-go/kubernetes/typed/flowcontrol/v1beta2" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var flowSchemasResource = schema.GroupVersionResource{Group: "flowcontrol.apiserver.k8s.io", Version: "v1beta2", Resource: "flowschemas"} -var flowSchemasKind = schema.GroupVersionKind{Group: "flowcontrol.apiserver.k8s.io", Version: "v1beta2", Kind: "FlowSchema"} - -type flowSchemasClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *flowSchemasClusterClient) Cluster(clusterPath logicalcluster.Path) flowcontrolv1beta2client.FlowSchemaInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &flowSchemasClient{Fake: c.Fake, ClusterPath: clusterPath} +// flowSchemaClusterClient implements FlowSchemaClusterInterface +type flowSchemaClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*flowcontrolv1beta2.FlowSchema, *flowcontrolv1beta2.FlowSchemaList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of FlowSchemas that match those selectors across all clusters. -func (c *flowSchemasClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*flowcontrolv1beta2.FlowSchemaList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(flowSchemasResource, flowSchemasKind, logicalcluster.Wildcard, opts), &flowcontrolv1beta2.FlowSchemaList{}) - if obj == nil { - return nil, err +func newFakeFlowSchemaClusterClient(fake *FlowcontrolV1beta2ClusterClient) typedkcpflowcontrolv1beta2.FlowSchemaClusterInterface { + return &flowSchemaClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*flowcontrolv1beta2.FlowSchema, *flowcontrolv1beta2.FlowSchemaList]( + fake.Fake, + flowcontrolv1beta2.SchemeGroupVersion.WithResource("flowschemas"), + flowcontrolv1beta2.SchemeGroupVersion.WithKind("FlowSchema"), + func() *flowcontrolv1beta2.FlowSchema { return &flowcontrolv1beta2.FlowSchema{} }, + func() *flowcontrolv1beta2.FlowSchemaList { return &flowcontrolv1beta2.FlowSchemaList{} }, + func(dst, src *flowcontrolv1beta2.FlowSchemaList) { dst.ListMeta = src.ListMeta }, + func(list *flowcontrolv1beta2.FlowSchemaList) []*flowcontrolv1beta2.FlowSchema { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *flowcontrolv1beta2.FlowSchemaList, items []*flowcontrolv1beta2.FlowSchema) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &flowcontrolv1beta2.FlowSchemaList{ListMeta: obj.(*flowcontrolv1beta2.FlowSchemaList).ListMeta} - for _, item := range obj.(*flowcontrolv1beta2.FlowSchemaList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested FlowSchemas across all clusters. -func (c *flowSchemasClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(flowSchemasResource, logicalcluster.Wildcard, opts)) +func (c *flowSchemaClusterClient) Cluster(cluster logicalcluster.Path) typedflowcontrolv1beta2.FlowSchemaInterface { + return newFakeFlowSchemaClient(c.Fake, cluster) } -type flowSchemasClient struct { - *kcptesting.Fake +// flowSchemaScopedClient implements FlowSchemaInterface +type flowSchemaScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*flowcontrolv1beta2.FlowSchema, *flowcontrolv1beta2.FlowSchemaList, *v1beta2.FlowSchemaApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *flowSchemasClient) Create(ctx context.Context, flowSchema *flowcontrolv1beta2.FlowSchema, opts metav1.CreateOptions) (*flowcontrolv1beta2.FlowSchema, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(flowSchemasResource, c.ClusterPath, flowSchema), &flowcontrolv1beta2.FlowSchema{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta2.FlowSchema), err -} - -func (c *flowSchemasClient) Update(ctx context.Context, flowSchema *flowcontrolv1beta2.FlowSchema, opts metav1.UpdateOptions) (*flowcontrolv1beta2.FlowSchema, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(flowSchemasResource, c.ClusterPath, flowSchema), &flowcontrolv1beta2.FlowSchema{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta2.FlowSchema), err -} - -func (c *flowSchemasClient) UpdateStatus(ctx context.Context, flowSchema *flowcontrolv1beta2.FlowSchema, opts metav1.UpdateOptions) (*flowcontrolv1beta2.FlowSchema, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(flowSchemasResource, c.ClusterPath, "status", flowSchema), &flowcontrolv1beta2.FlowSchema{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta2.FlowSchema), err -} - -func (c *flowSchemasClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(flowSchemasResource, c.ClusterPath, name, opts), &flowcontrolv1beta2.FlowSchema{}) - return err -} - -func (c *flowSchemasClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(flowSchemasResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &flowcontrolv1beta2.FlowSchemaList{}) - return err -} - -func (c *flowSchemasClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*flowcontrolv1beta2.FlowSchema, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(flowSchemasResource, c.ClusterPath, name), &flowcontrolv1beta2.FlowSchema{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta2.FlowSchema), err -} - -// List takes label and field selectors, and returns the list of FlowSchemas that match those selectors. -func (c *flowSchemasClient) List(ctx context.Context, opts metav1.ListOptions) (*flowcontrolv1beta2.FlowSchemaList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(flowSchemasResource, flowSchemasKind, c.ClusterPath, opts), &flowcontrolv1beta2.FlowSchemaList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &flowcontrolv1beta2.FlowSchemaList{ListMeta: obj.(*flowcontrolv1beta2.FlowSchemaList).ListMeta} - for _, item := range obj.(*flowcontrolv1beta2.FlowSchemaList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *flowSchemasClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(flowSchemasResource, c.ClusterPath, opts)) -} - -func (c *flowSchemasClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*flowcontrolv1beta2.FlowSchema, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(flowSchemasResource, c.ClusterPath, name, pt, data, subresources...), &flowcontrolv1beta2.FlowSchema{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta2.FlowSchema), err -} - -func (c *flowSchemasClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsflowcontrolv1beta2.FlowSchemaApplyConfiguration, opts metav1.ApplyOptions) (*flowcontrolv1beta2.FlowSchema, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(flowSchemasResource, c.ClusterPath, *name, types.ApplyPatchType, data), &flowcontrolv1beta2.FlowSchema{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta2.FlowSchema), err -} - -func (c *flowSchemasClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsflowcontrolv1beta2.FlowSchemaApplyConfiguration, opts metav1.ApplyOptions) (*flowcontrolv1beta2.FlowSchema, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(flowSchemasResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &flowcontrolv1beta2.FlowSchema{}) - if obj == nil { - return nil, err +func newFakeFlowSchemaClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedflowcontrolv1beta2.FlowSchemaInterface { + return &flowSchemaScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*flowcontrolv1beta2.FlowSchema, *flowcontrolv1beta2.FlowSchemaList, *v1beta2.FlowSchemaApplyConfiguration]( + fake, + clusterPath, + "", + flowcontrolv1beta2.SchemeGroupVersion.WithResource("flowschemas"), + flowcontrolv1beta2.SchemeGroupVersion.WithKind("FlowSchema"), + func() *flowcontrolv1beta2.FlowSchema { return &flowcontrolv1beta2.FlowSchema{} }, + func() *flowcontrolv1beta2.FlowSchemaList { return &flowcontrolv1beta2.FlowSchemaList{} }, + func(dst, src *flowcontrolv1beta2.FlowSchemaList) { dst.ListMeta = src.ListMeta }, + func(list *flowcontrolv1beta2.FlowSchemaList) []*flowcontrolv1beta2.FlowSchema { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *flowcontrolv1beta2.FlowSchemaList, items []*flowcontrolv1beta2.FlowSchema) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*flowcontrolv1beta2.FlowSchema), err } diff --git a/kubernetes/typed/flowcontrol/v1beta2/fake/prioritylevelconfiguration.go b/kubernetes/typed/flowcontrol/v1beta2/fake/prioritylevelconfiguration.go index f472b4435..c61a503f4 100644 --- a/kubernetes/typed/flowcontrol/v1beta2/fake/prioritylevelconfiguration.go +++ b/kubernetes/typed/flowcontrol/v1beta2/fake/prioritylevelconfiguration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,86 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" flowcontrolv1beta2 "k8s.io/api/flowcontrol/v1beta2" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsflowcontrolv1beta2 "k8s.io/client-go/applyconfigurations/flowcontrol/v1beta2" - flowcontrolv1beta2client "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2" - "k8s.io/client-go/testing" + v1beta2 "k8s.io/client-go/applyconfigurations/flowcontrol/v1beta2" + typedflowcontrolv1beta2 "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2" + typedkcpflowcontrolv1beta2 "github.com/kcp-dev/client-go/kubernetes/typed/flowcontrol/v1beta2" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var priorityLevelConfigurationsResource = schema.GroupVersionResource{Group: "flowcontrol.apiserver.k8s.io", Version: "v1beta2", Resource: "prioritylevelconfigurations"} -var priorityLevelConfigurationsKind = schema.GroupVersionKind{Group: "flowcontrol.apiserver.k8s.io", Version: "v1beta2", Kind: "PriorityLevelConfiguration"} - -type priorityLevelConfigurationsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *priorityLevelConfigurationsClusterClient) Cluster(clusterPath logicalcluster.Path) flowcontrolv1beta2client.PriorityLevelConfigurationInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &priorityLevelConfigurationsClient{Fake: c.Fake, ClusterPath: clusterPath} -} - -// List takes label and field selectors, and returns the list of PriorityLevelConfigurations that match those selectors across all clusters. -func (c *priorityLevelConfigurationsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*flowcontrolv1beta2.PriorityLevelConfigurationList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(priorityLevelConfigurationsResource, priorityLevelConfigurationsKind, logicalcluster.Wildcard, opts), &flowcontrolv1beta2.PriorityLevelConfigurationList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &flowcontrolv1beta2.PriorityLevelConfigurationList{ListMeta: obj.(*flowcontrolv1beta2.PriorityLevelConfigurationList).ListMeta} - for _, item := range obj.(*flowcontrolv1beta2.PriorityLevelConfigurationList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested PriorityLevelConfigurations across all clusters. -func (c *priorityLevelConfigurationsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(priorityLevelConfigurationsResource, logicalcluster.Wildcard, opts)) -} - -type priorityLevelConfigurationsClient struct { - *kcptesting.Fake +// priorityLevelConfigurationClusterClient implements PriorityLevelConfigurationClusterInterface +type priorityLevelConfigurationClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*flowcontrolv1beta2.PriorityLevelConfiguration, *flowcontrolv1beta2.PriorityLevelConfigurationList] + Fake *kcptesting.Fake +} + +func newFakePriorityLevelConfigurationClusterClient(fake *FlowcontrolV1beta2ClusterClient) typedkcpflowcontrolv1beta2.PriorityLevelConfigurationClusterInterface { + return &priorityLevelConfigurationClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*flowcontrolv1beta2.PriorityLevelConfiguration, *flowcontrolv1beta2.PriorityLevelConfigurationList]( + fake.Fake, + flowcontrolv1beta2.SchemeGroupVersion.WithResource("prioritylevelconfigurations"), + flowcontrolv1beta2.SchemeGroupVersion.WithKind("PriorityLevelConfiguration"), + func() *flowcontrolv1beta2.PriorityLevelConfiguration { + return &flowcontrolv1beta2.PriorityLevelConfiguration{} + }, + func() *flowcontrolv1beta2.PriorityLevelConfigurationList { + return &flowcontrolv1beta2.PriorityLevelConfigurationList{} + }, + func(dst, src *flowcontrolv1beta2.PriorityLevelConfigurationList) { dst.ListMeta = src.ListMeta }, + func(list *flowcontrolv1beta2.PriorityLevelConfigurationList) []*flowcontrolv1beta2.PriorityLevelConfiguration { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *flowcontrolv1beta2.PriorityLevelConfigurationList, items []*flowcontrolv1beta2.PriorityLevelConfiguration) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, + } +} + +func (c *priorityLevelConfigurationClusterClient) Cluster(cluster logicalcluster.Path) typedflowcontrolv1beta2.PriorityLevelConfigurationInterface { + return newFakePriorityLevelConfigurationClient(c.Fake, cluster) +} + +// priorityLevelConfigurationScopedClient implements PriorityLevelConfigurationInterface +type priorityLevelConfigurationScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*flowcontrolv1beta2.PriorityLevelConfiguration, *flowcontrolv1beta2.PriorityLevelConfigurationList, *v1beta2.PriorityLevelConfigurationApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *priorityLevelConfigurationsClient) Create(ctx context.Context, priorityLevelConfiguration *flowcontrolv1beta2.PriorityLevelConfiguration, opts metav1.CreateOptions) (*flowcontrolv1beta2.PriorityLevelConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(priorityLevelConfigurationsResource, c.ClusterPath, priorityLevelConfiguration), &flowcontrolv1beta2.PriorityLevelConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta2.PriorityLevelConfiguration), err -} - -func (c *priorityLevelConfigurationsClient) Update(ctx context.Context, priorityLevelConfiguration *flowcontrolv1beta2.PriorityLevelConfiguration, opts metav1.UpdateOptions) (*flowcontrolv1beta2.PriorityLevelConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(priorityLevelConfigurationsResource, c.ClusterPath, priorityLevelConfiguration), &flowcontrolv1beta2.PriorityLevelConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta2.PriorityLevelConfiguration), err -} - -func (c *priorityLevelConfigurationsClient) UpdateStatus(ctx context.Context, priorityLevelConfiguration *flowcontrolv1beta2.PriorityLevelConfiguration, opts metav1.UpdateOptions) (*flowcontrolv1beta2.PriorityLevelConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(priorityLevelConfigurationsResource, c.ClusterPath, "status", priorityLevelConfiguration), &flowcontrolv1beta2.PriorityLevelConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta2.PriorityLevelConfiguration), err -} - -func (c *priorityLevelConfigurationsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(priorityLevelConfigurationsResource, c.ClusterPath, name, opts), &flowcontrolv1beta2.PriorityLevelConfiguration{}) - return err -} - -func (c *priorityLevelConfigurationsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(priorityLevelConfigurationsResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &flowcontrolv1beta2.PriorityLevelConfigurationList{}) - return err -} - -func (c *priorityLevelConfigurationsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*flowcontrolv1beta2.PriorityLevelConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(priorityLevelConfigurationsResource, c.ClusterPath, name), &flowcontrolv1beta2.PriorityLevelConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta2.PriorityLevelConfiguration), err -} - -// List takes label and field selectors, and returns the list of PriorityLevelConfigurations that match those selectors. -func (c *priorityLevelConfigurationsClient) List(ctx context.Context, opts metav1.ListOptions) (*flowcontrolv1beta2.PriorityLevelConfigurationList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(priorityLevelConfigurationsResource, priorityLevelConfigurationsKind, c.ClusterPath, opts), &flowcontrolv1beta2.PriorityLevelConfigurationList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &flowcontrolv1beta2.PriorityLevelConfigurationList{ListMeta: obj.(*flowcontrolv1beta2.PriorityLevelConfigurationList).ListMeta} - for _, item := range obj.(*flowcontrolv1beta2.PriorityLevelConfigurationList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *priorityLevelConfigurationsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(priorityLevelConfigurationsResource, c.ClusterPath, opts)) -} - -func (c *priorityLevelConfigurationsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*flowcontrolv1beta2.PriorityLevelConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(priorityLevelConfigurationsResource, c.ClusterPath, name, pt, data, subresources...), &flowcontrolv1beta2.PriorityLevelConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta2.PriorityLevelConfiguration), err -} - -func (c *priorityLevelConfigurationsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsflowcontrolv1beta2.PriorityLevelConfigurationApplyConfiguration, opts metav1.ApplyOptions) (*flowcontrolv1beta2.PriorityLevelConfiguration, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(priorityLevelConfigurationsResource, c.ClusterPath, *name, types.ApplyPatchType, data), &flowcontrolv1beta2.PriorityLevelConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta2.PriorityLevelConfiguration), err -} - -func (c *priorityLevelConfigurationsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsflowcontrolv1beta2.PriorityLevelConfigurationApplyConfiguration, opts metav1.ApplyOptions) (*flowcontrolv1beta2.PriorityLevelConfiguration, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(priorityLevelConfigurationsResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &flowcontrolv1beta2.PriorityLevelConfiguration{}) - if obj == nil { - return nil, err +func newFakePriorityLevelConfigurationClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedflowcontrolv1beta2.PriorityLevelConfigurationInterface { + return &priorityLevelConfigurationScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*flowcontrolv1beta2.PriorityLevelConfiguration, *flowcontrolv1beta2.PriorityLevelConfigurationList, *v1beta2.PriorityLevelConfigurationApplyConfiguration]( + fake, + clusterPath, + "", + flowcontrolv1beta2.SchemeGroupVersion.WithResource("prioritylevelconfigurations"), + flowcontrolv1beta2.SchemeGroupVersion.WithKind("PriorityLevelConfiguration"), + func() *flowcontrolv1beta2.PriorityLevelConfiguration { + return &flowcontrolv1beta2.PriorityLevelConfiguration{} + }, + func() *flowcontrolv1beta2.PriorityLevelConfigurationList { + return &flowcontrolv1beta2.PriorityLevelConfigurationList{} + }, + func(dst, src *flowcontrolv1beta2.PriorityLevelConfigurationList) { dst.ListMeta = src.ListMeta }, + func(list *flowcontrolv1beta2.PriorityLevelConfigurationList) []*flowcontrolv1beta2.PriorityLevelConfiguration { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *flowcontrolv1beta2.PriorityLevelConfigurationList, items []*flowcontrolv1beta2.PriorityLevelConfiguration) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*flowcontrolv1beta2.PriorityLevelConfiguration), err } diff --git a/kubernetes/typed/flowcontrol/v1beta2/flowcontrol_client.go b/kubernetes/typed/flowcontrol/v1beta2/flowcontrol_client.go index 75f10602d..36f380479 100644 --- a/kubernetes/typed/flowcontrol/v1beta2/flowcontrol_client.go +++ b/kubernetes/typed/flowcontrol/v1beta2/flowcontrol_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta2 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apiflowcontrolv1beta2 "k8s.io/api/flowcontrol/v1beta2" flowcontrolv1beta2 "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type FlowcontrolV1beta2ClusterInterface interface { @@ -38,6 +41,7 @@ type FlowcontrolV1beta2ClusterScoper interface { Cluster(logicalcluster.Path) flowcontrolv1beta2.FlowcontrolV1beta2Interface } +// FlowcontrolV1beta2ClusterClient is used to interact with features provided by the flowcontrol.apiserver.k8s.io group. type FlowcontrolV1beta2ClusterClient struct { clientCache kcpclient.Cache[*flowcontrolv1beta2.FlowcontrolV1beta2Client] } @@ -61,11 +65,13 @@ func (c *FlowcontrolV1beta2ClusterClient) PriorityLevelConfigurations() Priority // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*FlowcontrolV1beta2ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new FlowcontrolV1beta2ClusterClient for the given config and http client. @@ -77,6 +83,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*FlowcontrolV1beta2C if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &FlowcontrolV1beta2ClusterClient{clientCache: cache}, nil } @@ -89,3 +96,14 @@ func NewForConfigOrDie(c *rest.Config) *FlowcontrolV1beta2ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apiflowcontrolv1beta2.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/flowcontrol/v1beta2/flowschema.go b/kubernetes/typed/flowcontrol/v1beta2/flowschema.go index 890e31e14..e1cb050fb 100644 --- a/kubernetes/typed/flowcontrol/v1beta2/flowschema.go +++ b/kubernetes/typed/flowcontrol/v1beta2/flowschema.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta2 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - flowcontrolv1beta2 "k8s.io/api/flowcontrol/v1beta2" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - flowcontrolv1beta2client "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2" + apiflowcontrolv1beta2 "k8s.io/api/flowcontrol/v1beta2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + flowcontrolv1beta2 "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2" ) // FlowSchemasClusterGetter has a method to return a FlowSchemaClusterInterface. @@ -37,19 +37,20 @@ type FlowSchemasClusterGetter interface { } // FlowSchemaClusterInterface can operate on FlowSchemas across all clusters, -// or scope down to one cluster and return a flowcontrolv1beta2client.FlowSchemaInterface. +// or scope down to one cluster and return a flowcontrolv1beta2.FlowSchemaInterface. type FlowSchemaClusterInterface interface { - Cluster(logicalcluster.Path) flowcontrolv1beta2client.FlowSchemaInterface - List(ctx context.Context, opts metav1.ListOptions) (*flowcontrolv1beta2.FlowSchemaList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) flowcontrolv1beta2.FlowSchemaInterface + List(ctx context.Context, opts v1.ListOptions) (*apiflowcontrolv1beta2.FlowSchemaList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + FlowSchemaClusterExpansion } type flowSchemasClusterInterface struct { - clientCache kcpclient.Cache[*flowcontrolv1beta2client.FlowcontrolV1beta2Client] + clientCache kcpclient.Cache[*flowcontrolv1beta2.FlowcontrolV1beta2Client] } // Cluster scopes the client down to a particular cluster. -func (c *flowSchemasClusterInterface) Cluster(clusterPath logicalcluster.Path) flowcontrolv1beta2client.FlowSchemaInterface { +func (c *flowSchemasClusterInterface) Cluster(clusterPath logicalcluster.Path) flowcontrolv1beta2.FlowSchemaInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *flowSchemasClusterInterface) Cluster(clusterPath logicalcluster.Path) f } // List returns the entire collection of all FlowSchemas across all clusters. -func (c *flowSchemasClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*flowcontrolv1beta2.FlowSchemaList, error) { +func (c *flowSchemasClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apiflowcontrolv1beta2.FlowSchemaList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).FlowSchemas().List(ctx, opts) } // Watch begins to watch all FlowSchemas across all clusters. -func (c *flowSchemasClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *flowSchemasClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).FlowSchemas().Watch(ctx, opts) } diff --git a/kubernetes/typed/flowcontrol/v1beta2/generated_expansion.go b/kubernetes/typed/flowcontrol/v1beta2/generated_expansion.go new file mode 100644 index 000000000..4988b1583 --- /dev/null +++ b/kubernetes/typed/flowcontrol/v1beta2/generated_expansion.go @@ -0,0 +1,23 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1beta2 + +type FlowSchemaClusterExpansion interface{} + +type PriorityLevelConfigurationClusterExpansion interface{} diff --git a/kubernetes/typed/flowcontrol/v1beta2/prioritylevelconfiguration.go b/kubernetes/typed/flowcontrol/v1beta2/prioritylevelconfiguration.go index cb141abd7..a04691b8c 100644 --- a/kubernetes/typed/flowcontrol/v1beta2/prioritylevelconfiguration.go +++ b/kubernetes/typed/flowcontrol/v1beta2/prioritylevelconfiguration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta2 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - flowcontrolv1beta2 "k8s.io/api/flowcontrol/v1beta2" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - flowcontrolv1beta2client "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2" + apiflowcontrolv1beta2 "k8s.io/api/flowcontrol/v1beta2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + flowcontrolv1beta2 "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2" ) // PriorityLevelConfigurationsClusterGetter has a method to return a PriorityLevelConfigurationClusterInterface. @@ -37,19 +37,20 @@ type PriorityLevelConfigurationsClusterGetter interface { } // PriorityLevelConfigurationClusterInterface can operate on PriorityLevelConfigurations across all clusters, -// or scope down to one cluster and return a flowcontrolv1beta2client.PriorityLevelConfigurationInterface. +// or scope down to one cluster and return a flowcontrolv1beta2.PriorityLevelConfigurationInterface. type PriorityLevelConfigurationClusterInterface interface { - Cluster(logicalcluster.Path) flowcontrolv1beta2client.PriorityLevelConfigurationInterface - List(ctx context.Context, opts metav1.ListOptions) (*flowcontrolv1beta2.PriorityLevelConfigurationList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) flowcontrolv1beta2.PriorityLevelConfigurationInterface + List(ctx context.Context, opts v1.ListOptions) (*apiflowcontrolv1beta2.PriorityLevelConfigurationList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + PriorityLevelConfigurationClusterExpansion } type priorityLevelConfigurationsClusterInterface struct { - clientCache kcpclient.Cache[*flowcontrolv1beta2client.FlowcontrolV1beta2Client] + clientCache kcpclient.Cache[*flowcontrolv1beta2.FlowcontrolV1beta2Client] } // Cluster scopes the client down to a particular cluster. -func (c *priorityLevelConfigurationsClusterInterface) Cluster(clusterPath logicalcluster.Path) flowcontrolv1beta2client.PriorityLevelConfigurationInterface { +func (c *priorityLevelConfigurationsClusterInterface) Cluster(clusterPath logicalcluster.Path) flowcontrolv1beta2.PriorityLevelConfigurationInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *priorityLevelConfigurationsClusterInterface) Cluster(clusterPath logica } // List returns the entire collection of all PriorityLevelConfigurations across all clusters. -func (c *priorityLevelConfigurationsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*flowcontrolv1beta2.PriorityLevelConfigurationList, error) { +func (c *priorityLevelConfigurationsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apiflowcontrolv1beta2.PriorityLevelConfigurationList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).PriorityLevelConfigurations().List(ctx, opts) } // Watch begins to watch all PriorityLevelConfigurations across all clusters. -func (c *priorityLevelConfigurationsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *priorityLevelConfigurationsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).PriorityLevelConfigurations().Watch(ctx, opts) } diff --git a/kubernetes/typed/flowcontrol/v1beta3/doc.go b/kubernetes/typed/flowcontrol/v1beta3/doc.go new file mode 100644 index 000000000..032758d66 --- /dev/null +++ b/kubernetes/typed/flowcontrol/v1beta3/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1beta3 diff --git a/kubernetes/typed/flowcontrol/v1beta3/fake/doc.go b/kubernetes/typed/flowcontrol/v1beta3/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/flowcontrol/v1beta3/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/flowcontrol/v1beta3/fake/flowcontrol_client.go b/kubernetes/typed/flowcontrol/v1beta3/fake/flowcontrol_client.go index b46c26582..61ac03fce 100644 --- a/kubernetes/typed/flowcontrol/v1beta3/fake/flowcontrol_client.go +++ b/kubernetes/typed/flowcontrol/v1beta3/fake/flowcontrol_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" flowcontrolv1beta3 "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpflowcontrolv1beta3 "github.com/kcp-dev/client-go/kubernetes/typed/flowcontrol/v1beta3" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -42,29 +42,29 @@ func (c *FlowcontrolV1beta3ClusterClient) Cluster(clusterPath logicalcluster.Pat } func (c *FlowcontrolV1beta3ClusterClient) FlowSchemas() kcpflowcontrolv1beta3.FlowSchemaClusterInterface { - return &flowSchemasClusterClient{Fake: c.Fake} + return newFakeFlowSchemaClusterClient(c) } func (c *FlowcontrolV1beta3ClusterClient) PriorityLevelConfigurations() kcpflowcontrolv1beta3.PriorityLevelConfigurationClusterInterface { - return &priorityLevelConfigurationsClusterClient{Fake: c.Fake} + return newFakePriorityLevelConfigurationClusterClient(c) } -var _ flowcontrolv1beta3.FlowcontrolV1beta3Interface = (*FlowcontrolV1beta3Client)(nil) - type FlowcontrolV1beta3Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *FlowcontrolV1beta3Client) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret -} - func (c *FlowcontrolV1beta3Client) FlowSchemas() flowcontrolv1beta3.FlowSchemaInterface { - return &flowSchemasClient{Fake: c.Fake, ClusterPath: c.ClusterPath} + return newFakeFlowSchemaClient(c.Fake, c.ClusterPath) } func (c *FlowcontrolV1beta3Client) PriorityLevelConfigurations() flowcontrolv1beta3.PriorityLevelConfigurationInterface { - return &priorityLevelConfigurationsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} + return newFakePriorityLevelConfigurationClient(c.Fake, c.ClusterPath) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FlowcontrolV1beta3Client) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret } diff --git a/kubernetes/typed/flowcontrol/v1beta3/fake/flowschema.go b/kubernetes/typed/flowcontrol/v1beta3/fake/flowschema.go index 3ca3bdcb6..4451111cc 100644 --- a/kubernetes/typed/flowcontrol/v1beta3/fake/flowschema.go +++ b/kubernetes/typed/flowcontrol/v1beta3/fake/flowschema.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsflowcontrolv1beta3 "k8s.io/client-go/applyconfigurations/flowcontrol/v1beta3" - flowcontrolv1beta3client "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3" - "k8s.io/client-go/testing" + v1beta3 "k8s.io/client-go/applyconfigurations/flowcontrol/v1beta3" + typedflowcontrolv1beta3 "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3" + typedkcpflowcontrolv1beta3 "github.com/kcp-dev/client-go/kubernetes/typed/flowcontrol/v1beta3" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var flowSchemasResource = schema.GroupVersionResource{Group: "flowcontrol.apiserver.k8s.io", Version: "v1beta3", Resource: "flowschemas"} -var flowSchemasKind = schema.GroupVersionKind{Group: "flowcontrol.apiserver.k8s.io", Version: "v1beta3", Kind: "FlowSchema"} - -type flowSchemasClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *flowSchemasClusterClient) Cluster(clusterPath logicalcluster.Path) flowcontrolv1beta3client.FlowSchemaInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &flowSchemasClient{Fake: c.Fake, ClusterPath: clusterPath} +// flowSchemaClusterClient implements FlowSchemaClusterInterface +type flowSchemaClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*flowcontrolv1beta3.FlowSchema, *flowcontrolv1beta3.FlowSchemaList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of FlowSchemas that match those selectors across all clusters. -func (c *flowSchemasClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*flowcontrolv1beta3.FlowSchemaList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(flowSchemasResource, flowSchemasKind, logicalcluster.Wildcard, opts), &flowcontrolv1beta3.FlowSchemaList{}) - if obj == nil { - return nil, err +func newFakeFlowSchemaClusterClient(fake *FlowcontrolV1beta3ClusterClient) typedkcpflowcontrolv1beta3.FlowSchemaClusterInterface { + return &flowSchemaClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*flowcontrolv1beta3.FlowSchema, *flowcontrolv1beta3.FlowSchemaList]( + fake.Fake, + flowcontrolv1beta3.SchemeGroupVersion.WithResource("flowschemas"), + flowcontrolv1beta3.SchemeGroupVersion.WithKind("FlowSchema"), + func() *flowcontrolv1beta3.FlowSchema { return &flowcontrolv1beta3.FlowSchema{} }, + func() *flowcontrolv1beta3.FlowSchemaList { return &flowcontrolv1beta3.FlowSchemaList{} }, + func(dst, src *flowcontrolv1beta3.FlowSchemaList) { dst.ListMeta = src.ListMeta }, + func(list *flowcontrolv1beta3.FlowSchemaList) []*flowcontrolv1beta3.FlowSchema { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *flowcontrolv1beta3.FlowSchemaList, items []*flowcontrolv1beta3.FlowSchema) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &flowcontrolv1beta3.FlowSchemaList{ListMeta: obj.(*flowcontrolv1beta3.FlowSchemaList).ListMeta} - for _, item := range obj.(*flowcontrolv1beta3.FlowSchemaList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested FlowSchemas across all clusters. -func (c *flowSchemasClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(flowSchemasResource, logicalcluster.Wildcard, opts)) +func (c *flowSchemaClusterClient) Cluster(cluster logicalcluster.Path) typedflowcontrolv1beta3.FlowSchemaInterface { + return newFakeFlowSchemaClient(c.Fake, cluster) } -type flowSchemasClient struct { - *kcptesting.Fake +// flowSchemaScopedClient implements FlowSchemaInterface +type flowSchemaScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*flowcontrolv1beta3.FlowSchema, *flowcontrolv1beta3.FlowSchemaList, *v1beta3.FlowSchemaApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *flowSchemasClient) Create(ctx context.Context, flowSchema *flowcontrolv1beta3.FlowSchema, opts metav1.CreateOptions) (*flowcontrolv1beta3.FlowSchema, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(flowSchemasResource, c.ClusterPath, flowSchema), &flowcontrolv1beta3.FlowSchema{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta3.FlowSchema), err -} - -func (c *flowSchemasClient) Update(ctx context.Context, flowSchema *flowcontrolv1beta3.FlowSchema, opts metav1.UpdateOptions) (*flowcontrolv1beta3.FlowSchema, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(flowSchemasResource, c.ClusterPath, flowSchema), &flowcontrolv1beta3.FlowSchema{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta3.FlowSchema), err -} - -func (c *flowSchemasClient) UpdateStatus(ctx context.Context, flowSchema *flowcontrolv1beta3.FlowSchema, opts metav1.UpdateOptions) (*flowcontrolv1beta3.FlowSchema, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(flowSchemasResource, c.ClusterPath, "status", flowSchema), &flowcontrolv1beta3.FlowSchema{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta3.FlowSchema), err -} - -func (c *flowSchemasClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(flowSchemasResource, c.ClusterPath, name, opts), &flowcontrolv1beta3.FlowSchema{}) - return err -} - -func (c *flowSchemasClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(flowSchemasResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &flowcontrolv1beta3.FlowSchemaList{}) - return err -} - -func (c *flowSchemasClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*flowcontrolv1beta3.FlowSchema, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(flowSchemasResource, c.ClusterPath, name), &flowcontrolv1beta3.FlowSchema{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta3.FlowSchema), err -} - -// List takes label and field selectors, and returns the list of FlowSchemas that match those selectors. -func (c *flowSchemasClient) List(ctx context.Context, opts metav1.ListOptions) (*flowcontrolv1beta3.FlowSchemaList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(flowSchemasResource, flowSchemasKind, c.ClusterPath, opts), &flowcontrolv1beta3.FlowSchemaList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &flowcontrolv1beta3.FlowSchemaList{ListMeta: obj.(*flowcontrolv1beta3.FlowSchemaList).ListMeta} - for _, item := range obj.(*flowcontrolv1beta3.FlowSchemaList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *flowSchemasClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(flowSchemasResource, c.ClusterPath, opts)) -} - -func (c *flowSchemasClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*flowcontrolv1beta3.FlowSchema, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(flowSchemasResource, c.ClusterPath, name, pt, data, subresources...), &flowcontrolv1beta3.FlowSchema{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta3.FlowSchema), err -} - -func (c *flowSchemasClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsflowcontrolv1beta3.FlowSchemaApplyConfiguration, opts metav1.ApplyOptions) (*flowcontrolv1beta3.FlowSchema, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(flowSchemasResource, c.ClusterPath, *name, types.ApplyPatchType, data), &flowcontrolv1beta3.FlowSchema{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta3.FlowSchema), err -} - -func (c *flowSchemasClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsflowcontrolv1beta3.FlowSchemaApplyConfiguration, opts metav1.ApplyOptions) (*flowcontrolv1beta3.FlowSchema, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(flowSchemasResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &flowcontrolv1beta3.FlowSchema{}) - if obj == nil { - return nil, err +func newFakeFlowSchemaClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedflowcontrolv1beta3.FlowSchemaInterface { + return &flowSchemaScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*flowcontrolv1beta3.FlowSchema, *flowcontrolv1beta3.FlowSchemaList, *v1beta3.FlowSchemaApplyConfiguration]( + fake, + clusterPath, + "", + flowcontrolv1beta3.SchemeGroupVersion.WithResource("flowschemas"), + flowcontrolv1beta3.SchemeGroupVersion.WithKind("FlowSchema"), + func() *flowcontrolv1beta3.FlowSchema { return &flowcontrolv1beta3.FlowSchema{} }, + func() *flowcontrolv1beta3.FlowSchemaList { return &flowcontrolv1beta3.FlowSchemaList{} }, + func(dst, src *flowcontrolv1beta3.FlowSchemaList) { dst.ListMeta = src.ListMeta }, + func(list *flowcontrolv1beta3.FlowSchemaList) []*flowcontrolv1beta3.FlowSchema { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *flowcontrolv1beta3.FlowSchemaList, items []*flowcontrolv1beta3.FlowSchema) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*flowcontrolv1beta3.FlowSchema), err } diff --git a/kubernetes/typed/flowcontrol/v1beta3/fake/prioritylevelconfiguration.go b/kubernetes/typed/flowcontrol/v1beta3/fake/prioritylevelconfiguration.go index d3b484c3b..1266a172c 100644 --- a/kubernetes/typed/flowcontrol/v1beta3/fake/prioritylevelconfiguration.go +++ b/kubernetes/typed/flowcontrol/v1beta3/fake/prioritylevelconfiguration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,86 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsflowcontrolv1beta3 "k8s.io/client-go/applyconfigurations/flowcontrol/v1beta3" - flowcontrolv1beta3client "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3" - "k8s.io/client-go/testing" + v1beta3 "k8s.io/client-go/applyconfigurations/flowcontrol/v1beta3" + typedflowcontrolv1beta3 "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3" + typedkcpflowcontrolv1beta3 "github.com/kcp-dev/client-go/kubernetes/typed/flowcontrol/v1beta3" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var priorityLevelConfigurationsResource = schema.GroupVersionResource{Group: "flowcontrol.apiserver.k8s.io", Version: "v1beta3", Resource: "prioritylevelconfigurations"} -var priorityLevelConfigurationsKind = schema.GroupVersionKind{Group: "flowcontrol.apiserver.k8s.io", Version: "v1beta3", Kind: "PriorityLevelConfiguration"} - -type priorityLevelConfigurationsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *priorityLevelConfigurationsClusterClient) Cluster(clusterPath logicalcluster.Path) flowcontrolv1beta3client.PriorityLevelConfigurationInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &priorityLevelConfigurationsClient{Fake: c.Fake, ClusterPath: clusterPath} -} - -// List takes label and field selectors, and returns the list of PriorityLevelConfigurations that match those selectors across all clusters. -func (c *priorityLevelConfigurationsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*flowcontrolv1beta3.PriorityLevelConfigurationList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(priorityLevelConfigurationsResource, priorityLevelConfigurationsKind, logicalcluster.Wildcard, opts), &flowcontrolv1beta3.PriorityLevelConfigurationList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &flowcontrolv1beta3.PriorityLevelConfigurationList{ListMeta: obj.(*flowcontrolv1beta3.PriorityLevelConfigurationList).ListMeta} - for _, item := range obj.(*flowcontrolv1beta3.PriorityLevelConfigurationList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested PriorityLevelConfigurations across all clusters. -func (c *priorityLevelConfigurationsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(priorityLevelConfigurationsResource, logicalcluster.Wildcard, opts)) -} - -type priorityLevelConfigurationsClient struct { - *kcptesting.Fake +// priorityLevelConfigurationClusterClient implements PriorityLevelConfigurationClusterInterface +type priorityLevelConfigurationClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*flowcontrolv1beta3.PriorityLevelConfiguration, *flowcontrolv1beta3.PriorityLevelConfigurationList] + Fake *kcptesting.Fake +} + +func newFakePriorityLevelConfigurationClusterClient(fake *FlowcontrolV1beta3ClusterClient) typedkcpflowcontrolv1beta3.PriorityLevelConfigurationClusterInterface { + return &priorityLevelConfigurationClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*flowcontrolv1beta3.PriorityLevelConfiguration, *flowcontrolv1beta3.PriorityLevelConfigurationList]( + fake.Fake, + flowcontrolv1beta3.SchemeGroupVersion.WithResource("prioritylevelconfigurations"), + flowcontrolv1beta3.SchemeGroupVersion.WithKind("PriorityLevelConfiguration"), + func() *flowcontrolv1beta3.PriorityLevelConfiguration { + return &flowcontrolv1beta3.PriorityLevelConfiguration{} + }, + func() *flowcontrolv1beta3.PriorityLevelConfigurationList { + return &flowcontrolv1beta3.PriorityLevelConfigurationList{} + }, + func(dst, src *flowcontrolv1beta3.PriorityLevelConfigurationList) { dst.ListMeta = src.ListMeta }, + func(list *flowcontrolv1beta3.PriorityLevelConfigurationList) []*flowcontrolv1beta3.PriorityLevelConfiguration { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *flowcontrolv1beta3.PriorityLevelConfigurationList, items []*flowcontrolv1beta3.PriorityLevelConfiguration) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, + } +} + +func (c *priorityLevelConfigurationClusterClient) Cluster(cluster logicalcluster.Path) typedflowcontrolv1beta3.PriorityLevelConfigurationInterface { + return newFakePriorityLevelConfigurationClient(c.Fake, cluster) +} + +// priorityLevelConfigurationScopedClient implements PriorityLevelConfigurationInterface +type priorityLevelConfigurationScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*flowcontrolv1beta3.PriorityLevelConfiguration, *flowcontrolv1beta3.PriorityLevelConfigurationList, *v1beta3.PriorityLevelConfigurationApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *priorityLevelConfigurationsClient) Create(ctx context.Context, priorityLevelConfiguration *flowcontrolv1beta3.PriorityLevelConfiguration, opts metav1.CreateOptions) (*flowcontrolv1beta3.PriorityLevelConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(priorityLevelConfigurationsResource, c.ClusterPath, priorityLevelConfiguration), &flowcontrolv1beta3.PriorityLevelConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta3.PriorityLevelConfiguration), err -} - -func (c *priorityLevelConfigurationsClient) Update(ctx context.Context, priorityLevelConfiguration *flowcontrolv1beta3.PriorityLevelConfiguration, opts metav1.UpdateOptions) (*flowcontrolv1beta3.PriorityLevelConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(priorityLevelConfigurationsResource, c.ClusterPath, priorityLevelConfiguration), &flowcontrolv1beta3.PriorityLevelConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta3.PriorityLevelConfiguration), err -} - -func (c *priorityLevelConfigurationsClient) UpdateStatus(ctx context.Context, priorityLevelConfiguration *flowcontrolv1beta3.PriorityLevelConfiguration, opts metav1.UpdateOptions) (*flowcontrolv1beta3.PriorityLevelConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(priorityLevelConfigurationsResource, c.ClusterPath, "status", priorityLevelConfiguration), &flowcontrolv1beta3.PriorityLevelConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta3.PriorityLevelConfiguration), err -} - -func (c *priorityLevelConfigurationsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(priorityLevelConfigurationsResource, c.ClusterPath, name, opts), &flowcontrolv1beta3.PriorityLevelConfiguration{}) - return err -} - -func (c *priorityLevelConfigurationsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(priorityLevelConfigurationsResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &flowcontrolv1beta3.PriorityLevelConfigurationList{}) - return err -} - -func (c *priorityLevelConfigurationsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*flowcontrolv1beta3.PriorityLevelConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(priorityLevelConfigurationsResource, c.ClusterPath, name), &flowcontrolv1beta3.PriorityLevelConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta3.PriorityLevelConfiguration), err -} - -// List takes label and field selectors, and returns the list of PriorityLevelConfigurations that match those selectors. -func (c *priorityLevelConfigurationsClient) List(ctx context.Context, opts metav1.ListOptions) (*flowcontrolv1beta3.PriorityLevelConfigurationList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(priorityLevelConfigurationsResource, priorityLevelConfigurationsKind, c.ClusterPath, opts), &flowcontrolv1beta3.PriorityLevelConfigurationList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &flowcontrolv1beta3.PriorityLevelConfigurationList{ListMeta: obj.(*flowcontrolv1beta3.PriorityLevelConfigurationList).ListMeta} - for _, item := range obj.(*flowcontrolv1beta3.PriorityLevelConfigurationList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *priorityLevelConfigurationsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(priorityLevelConfigurationsResource, c.ClusterPath, opts)) -} - -func (c *priorityLevelConfigurationsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*flowcontrolv1beta3.PriorityLevelConfiguration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(priorityLevelConfigurationsResource, c.ClusterPath, name, pt, data, subresources...), &flowcontrolv1beta3.PriorityLevelConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta3.PriorityLevelConfiguration), err -} - -func (c *priorityLevelConfigurationsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsflowcontrolv1beta3.PriorityLevelConfigurationApplyConfiguration, opts metav1.ApplyOptions) (*flowcontrolv1beta3.PriorityLevelConfiguration, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(priorityLevelConfigurationsResource, c.ClusterPath, *name, types.ApplyPatchType, data), &flowcontrolv1beta3.PriorityLevelConfiguration{}) - if obj == nil { - return nil, err - } - return obj.(*flowcontrolv1beta3.PriorityLevelConfiguration), err -} - -func (c *priorityLevelConfigurationsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsflowcontrolv1beta3.PriorityLevelConfigurationApplyConfiguration, opts metav1.ApplyOptions) (*flowcontrolv1beta3.PriorityLevelConfiguration, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(priorityLevelConfigurationsResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &flowcontrolv1beta3.PriorityLevelConfiguration{}) - if obj == nil { - return nil, err +func newFakePriorityLevelConfigurationClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedflowcontrolv1beta3.PriorityLevelConfigurationInterface { + return &priorityLevelConfigurationScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*flowcontrolv1beta3.PriorityLevelConfiguration, *flowcontrolv1beta3.PriorityLevelConfigurationList, *v1beta3.PriorityLevelConfigurationApplyConfiguration]( + fake, + clusterPath, + "", + flowcontrolv1beta3.SchemeGroupVersion.WithResource("prioritylevelconfigurations"), + flowcontrolv1beta3.SchemeGroupVersion.WithKind("PriorityLevelConfiguration"), + func() *flowcontrolv1beta3.PriorityLevelConfiguration { + return &flowcontrolv1beta3.PriorityLevelConfiguration{} + }, + func() *flowcontrolv1beta3.PriorityLevelConfigurationList { + return &flowcontrolv1beta3.PriorityLevelConfigurationList{} + }, + func(dst, src *flowcontrolv1beta3.PriorityLevelConfigurationList) { dst.ListMeta = src.ListMeta }, + func(list *flowcontrolv1beta3.PriorityLevelConfigurationList) []*flowcontrolv1beta3.PriorityLevelConfiguration { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *flowcontrolv1beta3.PriorityLevelConfigurationList, items []*flowcontrolv1beta3.PriorityLevelConfiguration) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*flowcontrolv1beta3.PriorityLevelConfiguration), err } diff --git a/kubernetes/typed/flowcontrol/v1beta3/flowcontrol_client.go b/kubernetes/typed/flowcontrol/v1beta3/flowcontrol_client.go index e8de57c1c..eb9f7ad32 100644 --- a/kubernetes/typed/flowcontrol/v1beta3/flowcontrol_client.go +++ b/kubernetes/typed/flowcontrol/v1beta3/flowcontrol_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta3 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apiflowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3" flowcontrolv1beta3 "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type FlowcontrolV1beta3ClusterInterface interface { @@ -38,6 +41,7 @@ type FlowcontrolV1beta3ClusterScoper interface { Cluster(logicalcluster.Path) flowcontrolv1beta3.FlowcontrolV1beta3Interface } +// FlowcontrolV1beta3ClusterClient is used to interact with features provided by the flowcontrol.apiserver.k8s.io group. type FlowcontrolV1beta3ClusterClient struct { clientCache kcpclient.Cache[*flowcontrolv1beta3.FlowcontrolV1beta3Client] } @@ -61,11 +65,13 @@ func (c *FlowcontrolV1beta3ClusterClient) PriorityLevelConfigurations() Priority // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*FlowcontrolV1beta3ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new FlowcontrolV1beta3ClusterClient for the given config and http client. @@ -77,6 +83,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*FlowcontrolV1beta3C if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &FlowcontrolV1beta3ClusterClient{clientCache: cache}, nil } @@ -89,3 +96,14 @@ func NewForConfigOrDie(c *rest.Config) *FlowcontrolV1beta3ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apiflowcontrolv1beta3.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/flowcontrol/v1beta3/flowschema.go b/kubernetes/typed/flowcontrol/v1beta3/flowschema.go index c2122b079..7fc1963d9 100644 --- a/kubernetes/typed/flowcontrol/v1beta3/flowschema.go +++ b/kubernetes/typed/flowcontrol/v1beta3/flowschema.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta3 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - flowcontrolv1beta3client "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3" + apiflowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + flowcontrolv1beta3 "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3" ) // FlowSchemasClusterGetter has a method to return a FlowSchemaClusterInterface. @@ -37,19 +37,20 @@ type FlowSchemasClusterGetter interface { } // FlowSchemaClusterInterface can operate on FlowSchemas across all clusters, -// or scope down to one cluster and return a flowcontrolv1beta3client.FlowSchemaInterface. +// or scope down to one cluster and return a flowcontrolv1beta3.FlowSchemaInterface. type FlowSchemaClusterInterface interface { - Cluster(logicalcluster.Path) flowcontrolv1beta3client.FlowSchemaInterface - List(ctx context.Context, opts metav1.ListOptions) (*flowcontrolv1beta3.FlowSchemaList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) flowcontrolv1beta3.FlowSchemaInterface + List(ctx context.Context, opts v1.ListOptions) (*apiflowcontrolv1beta3.FlowSchemaList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + FlowSchemaClusterExpansion } type flowSchemasClusterInterface struct { - clientCache kcpclient.Cache[*flowcontrolv1beta3client.FlowcontrolV1beta3Client] + clientCache kcpclient.Cache[*flowcontrolv1beta3.FlowcontrolV1beta3Client] } // Cluster scopes the client down to a particular cluster. -func (c *flowSchemasClusterInterface) Cluster(clusterPath logicalcluster.Path) flowcontrolv1beta3client.FlowSchemaInterface { +func (c *flowSchemasClusterInterface) Cluster(clusterPath logicalcluster.Path) flowcontrolv1beta3.FlowSchemaInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *flowSchemasClusterInterface) Cluster(clusterPath logicalcluster.Path) f } // List returns the entire collection of all FlowSchemas across all clusters. -func (c *flowSchemasClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*flowcontrolv1beta3.FlowSchemaList, error) { +func (c *flowSchemasClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apiflowcontrolv1beta3.FlowSchemaList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).FlowSchemas().List(ctx, opts) } // Watch begins to watch all FlowSchemas across all clusters. -func (c *flowSchemasClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *flowSchemasClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).FlowSchemas().Watch(ctx, opts) } diff --git a/kubernetes/typed/flowcontrol/v1beta3/generated_expansion.go b/kubernetes/typed/flowcontrol/v1beta3/generated_expansion.go new file mode 100644 index 000000000..d8400ec71 --- /dev/null +++ b/kubernetes/typed/flowcontrol/v1beta3/generated_expansion.go @@ -0,0 +1,23 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1beta3 + +type FlowSchemaClusterExpansion interface{} + +type PriorityLevelConfigurationClusterExpansion interface{} diff --git a/kubernetes/typed/flowcontrol/v1beta3/prioritylevelconfiguration.go b/kubernetes/typed/flowcontrol/v1beta3/prioritylevelconfiguration.go index 18f8a1121..2e83ca7ef 100644 --- a/kubernetes/typed/flowcontrol/v1beta3/prioritylevelconfiguration.go +++ b/kubernetes/typed/flowcontrol/v1beta3/prioritylevelconfiguration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta3 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - flowcontrolv1beta3client "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3" + apiflowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + flowcontrolv1beta3 "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3" ) // PriorityLevelConfigurationsClusterGetter has a method to return a PriorityLevelConfigurationClusterInterface. @@ -37,19 +37,20 @@ type PriorityLevelConfigurationsClusterGetter interface { } // PriorityLevelConfigurationClusterInterface can operate on PriorityLevelConfigurations across all clusters, -// or scope down to one cluster and return a flowcontrolv1beta3client.PriorityLevelConfigurationInterface. +// or scope down to one cluster and return a flowcontrolv1beta3.PriorityLevelConfigurationInterface. type PriorityLevelConfigurationClusterInterface interface { - Cluster(logicalcluster.Path) flowcontrolv1beta3client.PriorityLevelConfigurationInterface - List(ctx context.Context, opts metav1.ListOptions) (*flowcontrolv1beta3.PriorityLevelConfigurationList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) flowcontrolv1beta3.PriorityLevelConfigurationInterface + List(ctx context.Context, opts v1.ListOptions) (*apiflowcontrolv1beta3.PriorityLevelConfigurationList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + PriorityLevelConfigurationClusterExpansion } type priorityLevelConfigurationsClusterInterface struct { - clientCache kcpclient.Cache[*flowcontrolv1beta3client.FlowcontrolV1beta3Client] + clientCache kcpclient.Cache[*flowcontrolv1beta3.FlowcontrolV1beta3Client] } // Cluster scopes the client down to a particular cluster. -func (c *priorityLevelConfigurationsClusterInterface) Cluster(clusterPath logicalcluster.Path) flowcontrolv1beta3client.PriorityLevelConfigurationInterface { +func (c *priorityLevelConfigurationsClusterInterface) Cluster(clusterPath logicalcluster.Path) flowcontrolv1beta3.PriorityLevelConfigurationInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *priorityLevelConfigurationsClusterInterface) Cluster(clusterPath logica } // List returns the entire collection of all PriorityLevelConfigurations across all clusters. -func (c *priorityLevelConfigurationsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*flowcontrolv1beta3.PriorityLevelConfigurationList, error) { +func (c *priorityLevelConfigurationsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apiflowcontrolv1beta3.PriorityLevelConfigurationList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).PriorityLevelConfigurations().List(ctx, opts) } // Watch begins to watch all PriorityLevelConfigurations across all clusters. -func (c *priorityLevelConfigurationsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *priorityLevelConfigurationsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).PriorityLevelConfigurations().Watch(ctx, opts) } diff --git a/kubernetes/typed/networking/v1/doc.go b/kubernetes/typed/networking/v1/doc.go new file mode 100644 index 000000000..d2f3412ab --- /dev/null +++ b/kubernetes/typed/networking/v1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1 diff --git a/kubernetes/typed/networking/v1/fake/doc.go b/kubernetes/typed/networking/v1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/networking/v1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/networking/v1/fake/ingress.go b/kubernetes/typed/networking/v1/fake/ingress.go index 50163d559..37f8a8f15 100644 --- a/kubernetes/typed/networking/v1/fake/ingress.go +++ b/kubernetes/typed/networking/v1/fake/ingress.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" networkingv1 "k8s.io/api/networking/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsnetworkingv1 "k8s.io/client-go/applyconfigurations/networking/v1" - networkingv1client "k8s.io/client-go/kubernetes/typed/networking/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/networking/v1" + typednetworkingv1 "k8s.io/client-go/kubernetes/typed/networking/v1" - kcpnetworkingv1 "github.com/kcp-dev/client-go/kubernetes/typed/networking/v1" + typedkcpnetworkingv1 "github.com/kcp-dev/client-go/kubernetes/typed/networking/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var ingressesResource = schema.GroupVersionResource{Group: "networking.k8s.io", Version: "v1", Resource: "ingresses"} -var ingressesKind = schema.GroupVersionKind{Group: "networking.k8s.io", Version: "v1", Kind: "Ingress"} - -type ingressesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *ingressesClusterClient) Cluster(clusterPath logicalcluster.Path) kcpnetworkingv1.IngressesNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &ingressesNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// ingressClusterClient implements IngressClusterInterface +type ingressClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*networkingv1.Ingress, *networkingv1.IngressList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of Ingresses that match those selectors across all clusters. -func (c *ingressesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*networkingv1.IngressList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(ingressesResource, ingressesKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &networkingv1.IngressList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeIngressClusterClient(fake *NetworkingV1ClusterClient) typedkcpnetworkingv1.IngressClusterInterface { + return &ingressClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*networkingv1.Ingress, *networkingv1.IngressList]( + fake.Fake, + networkingv1.SchemeGroupVersion.WithResource("ingresses"), + networkingv1.SchemeGroupVersion.WithKind("Ingress"), + func() *networkingv1.Ingress { return &networkingv1.Ingress{} }, + func() *networkingv1.IngressList { return &networkingv1.IngressList{} }, + func(dst, src *networkingv1.IngressList) { dst.ListMeta = src.ListMeta }, + func(list *networkingv1.IngressList) []*networkingv1.Ingress { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *networkingv1.IngressList, items []*networkingv1.Ingress) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &networkingv1.IngressList{ListMeta: obj.(*networkingv1.IngressList).ListMeta} - for _, item := range obj.(*networkingv1.IngressList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested Ingresses across all clusters. -func (c *ingressesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(ingressesResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *ingressClusterClient) Cluster(cluster logicalcluster.Path) typedkcpnetworkingv1.IngressesNamespacer { + return &ingressNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type ingressesNamespacer struct { +type ingressNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *ingressesNamespacer) Namespace(namespace string) networkingv1client.IngressInterface { - return &ingressesClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *ingressNamespacer) Namespace(namespace string) typednetworkingv1.IngressInterface { + return newFakeIngressClient(n.Fake, namespace, n.ClusterPath) } -type ingressesClient struct { - *kcptesting.Fake +// ingressScopedClient implements IngressInterface +type ingressScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*networkingv1.Ingress, *networkingv1.IngressList, *v1.IngressApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *ingressesClient) Create(ctx context.Context, ingress *networkingv1.Ingress, opts metav1.CreateOptions) (*networkingv1.Ingress, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(ingressesResource, c.ClusterPath, c.Namespace, ingress), &networkingv1.Ingress{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1.Ingress), err -} - -func (c *ingressesClient) Update(ctx context.Context, ingress *networkingv1.Ingress, opts metav1.UpdateOptions) (*networkingv1.Ingress, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(ingressesResource, c.ClusterPath, c.Namespace, ingress), &networkingv1.Ingress{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1.Ingress), err -} - -func (c *ingressesClient) UpdateStatus(ctx context.Context, ingress *networkingv1.Ingress, opts metav1.UpdateOptions) (*networkingv1.Ingress, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(ingressesResource, c.ClusterPath, "status", c.Namespace, ingress), &networkingv1.Ingress{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1.Ingress), err -} - -func (c *ingressesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(ingressesResource, c.ClusterPath, c.Namespace, name, opts), &networkingv1.Ingress{}) - return err -} - -func (c *ingressesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(ingressesResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &networkingv1.IngressList{}) - return err -} - -func (c *ingressesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*networkingv1.Ingress, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(ingressesResource, c.ClusterPath, c.Namespace, name), &networkingv1.Ingress{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1.Ingress), err -} - -// List takes label and field selectors, and returns the list of Ingresses that match those selectors. -func (c *ingressesClient) List(ctx context.Context, opts metav1.ListOptions) (*networkingv1.IngressList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(ingressesResource, ingressesKind, c.ClusterPath, c.Namespace, opts), &networkingv1.IngressList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &networkingv1.IngressList{ListMeta: obj.(*networkingv1.IngressList).ListMeta} - for _, item := range obj.(*networkingv1.IngressList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *ingressesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(ingressesResource, c.ClusterPath, c.Namespace, opts)) } -func (c *ingressesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*networkingv1.Ingress, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(ingressesResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &networkingv1.Ingress{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1.Ingress), err -} - -func (c *ingressesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsnetworkingv1.IngressApplyConfiguration, opts metav1.ApplyOptions) (*networkingv1.Ingress, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(ingressesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &networkingv1.Ingress{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1.Ingress), err -} - -func (c *ingressesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsnetworkingv1.IngressApplyConfiguration, opts metav1.ApplyOptions) (*networkingv1.Ingress, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(ingressesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &networkingv1.Ingress{}) - if obj == nil { - return nil, err +func newFakeIngressClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typednetworkingv1.IngressInterface { + return &ingressScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*networkingv1.Ingress, *networkingv1.IngressList, *v1.IngressApplyConfiguration]( + fake, + clusterPath, + namespace, + networkingv1.SchemeGroupVersion.WithResource("ingresses"), + networkingv1.SchemeGroupVersion.WithKind("Ingress"), + func() *networkingv1.Ingress { return &networkingv1.Ingress{} }, + func() *networkingv1.IngressList { return &networkingv1.IngressList{} }, + func(dst, src *networkingv1.IngressList) { dst.ListMeta = src.ListMeta }, + func(list *networkingv1.IngressList) []*networkingv1.Ingress { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *networkingv1.IngressList, items []*networkingv1.Ingress) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*networkingv1.Ingress), err } diff --git a/kubernetes/typed/networking/v1/fake/ingressclass.go b/kubernetes/typed/networking/v1/fake/ingressclass.go index f74a466d8..7808bc5be 100644 --- a/kubernetes/typed/networking/v1/fake/ingressclass.go +++ b/kubernetes/typed/networking/v1/fake/ingressclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" networkingv1 "k8s.io/api/networking/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsnetworkingv1 "k8s.io/client-go/applyconfigurations/networking/v1" - networkingv1client "k8s.io/client-go/kubernetes/typed/networking/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/networking/v1" + typednetworkingv1 "k8s.io/client-go/kubernetes/typed/networking/v1" + typedkcpnetworkingv1 "github.com/kcp-dev/client-go/kubernetes/typed/networking/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var ingressClassesResource = schema.GroupVersionResource{Group: "networking.k8s.io", Version: "v1", Resource: "ingressclasses"} -var ingressClassesKind = schema.GroupVersionKind{Group: "networking.k8s.io", Version: "v1", Kind: "IngressClass"} - -type ingressClassesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *ingressClassesClusterClient) Cluster(clusterPath logicalcluster.Path) networkingv1client.IngressClassInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &ingressClassesClient{Fake: c.Fake, ClusterPath: clusterPath} +// ingressClassClusterClient implements IngressClassClusterInterface +type ingressClassClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*networkingv1.IngressClass, *networkingv1.IngressClassList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of IngressClasses that match those selectors across all clusters. -func (c *ingressClassesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*networkingv1.IngressClassList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(ingressClassesResource, ingressClassesKind, logicalcluster.Wildcard, opts), &networkingv1.IngressClassList{}) - if obj == nil { - return nil, err +func newFakeIngressClassClusterClient(fake *NetworkingV1ClusterClient) typedkcpnetworkingv1.IngressClassClusterInterface { + return &ingressClassClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*networkingv1.IngressClass, *networkingv1.IngressClassList]( + fake.Fake, + networkingv1.SchemeGroupVersion.WithResource("ingressclasses"), + networkingv1.SchemeGroupVersion.WithKind("IngressClass"), + func() *networkingv1.IngressClass { return &networkingv1.IngressClass{} }, + func() *networkingv1.IngressClassList { return &networkingv1.IngressClassList{} }, + func(dst, src *networkingv1.IngressClassList) { dst.ListMeta = src.ListMeta }, + func(list *networkingv1.IngressClassList) []*networkingv1.IngressClass { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *networkingv1.IngressClassList, items []*networkingv1.IngressClass) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &networkingv1.IngressClassList{ListMeta: obj.(*networkingv1.IngressClassList).ListMeta} - for _, item := range obj.(*networkingv1.IngressClassList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested IngressClasses across all clusters. -func (c *ingressClassesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(ingressClassesResource, logicalcluster.Wildcard, opts)) +func (c *ingressClassClusterClient) Cluster(cluster logicalcluster.Path) typednetworkingv1.IngressClassInterface { + return newFakeIngressClassClient(c.Fake, cluster) } -type ingressClassesClient struct { - *kcptesting.Fake +// ingressClassScopedClient implements IngressClassInterface +type ingressClassScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*networkingv1.IngressClass, *networkingv1.IngressClassList, *v1.IngressClassApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *ingressClassesClient) Create(ctx context.Context, ingressClass *networkingv1.IngressClass, opts metav1.CreateOptions) (*networkingv1.IngressClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(ingressClassesResource, c.ClusterPath, ingressClass), &networkingv1.IngressClass{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1.IngressClass), err -} - -func (c *ingressClassesClient) Update(ctx context.Context, ingressClass *networkingv1.IngressClass, opts metav1.UpdateOptions) (*networkingv1.IngressClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(ingressClassesResource, c.ClusterPath, ingressClass), &networkingv1.IngressClass{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1.IngressClass), err -} - -func (c *ingressClassesClient) UpdateStatus(ctx context.Context, ingressClass *networkingv1.IngressClass, opts metav1.UpdateOptions) (*networkingv1.IngressClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(ingressClassesResource, c.ClusterPath, "status", ingressClass), &networkingv1.IngressClass{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1.IngressClass), err -} - -func (c *ingressClassesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(ingressClassesResource, c.ClusterPath, name, opts), &networkingv1.IngressClass{}) - return err -} - -func (c *ingressClassesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(ingressClassesResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &networkingv1.IngressClassList{}) - return err -} - -func (c *ingressClassesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*networkingv1.IngressClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(ingressClassesResource, c.ClusterPath, name), &networkingv1.IngressClass{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1.IngressClass), err -} - -// List takes label and field selectors, and returns the list of IngressClasses that match those selectors. -func (c *ingressClassesClient) List(ctx context.Context, opts metav1.ListOptions) (*networkingv1.IngressClassList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(ingressClassesResource, ingressClassesKind, c.ClusterPath, opts), &networkingv1.IngressClassList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &networkingv1.IngressClassList{ListMeta: obj.(*networkingv1.IngressClassList).ListMeta} - for _, item := range obj.(*networkingv1.IngressClassList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *ingressClassesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(ingressClassesResource, c.ClusterPath, opts)) -} - -func (c *ingressClassesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*networkingv1.IngressClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(ingressClassesResource, c.ClusterPath, name, pt, data, subresources...), &networkingv1.IngressClass{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1.IngressClass), err -} - -func (c *ingressClassesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsnetworkingv1.IngressClassApplyConfiguration, opts metav1.ApplyOptions) (*networkingv1.IngressClass, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(ingressClassesResource, c.ClusterPath, *name, types.ApplyPatchType, data), &networkingv1.IngressClass{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1.IngressClass), err -} - -func (c *ingressClassesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsnetworkingv1.IngressClassApplyConfiguration, opts metav1.ApplyOptions) (*networkingv1.IngressClass, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(ingressClassesResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &networkingv1.IngressClass{}) - if obj == nil { - return nil, err +func newFakeIngressClassClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typednetworkingv1.IngressClassInterface { + return &ingressClassScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*networkingv1.IngressClass, *networkingv1.IngressClassList, *v1.IngressClassApplyConfiguration]( + fake, + clusterPath, + "", + networkingv1.SchemeGroupVersion.WithResource("ingressclasses"), + networkingv1.SchemeGroupVersion.WithKind("IngressClass"), + func() *networkingv1.IngressClass { return &networkingv1.IngressClass{} }, + func() *networkingv1.IngressClassList { return &networkingv1.IngressClassList{} }, + func(dst, src *networkingv1.IngressClassList) { dst.ListMeta = src.ListMeta }, + func(list *networkingv1.IngressClassList) []*networkingv1.IngressClass { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *networkingv1.IngressClassList, items []*networkingv1.IngressClass) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*networkingv1.IngressClass), err } diff --git a/kubernetes/typed/networking/v1/fake/networking_client.go b/kubernetes/typed/networking/v1/fake/networking_client.go index ee7e02f5b..7503ed171 100644 --- a/kubernetes/typed/networking/v1/fake/networking_client.go +++ b/kubernetes/typed/networking/v1/fake/networking_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" networkingv1 "k8s.io/client-go/kubernetes/typed/networking/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpnetworkingv1 "github.com/kcp-dev/client-go/kubernetes/typed/networking/v1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -41,38 +41,38 @@ func (c *NetworkingV1ClusterClient) Cluster(clusterPath logicalcluster.Path) net return &NetworkingV1Client{Fake: c.Fake, ClusterPath: clusterPath} } -func (c *NetworkingV1ClusterClient) NetworkPolicies() kcpnetworkingv1.NetworkPolicyClusterInterface { - return &networkPoliciesClusterClient{Fake: c.Fake} -} - func (c *NetworkingV1ClusterClient) Ingresses() kcpnetworkingv1.IngressClusterInterface { - return &ingressesClusterClient{Fake: c.Fake} + return newFakeIngressClusterClient(c) } func (c *NetworkingV1ClusterClient) IngressClasses() kcpnetworkingv1.IngressClassClusterInterface { - return &ingressClassesClusterClient{Fake: c.Fake} + return newFakeIngressClassClusterClient(c) } -var _ networkingv1.NetworkingV1Interface = (*NetworkingV1Client)(nil) +func (c *NetworkingV1ClusterClient) NetworkPolicies() kcpnetworkingv1.NetworkPolicyClusterInterface { + return newFakeNetworkPolicyClusterClient(c) +} type NetworkingV1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *NetworkingV1Client) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret +func (c *NetworkingV1Client) Ingresses(namespace string) networkingv1.IngressInterface { + return newFakeIngressClient(c.Fake, namespace, c.ClusterPath) } -func (c *NetworkingV1Client) NetworkPolicies(namespace string) networkingv1.NetworkPolicyInterface { - return &networkPoliciesClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *NetworkingV1Client) IngressClasses() networkingv1.IngressClassInterface { + return newFakeIngressClassClient(c.Fake, c.ClusterPath) } -func (c *NetworkingV1Client) Ingresses(namespace string) networkingv1.IngressInterface { - return &ingressesClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *NetworkingV1Client) NetworkPolicies(namespace string) networkingv1.NetworkPolicyInterface { + return newFakeNetworkPolicyClient(c.Fake, namespace, c.ClusterPath) } -func (c *NetworkingV1Client) IngressClasses() networkingv1.IngressClassInterface { - return &ingressClassesClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *NetworkingV1Client) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret } diff --git a/kubernetes/typed/networking/v1/fake/networkpolicy.go b/kubernetes/typed/networking/v1/fake/networkpolicy.go index 7b9e4e14e..8699edad7 100644 --- a/kubernetes/typed/networking/v1/fake/networkpolicy.go +++ b/kubernetes/typed/networking/v1/fake/networkpolicy.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" networkingv1 "k8s.io/api/networking/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsnetworkingv1 "k8s.io/client-go/applyconfigurations/networking/v1" - networkingv1client "k8s.io/client-go/kubernetes/typed/networking/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/networking/v1" + typednetworkingv1 "k8s.io/client-go/kubernetes/typed/networking/v1" - kcpnetworkingv1 "github.com/kcp-dev/client-go/kubernetes/typed/networking/v1" + typedkcpnetworkingv1 "github.com/kcp-dev/client-go/kubernetes/typed/networking/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var networkPoliciesResource = schema.GroupVersionResource{Group: "networking.k8s.io", Version: "v1", Resource: "networkpolicies"} -var networkPoliciesKind = schema.GroupVersionKind{Group: "networking.k8s.io", Version: "v1", Kind: "NetworkPolicy"} - -type networkPoliciesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *networkPoliciesClusterClient) Cluster(clusterPath logicalcluster.Path) kcpnetworkingv1.NetworkPoliciesNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &networkPoliciesNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// networkPolicyClusterClient implements NetworkPolicyClusterInterface +type networkPolicyClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*networkingv1.NetworkPolicy, *networkingv1.NetworkPolicyList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of NetworkPolicies that match those selectors across all clusters. -func (c *networkPoliciesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*networkingv1.NetworkPolicyList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(networkPoliciesResource, networkPoliciesKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &networkingv1.NetworkPolicyList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeNetworkPolicyClusterClient(fake *NetworkingV1ClusterClient) typedkcpnetworkingv1.NetworkPolicyClusterInterface { + return &networkPolicyClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*networkingv1.NetworkPolicy, *networkingv1.NetworkPolicyList]( + fake.Fake, + networkingv1.SchemeGroupVersion.WithResource("networkpolicies"), + networkingv1.SchemeGroupVersion.WithKind("NetworkPolicy"), + func() *networkingv1.NetworkPolicy { return &networkingv1.NetworkPolicy{} }, + func() *networkingv1.NetworkPolicyList { return &networkingv1.NetworkPolicyList{} }, + func(dst, src *networkingv1.NetworkPolicyList) { dst.ListMeta = src.ListMeta }, + func(list *networkingv1.NetworkPolicyList) []*networkingv1.NetworkPolicy { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *networkingv1.NetworkPolicyList, items []*networkingv1.NetworkPolicy) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &networkingv1.NetworkPolicyList{ListMeta: obj.(*networkingv1.NetworkPolicyList).ListMeta} - for _, item := range obj.(*networkingv1.NetworkPolicyList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested NetworkPolicies across all clusters. -func (c *networkPoliciesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(networkPoliciesResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *networkPolicyClusterClient) Cluster(cluster logicalcluster.Path) typedkcpnetworkingv1.NetworkPoliciesNamespacer { + return &networkPolicyNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type networkPoliciesNamespacer struct { +type networkPolicyNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *networkPoliciesNamespacer) Namespace(namespace string) networkingv1client.NetworkPolicyInterface { - return &networkPoliciesClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *networkPolicyNamespacer) Namespace(namespace string) typednetworkingv1.NetworkPolicyInterface { + return newFakeNetworkPolicyClient(n.Fake, namespace, n.ClusterPath) } -type networkPoliciesClient struct { - *kcptesting.Fake +// networkPolicyScopedClient implements NetworkPolicyInterface +type networkPolicyScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*networkingv1.NetworkPolicy, *networkingv1.NetworkPolicyList, *v1.NetworkPolicyApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *networkPoliciesClient) Create(ctx context.Context, networkPolicy *networkingv1.NetworkPolicy, opts metav1.CreateOptions) (*networkingv1.NetworkPolicy, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(networkPoliciesResource, c.ClusterPath, c.Namespace, networkPolicy), &networkingv1.NetworkPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1.NetworkPolicy), err -} - -func (c *networkPoliciesClient) Update(ctx context.Context, networkPolicy *networkingv1.NetworkPolicy, opts metav1.UpdateOptions) (*networkingv1.NetworkPolicy, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(networkPoliciesResource, c.ClusterPath, c.Namespace, networkPolicy), &networkingv1.NetworkPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1.NetworkPolicy), err -} - -func (c *networkPoliciesClient) UpdateStatus(ctx context.Context, networkPolicy *networkingv1.NetworkPolicy, opts metav1.UpdateOptions) (*networkingv1.NetworkPolicy, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(networkPoliciesResource, c.ClusterPath, "status", c.Namespace, networkPolicy), &networkingv1.NetworkPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1.NetworkPolicy), err -} - -func (c *networkPoliciesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(networkPoliciesResource, c.ClusterPath, c.Namespace, name, opts), &networkingv1.NetworkPolicy{}) - return err -} - -func (c *networkPoliciesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(networkPoliciesResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &networkingv1.NetworkPolicyList{}) - return err -} - -func (c *networkPoliciesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*networkingv1.NetworkPolicy, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(networkPoliciesResource, c.ClusterPath, c.Namespace, name), &networkingv1.NetworkPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1.NetworkPolicy), err -} - -// List takes label and field selectors, and returns the list of NetworkPolicies that match those selectors. -func (c *networkPoliciesClient) List(ctx context.Context, opts metav1.ListOptions) (*networkingv1.NetworkPolicyList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(networkPoliciesResource, networkPoliciesKind, c.ClusterPath, c.Namespace, opts), &networkingv1.NetworkPolicyList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &networkingv1.NetworkPolicyList{ListMeta: obj.(*networkingv1.NetworkPolicyList).ListMeta} - for _, item := range obj.(*networkingv1.NetworkPolicyList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *networkPoliciesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(networkPoliciesResource, c.ClusterPath, c.Namespace, opts)) } -func (c *networkPoliciesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*networkingv1.NetworkPolicy, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(networkPoliciesResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &networkingv1.NetworkPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1.NetworkPolicy), err -} - -func (c *networkPoliciesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsnetworkingv1.NetworkPolicyApplyConfiguration, opts metav1.ApplyOptions) (*networkingv1.NetworkPolicy, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(networkPoliciesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &networkingv1.NetworkPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1.NetworkPolicy), err -} - -func (c *networkPoliciesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsnetworkingv1.NetworkPolicyApplyConfiguration, opts metav1.ApplyOptions) (*networkingv1.NetworkPolicy, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(networkPoliciesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &networkingv1.NetworkPolicy{}) - if obj == nil { - return nil, err +func newFakeNetworkPolicyClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typednetworkingv1.NetworkPolicyInterface { + return &networkPolicyScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*networkingv1.NetworkPolicy, *networkingv1.NetworkPolicyList, *v1.NetworkPolicyApplyConfiguration]( + fake, + clusterPath, + namespace, + networkingv1.SchemeGroupVersion.WithResource("networkpolicies"), + networkingv1.SchemeGroupVersion.WithKind("NetworkPolicy"), + func() *networkingv1.NetworkPolicy { return &networkingv1.NetworkPolicy{} }, + func() *networkingv1.NetworkPolicyList { return &networkingv1.NetworkPolicyList{} }, + func(dst, src *networkingv1.NetworkPolicyList) { dst.ListMeta = src.ListMeta }, + func(list *networkingv1.NetworkPolicyList) []*networkingv1.NetworkPolicy { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *networkingv1.NetworkPolicyList, items []*networkingv1.NetworkPolicy) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*networkingv1.NetworkPolicy), err } diff --git a/kubernetes/typed/networking/v1/generated_expansion.go b/kubernetes/typed/networking/v1/generated_expansion.go new file mode 100644 index 000000000..f4788ea78 --- /dev/null +++ b/kubernetes/typed/networking/v1/generated_expansion.go @@ -0,0 +1,25 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1 + +type IngressClusterExpansion interface{} + +type IngressClassClusterExpansion interface{} + +type NetworkPolicyClusterExpansion interface{} diff --git a/kubernetes/typed/networking/v1/ingress.go b/kubernetes/typed/networking/v1/ingress.go index dabfced65..895d9b675 100644 --- a/kubernetes/typed/networking/v1/ingress.go +++ b/kubernetes/typed/networking/v1/ingress.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" networkingv1 "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - networkingv1client "k8s.io/client-go/kubernetes/typed/networking/v1" + watch "k8s.io/apimachinery/pkg/watch" + typednetworkingv1 "k8s.io/client-go/kubernetes/typed/networking/v1" ) // IngressesClusterGetter has a method to return a IngressClusterInterface. @@ -42,10 +42,11 @@ type IngressClusterInterface interface { Cluster(logicalcluster.Path) IngressesNamespacer List(ctx context.Context, opts metav1.ListOptions) (*networkingv1.IngressList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + IngressClusterExpansion } type ingressesClusterInterface struct { - clientCache kcpclient.Cache[*networkingv1client.NetworkingV1Client] + clientCache kcpclient.Cache[*typednetworkingv1.NetworkingV1Client] } // Cluster scopes the client down to a particular cluster. @@ -67,16 +68,16 @@ func (c *ingressesClusterInterface) Watch(ctx context.Context, opts metav1.ListO return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Ingresses(metav1.NamespaceAll).Watch(ctx, opts) } -// IngressesNamespacer can scope to objects within a namespace, returning a networkingv1client.IngressInterface. +// IngressesNamespacer can scope to objects within a namespace, returning a typednetworkingv1.IngressInterface. type IngressesNamespacer interface { - Namespace(string) networkingv1client.IngressInterface + Namespace(string) typednetworkingv1.IngressInterface } type ingressesNamespacer struct { - clientCache kcpclient.Cache[*networkingv1client.NetworkingV1Client] + clientCache kcpclient.Cache[*typednetworkingv1.NetworkingV1Client] clusterPath logicalcluster.Path } -func (n *ingressesNamespacer) Namespace(namespace string) networkingv1client.IngressInterface { +func (n *ingressesNamespacer) Namespace(namespace string) typednetworkingv1.IngressInterface { return n.clientCache.ClusterOrDie(n.clusterPath).Ingresses(namespace) } diff --git a/kubernetes/typed/networking/v1/ingressclass.go b/kubernetes/typed/networking/v1/ingressclass.go index f0a9911af..dd6728d87 100644 --- a/kubernetes/typed/networking/v1/ingressclass.go +++ b/kubernetes/typed/networking/v1/ingressclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - networkingv1 "k8s.io/api/networking/v1" + apinetworkingv1 "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - networkingv1client "k8s.io/client-go/kubernetes/typed/networking/v1" + watch "k8s.io/apimachinery/pkg/watch" + networkingv1 "k8s.io/client-go/kubernetes/typed/networking/v1" ) // IngressClassesClusterGetter has a method to return a IngressClassClusterInterface. @@ -37,19 +37,20 @@ type IngressClassesClusterGetter interface { } // IngressClassClusterInterface can operate on IngressClasses across all clusters, -// or scope down to one cluster and return a networkingv1client.IngressClassInterface. +// or scope down to one cluster and return a networkingv1.IngressClassInterface. type IngressClassClusterInterface interface { - Cluster(logicalcluster.Path) networkingv1client.IngressClassInterface - List(ctx context.Context, opts metav1.ListOptions) (*networkingv1.IngressClassList, error) + Cluster(logicalcluster.Path) networkingv1.IngressClassInterface + List(ctx context.Context, opts metav1.ListOptions) (*apinetworkingv1.IngressClassList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + IngressClassClusterExpansion } type ingressClassesClusterInterface struct { - clientCache kcpclient.Cache[*networkingv1client.NetworkingV1Client] + clientCache kcpclient.Cache[*networkingv1.NetworkingV1Client] } // Cluster scopes the client down to a particular cluster. -func (c *ingressClassesClusterInterface) Cluster(clusterPath logicalcluster.Path) networkingv1client.IngressClassInterface { +func (c *ingressClassesClusterInterface) Cluster(clusterPath logicalcluster.Path) networkingv1.IngressClassInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,7 +59,7 @@ func (c *ingressClassesClusterInterface) Cluster(clusterPath logicalcluster.Path } // List returns the entire collection of all IngressClasses across all clusters. -func (c *ingressClassesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*networkingv1.IngressClassList, error) { +func (c *ingressClassesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*apinetworkingv1.IngressClassList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).IngressClasses().List(ctx, opts) } diff --git a/kubernetes/typed/networking/v1/networking_client.go b/kubernetes/typed/networking/v1/networking_client.go index ef3e2926b..9af6fa632 100644 --- a/kubernetes/typed/networking/v1/networking_client.go +++ b/kubernetes/typed/networking/v1/networking_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,31 +14,35 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apinetworkingv1 "k8s.io/api/networking/v1" networkingv1 "k8s.io/client-go/kubernetes/typed/networking/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type NetworkingV1ClusterInterface interface { NetworkingV1ClusterScoper - NetworkPoliciesClusterGetter IngressesClusterGetter IngressClassesClusterGetter + NetworkPoliciesClusterGetter } type NetworkingV1ClusterScoper interface { Cluster(logicalcluster.Path) networkingv1.NetworkingV1Interface } +// NetworkingV1ClusterClient is used to interact with features provided by the networking.k8s.io group. type NetworkingV1ClusterClient struct { clientCache kcpclient.Cache[*networkingv1.NetworkingV1Client] } @@ -50,10 +54,6 @@ func (c *NetworkingV1ClusterClient) Cluster(clusterPath logicalcluster.Path) net return c.clientCache.ClusterOrDie(clusterPath) } -func (c *NetworkingV1ClusterClient) NetworkPolicies() NetworkPolicyClusterInterface { - return &networkPoliciesClusterInterface{clientCache: c.clientCache} -} - func (c *NetworkingV1ClusterClient) Ingresses() IngressClusterInterface { return &ingressesClusterInterface{clientCache: c.clientCache} } @@ -62,15 +62,21 @@ func (c *NetworkingV1ClusterClient) IngressClasses() IngressClassClusterInterfac return &ingressClassesClusterInterface{clientCache: c.clientCache} } +func (c *NetworkingV1ClusterClient) NetworkPolicies() NetworkPolicyClusterInterface { + return &networkPoliciesClusterInterface{clientCache: c.clientCache} +} + // NewForConfig creates a new NetworkingV1ClusterClient for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*NetworkingV1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new NetworkingV1ClusterClient for the given config and http client. @@ -82,6 +88,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*NetworkingV1Cluster if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &NetworkingV1ClusterClient{clientCache: cache}, nil } @@ -94,3 +101,14 @@ func NewForConfigOrDie(c *rest.Config) *NetworkingV1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apinetworkingv1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/networking/v1/networkpolicy.go b/kubernetes/typed/networking/v1/networkpolicy.go index 2f8f64c2e..42fbb7a7d 100644 --- a/kubernetes/typed/networking/v1/networkpolicy.go +++ b/kubernetes/typed/networking/v1/networkpolicy.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" networkingv1 "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - networkingv1client "k8s.io/client-go/kubernetes/typed/networking/v1" + watch "k8s.io/apimachinery/pkg/watch" + typednetworkingv1 "k8s.io/client-go/kubernetes/typed/networking/v1" ) // NetworkPoliciesClusterGetter has a method to return a NetworkPolicyClusterInterface. @@ -42,10 +42,11 @@ type NetworkPolicyClusterInterface interface { Cluster(logicalcluster.Path) NetworkPoliciesNamespacer List(ctx context.Context, opts metav1.ListOptions) (*networkingv1.NetworkPolicyList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + NetworkPolicyClusterExpansion } type networkPoliciesClusterInterface struct { - clientCache kcpclient.Cache[*networkingv1client.NetworkingV1Client] + clientCache kcpclient.Cache[*typednetworkingv1.NetworkingV1Client] } // Cluster scopes the client down to a particular cluster. @@ -67,16 +68,16 @@ func (c *networkPoliciesClusterInterface) Watch(ctx context.Context, opts metav1 return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).NetworkPolicies(metav1.NamespaceAll).Watch(ctx, opts) } -// NetworkPoliciesNamespacer can scope to objects within a namespace, returning a networkingv1client.NetworkPolicyInterface. +// NetworkPoliciesNamespacer can scope to objects within a namespace, returning a typednetworkingv1.NetworkPolicyInterface. type NetworkPoliciesNamespacer interface { - Namespace(string) networkingv1client.NetworkPolicyInterface + Namespace(string) typednetworkingv1.NetworkPolicyInterface } type networkPoliciesNamespacer struct { - clientCache kcpclient.Cache[*networkingv1client.NetworkingV1Client] + clientCache kcpclient.Cache[*typednetworkingv1.NetworkingV1Client] clusterPath logicalcluster.Path } -func (n *networkPoliciesNamespacer) Namespace(namespace string) networkingv1client.NetworkPolicyInterface { +func (n *networkPoliciesNamespacer) Namespace(namespace string) typednetworkingv1.NetworkPolicyInterface { return n.clientCache.ClusterOrDie(n.clusterPath).NetworkPolicies(namespace) } diff --git a/kubernetes/typed/networking/v1alpha1/doc.go b/kubernetes/typed/networking/v1alpha1/doc.go new file mode 100644 index 000000000..08b80237c --- /dev/null +++ b/kubernetes/typed/networking/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/kubernetes/typed/networking/v1alpha1/fake/doc.go b/kubernetes/typed/networking/v1alpha1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/networking/v1alpha1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/networking/v1alpha1/fake/ipaddress.go b/kubernetes/typed/networking/v1alpha1/fake/ipaddress.go index 5203eb1bb..18f3fac8a 100644 --- a/kubernetes/typed/networking/v1alpha1/fake/ipaddress.go +++ b/kubernetes/typed/networking/v1alpha1/fake/ipaddress.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" networkingv1alpha1 "k8s.io/api/networking/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsnetworkingv1alpha1 "k8s.io/client-go/applyconfigurations/networking/v1alpha1" - networkingv1alpha1client "k8s.io/client-go/kubernetes/typed/networking/v1alpha1" - "k8s.io/client-go/testing" + v1alpha1 "k8s.io/client-go/applyconfigurations/networking/v1alpha1" + typednetworkingv1alpha1 "k8s.io/client-go/kubernetes/typed/networking/v1alpha1" + typedkcpnetworkingv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/networking/v1alpha1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var iPAddressesResource = schema.GroupVersionResource{Group: "networking.k8s.io", Version: "v1alpha1", Resource: "ipaddresses"} -var iPAddressesKind = schema.GroupVersionKind{Group: "networking.k8s.io", Version: "v1alpha1", Kind: "IPAddress"} - -type iPAddressesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *iPAddressesClusterClient) Cluster(clusterPath logicalcluster.Path) networkingv1alpha1client.IPAddressInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &iPAddressesClient{Fake: c.Fake, ClusterPath: clusterPath} +// iPAddressClusterClient implements IPAddressClusterInterface +type iPAddressClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*networkingv1alpha1.IPAddress, *networkingv1alpha1.IPAddressList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of IPAddresses that match those selectors across all clusters. -func (c *iPAddressesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*networkingv1alpha1.IPAddressList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(iPAddressesResource, iPAddressesKind, logicalcluster.Wildcard, opts), &networkingv1alpha1.IPAddressList{}) - if obj == nil { - return nil, err +func newFakeIPAddressClusterClient(fake *NetworkingV1alpha1ClusterClient) typedkcpnetworkingv1alpha1.IPAddressClusterInterface { + return &iPAddressClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*networkingv1alpha1.IPAddress, *networkingv1alpha1.IPAddressList]( + fake.Fake, + networkingv1alpha1.SchemeGroupVersion.WithResource("ipaddresses"), + networkingv1alpha1.SchemeGroupVersion.WithKind("IPAddress"), + func() *networkingv1alpha1.IPAddress { return &networkingv1alpha1.IPAddress{} }, + func() *networkingv1alpha1.IPAddressList { return &networkingv1alpha1.IPAddressList{} }, + func(dst, src *networkingv1alpha1.IPAddressList) { dst.ListMeta = src.ListMeta }, + func(list *networkingv1alpha1.IPAddressList) []*networkingv1alpha1.IPAddress { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *networkingv1alpha1.IPAddressList, items []*networkingv1alpha1.IPAddress) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &networkingv1alpha1.IPAddressList{ListMeta: obj.(*networkingv1alpha1.IPAddressList).ListMeta} - for _, item := range obj.(*networkingv1alpha1.IPAddressList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested IPAddresses across all clusters. -func (c *iPAddressesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(iPAddressesResource, logicalcluster.Wildcard, opts)) +func (c *iPAddressClusterClient) Cluster(cluster logicalcluster.Path) typednetworkingv1alpha1.IPAddressInterface { + return newFakeIPAddressClient(c.Fake, cluster) } -type iPAddressesClient struct { - *kcptesting.Fake +// iPAddressScopedClient implements IPAddressInterface +type iPAddressScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*networkingv1alpha1.IPAddress, *networkingv1alpha1.IPAddressList, *v1alpha1.IPAddressApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *iPAddressesClient) Create(ctx context.Context, iPAddress *networkingv1alpha1.IPAddress, opts metav1.CreateOptions) (*networkingv1alpha1.IPAddress, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(iPAddressesResource, c.ClusterPath, iPAddress), &networkingv1alpha1.IPAddress{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1alpha1.IPAddress), err -} - -func (c *iPAddressesClient) Update(ctx context.Context, iPAddress *networkingv1alpha1.IPAddress, opts metav1.UpdateOptions) (*networkingv1alpha1.IPAddress, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(iPAddressesResource, c.ClusterPath, iPAddress), &networkingv1alpha1.IPAddress{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1alpha1.IPAddress), err -} - -func (c *iPAddressesClient) UpdateStatus(ctx context.Context, iPAddress *networkingv1alpha1.IPAddress, opts metav1.UpdateOptions) (*networkingv1alpha1.IPAddress, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(iPAddressesResource, c.ClusterPath, "status", iPAddress), &networkingv1alpha1.IPAddress{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1alpha1.IPAddress), err -} - -func (c *iPAddressesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(iPAddressesResource, c.ClusterPath, name, opts), &networkingv1alpha1.IPAddress{}) - return err -} - -func (c *iPAddressesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(iPAddressesResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &networkingv1alpha1.IPAddressList{}) - return err -} - -func (c *iPAddressesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*networkingv1alpha1.IPAddress, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(iPAddressesResource, c.ClusterPath, name), &networkingv1alpha1.IPAddress{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1alpha1.IPAddress), err -} - -// List takes label and field selectors, and returns the list of IPAddresses that match those selectors. -func (c *iPAddressesClient) List(ctx context.Context, opts metav1.ListOptions) (*networkingv1alpha1.IPAddressList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(iPAddressesResource, iPAddressesKind, c.ClusterPath, opts), &networkingv1alpha1.IPAddressList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &networkingv1alpha1.IPAddressList{ListMeta: obj.(*networkingv1alpha1.IPAddressList).ListMeta} - for _, item := range obj.(*networkingv1alpha1.IPAddressList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *iPAddressesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(iPAddressesResource, c.ClusterPath, opts)) -} - -func (c *iPAddressesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*networkingv1alpha1.IPAddress, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(iPAddressesResource, c.ClusterPath, name, pt, data, subresources...), &networkingv1alpha1.IPAddress{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1alpha1.IPAddress), err -} - -func (c *iPAddressesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsnetworkingv1alpha1.IPAddressApplyConfiguration, opts metav1.ApplyOptions) (*networkingv1alpha1.IPAddress, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(iPAddressesResource, c.ClusterPath, *name, types.ApplyPatchType, data), &networkingv1alpha1.IPAddress{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1alpha1.IPAddress), err -} - -func (c *iPAddressesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsnetworkingv1alpha1.IPAddressApplyConfiguration, opts metav1.ApplyOptions) (*networkingv1alpha1.IPAddress, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(iPAddressesResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &networkingv1alpha1.IPAddress{}) - if obj == nil { - return nil, err +func newFakeIPAddressClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typednetworkingv1alpha1.IPAddressInterface { + return &iPAddressScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*networkingv1alpha1.IPAddress, *networkingv1alpha1.IPAddressList, *v1alpha1.IPAddressApplyConfiguration]( + fake, + clusterPath, + "", + networkingv1alpha1.SchemeGroupVersion.WithResource("ipaddresses"), + networkingv1alpha1.SchemeGroupVersion.WithKind("IPAddress"), + func() *networkingv1alpha1.IPAddress { return &networkingv1alpha1.IPAddress{} }, + func() *networkingv1alpha1.IPAddressList { return &networkingv1alpha1.IPAddressList{} }, + func(dst, src *networkingv1alpha1.IPAddressList) { dst.ListMeta = src.ListMeta }, + func(list *networkingv1alpha1.IPAddressList) []*networkingv1alpha1.IPAddress { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *networkingv1alpha1.IPAddressList, items []*networkingv1alpha1.IPAddress) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*networkingv1alpha1.IPAddress), err } diff --git a/kubernetes/typed/networking/v1alpha1/fake/networking_client.go b/kubernetes/typed/networking/v1alpha1/fake/networking_client.go index ca01f46fb..b7de2028a 100644 --- a/kubernetes/typed/networking/v1alpha1/fake/networking_client.go +++ b/kubernetes/typed/networking/v1alpha1/fake/networking_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" networkingv1alpha1 "k8s.io/client-go/kubernetes/typed/networking/v1alpha1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpnetworkingv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/networking/v1alpha1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -42,29 +42,29 @@ func (c *NetworkingV1alpha1ClusterClient) Cluster(clusterPath logicalcluster.Pat } func (c *NetworkingV1alpha1ClusterClient) IPAddresses() kcpnetworkingv1alpha1.IPAddressClusterInterface { - return &iPAddressesClusterClient{Fake: c.Fake} + return newFakeIPAddressClusterClient(c) } func (c *NetworkingV1alpha1ClusterClient) ServiceCIDRs() kcpnetworkingv1alpha1.ServiceCIDRClusterInterface { - return &serviceCIDRsClusterClient{Fake: c.Fake} + return newFakeServiceCIDRClusterClient(c) } -var _ networkingv1alpha1.NetworkingV1alpha1Interface = (*NetworkingV1alpha1Client)(nil) - type NetworkingV1alpha1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *NetworkingV1alpha1Client) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret -} - func (c *NetworkingV1alpha1Client) IPAddresses() networkingv1alpha1.IPAddressInterface { - return &iPAddressesClient{Fake: c.Fake, ClusterPath: c.ClusterPath} + return newFakeIPAddressClient(c.Fake, c.ClusterPath) } func (c *NetworkingV1alpha1Client) ServiceCIDRs() networkingv1alpha1.ServiceCIDRInterface { - return &serviceCIDRsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} + return newFakeServiceCIDRClient(c.Fake, c.ClusterPath) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *NetworkingV1alpha1Client) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret } diff --git a/kubernetes/typed/networking/v1alpha1/fake/servicecidr.go b/kubernetes/typed/networking/v1alpha1/fake/servicecidr.go index 867a5edb9..96d4a6e08 100644 --- a/kubernetes/typed/networking/v1alpha1/fake/servicecidr.go +++ b/kubernetes/typed/networking/v1alpha1/fake/servicecidr.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" networkingv1alpha1 "k8s.io/api/networking/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsnetworkingv1alpha1 "k8s.io/client-go/applyconfigurations/networking/v1alpha1" - networkingv1alpha1client "k8s.io/client-go/kubernetes/typed/networking/v1alpha1" - "k8s.io/client-go/testing" + v1alpha1 "k8s.io/client-go/applyconfigurations/networking/v1alpha1" + typednetworkingv1alpha1 "k8s.io/client-go/kubernetes/typed/networking/v1alpha1" + typedkcpnetworkingv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/networking/v1alpha1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var serviceCIDRsResource = schema.GroupVersionResource{Group: "networking.k8s.io", Version: "v1alpha1", Resource: "servicecidrs"} -var serviceCIDRsKind = schema.GroupVersionKind{Group: "networking.k8s.io", Version: "v1alpha1", Kind: "ServiceCIDR"} - -type serviceCIDRsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *serviceCIDRsClusterClient) Cluster(clusterPath logicalcluster.Path) networkingv1alpha1client.ServiceCIDRInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &serviceCIDRsClient{Fake: c.Fake, ClusterPath: clusterPath} +// serviceCIDRClusterClient implements ServiceCIDRClusterInterface +type serviceCIDRClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*networkingv1alpha1.ServiceCIDR, *networkingv1alpha1.ServiceCIDRList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of ServiceCIDRs that match those selectors across all clusters. -func (c *serviceCIDRsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*networkingv1alpha1.ServiceCIDRList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(serviceCIDRsResource, serviceCIDRsKind, logicalcluster.Wildcard, opts), &networkingv1alpha1.ServiceCIDRList{}) - if obj == nil { - return nil, err +func newFakeServiceCIDRClusterClient(fake *NetworkingV1alpha1ClusterClient) typedkcpnetworkingv1alpha1.ServiceCIDRClusterInterface { + return &serviceCIDRClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*networkingv1alpha1.ServiceCIDR, *networkingv1alpha1.ServiceCIDRList]( + fake.Fake, + networkingv1alpha1.SchemeGroupVersion.WithResource("servicecidrs"), + networkingv1alpha1.SchemeGroupVersion.WithKind("ServiceCIDR"), + func() *networkingv1alpha1.ServiceCIDR { return &networkingv1alpha1.ServiceCIDR{} }, + func() *networkingv1alpha1.ServiceCIDRList { return &networkingv1alpha1.ServiceCIDRList{} }, + func(dst, src *networkingv1alpha1.ServiceCIDRList) { dst.ListMeta = src.ListMeta }, + func(list *networkingv1alpha1.ServiceCIDRList) []*networkingv1alpha1.ServiceCIDR { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *networkingv1alpha1.ServiceCIDRList, items []*networkingv1alpha1.ServiceCIDR) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &networkingv1alpha1.ServiceCIDRList{ListMeta: obj.(*networkingv1alpha1.ServiceCIDRList).ListMeta} - for _, item := range obj.(*networkingv1alpha1.ServiceCIDRList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested ServiceCIDRs across all clusters. -func (c *serviceCIDRsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(serviceCIDRsResource, logicalcluster.Wildcard, opts)) +func (c *serviceCIDRClusterClient) Cluster(cluster logicalcluster.Path) typednetworkingv1alpha1.ServiceCIDRInterface { + return newFakeServiceCIDRClient(c.Fake, cluster) } -type serviceCIDRsClient struct { - *kcptesting.Fake +// serviceCIDRScopedClient implements ServiceCIDRInterface +type serviceCIDRScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*networkingv1alpha1.ServiceCIDR, *networkingv1alpha1.ServiceCIDRList, *v1alpha1.ServiceCIDRApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *serviceCIDRsClient) Create(ctx context.Context, serviceCIDR *networkingv1alpha1.ServiceCIDR, opts metav1.CreateOptions) (*networkingv1alpha1.ServiceCIDR, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(serviceCIDRsResource, c.ClusterPath, serviceCIDR), &networkingv1alpha1.ServiceCIDR{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1alpha1.ServiceCIDR), err -} - -func (c *serviceCIDRsClient) Update(ctx context.Context, serviceCIDR *networkingv1alpha1.ServiceCIDR, opts metav1.UpdateOptions) (*networkingv1alpha1.ServiceCIDR, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(serviceCIDRsResource, c.ClusterPath, serviceCIDR), &networkingv1alpha1.ServiceCIDR{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1alpha1.ServiceCIDR), err -} - -func (c *serviceCIDRsClient) UpdateStatus(ctx context.Context, serviceCIDR *networkingv1alpha1.ServiceCIDR, opts metav1.UpdateOptions) (*networkingv1alpha1.ServiceCIDR, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(serviceCIDRsResource, c.ClusterPath, "status", serviceCIDR), &networkingv1alpha1.ServiceCIDR{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1alpha1.ServiceCIDR), err -} - -func (c *serviceCIDRsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(serviceCIDRsResource, c.ClusterPath, name, opts), &networkingv1alpha1.ServiceCIDR{}) - return err -} - -func (c *serviceCIDRsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(serviceCIDRsResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &networkingv1alpha1.ServiceCIDRList{}) - return err -} - -func (c *serviceCIDRsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*networkingv1alpha1.ServiceCIDR, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(serviceCIDRsResource, c.ClusterPath, name), &networkingv1alpha1.ServiceCIDR{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1alpha1.ServiceCIDR), err -} - -// List takes label and field selectors, and returns the list of ServiceCIDRs that match those selectors. -func (c *serviceCIDRsClient) List(ctx context.Context, opts metav1.ListOptions) (*networkingv1alpha1.ServiceCIDRList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(serviceCIDRsResource, serviceCIDRsKind, c.ClusterPath, opts), &networkingv1alpha1.ServiceCIDRList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &networkingv1alpha1.ServiceCIDRList{ListMeta: obj.(*networkingv1alpha1.ServiceCIDRList).ListMeta} - for _, item := range obj.(*networkingv1alpha1.ServiceCIDRList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *serviceCIDRsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(serviceCIDRsResource, c.ClusterPath, opts)) -} - -func (c *serviceCIDRsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*networkingv1alpha1.ServiceCIDR, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(serviceCIDRsResource, c.ClusterPath, name, pt, data, subresources...), &networkingv1alpha1.ServiceCIDR{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1alpha1.ServiceCIDR), err -} - -func (c *serviceCIDRsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsnetworkingv1alpha1.ServiceCIDRApplyConfiguration, opts metav1.ApplyOptions) (*networkingv1alpha1.ServiceCIDR, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(serviceCIDRsResource, c.ClusterPath, *name, types.ApplyPatchType, data), &networkingv1alpha1.ServiceCIDR{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1alpha1.ServiceCIDR), err -} - -func (c *serviceCIDRsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsnetworkingv1alpha1.ServiceCIDRApplyConfiguration, opts metav1.ApplyOptions) (*networkingv1alpha1.ServiceCIDR, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(serviceCIDRsResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &networkingv1alpha1.ServiceCIDR{}) - if obj == nil { - return nil, err +func newFakeServiceCIDRClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typednetworkingv1alpha1.ServiceCIDRInterface { + return &serviceCIDRScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*networkingv1alpha1.ServiceCIDR, *networkingv1alpha1.ServiceCIDRList, *v1alpha1.ServiceCIDRApplyConfiguration]( + fake, + clusterPath, + "", + networkingv1alpha1.SchemeGroupVersion.WithResource("servicecidrs"), + networkingv1alpha1.SchemeGroupVersion.WithKind("ServiceCIDR"), + func() *networkingv1alpha1.ServiceCIDR { return &networkingv1alpha1.ServiceCIDR{} }, + func() *networkingv1alpha1.ServiceCIDRList { return &networkingv1alpha1.ServiceCIDRList{} }, + func(dst, src *networkingv1alpha1.ServiceCIDRList) { dst.ListMeta = src.ListMeta }, + func(list *networkingv1alpha1.ServiceCIDRList) []*networkingv1alpha1.ServiceCIDR { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *networkingv1alpha1.ServiceCIDRList, items []*networkingv1alpha1.ServiceCIDR) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*networkingv1alpha1.ServiceCIDR), err } diff --git a/kubernetes/typed/networking/v1alpha1/generated_expansion.go b/kubernetes/typed/networking/v1alpha1/generated_expansion.go new file mode 100644 index 000000000..2c80d7e71 --- /dev/null +++ b/kubernetes/typed/networking/v1alpha1/generated_expansion.go @@ -0,0 +1,23 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1alpha1 + +type IPAddressClusterExpansion interface{} + +type ServiceCIDRClusterExpansion interface{} diff --git a/kubernetes/typed/networking/v1alpha1/ipaddress.go b/kubernetes/typed/networking/v1alpha1/ipaddress.go index a6ec58bfa..9dbf9723c 100644 --- a/kubernetes/typed/networking/v1alpha1/ipaddress.go +++ b/kubernetes/typed/networking/v1alpha1/ipaddress.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - networkingv1alpha1 "k8s.io/api/networking/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - networkingv1alpha1client "k8s.io/client-go/kubernetes/typed/networking/v1alpha1" + apinetworkingv1alpha1 "k8s.io/api/networking/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + networkingv1alpha1 "k8s.io/client-go/kubernetes/typed/networking/v1alpha1" ) // IPAddressesClusterGetter has a method to return a IPAddressClusterInterface. @@ -37,19 +37,20 @@ type IPAddressesClusterGetter interface { } // IPAddressClusterInterface can operate on IPAddresses across all clusters, -// or scope down to one cluster and return a networkingv1alpha1client.IPAddressInterface. +// or scope down to one cluster and return a networkingv1alpha1.IPAddressInterface. type IPAddressClusterInterface interface { - Cluster(logicalcluster.Path) networkingv1alpha1client.IPAddressInterface - List(ctx context.Context, opts metav1.ListOptions) (*networkingv1alpha1.IPAddressList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) networkingv1alpha1.IPAddressInterface + List(ctx context.Context, opts v1.ListOptions) (*apinetworkingv1alpha1.IPAddressList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + IPAddressClusterExpansion } type iPAddressesClusterInterface struct { - clientCache kcpclient.Cache[*networkingv1alpha1client.NetworkingV1alpha1Client] + clientCache kcpclient.Cache[*networkingv1alpha1.NetworkingV1alpha1Client] } // Cluster scopes the client down to a particular cluster. -func (c *iPAddressesClusterInterface) Cluster(clusterPath logicalcluster.Path) networkingv1alpha1client.IPAddressInterface { +func (c *iPAddressesClusterInterface) Cluster(clusterPath logicalcluster.Path) networkingv1alpha1.IPAddressInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *iPAddressesClusterInterface) Cluster(clusterPath logicalcluster.Path) n } // List returns the entire collection of all IPAddresses across all clusters. -func (c *iPAddressesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*networkingv1alpha1.IPAddressList, error) { +func (c *iPAddressesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apinetworkingv1alpha1.IPAddressList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).IPAddresses().List(ctx, opts) } // Watch begins to watch all IPAddresses across all clusters. -func (c *iPAddressesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *iPAddressesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).IPAddresses().Watch(ctx, opts) } diff --git a/kubernetes/typed/networking/v1alpha1/networking_client.go b/kubernetes/typed/networking/v1alpha1/networking_client.go index 05b09739e..f21b8e2a0 100644 --- a/kubernetes/typed/networking/v1alpha1/networking_client.go +++ b/kubernetes/typed/networking/v1alpha1/networking_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apinetworkingv1alpha1 "k8s.io/api/networking/v1alpha1" networkingv1alpha1 "k8s.io/client-go/kubernetes/typed/networking/v1alpha1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type NetworkingV1alpha1ClusterInterface interface { @@ -38,6 +41,7 @@ type NetworkingV1alpha1ClusterScoper interface { Cluster(logicalcluster.Path) networkingv1alpha1.NetworkingV1alpha1Interface } +// NetworkingV1alpha1ClusterClient is used to interact with features provided by the networking.k8s.io group. type NetworkingV1alpha1ClusterClient struct { clientCache kcpclient.Cache[*networkingv1alpha1.NetworkingV1alpha1Client] } @@ -61,11 +65,13 @@ func (c *NetworkingV1alpha1ClusterClient) ServiceCIDRs() ServiceCIDRClusterInter // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*NetworkingV1alpha1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new NetworkingV1alpha1ClusterClient for the given config and http client. @@ -77,6 +83,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*NetworkingV1alpha1C if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &NetworkingV1alpha1ClusterClient{clientCache: cache}, nil } @@ -89,3 +96,14 @@ func NewForConfigOrDie(c *rest.Config) *NetworkingV1alpha1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apinetworkingv1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/networking/v1alpha1/servicecidr.go b/kubernetes/typed/networking/v1alpha1/servicecidr.go index 149b89c98..100dd6ff8 100644 --- a/kubernetes/typed/networking/v1alpha1/servicecidr.go +++ b/kubernetes/typed/networking/v1alpha1/servicecidr.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - networkingv1alpha1 "k8s.io/api/networking/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - networkingv1alpha1client "k8s.io/client-go/kubernetes/typed/networking/v1alpha1" + apinetworkingv1alpha1 "k8s.io/api/networking/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + networkingv1alpha1 "k8s.io/client-go/kubernetes/typed/networking/v1alpha1" ) // ServiceCIDRsClusterGetter has a method to return a ServiceCIDRClusterInterface. @@ -37,19 +37,20 @@ type ServiceCIDRsClusterGetter interface { } // ServiceCIDRClusterInterface can operate on ServiceCIDRs across all clusters, -// or scope down to one cluster and return a networkingv1alpha1client.ServiceCIDRInterface. +// or scope down to one cluster and return a networkingv1alpha1.ServiceCIDRInterface. type ServiceCIDRClusterInterface interface { - Cluster(logicalcluster.Path) networkingv1alpha1client.ServiceCIDRInterface - List(ctx context.Context, opts metav1.ListOptions) (*networkingv1alpha1.ServiceCIDRList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) networkingv1alpha1.ServiceCIDRInterface + List(ctx context.Context, opts v1.ListOptions) (*apinetworkingv1alpha1.ServiceCIDRList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + ServiceCIDRClusterExpansion } type serviceCIDRsClusterInterface struct { - clientCache kcpclient.Cache[*networkingv1alpha1client.NetworkingV1alpha1Client] + clientCache kcpclient.Cache[*networkingv1alpha1.NetworkingV1alpha1Client] } // Cluster scopes the client down to a particular cluster. -func (c *serviceCIDRsClusterInterface) Cluster(clusterPath logicalcluster.Path) networkingv1alpha1client.ServiceCIDRInterface { +func (c *serviceCIDRsClusterInterface) Cluster(clusterPath logicalcluster.Path) networkingv1alpha1.ServiceCIDRInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *serviceCIDRsClusterInterface) Cluster(clusterPath logicalcluster.Path) } // List returns the entire collection of all ServiceCIDRs across all clusters. -func (c *serviceCIDRsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*networkingv1alpha1.ServiceCIDRList, error) { +func (c *serviceCIDRsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apinetworkingv1alpha1.ServiceCIDRList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ServiceCIDRs().List(ctx, opts) } // Watch begins to watch all ServiceCIDRs across all clusters. -func (c *serviceCIDRsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *serviceCIDRsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ServiceCIDRs().Watch(ctx, opts) } diff --git a/kubernetes/typed/networking/v1beta1/doc.go b/kubernetes/typed/networking/v1beta1/doc.go new file mode 100644 index 000000000..541e9d258 --- /dev/null +++ b/kubernetes/typed/networking/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1beta1 diff --git a/kubernetes/typed/networking/v1beta1/fake/doc.go b/kubernetes/typed/networking/v1beta1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/networking/v1beta1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/networking/v1beta1/fake/ingress.go b/kubernetes/typed/networking/v1beta1/fake/ingress.go index 8366c5d9d..192499051 100644 --- a/kubernetes/typed/networking/v1beta1/fake/ingress.go +++ b/kubernetes/typed/networking/v1beta1/fake/ingress.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" networkingv1beta1 "k8s.io/api/networking/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsnetworkingv1beta1 "k8s.io/client-go/applyconfigurations/networking/v1beta1" - networkingv1beta1client "k8s.io/client-go/kubernetes/typed/networking/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/networking/v1beta1" + typednetworkingv1beta1 "k8s.io/client-go/kubernetes/typed/networking/v1beta1" - kcpnetworkingv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/networking/v1beta1" + typedkcpnetworkingv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/networking/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var ingressesResource = schema.GroupVersionResource{Group: "networking.k8s.io", Version: "v1beta1", Resource: "ingresses"} -var ingressesKind = schema.GroupVersionKind{Group: "networking.k8s.io", Version: "v1beta1", Kind: "Ingress"} - -type ingressesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *ingressesClusterClient) Cluster(clusterPath logicalcluster.Path) kcpnetworkingv1beta1.IngressesNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &ingressesNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// ingressClusterClient implements IngressClusterInterface +type ingressClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*networkingv1beta1.Ingress, *networkingv1beta1.IngressList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of Ingresses that match those selectors across all clusters. -func (c *ingressesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*networkingv1beta1.IngressList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(ingressesResource, ingressesKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &networkingv1beta1.IngressList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeIngressClusterClient(fake *NetworkingV1beta1ClusterClient) typedkcpnetworkingv1beta1.IngressClusterInterface { + return &ingressClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*networkingv1beta1.Ingress, *networkingv1beta1.IngressList]( + fake.Fake, + networkingv1beta1.SchemeGroupVersion.WithResource("ingresses"), + networkingv1beta1.SchemeGroupVersion.WithKind("Ingress"), + func() *networkingv1beta1.Ingress { return &networkingv1beta1.Ingress{} }, + func() *networkingv1beta1.IngressList { return &networkingv1beta1.IngressList{} }, + func(dst, src *networkingv1beta1.IngressList) { dst.ListMeta = src.ListMeta }, + func(list *networkingv1beta1.IngressList) []*networkingv1beta1.Ingress { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *networkingv1beta1.IngressList, items []*networkingv1beta1.Ingress) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &networkingv1beta1.IngressList{ListMeta: obj.(*networkingv1beta1.IngressList).ListMeta} - for _, item := range obj.(*networkingv1beta1.IngressList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested Ingresses across all clusters. -func (c *ingressesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(ingressesResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *ingressClusterClient) Cluster(cluster logicalcluster.Path) typedkcpnetworkingv1beta1.IngressesNamespacer { + return &ingressNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type ingressesNamespacer struct { +type ingressNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *ingressesNamespacer) Namespace(namespace string) networkingv1beta1client.IngressInterface { - return &ingressesClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *ingressNamespacer) Namespace(namespace string) typednetworkingv1beta1.IngressInterface { + return newFakeIngressClient(n.Fake, namespace, n.ClusterPath) } -type ingressesClient struct { - *kcptesting.Fake +// ingressScopedClient implements IngressInterface +type ingressScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*networkingv1beta1.Ingress, *networkingv1beta1.IngressList, *v1beta1.IngressApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *ingressesClient) Create(ctx context.Context, ingress *networkingv1beta1.Ingress, opts metav1.CreateOptions) (*networkingv1beta1.Ingress, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(ingressesResource, c.ClusterPath, c.Namespace, ingress), &networkingv1beta1.Ingress{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1beta1.Ingress), err -} - -func (c *ingressesClient) Update(ctx context.Context, ingress *networkingv1beta1.Ingress, opts metav1.UpdateOptions) (*networkingv1beta1.Ingress, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(ingressesResource, c.ClusterPath, c.Namespace, ingress), &networkingv1beta1.Ingress{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1beta1.Ingress), err -} - -func (c *ingressesClient) UpdateStatus(ctx context.Context, ingress *networkingv1beta1.Ingress, opts metav1.UpdateOptions) (*networkingv1beta1.Ingress, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(ingressesResource, c.ClusterPath, "status", c.Namespace, ingress), &networkingv1beta1.Ingress{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1beta1.Ingress), err -} - -func (c *ingressesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(ingressesResource, c.ClusterPath, c.Namespace, name, opts), &networkingv1beta1.Ingress{}) - return err -} - -func (c *ingressesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(ingressesResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &networkingv1beta1.IngressList{}) - return err -} - -func (c *ingressesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*networkingv1beta1.Ingress, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(ingressesResource, c.ClusterPath, c.Namespace, name), &networkingv1beta1.Ingress{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1beta1.Ingress), err -} - -// List takes label and field selectors, and returns the list of Ingresses that match those selectors. -func (c *ingressesClient) List(ctx context.Context, opts metav1.ListOptions) (*networkingv1beta1.IngressList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(ingressesResource, ingressesKind, c.ClusterPath, c.Namespace, opts), &networkingv1beta1.IngressList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &networkingv1beta1.IngressList{ListMeta: obj.(*networkingv1beta1.IngressList).ListMeta} - for _, item := range obj.(*networkingv1beta1.IngressList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *ingressesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(ingressesResource, c.ClusterPath, c.Namespace, opts)) } -func (c *ingressesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*networkingv1beta1.Ingress, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(ingressesResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &networkingv1beta1.Ingress{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1beta1.Ingress), err -} - -func (c *ingressesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsnetworkingv1beta1.IngressApplyConfiguration, opts metav1.ApplyOptions) (*networkingv1beta1.Ingress, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(ingressesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &networkingv1beta1.Ingress{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1beta1.Ingress), err -} - -func (c *ingressesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsnetworkingv1beta1.IngressApplyConfiguration, opts metav1.ApplyOptions) (*networkingv1beta1.Ingress, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(ingressesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &networkingv1beta1.Ingress{}) - if obj == nil { - return nil, err +func newFakeIngressClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typednetworkingv1beta1.IngressInterface { + return &ingressScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*networkingv1beta1.Ingress, *networkingv1beta1.IngressList, *v1beta1.IngressApplyConfiguration]( + fake, + clusterPath, + namespace, + networkingv1beta1.SchemeGroupVersion.WithResource("ingresses"), + networkingv1beta1.SchemeGroupVersion.WithKind("Ingress"), + func() *networkingv1beta1.Ingress { return &networkingv1beta1.Ingress{} }, + func() *networkingv1beta1.IngressList { return &networkingv1beta1.IngressList{} }, + func(dst, src *networkingv1beta1.IngressList) { dst.ListMeta = src.ListMeta }, + func(list *networkingv1beta1.IngressList) []*networkingv1beta1.Ingress { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *networkingv1beta1.IngressList, items []*networkingv1beta1.Ingress) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*networkingv1beta1.Ingress), err } diff --git a/kubernetes/typed/networking/v1beta1/fake/ingressclass.go b/kubernetes/typed/networking/v1beta1/fake/ingressclass.go index 6420c3d63..f13f08739 100644 --- a/kubernetes/typed/networking/v1beta1/fake/ingressclass.go +++ b/kubernetes/typed/networking/v1beta1/fake/ingressclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" networkingv1beta1 "k8s.io/api/networking/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsnetworkingv1beta1 "k8s.io/client-go/applyconfigurations/networking/v1beta1" - networkingv1beta1client "k8s.io/client-go/kubernetes/typed/networking/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/networking/v1beta1" + typednetworkingv1beta1 "k8s.io/client-go/kubernetes/typed/networking/v1beta1" + typedkcpnetworkingv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/networking/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var ingressClassesResource = schema.GroupVersionResource{Group: "networking.k8s.io", Version: "v1beta1", Resource: "ingressclasses"} -var ingressClassesKind = schema.GroupVersionKind{Group: "networking.k8s.io", Version: "v1beta1", Kind: "IngressClass"} - -type ingressClassesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *ingressClassesClusterClient) Cluster(clusterPath logicalcluster.Path) networkingv1beta1client.IngressClassInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &ingressClassesClient{Fake: c.Fake, ClusterPath: clusterPath} +// ingressClassClusterClient implements IngressClassClusterInterface +type ingressClassClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*networkingv1beta1.IngressClass, *networkingv1beta1.IngressClassList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of IngressClasses that match those selectors across all clusters. -func (c *ingressClassesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*networkingv1beta1.IngressClassList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(ingressClassesResource, ingressClassesKind, logicalcluster.Wildcard, opts), &networkingv1beta1.IngressClassList{}) - if obj == nil { - return nil, err +func newFakeIngressClassClusterClient(fake *NetworkingV1beta1ClusterClient) typedkcpnetworkingv1beta1.IngressClassClusterInterface { + return &ingressClassClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*networkingv1beta1.IngressClass, *networkingv1beta1.IngressClassList]( + fake.Fake, + networkingv1beta1.SchemeGroupVersion.WithResource("ingressclasses"), + networkingv1beta1.SchemeGroupVersion.WithKind("IngressClass"), + func() *networkingv1beta1.IngressClass { return &networkingv1beta1.IngressClass{} }, + func() *networkingv1beta1.IngressClassList { return &networkingv1beta1.IngressClassList{} }, + func(dst, src *networkingv1beta1.IngressClassList) { dst.ListMeta = src.ListMeta }, + func(list *networkingv1beta1.IngressClassList) []*networkingv1beta1.IngressClass { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *networkingv1beta1.IngressClassList, items []*networkingv1beta1.IngressClass) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &networkingv1beta1.IngressClassList{ListMeta: obj.(*networkingv1beta1.IngressClassList).ListMeta} - for _, item := range obj.(*networkingv1beta1.IngressClassList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested IngressClasses across all clusters. -func (c *ingressClassesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(ingressClassesResource, logicalcluster.Wildcard, opts)) +func (c *ingressClassClusterClient) Cluster(cluster logicalcluster.Path) typednetworkingv1beta1.IngressClassInterface { + return newFakeIngressClassClient(c.Fake, cluster) } -type ingressClassesClient struct { - *kcptesting.Fake +// ingressClassScopedClient implements IngressClassInterface +type ingressClassScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*networkingv1beta1.IngressClass, *networkingv1beta1.IngressClassList, *v1beta1.IngressClassApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *ingressClassesClient) Create(ctx context.Context, ingressClass *networkingv1beta1.IngressClass, opts metav1.CreateOptions) (*networkingv1beta1.IngressClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(ingressClassesResource, c.ClusterPath, ingressClass), &networkingv1beta1.IngressClass{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1beta1.IngressClass), err -} - -func (c *ingressClassesClient) Update(ctx context.Context, ingressClass *networkingv1beta1.IngressClass, opts metav1.UpdateOptions) (*networkingv1beta1.IngressClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(ingressClassesResource, c.ClusterPath, ingressClass), &networkingv1beta1.IngressClass{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1beta1.IngressClass), err -} - -func (c *ingressClassesClient) UpdateStatus(ctx context.Context, ingressClass *networkingv1beta1.IngressClass, opts metav1.UpdateOptions) (*networkingv1beta1.IngressClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(ingressClassesResource, c.ClusterPath, "status", ingressClass), &networkingv1beta1.IngressClass{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1beta1.IngressClass), err -} - -func (c *ingressClassesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(ingressClassesResource, c.ClusterPath, name, opts), &networkingv1beta1.IngressClass{}) - return err -} - -func (c *ingressClassesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(ingressClassesResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &networkingv1beta1.IngressClassList{}) - return err -} - -func (c *ingressClassesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*networkingv1beta1.IngressClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(ingressClassesResource, c.ClusterPath, name), &networkingv1beta1.IngressClass{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1beta1.IngressClass), err -} - -// List takes label and field selectors, and returns the list of IngressClasses that match those selectors. -func (c *ingressClassesClient) List(ctx context.Context, opts metav1.ListOptions) (*networkingv1beta1.IngressClassList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(ingressClassesResource, ingressClassesKind, c.ClusterPath, opts), &networkingv1beta1.IngressClassList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &networkingv1beta1.IngressClassList{ListMeta: obj.(*networkingv1beta1.IngressClassList).ListMeta} - for _, item := range obj.(*networkingv1beta1.IngressClassList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *ingressClassesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(ingressClassesResource, c.ClusterPath, opts)) -} - -func (c *ingressClassesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*networkingv1beta1.IngressClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(ingressClassesResource, c.ClusterPath, name, pt, data, subresources...), &networkingv1beta1.IngressClass{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1beta1.IngressClass), err -} - -func (c *ingressClassesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsnetworkingv1beta1.IngressClassApplyConfiguration, opts metav1.ApplyOptions) (*networkingv1beta1.IngressClass, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(ingressClassesResource, c.ClusterPath, *name, types.ApplyPatchType, data), &networkingv1beta1.IngressClass{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1beta1.IngressClass), err -} - -func (c *ingressClassesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsnetworkingv1beta1.IngressClassApplyConfiguration, opts metav1.ApplyOptions) (*networkingv1beta1.IngressClass, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(ingressClassesResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &networkingv1beta1.IngressClass{}) - if obj == nil { - return nil, err +func newFakeIngressClassClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typednetworkingv1beta1.IngressClassInterface { + return &ingressClassScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*networkingv1beta1.IngressClass, *networkingv1beta1.IngressClassList, *v1beta1.IngressClassApplyConfiguration]( + fake, + clusterPath, + "", + networkingv1beta1.SchemeGroupVersion.WithResource("ingressclasses"), + networkingv1beta1.SchemeGroupVersion.WithKind("IngressClass"), + func() *networkingv1beta1.IngressClass { return &networkingv1beta1.IngressClass{} }, + func() *networkingv1beta1.IngressClassList { return &networkingv1beta1.IngressClassList{} }, + func(dst, src *networkingv1beta1.IngressClassList) { dst.ListMeta = src.ListMeta }, + func(list *networkingv1beta1.IngressClassList) []*networkingv1beta1.IngressClass { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *networkingv1beta1.IngressClassList, items []*networkingv1beta1.IngressClass) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*networkingv1beta1.IngressClass), err } diff --git a/kubernetes/typed/networking/v1beta1/fake/ipaddress.go b/kubernetes/typed/networking/v1beta1/fake/ipaddress.go index aa8e14fca..2b0bddbe3 100644 --- a/kubernetes/typed/networking/v1beta1/fake/ipaddress.go +++ b/kubernetes/typed/networking/v1beta1/fake/ipaddress.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" networkingv1beta1 "k8s.io/api/networking/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsnetworkingv1beta1 "k8s.io/client-go/applyconfigurations/networking/v1beta1" - networkingv1beta1client "k8s.io/client-go/kubernetes/typed/networking/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/networking/v1beta1" + typednetworkingv1beta1 "k8s.io/client-go/kubernetes/typed/networking/v1beta1" + typedkcpnetworkingv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/networking/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var iPAddressesResource = schema.GroupVersionResource{Group: "networking.k8s.io", Version: "v1beta1", Resource: "ipaddresses"} -var iPAddressesKind = schema.GroupVersionKind{Group: "networking.k8s.io", Version: "v1beta1", Kind: "IPAddress"} - -type iPAddressesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *iPAddressesClusterClient) Cluster(clusterPath logicalcluster.Path) networkingv1beta1client.IPAddressInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &iPAddressesClient{Fake: c.Fake, ClusterPath: clusterPath} +// iPAddressClusterClient implements IPAddressClusterInterface +type iPAddressClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*networkingv1beta1.IPAddress, *networkingv1beta1.IPAddressList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of IPAddresses that match those selectors across all clusters. -func (c *iPAddressesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*networkingv1beta1.IPAddressList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(iPAddressesResource, iPAddressesKind, logicalcluster.Wildcard, opts), &networkingv1beta1.IPAddressList{}) - if obj == nil { - return nil, err +func newFakeIPAddressClusterClient(fake *NetworkingV1beta1ClusterClient) typedkcpnetworkingv1beta1.IPAddressClusterInterface { + return &iPAddressClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*networkingv1beta1.IPAddress, *networkingv1beta1.IPAddressList]( + fake.Fake, + networkingv1beta1.SchemeGroupVersion.WithResource("ipaddresses"), + networkingv1beta1.SchemeGroupVersion.WithKind("IPAddress"), + func() *networkingv1beta1.IPAddress { return &networkingv1beta1.IPAddress{} }, + func() *networkingv1beta1.IPAddressList { return &networkingv1beta1.IPAddressList{} }, + func(dst, src *networkingv1beta1.IPAddressList) { dst.ListMeta = src.ListMeta }, + func(list *networkingv1beta1.IPAddressList) []*networkingv1beta1.IPAddress { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *networkingv1beta1.IPAddressList, items []*networkingv1beta1.IPAddress) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &networkingv1beta1.IPAddressList{ListMeta: obj.(*networkingv1beta1.IPAddressList).ListMeta} - for _, item := range obj.(*networkingv1beta1.IPAddressList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested IPAddresses across all clusters. -func (c *iPAddressesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(iPAddressesResource, logicalcluster.Wildcard, opts)) +func (c *iPAddressClusterClient) Cluster(cluster logicalcluster.Path) typednetworkingv1beta1.IPAddressInterface { + return newFakeIPAddressClient(c.Fake, cluster) } -type iPAddressesClient struct { - *kcptesting.Fake +// iPAddressScopedClient implements IPAddressInterface +type iPAddressScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*networkingv1beta1.IPAddress, *networkingv1beta1.IPAddressList, *v1beta1.IPAddressApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *iPAddressesClient) Create(ctx context.Context, iPAddress *networkingv1beta1.IPAddress, opts metav1.CreateOptions) (*networkingv1beta1.IPAddress, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(iPAddressesResource, c.ClusterPath, iPAddress), &networkingv1beta1.IPAddress{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1beta1.IPAddress), err -} - -func (c *iPAddressesClient) Update(ctx context.Context, iPAddress *networkingv1beta1.IPAddress, opts metav1.UpdateOptions) (*networkingv1beta1.IPAddress, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(iPAddressesResource, c.ClusterPath, iPAddress), &networkingv1beta1.IPAddress{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1beta1.IPAddress), err -} - -func (c *iPAddressesClient) UpdateStatus(ctx context.Context, iPAddress *networkingv1beta1.IPAddress, opts metav1.UpdateOptions) (*networkingv1beta1.IPAddress, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(iPAddressesResource, c.ClusterPath, "status", iPAddress), &networkingv1beta1.IPAddress{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1beta1.IPAddress), err -} - -func (c *iPAddressesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(iPAddressesResource, c.ClusterPath, name, opts), &networkingv1beta1.IPAddress{}) - return err -} - -func (c *iPAddressesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(iPAddressesResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &networkingv1beta1.IPAddressList{}) - return err -} - -func (c *iPAddressesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*networkingv1beta1.IPAddress, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(iPAddressesResource, c.ClusterPath, name), &networkingv1beta1.IPAddress{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1beta1.IPAddress), err -} - -// List takes label and field selectors, and returns the list of IPAddresses that match those selectors. -func (c *iPAddressesClient) List(ctx context.Context, opts metav1.ListOptions) (*networkingv1beta1.IPAddressList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(iPAddressesResource, iPAddressesKind, c.ClusterPath, opts), &networkingv1beta1.IPAddressList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &networkingv1beta1.IPAddressList{ListMeta: obj.(*networkingv1beta1.IPAddressList).ListMeta} - for _, item := range obj.(*networkingv1beta1.IPAddressList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *iPAddressesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(iPAddressesResource, c.ClusterPath, opts)) -} - -func (c *iPAddressesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*networkingv1beta1.IPAddress, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(iPAddressesResource, c.ClusterPath, name, pt, data, subresources...), &networkingv1beta1.IPAddress{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1beta1.IPAddress), err -} - -func (c *iPAddressesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsnetworkingv1beta1.IPAddressApplyConfiguration, opts metav1.ApplyOptions) (*networkingv1beta1.IPAddress, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(iPAddressesResource, c.ClusterPath, *name, types.ApplyPatchType, data), &networkingv1beta1.IPAddress{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1beta1.IPAddress), err -} - -func (c *iPAddressesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsnetworkingv1beta1.IPAddressApplyConfiguration, opts metav1.ApplyOptions) (*networkingv1beta1.IPAddress, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(iPAddressesResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &networkingv1beta1.IPAddress{}) - if obj == nil { - return nil, err +func newFakeIPAddressClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typednetworkingv1beta1.IPAddressInterface { + return &iPAddressScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*networkingv1beta1.IPAddress, *networkingv1beta1.IPAddressList, *v1beta1.IPAddressApplyConfiguration]( + fake, + clusterPath, + "", + networkingv1beta1.SchemeGroupVersion.WithResource("ipaddresses"), + networkingv1beta1.SchemeGroupVersion.WithKind("IPAddress"), + func() *networkingv1beta1.IPAddress { return &networkingv1beta1.IPAddress{} }, + func() *networkingv1beta1.IPAddressList { return &networkingv1beta1.IPAddressList{} }, + func(dst, src *networkingv1beta1.IPAddressList) { dst.ListMeta = src.ListMeta }, + func(list *networkingv1beta1.IPAddressList) []*networkingv1beta1.IPAddress { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *networkingv1beta1.IPAddressList, items []*networkingv1beta1.IPAddress) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*networkingv1beta1.IPAddress), err } diff --git a/kubernetes/typed/networking/v1beta1/fake/networking_client.go b/kubernetes/typed/networking/v1beta1/fake/networking_client.go index 578d7761d..20c53d1df 100644 --- a/kubernetes/typed/networking/v1beta1/fake/networking_client.go +++ b/kubernetes/typed/networking/v1beta1/fake/networking_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" networkingv1beta1 "k8s.io/client-go/kubernetes/typed/networking/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpnetworkingv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/networking/v1beta1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -41,46 +41,46 @@ func (c *NetworkingV1beta1ClusterClient) Cluster(clusterPath logicalcluster.Path return &NetworkingV1beta1Client{Fake: c.Fake, ClusterPath: clusterPath} } -func (c *NetworkingV1beta1ClusterClient) Ingresses() kcpnetworkingv1beta1.IngressClusterInterface { - return &ingressesClusterClient{Fake: c.Fake} +func (c *NetworkingV1beta1ClusterClient) IPAddresses() kcpnetworkingv1beta1.IPAddressClusterInterface { + return newFakeIPAddressClusterClient(c) } -func (c *NetworkingV1beta1ClusterClient) IngressClasses() kcpnetworkingv1beta1.IngressClassClusterInterface { - return &ingressClassesClusterClient{Fake: c.Fake} +func (c *NetworkingV1beta1ClusterClient) Ingresses() kcpnetworkingv1beta1.IngressClusterInterface { + return newFakeIngressClusterClient(c) } -func (c *NetworkingV1beta1ClusterClient) IPAddresses() kcpnetworkingv1beta1.IPAddressClusterInterface { - return &iPAddressesClusterClient{Fake: c.Fake} +func (c *NetworkingV1beta1ClusterClient) IngressClasses() kcpnetworkingv1beta1.IngressClassClusterInterface { + return newFakeIngressClassClusterClient(c) } func (c *NetworkingV1beta1ClusterClient) ServiceCIDRs() kcpnetworkingv1beta1.ServiceCIDRClusterInterface { - return &serviceCIDRsClusterClient{Fake: c.Fake} + return newFakeServiceCIDRClusterClient(c) } -var _ networkingv1beta1.NetworkingV1beta1Interface = (*NetworkingV1beta1Client)(nil) - type NetworkingV1beta1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *NetworkingV1beta1Client) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret +func (c *NetworkingV1beta1Client) IPAddresses() networkingv1beta1.IPAddressInterface { + return newFakeIPAddressClient(c.Fake, c.ClusterPath) } func (c *NetworkingV1beta1Client) Ingresses(namespace string) networkingv1beta1.IngressInterface { - return &ingressesClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} + return newFakeIngressClient(c.Fake, namespace, c.ClusterPath) } func (c *NetworkingV1beta1Client) IngressClasses() networkingv1beta1.IngressClassInterface { - return &ingressClassesClient{Fake: c.Fake, ClusterPath: c.ClusterPath} + return newFakeIngressClassClient(c.Fake, c.ClusterPath) } -func (c *NetworkingV1beta1Client) IPAddresses() networkingv1beta1.IPAddressInterface { - return &iPAddressesClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +func (c *NetworkingV1beta1Client) ServiceCIDRs() networkingv1beta1.ServiceCIDRInterface { + return newFakeServiceCIDRClient(c.Fake, c.ClusterPath) } -func (c *NetworkingV1beta1Client) ServiceCIDRs() networkingv1beta1.ServiceCIDRInterface { - return &serviceCIDRsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *NetworkingV1beta1Client) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret } diff --git a/kubernetes/typed/networking/v1beta1/fake/servicecidr.go b/kubernetes/typed/networking/v1beta1/fake/servicecidr.go index 2c86ebf60..319dab987 100644 --- a/kubernetes/typed/networking/v1beta1/fake/servicecidr.go +++ b/kubernetes/typed/networking/v1beta1/fake/servicecidr.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" networkingv1beta1 "k8s.io/api/networking/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsnetworkingv1beta1 "k8s.io/client-go/applyconfigurations/networking/v1beta1" - networkingv1beta1client "k8s.io/client-go/kubernetes/typed/networking/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/networking/v1beta1" + typednetworkingv1beta1 "k8s.io/client-go/kubernetes/typed/networking/v1beta1" + typedkcpnetworkingv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/networking/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var serviceCIDRsResource = schema.GroupVersionResource{Group: "networking.k8s.io", Version: "v1beta1", Resource: "servicecidrs"} -var serviceCIDRsKind = schema.GroupVersionKind{Group: "networking.k8s.io", Version: "v1beta1", Kind: "ServiceCIDR"} - -type serviceCIDRsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *serviceCIDRsClusterClient) Cluster(clusterPath logicalcluster.Path) networkingv1beta1client.ServiceCIDRInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &serviceCIDRsClient{Fake: c.Fake, ClusterPath: clusterPath} +// serviceCIDRClusterClient implements ServiceCIDRClusterInterface +type serviceCIDRClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*networkingv1beta1.ServiceCIDR, *networkingv1beta1.ServiceCIDRList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of ServiceCIDRs that match those selectors across all clusters. -func (c *serviceCIDRsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*networkingv1beta1.ServiceCIDRList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(serviceCIDRsResource, serviceCIDRsKind, logicalcluster.Wildcard, opts), &networkingv1beta1.ServiceCIDRList{}) - if obj == nil { - return nil, err +func newFakeServiceCIDRClusterClient(fake *NetworkingV1beta1ClusterClient) typedkcpnetworkingv1beta1.ServiceCIDRClusterInterface { + return &serviceCIDRClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*networkingv1beta1.ServiceCIDR, *networkingv1beta1.ServiceCIDRList]( + fake.Fake, + networkingv1beta1.SchemeGroupVersion.WithResource("servicecidrs"), + networkingv1beta1.SchemeGroupVersion.WithKind("ServiceCIDR"), + func() *networkingv1beta1.ServiceCIDR { return &networkingv1beta1.ServiceCIDR{} }, + func() *networkingv1beta1.ServiceCIDRList { return &networkingv1beta1.ServiceCIDRList{} }, + func(dst, src *networkingv1beta1.ServiceCIDRList) { dst.ListMeta = src.ListMeta }, + func(list *networkingv1beta1.ServiceCIDRList) []*networkingv1beta1.ServiceCIDR { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *networkingv1beta1.ServiceCIDRList, items []*networkingv1beta1.ServiceCIDR) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &networkingv1beta1.ServiceCIDRList{ListMeta: obj.(*networkingv1beta1.ServiceCIDRList).ListMeta} - for _, item := range obj.(*networkingv1beta1.ServiceCIDRList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested ServiceCIDRs across all clusters. -func (c *serviceCIDRsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(serviceCIDRsResource, logicalcluster.Wildcard, opts)) +func (c *serviceCIDRClusterClient) Cluster(cluster logicalcluster.Path) typednetworkingv1beta1.ServiceCIDRInterface { + return newFakeServiceCIDRClient(c.Fake, cluster) } -type serviceCIDRsClient struct { - *kcptesting.Fake +// serviceCIDRScopedClient implements ServiceCIDRInterface +type serviceCIDRScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*networkingv1beta1.ServiceCIDR, *networkingv1beta1.ServiceCIDRList, *v1beta1.ServiceCIDRApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *serviceCIDRsClient) Create(ctx context.Context, serviceCIDR *networkingv1beta1.ServiceCIDR, opts metav1.CreateOptions) (*networkingv1beta1.ServiceCIDR, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(serviceCIDRsResource, c.ClusterPath, serviceCIDR), &networkingv1beta1.ServiceCIDR{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1beta1.ServiceCIDR), err -} - -func (c *serviceCIDRsClient) Update(ctx context.Context, serviceCIDR *networkingv1beta1.ServiceCIDR, opts metav1.UpdateOptions) (*networkingv1beta1.ServiceCIDR, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(serviceCIDRsResource, c.ClusterPath, serviceCIDR), &networkingv1beta1.ServiceCIDR{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1beta1.ServiceCIDR), err -} - -func (c *serviceCIDRsClient) UpdateStatus(ctx context.Context, serviceCIDR *networkingv1beta1.ServiceCIDR, opts metav1.UpdateOptions) (*networkingv1beta1.ServiceCIDR, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(serviceCIDRsResource, c.ClusterPath, "status", serviceCIDR), &networkingv1beta1.ServiceCIDR{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1beta1.ServiceCIDR), err -} - -func (c *serviceCIDRsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(serviceCIDRsResource, c.ClusterPath, name, opts), &networkingv1beta1.ServiceCIDR{}) - return err -} - -func (c *serviceCIDRsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(serviceCIDRsResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &networkingv1beta1.ServiceCIDRList{}) - return err -} - -func (c *serviceCIDRsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*networkingv1beta1.ServiceCIDR, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(serviceCIDRsResource, c.ClusterPath, name), &networkingv1beta1.ServiceCIDR{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1beta1.ServiceCIDR), err -} - -// List takes label and field selectors, and returns the list of ServiceCIDRs that match those selectors. -func (c *serviceCIDRsClient) List(ctx context.Context, opts metav1.ListOptions) (*networkingv1beta1.ServiceCIDRList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(serviceCIDRsResource, serviceCIDRsKind, c.ClusterPath, opts), &networkingv1beta1.ServiceCIDRList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &networkingv1beta1.ServiceCIDRList{ListMeta: obj.(*networkingv1beta1.ServiceCIDRList).ListMeta} - for _, item := range obj.(*networkingv1beta1.ServiceCIDRList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *serviceCIDRsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(serviceCIDRsResource, c.ClusterPath, opts)) -} - -func (c *serviceCIDRsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*networkingv1beta1.ServiceCIDR, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(serviceCIDRsResource, c.ClusterPath, name, pt, data, subresources...), &networkingv1beta1.ServiceCIDR{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1beta1.ServiceCIDR), err -} - -func (c *serviceCIDRsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsnetworkingv1beta1.ServiceCIDRApplyConfiguration, opts metav1.ApplyOptions) (*networkingv1beta1.ServiceCIDR, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(serviceCIDRsResource, c.ClusterPath, *name, types.ApplyPatchType, data), &networkingv1beta1.ServiceCIDR{}) - if obj == nil { - return nil, err - } - return obj.(*networkingv1beta1.ServiceCIDR), err -} - -func (c *serviceCIDRsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsnetworkingv1beta1.ServiceCIDRApplyConfiguration, opts metav1.ApplyOptions) (*networkingv1beta1.ServiceCIDR, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(serviceCIDRsResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &networkingv1beta1.ServiceCIDR{}) - if obj == nil { - return nil, err +func newFakeServiceCIDRClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typednetworkingv1beta1.ServiceCIDRInterface { + return &serviceCIDRScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*networkingv1beta1.ServiceCIDR, *networkingv1beta1.ServiceCIDRList, *v1beta1.ServiceCIDRApplyConfiguration]( + fake, + clusterPath, + "", + networkingv1beta1.SchemeGroupVersion.WithResource("servicecidrs"), + networkingv1beta1.SchemeGroupVersion.WithKind("ServiceCIDR"), + func() *networkingv1beta1.ServiceCIDR { return &networkingv1beta1.ServiceCIDR{} }, + func() *networkingv1beta1.ServiceCIDRList { return &networkingv1beta1.ServiceCIDRList{} }, + func(dst, src *networkingv1beta1.ServiceCIDRList) { dst.ListMeta = src.ListMeta }, + func(list *networkingv1beta1.ServiceCIDRList) []*networkingv1beta1.ServiceCIDR { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *networkingv1beta1.ServiceCIDRList, items []*networkingv1beta1.ServiceCIDR) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*networkingv1beta1.ServiceCIDR), err } diff --git a/kubernetes/typed/networking/v1beta1/generated_expansion.go b/kubernetes/typed/networking/v1beta1/generated_expansion.go new file mode 100644 index 000000000..244d7979f --- /dev/null +++ b/kubernetes/typed/networking/v1beta1/generated_expansion.go @@ -0,0 +1,27 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1beta1 + +type IPAddressClusterExpansion interface{} + +type IngressClusterExpansion interface{} + +type IngressClassClusterExpansion interface{} + +type ServiceCIDRClusterExpansion interface{} diff --git a/kubernetes/typed/networking/v1beta1/ingress.go b/kubernetes/typed/networking/v1beta1/ingress.go index 85a2f5a31..0bea85ab0 100644 --- a/kubernetes/typed/networking/v1beta1/ingress.go +++ b/kubernetes/typed/networking/v1beta1/ingress.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" networkingv1beta1 "k8s.io/api/networking/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - networkingv1beta1client "k8s.io/client-go/kubernetes/typed/networking/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typednetworkingv1beta1 "k8s.io/client-go/kubernetes/typed/networking/v1beta1" ) // IngressesClusterGetter has a method to return a IngressClusterInterface. @@ -40,12 +40,13 @@ type IngressesClusterGetter interface { // or scope down to one cluster and return a IngressesNamespacer. type IngressClusterInterface interface { Cluster(logicalcluster.Path) IngressesNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*networkingv1beta1.IngressList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*networkingv1beta1.IngressList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + IngressClusterExpansion } type ingressesClusterInterface struct { - clientCache kcpclient.Cache[*networkingv1beta1client.NetworkingV1beta1Client] + clientCache kcpclient.Cache[*typednetworkingv1beta1.NetworkingV1beta1Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *ingressesClusterInterface) Cluster(clusterPath logicalcluster.Path) Ing } // List returns the entire collection of all Ingresses across all clusters. -func (c *ingressesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*networkingv1beta1.IngressList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Ingresses(metav1.NamespaceAll).List(ctx, opts) +func (c *ingressesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*networkingv1beta1.IngressList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Ingresses(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all Ingresses across all clusters. -func (c *ingressesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Ingresses(metav1.NamespaceAll).Watch(ctx, opts) +func (c *ingressesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Ingresses(v1.NamespaceAll).Watch(ctx, opts) } -// IngressesNamespacer can scope to objects within a namespace, returning a networkingv1beta1client.IngressInterface. +// IngressesNamespacer can scope to objects within a namespace, returning a typednetworkingv1beta1.IngressInterface. type IngressesNamespacer interface { - Namespace(string) networkingv1beta1client.IngressInterface + Namespace(string) typednetworkingv1beta1.IngressInterface } type ingressesNamespacer struct { - clientCache kcpclient.Cache[*networkingv1beta1client.NetworkingV1beta1Client] + clientCache kcpclient.Cache[*typednetworkingv1beta1.NetworkingV1beta1Client] clusterPath logicalcluster.Path } -func (n *ingressesNamespacer) Namespace(namespace string) networkingv1beta1client.IngressInterface { +func (n *ingressesNamespacer) Namespace(namespace string) typednetworkingv1beta1.IngressInterface { return n.clientCache.ClusterOrDie(n.clusterPath).Ingresses(namespace) } diff --git a/kubernetes/typed/networking/v1beta1/ingressclass.go b/kubernetes/typed/networking/v1beta1/ingressclass.go index b5f656419..b46ea854d 100644 --- a/kubernetes/typed/networking/v1beta1/ingressclass.go +++ b/kubernetes/typed/networking/v1beta1/ingressclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - networkingv1beta1 "k8s.io/api/networking/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - networkingv1beta1client "k8s.io/client-go/kubernetes/typed/networking/v1beta1" + apinetworkingv1beta1 "k8s.io/api/networking/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + networkingv1beta1 "k8s.io/client-go/kubernetes/typed/networking/v1beta1" ) // IngressClassesClusterGetter has a method to return a IngressClassClusterInterface. @@ -37,19 +37,20 @@ type IngressClassesClusterGetter interface { } // IngressClassClusterInterface can operate on IngressClasses across all clusters, -// or scope down to one cluster and return a networkingv1beta1client.IngressClassInterface. +// or scope down to one cluster and return a networkingv1beta1.IngressClassInterface. type IngressClassClusterInterface interface { - Cluster(logicalcluster.Path) networkingv1beta1client.IngressClassInterface - List(ctx context.Context, opts metav1.ListOptions) (*networkingv1beta1.IngressClassList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) networkingv1beta1.IngressClassInterface + List(ctx context.Context, opts v1.ListOptions) (*apinetworkingv1beta1.IngressClassList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + IngressClassClusterExpansion } type ingressClassesClusterInterface struct { - clientCache kcpclient.Cache[*networkingv1beta1client.NetworkingV1beta1Client] + clientCache kcpclient.Cache[*networkingv1beta1.NetworkingV1beta1Client] } // Cluster scopes the client down to a particular cluster. -func (c *ingressClassesClusterInterface) Cluster(clusterPath logicalcluster.Path) networkingv1beta1client.IngressClassInterface { +func (c *ingressClassesClusterInterface) Cluster(clusterPath logicalcluster.Path) networkingv1beta1.IngressClassInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *ingressClassesClusterInterface) Cluster(clusterPath logicalcluster.Path } // List returns the entire collection of all IngressClasses across all clusters. -func (c *ingressClassesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*networkingv1beta1.IngressClassList, error) { +func (c *ingressClassesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apinetworkingv1beta1.IngressClassList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).IngressClasses().List(ctx, opts) } // Watch begins to watch all IngressClasses across all clusters. -func (c *ingressClassesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *ingressClassesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).IngressClasses().Watch(ctx, opts) } diff --git a/kubernetes/typed/networking/v1beta1/ipaddress.go b/kubernetes/typed/networking/v1beta1/ipaddress.go index 5be7fcae6..1ec833037 100644 --- a/kubernetes/typed/networking/v1beta1/ipaddress.go +++ b/kubernetes/typed/networking/v1beta1/ipaddress.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - networkingv1beta1 "k8s.io/api/networking/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - networkingv1beta1client "k8s.io/client-go/kubernetes/typed/networking/v1beta1" + apinetworkingv1beta1 "k8s.io/api/networking/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + networkingv1beta1 "k8s.io/client-go/kubernetes/typed/networking/v1beta1" ) // IPAddressesClusterGetter has a method to return a IPAddressClusterInterface. @@ -37,19 +37,20 @@ type IPAddressesClusterGetter interface { } // IPAddressClusterInterface can operate on IPAddresses across all clusters, -// or scope down to one cluster and return a networkingv1beta1client.IPAddressInterface. +// or scope down to one cluster and return a networkingv1beta1.IPAddressInterface. type IPAddressClusterInterface interface { - Cluster(logicalcluster.Path) networkingv1beta1client.IPAddressInterface - List(ctx context.Context, opts metav1.ListOptions) (*networkingv1beta1.IPAddressList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) networkingv1beta1.IPAddressInterface + List(ctx context.Context, opts v1.ListOptions) (*apinetworkingv1beta1.IPAddressList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + IPAddressClusterExpansion } type iPAddressesClusterInterface struct { - clientCache kcpclient.Cache[*networkingv1beta1client.NetworkingV1beta1Client] + clientCache kcpclient.Cache[*networkingv1beta1.NetworkingV1beta1Client] } // Cluster scopes the client down to a particular cluster. -func (c *iPAddressesClusterInterface) Cluster(clusterPath logicalcluster.Path) networkingv1beta1client.IPAddressInterface { +func (c *iPAddressesClusterInterface) Cluster(clusterPath logicalcluster.Path) networkingv1beta1.IPAddressInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *iPAddressesClusterInterface) Cluster(clusterPath logicalcluster.Path) n } // List returns the entire collection of all IPAddresses across all clusters. -func (c *iPAddressesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*networkingv1beta1.IPAddressList, error) { +func (c *iPAddressesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apinetworkingv1beta1.IPAddressList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).IPAddresses().List(ctx, opts) } // Watch begins to watch all IPAddresses across all clusters. -func (c *iPAddressesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *iPAddressesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).IPAddresses().Watch(ctx, opts) } diff --git a/kubernetes/typed/networking/v1beta1/networking_client.go b/kubernetes/typed/networking/v1beta1/networking_client.go index 74a385569..2064c9b06 100644 --- a/kubernetes/typed/networking/v1beta1/networking_client.go +++ b/kubernetes/typed/networking/v1beta1/networking_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,25 +14,28 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apinetworkingv1beta1 "k8s.io/api/networking/v1beta1" networkingv1beta1 "k8s.io/client-go/kubernetes/typed/networking/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type NetworkingV1beta1ClusterInterface interface { NetworkingV1beta1ClusterScoper + IPAddressesClusterGetter IngressesClusterGetter IngressClassesClusterGetter - IPAddressesClusterGetter ServiceCIDRsClusterGetter } @@ -40,6 +43,7 @@ type NetworkingV1beta1ClusterScoper interface { Cluster(logicalcluster.Path) networkingv1beta1.NetworkingV1beta1Interface } +// NetworkingV1beta1ClusterClient is used to interact with features provided by the networking.k8s.io group. type NetworkingV1beta1ClusterClient struct { clientCache kcpclient.Cache[*networkingv1beta1.NetworkingV1beta1Client] } @@ -51,6 +55,10 @@ func (c *NetworkingV1beta1ClusterClient) Cluster(clusterPath logicalcluster.Path return c.clientCache.ClusterOrDie(clusterPath) } +func (c *NetworkingV1beta1ClusterClient) IPAddresses() IPAddressClusterInterface { + return &iPAddressesClusterInterface{clientCache: c.clientCache} +} + func (c *NetworkingV1beta1ClusterClient) Ingresses() IngressClusterInterface { return &ingressesClusterInterface{clientCache: c.clientCache} } @@ -59,10 +67,6 @@ func (c *NetworkingV1beta1ClusterClient) IngressClasses() IngressClassClusterInt return &ingressClassesClusterInterface{clientCache: c.clientCache} } -func (c *NetworkingV1beta1ClusterClient) IPAddresses() IPAddressClusterInterface { - return &iPAddressesClusterInterface{clientCache: c.clientCache} -} - func (c *NetworkingV1beta1ClusterClient) ServiceCIDRs() ServiceCIDRClusterInterface { return &serviceCIDRsClusterInterface{clientCache: c.clientCache} } @@ -71,11 +75,13 @@ func (c *NetworkingV1beta1ClusterClient) ServiceCIDRs() ServiceCIDRClusterInterf // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*NetworkingV1beta1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new NetworkingV1beta1ClusterClient for the given config and http client. @@ -87,6 +93,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*NetworkingV1beta1Cl if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &NetworkingV1beta1ClusterClient{clientCache: cache}, nil } @@ -99,3 +106,14 @@ func NewForConfigOrDie(c *rest.Config) *NetworkingV1beta1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apinetworkingv1beta1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/networking/v1beta1/servicecidr.go b/kubernetes/typed/networking/v1beta1/servicecidr.go index 621505542..7519898df 100644 --- a/kubernetes/typed/networking/v1beta1/servicecidr.go +++ b/kubernetes/typed/networking/v1beta1/servicecidr.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - networkingv1beta1 "k8s.io/api/networking/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - networkingv1beta1client "k8s.io/client-go/kubernetes/typed/networking/v1beta1" + apinetworkingv1beta1 "k8s.io/api/networking/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + networkingv1beta1 "k8s.io/client-go/kubernetes/typed/networking/v1beta1" ) // ServiceCIDRsClusterGetter has a method to return a ServiceCIDRClusterInterface. @@ -37,19 +37,20 @@ type ServiceCIDRsClusterGetter interface { } // ServiceCIDRClusterInterface can operate on ServiceCIDRs across all clusters, -// or scope down to one cluster and return a networkingv1beta1client.ServiceCIDRInterface. +// or scope down to one cluster and return a networkingv1beta1.ServiceCIDRInterface. type ServiceCIDRClusterInterface interface { - Cluster(logicalcluster.Path) networkingv1beta1client.ServiceCIDRInterface - List(ctx context.Context, opts metav1.ListOptions) (*networkingv1beta1.ServiceCIDRList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) networkingv1beta1.ServiceCIDRInterface + List(ctx context.Context, opts v1.ListOptions) (*apinetworkingv1beta1.ServiceCIDRList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + ServiceCIDRClusterExpansion } type serviceCIDRsClusterInterface struct { - clientCache kcpclient.Cache[*networkingv1beta1client.NetworkingV1beta1Client] + clientCache kcpclient.Cache[*networkingv1beta1.NetworkingV1beta1Client] } // Cluster scopes the client down to a particular cluster. -func (c *serviceCIDRsClusterInterface) Cluster(clusterPath logicalcluster.Path) networkingv1beta1client.ServiceCIDRInterface { +func (c *serviceCIDRsClusterInterface) Cluster(clusterPath logicalcluster.Path) networkingv1beta1.ServiceCIDRInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *serviceCIDRsClusterInterface) Cluster(clusterPath logicalcluster.Path) } // List returns the entire collection of all ServiceCIDRs across all clusters. -func (c *serviceCIDRsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*networkingv1beta1.ServiceCIDRList, error) { +func (c *serviceCIDRsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apinetworkingv1beta1.ServiceCIDRList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ServiceCIDRs().List(ctx, opts) } // Watch begins to watch all ServiceCIDRs across all clusters. -func (c *serviceCIDRsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *serviceCIDRsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ServiceCIDRs().Watch(ctx, opts) } diff --git a/kubernetes/typed/node/v1/doc.go b/kubernetes/typed/node/v1/doc.go new file mode 100644 index 000000000..d2f3412ab --- /dev/null +++ b/kubernetes/typed/node/v1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1 diff --git a/kubernetes/typed/node/v1/fake/doc.go b/kubernetes/typed/node/v1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/node/v1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/node/v1/fake/node_client.go b/kubernetes/typed/node/v1/fake/node_client.go index 336b9970c..950b40c92 100644 --- a/kubernetes/typed/node/v1/fake/node_client.go +++ b/kubernetes/typed/node/v1/fake/node_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" nodev1 "k8s.io/client-go/kubernetes/typed/node/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpnodev1 "github.com/kcp-dev/client-go/kubernetes/typed/node/v1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -42,21 +42,21 @@ func (c *NodeV1ClusterClient) Cluster(clusterPath logicalcluster.Path) nodev1.No } func (c *NodeV1ClusterClient) RuntimeClasses() kcpnodev1.RuntimeClassClusterInterface { - return &runtimeClassesClusterClient{Fake: c.Fake} + return newFakeRuntimeClassClusterClient(c) } -var _ nodev1.NodeV1Interface = (*NodeV1Client)(nil) - type NodeV1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } +func (c *NodeV1Client) RuntimeClasses() nodev1.RuntimeClassInterface { + return newFakeRuntimeClassClient(c.Fake, c.ClusterPath) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. func (c *NodeV1Client) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } - -func (c *NodeV1Client) RuntimeClasses() nodev1.RuntimeClassInterface { - return &runtimeClassesClient{Fake: c.Fake, ClusterPath: c.ClusterPath} -} diff --git a/kubernetes/typed/node/v1/fake/runtimeclass.go b/kubernetes/typed/node/v1/fake/runtimeclass.go index 447c7ed4a..4f552e6ff 100644 --- a/kubernetes/typed/node/v1/fake/runtimeclass.go +++ b/kubernetes/typed/node/v1/fake/runtimeclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" nodev1 "k8s.io/api/node/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsnodev1 "k8s.io/client-go/applyconfigurations/node/v1" - nodev1client "k8s.io/client-go/kubernetes/typed/node/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/node/v1" + typednodev1 "k8s.io/client-go/kubernetes/typed/node/v1" + typedkcpnodev1 "github.com/kcp-dev/client-go/kubernetes/typed/node/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var runtimeClassesResource = schema.GroupVersionResource{Group: "node.k8s.io", Version: "v1", Resource: "runtimeclasses"} -var runtimeClassesKind = schema.GroupVersionKind{Group: "node.k8s.io", Version: "v1", Kind: "RuntimeClass"} - -type runtimeClassesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *runtimeClassesClusterClient) Cluster(clusterPath logicalcluster.Path) nodev1client.RuntimeClassInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &runtimeClassesClient{Fake: c.Fake, ClusterPath: clusterPath} +// runtimeClassClusterClient implements RuntimeClassClusterInterface +type runtimeClassClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*nodev1.RuntimeClass, *nodev1.RuntimeClassList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of RuntimeClasses that match those selectors across all clusters. -func (c *runtimeClassesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*nodev1.RuntimeClassList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(runtimeClassesResource, runtimeClassesKind, logicalcluster.Wildcard, opts), &nodev1.RuntimeClassList{}) - if obj == nil { - return nil, err +func newFakeRuntimeClassClusterClient(fake *NodeV1ClusterClient) typedkcpnodev1.RuntimeClassClusterInterface { + return &runtimeClassClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*nodev1.RuntimeClass, *nodev1.RuntimeClassList]( + fake.Fake, + nodev1.SchemeGroupVersion.WithResource("runtimeclasses"), + nodev1.SchemeGroupVersion.WithKind("RuntimeClass"), + func() *nodev1.RuntimeClass { return &nodev1.RuntimeClass{} }, + func() *nodev1.RuntimeClassList { return &nodev1.RuntimeClassList{} }, + func(dst, src *nodev1.RuntimeClassList) { dst.ListMeta = src.ListMeta }, + func(list *nodev1.RuntimeClassList) []*nodev1.RuntimeClass { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *nodev1.RuntimeClassList, items []*nodev1.RuntimeClass) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &nodev1.RuntimeClassList{ListMeta: obj.(*nodev1.RuntimeClassList).ListMeta} - for _, item := range obj.(*nodev1.RuntimeClassList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested RuntimeClasses across all clusters. -func (c *runtimeClassesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(runtimeClassesResource, logicalcluster.Wildcard, opts)) +func (c *runtimeClassClusterClient) Cluster(cluster logicalcluster.Path) typednodev1.RuntimeClassInterface { + return newFakeRuntimeClassClient(c.Fake, cluster) } -type runtimeClassesClient struct { - *kcptesting.Fake +// runtimeClassScopedClient implements RuntimeClassInterface +type runtimeClassScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*nodev1.RuntimeClass, *nodev1.RuntimeClassList, *v1.RuntimeClassApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *runtimeClassesClient) Create(ctx context.Context, runtimeClass *nodev1.RuntimeClass, opts metav1.CreateOptions) (*nodev1.RuntimeClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(runtimeClassesResource, c.ClusterPath, runtimeClass), &nodev1.RuntimeClass{}) - if obj == nil { - return nil, err - } - return obj.(*nodev1.RuntimeClass), err -} - -func (c *runtimeClassesClient) Update(ctx context.Context, runtimeClass *nodev1.RuntimeClass, opts metav1.UpdateOptions) (*nodev1.RuntimeClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(runtimeClassesResource, c.ClusterPath, runtimeClass), &nodev1.RuntimeClass{}) - if obj == nil { - return nil, err - } - return obj.(*nodev1.RuntimeClass), err -} - -func (c *runtimeClassesClient) UpdateStatus(ctx context.Context, runtimeClass *nodev1.RuntimeClass, opts metav1.UpdateOptions) (*nodev1.RuntimeClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(runtimeClassesResource, c.ClusterPath, "status", runtimeClass), &nodev1.RuntimeClass{}) - if obj == nil { - return nil, err - } - return obj.(*nodev1.RuntimeClass), err -} - -func (c *runtimeClassesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(runtimeClassesResource, c.ClusterPath, name, opts), &nodev1.RuntimeClass{}) - return err -} - -func (c *runtimeClassesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(runtimeClassesResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &nodev1.RuntimeClassList{}) - return err -} - -func (c *runtimeClassesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*nodev1.RuntimeClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(runtimeClassesResource, c.ClusterPath, name), &nodev1.RuntimeClass{}) - if obj == nil { - return nil, err - } - return obj.(*nodev1.RuntimeClass), err -} - -// List takes label and field selectors, and returns the list of RuntimeClasses that match those selectors. -func (c *runtimeClassesClient) List(ctx context.Context, opts metav1.ListOptions) (*nodev1.RuntimeClassList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(runtimeClassesResource, runtimeClassesKind, c.ClusterPath, opts), &nodev1.RuntimeClassList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &nodev1.RuntimeClassList{ListMeta: obj.(*nodev1.RuntimeClassList).ListMeta} - for _, item := range obj.(*nodev1.RuntimeClassList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *runtimeClassesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(runtimeClassesResource, c.ClusterPath, opts)) -} - -func (c *runtimeClassesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*nodev1.RuntimeClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(runtimeClassesResource, c.ClusterPath, name, pt, data, subresources...), &nodev1.RuntimeClass{}) - if obj == nil { - return nil, err - } - return obj.(*nodev1.RuntimeClass), err -} - -func (c *runtimeClassesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsnodev1.RuntimeClassApplyConfiguration, opts metav1.ApplyOptions) (*nodev1.RuntimeClass, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(runtimeClassesResource, c.ClusterPath, *name, types.ApplyPatchType, data), &nodev1.RuntimeClass{}) - if obj == nil { - return nil, err - } - return obj.(*nodev1.RuntimeClass), err -} - -func (c *runtimeClassesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsnodev1.RuntimeClassApplyConfiguration, opts metav1.ApplyOptions) (*nodev1.RuntimeClass, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(runtimeClassesResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &nodev1.RuntimeClass{}) - if obj == nil { - return nil, err +func newFakeRuntimeClassClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typednodev1.RuntimeClassInterface { + return &runtimeClassScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*nodev1.RuntimeClass, *nodev1.RuntimeClassList, *v1.RuntimeClassApplyConfiguration]( + fake, + clusterPath, + "", + nodev1.SchemeGroupVersion.WithResource("runtimeclasses"), + nodev1.SchemeGroupVersion.WithKind("RuntimeClass"), + func() *nodev1.RuntimeClass { return &nodev1.RuntimeClass{} }, + func() *nodev1.RuntimeClassList { return &nodev1.RuntimeClassList{} }, + func(dst, src *nodev1.RuntimeClassList) { dst.ListMeta = src.ListMeta }, + func(list *nodev1.RuntimeClassList) []*nodev1.RuntimeClass { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *nodev1.RuntimeClassList, items []*nodev1.RuntimeClass) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*nodev1.RuntimeClass), err } diff --git a/kubernetes/typed/node/v1/generated_expansion.go b/kubernetes/typed/node/v1/generated_expansion.go new file mode 100644 index 000000000..3e0fa37f6 --- /dev/null +++ b/kubernetes/typed/node/v1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1 + +type RuntimeClassClusterExpansion interface{} diff --git a/kubernetes/typed/node/v1/node_client.go b/kubernetes/typed/node/v1/node_client.go index 0ddba6692..581434a0c 100644 --- a/kubernetes/typed/node/v1/node_client.go +++ b/kubernetes/typed/node/v1/node_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apinodev1 "k8s.io/api/node/v1" nodev1 "k8s.io/client-go/kubernetes/typed/node/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type NodeV1ClusterInterface interface { @@ -37,6 +40,7 @@ type NodeV1ClusterScoper interface { Cluster(logicalcluster.Path) nodev1.NodeV1Interface } +// NodeV1ClusterClient is used to interact with features provided by the node.k8s.io group. type NodeV1ClusterClient struct { clientCache kcpclient.Cache[*nodev1.NodeV1Client] } @@ -56,11 +60,13 @@ func (c *NodeV1ClusterClient) RuntimeClasses() RuntimeClassClusterInterface { // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*NodeV1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new NodeV1ClusterClient for the given config and http client. @@ -72,6 +78,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*NodeV1ClusterClient if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &NodeV1ClusterClient{clientCache: cache}, nil } @@ -84,3 +91,14 @@ func NewForConfigOrDie(c *rest.Config) *NodeV1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apinodev1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/node/v1/runtimeclass.go b/kubernetes/typed/node/v1/runtimeclass.go index 12d305d26..3eacc8495 100644 --- a/kubernetes/typed/node/v1/runtimeclass.go +++ b/kubernetes/typed/node/v1/runtimeclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - nodev1 "k8s.io/api/node/v1" + apinodev1 "k8s.io/api/node/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - nodev1client "k8s.io/client-go/kubernetes/typed/node/v1" + watch "k8s.io/apimachinery/pkg/watch" + nodev1 "k8s.io/client-go/kubernetes/typed/node/v1" ) // RuntimeClassesClusterGetter has a method to return a RuntimeClassClusterInterface. @@ -37,19 +37,20 @@ type RuntimeClassesClusterGetter interface { } // RuntimeClassClusterInterface can operate on RuntimeClasses across all clusters, -// or scope down to one cluster and return a nodev1client.RuntimeClassInterface. +// or scope down to one cluster and return a nodev1.RuntimeClassInterface. type RuntimeClassClusterInterface interface { - Cluster(logicalcluster.Path) nodev1client.RuntimeClassInterface - List(ctx context.Context, opts metav1.ListOptions) (*nodev1.RuntimeClassList, error) + Cluster(logicalcluster.Path) nodev1.RuntimeClassInterface + List(ctx context.Context, opts metav1.ListOptions) (*apinodev1.RuntimeClassList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + RuntimeClassClusterExpansion } type runtimeClassesClusterInterface struct { - clientCache kcpclient.Cache[*nodev1client.NodeV1Client] + clientCache kcpclient.Cache[*nodev1.NodeV1Client] } // Cluster scopes the client down to a particular cluster. -func (c *runtimeClassesClusterInterface) Cluster(clusterPath logicalcluster.Path) nodev1client.RuntimeClassInterface { +func (c *runtimeClassesClusterInterface) Cluster(clusterPath logicalcluster.Path) nodev1.RuntimeClassInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,7 +59,7 @@ func (c *runtimeClassesClusterInterface) Cluster(clusterPath logicalcluster.Path } // List returns the entire collection of all RuntimeClasses across all clusters. -func (c *runtimeClassesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*nodev1.RuntimeClassList, error) { +func (c *runtimeClassesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*apinodev1.RuntimeClassList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).RuntimeClasses().List(ctx, opts) } diff --git a/kubernetes/typed/node/v1alpha1/doc.go b/kubernetes/typed/node/v1alpha1/doc.go new file mode 100644 index 000000000..08b80237c --- /dev/null +++ b/kubernetes/typed/node/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/kubernetes/typed/node/v1alpha1/fake/doc.go b/kubernetes/typed/node/v1alpha1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/node/v1alpha1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/node/v1alpha1/fake/node_client.go b/kubernetes/typed/node/v1alpha1/fake/node_client.go index 997aafcdd..57b6ed1c3 100644 --- a/kubernetes/typed/node/v1alpha1/fake/node_client.go +++ b/kubernetes/typed/node/v1alpha1/fake/node_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" nodev1alpha1 "k8s.io/client-go/kubernetes/typed/node/v1alpha1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpnodev1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/node/v1alpha1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -42,21 +42,21 @@ func (c *NodeV1alpha1ClusterClient) Cluster(clusterPath logicalcluster.Path) nod } func (c *NodeV1alpha1ClusterClient) RuntimeClasses() kcpnodev1alpha1.RuntimeClassClusterInterface { - return &runtimeClassesClusterClient{Fake: c.Fake} + return newFakeRuntimeClassClusterClient(c) } -var _ nodev1alpha1.NodeV1alpha1Interface = (*NodeV1alpha1Client)(nil) - type NodeV1alpha1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } +func (c *NodeV1alpha1Client) RuntimeClasses() nodev1alpha1.RuntimeClassInterface { + return newFakeRuntimeClassClient(c.Fake, c.ClusterPath) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. func (c *NodeV1alpha1Client) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } - -func (c *NodeV1alpha1Client) RuntimeClasses() nodev1alpha1.RuntimeClassInterface { - return &runtimeClassesClient{Fake: c.Fake, ClusterPath: c.ClusterPath} -} diff --git a/kubernetes/typed/node/v1alpha1/fake/runtimeclass.go b/kubernetes/typed/node/v1alpha1/fake/runtimeclass.go index ca97da89f..7d2273618 100644 --- a/kubernetes/typed/node/v1alpha1/fake/runtimeclass.go +++ b/kubernetes/typed/node/v1alpha1/fake/runtimeclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" nodev1alpha1 "k8s.io/api/node/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsnodev1alpha1 "k8s.io/client-go/applyconfigurations/node/v1alpha1" - nodev1alpha1client "k8s.io/client-go/kubernetes/typed/node/v1alpha1" - "k8s.io/client-go/testing" + v1alpha1 "k8s.io/client-go/applyconfigurations/node/v1alpha1" + typednodev1alpha1 "k8s.io/client-go/kubernetes/typed/node/v1alpha1" + typedkcpnodev1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/node/v1alpha1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var runtimeClassesResource = schema.GroupVersionResource{Group: "node.k8s.io", Version: "v1alpha1", Resource: "runtimeclasses"} -var runtimeClassesKind = schema.GroupVersionKind{Group: "node.k8s.io", Version: "v1alpha1", Kind: "RuntimeClass"} - -type runtimeClassesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *runtimeClassesClusterClient) Cluster(clusterPath logicalcluster.Path) nodev1alpha1client.RuntimeClassInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &runtimeClassesClient{Fake: c.Fake, ClusterPath: clusterPath} +// runtimeClassClusterClient implements RuntimeClassClusterInterface +type runtimeClassClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*nodev1alpha1.RuntimeClass, *nodev1alpha1.RuntimeClassList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of RuntimeClasses that match those selectors across all clusters. -func (c *runtimeClassesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*nodev1alpha1.RuntimeClassList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(runtimeClassesResource, runtimeClassesKind, logicalcluster.Wildcard, opts), &nodev1alpha1.RuntimeClassList{}) - if obj == nil { - return nil, err +func newFakeRuntimeClassClusterClient(fake *NodeV1alpha1ClusterClient) typedkcpnodev1alpha1.RuntimeClassClusterInterface { + return &runtimeClassClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*nodev1alpha1.RuntimeClass, *nodev1alpha1.RuntimeClassList]( + fake.Fake, + nodev1alpha1.SchemeGroupVersion.WithResource("runtimeclasses"), + nodev1alpha1.SchemeGroupVersion.WithKind("RuntimeClass"), + func() *nodev1alpha1.RuntimeClass { return &nodev1alpha1.RuntimeClass{} }, + func() *nodev1alpha1.RuntimeClassList { return &nodev1alpha1.RuntimeClassList{} }, + func(dst, src *nodev1alpha1.RuntimeClassList) { dst.ListMeta = src.ListMeta }, + func(list *nodev1alpha1.RuntimeClassList) []*nodev1alpha1.RuntimeClass { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *nodev1alpha1.RuntimeClassList, items []*nodev1alpha1.RuntimeClass) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &nodev1alpha1.RuntimeClassList{ListMeta: obj.(*nodev1alpha1.RuntimeClassList).ListMeta} - for _, item := range obj.(*nodev1alpha1.RuntimeClassList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested RuntimeClasses across all clusters. -func (c *runtimeClassesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(runtimeClassesResource, logicalcluster.Wildcard, opts)) +func (c *runtimeClassClusterClient) Cluster(cluster logicalcluster.Path) typednodev1alpha1.RuntimeClassInterface { + return newFakeRuntimeClassClient(c.Fake, cluster) } -type runtimeClassesClient struct { - *kcptesting.Fake +// runtimeClassScopedClient implements RuntimeClassInterface +type runtimeClassScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*nodev1alpha1.RuntimeClass, *nodev1alpha1.RuntimeClassList, *v1alpha1.RuntimeClassApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *runtimeClassesClient) Create(ctx context.Context, runtimeClass *nodev1alpha1.RuntimeClass, opts metav1.CreateOptions) (*nodev1alpha1.RuntimeClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(runtimeClassesResource, c.ClusterPath, runtimeClass), &nodev1alpha1.RuntimeClass{}) - if obj == nil { - return nil, err - } - return obj.(*nodev1alpha1.RuntimeClass), err -} - -func (c *runtimeClassesClient) Update(ctx context.Context, runtimeClass *nodev1alpha1.RuntimeClass, opts metav1.UpdateOptions) (*nodev1alpha1.RuntimeClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(runtimeClassesResource, c.ClusterPath, runtimeClass), &nodev1alpha1.RuntimeClass{}) - if obj == nil { - return nil, err - } - return obj.(*nodev1alpha1.RuntimeClass), err -} - -func (c *runtimeClassesClient) UpdateStatus(ctx context.Context, runtimeClass *nodev1alpha1.RuntimeClass, opts metav1.UpdateOptions) (*nodev1alpha1.RuntimeClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(runtimeClassesResource, c.ClusterPath, "status", runtimeClass), &nodev1alpha1.RuntimeClass{}) - if obj == nil { - return nil, err - } - return obj.(*nodev1alpha1.RuntimeClass), err -} - -func (c *runtimeClassesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(runtimeClassesResource, c.ClusterPath, name, opts), &nodev1alpha1.RuntimeClass{}) - return err -} - -func (c *runtimeClassesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(runtimeClassesResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &nodev1alpha1.RuntimeClassList{}) - return err -} - -func (c *runtimeClassesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*nodev1alpha1.RuntimeClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(runtimeClassesResource, c.ClusterPath, name), &nodev1alpha1.RuntimeClass{}) - if obj == nil { - return nil, err - } - return obj.(*nodev1alpha1.RuntimeClass), err -} - -// List takes label and field selectors, and returns the list of RuntimeClasses that match those selectors. -func (c *runtimeClassesClient) List(ctx context.Context, opts metav1.ListOptions) (*nodev1alpha1.RuntimeClassList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(runtimeClassesResource, runtimeClassesKind, c.ClusterPath, opts), &nodev1alpha1.RuntimeClassList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &nodev1alpha1.RuntimeClassList{ListMeta: obj.(*nodev1alpha1.RuntimeClassList).ListMeta} - for _, item := range obj.(*nodev1alpha1.RuntimeClassList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *runtimeClassesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(runtimeClassesResource, c.ClusterPath, opts)) -} - -func (c *runtimeClassesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*nodev1alpha1.RuntimeClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(runtimeClassesResource, c.ClusterPath, name, pt, data, subresources...), &nodev1alpha1.RuntimeClass{}) - if obj == nil { - return nil, err - } - return obj.(*nodev1alpha1.RuntimeClass), err -} - -func (c *runtimeClassesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsnodev1alpha1.RuntimeClassApplyConfiguration, opts metav1.ApplyOptions) (*nodev1alpha1.RuntimeClass, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(runtimeClassesResource, c.ClusterPath, *name, types.ApplyPatchType, data), &nodev1alpha1.RuntimeClass{}) - if obj == nil { - return nil, err - } - return obj.(*nodev1alpha1.RuntimeClass), err -} - -func (c *runtimeClassesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsnodev1alpha1.RuntimeClassApplyConfiguration, opts metav1.ApplyOptions) (*nodev1alpha1.RuntimeClass, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(runtimeClassesResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &nodev1alpha1.RuntimeClass{}) - if obj == nil { - return nil, err +func newFakeRuntimeClassClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typednodev1alpha1.RuntimeClassInterface { + return &runtimeClassScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*nodev1alpha1.RuntimeClass, *nodev1alpha1.RuntimeClassList, *v1alpha1.RuntimeClassApplyConfiguration]( + fake, + clusterPath, + "", + nodev1alpha1.SchemeGroupVersion.WithResource("runtimeclasses"), + nodev1alpha1.SchemeGroupVersion.WithKind("RuntimeClass"), + func() *nodev1alpha1.RuntimeClass { return &nodev1alpha1.RuntimeClass{} }, + func() *nodev1alpha1.RuntimeClassList { return &nodev1alpha1.RuntimeClassList{} }, + func(dst, src *nodev1alpha1.RuntimeClassList) { dst.ListMeta = src.ListMeta }, + func(list *nodev1alpha1.RuntimeClassList) []*nodev1alpha1.RuntimeClass { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *nodev1alpha1.RuntimeClassList, items []*nodev1alpha1.RuntimeClass) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*nodev1alpha1.RuntimeClass), err } diff --git a/kubernetes/typed/node/v1alpha1/generated_expansion.go b/kubernetes/typed/node/v1alpha1/generated_expansion.go new file mode 100644 index 000000000..db8e708bc --- /dev/null +++ b/kubernetes/typed/node/v1alpha1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1alpha1 + +type RuntimeClassClusterExpansion interface{} diff --git a/kubernetes/typed/node/v1alpha1/node_client.go b/kubernetes/typed/node/v1alpha1/node_client.go index 2d5723484..643447c75 100644 --- a/kubernetes/typed/node/v1alpha1/node_client.go +++ b/kubernetes/typed/node/v1alpha1/node_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apinodev1alpha1 "k8s.io/api/node/v1alpha1" nodev1alpha1 "k8s.io/client-go/kubernetes/typed/node/v1alpha1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type NodeV1alpha1ClusterInterface interface { @@ -37,6 +40,7 @@ type NodeV1alpha1ClusterScoper interface { Cluster(logicalcluster.Path) nodev1alpha1.NodeV1alpha1Interface } +// NodeV1alpha1ClusterClient is used to interact with features provided by the node.k8s.io group. type NodeV1alpha1ClusterClient struct { clientCache kcpclient.Cache[*nodev1alpha1.NodeV1alpha1Client] } @@ -56,11 +60,13 @@ func (c *NodeV1alpha1ClusterClient) RuntimeClasses() RuntimeClassClusterInterfac // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*NodeV1alpha1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new NodeV1alpha1ClusterClient for the given config and http client. @@ -72,6 +78,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*NodeV1alpha1Cluster if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &NodeV1alpha1ClusterClient{clientCache: cache}, nil } @@ -84,3 +91,14 @@ func NewForConfigOrDie(c *rest.Config) *NodeV1alpha1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apinodev1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/node/v1alpha1/runtimeclass.go b/kubernetes/typed/node/v1alpha1/runtimeclass.go index 1d440ff71..c06e1d27d 100644 --- a/kubernetes/typed/node/v1alpha1/runtimeclass.go +++ b/kubernetes/typed/node/v1alpha1/runtimeclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - nodev1alpha1 "k8s.io/api/node/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - nodev1alpha1client "k8s.io/client-go/kubernetes/typed/node/v1alpha1" + apinodev1alpha1 "k8s.io/api/node/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + nodev1alpha1 "k8s.io/client-go/kubernetes/typed/node/v1alpha1" ) // RuntimeClassesClusterGetter has a method to return a RuntimeClassClusterInterface. @@ -37,19 +37,20 @@ type RuntimeClassesClusterGetter interface { } // RuntimeClassClusterInterface can operate on RuntimeClasses across all clusters, -// or scope down to one cluster and return a nodev1alpha1client.RuntimeClassInterface. +// or scope down to one cluster and return a nodev1alpha1.RuntimeClassInterface. type RuntimeClassClusterInterface interface { - Cluster(logicalcluster.Path) nodev1alpha1client.RuntimeClassInterface - List(ctx context.Context, opts metav1.ListOptions) (*nodev1alpha1.RuntimeClassList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) nodev1alpha1.RuntimeClassInterface + List(ctx context.Context, opts v1.ListOptions) (*apinodev1alpha1.RuntimeClassList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + RuntimeClassClusterExpansion } type runtimeClassesClusterInterface struct { - clientCache kcpclient.Cache[*nodev1alpha1client.NodeV1alpha1Client] + clientCache kcpclient.Cache[*nodev1alpha1.NodeV1alpha1Client] } // Cluster scopes the client down to a particular cluster. -func (c *runtimeClassesClusterInterface) Cluster(clusterPath logicalcluster.Path) nodev1alpha1client.RuntimeClassInterface { +func (c *runtimeClassesClusterInterface) Cluster(clusterPath logicalcluster.Path) nodev1alpha1.RuntimeClassInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *runtimeClassesClusterInterface) Cluster(clusterPath logicalcluster.Path } // List returns the entire collection of all RuntimeClasses across all clusters. -func (c *runtimeClassesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*nodev1alpha1.RuntimeClassList, error) { +func (c *runtimeClassesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apinodev1alpha1.RuntimeClassList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).RuntimeClasses().List(ctx, opts) } // Watch begins to watch all RuntimeClasses across all clusters. -func (c *runtimeClassesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *runtimeClassesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).RuntimeClasses().Watch(ctx, opts) } diff --git a/kubernetes/typed/node/v1beta1/doc.go b/kubernetes/typed/node/v1beta1/doc.go new file mode 100644 index 000000000..541e9d258 --- /dev/null +++ b/kubernetes/typed/node/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1beta1 diff --git a/kubernetes/typed/node/v1beta1/fake/doc.go b/kubernetes/typed/node/v1beta1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/node/v1beta1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/node/v1beta1/fake/node_client.go b/kubernetes/typed/node/v1beta1/fake/node_client.go index e538a132e..07a35456f 100644 --- a/kubernetes/typed/node/v1beta1/fake/node_client.go +++ b/kubernetes/typed/node/v1beta1/fake/node_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" nodev1beta1 "k8s.io/client-go/kubernetes/typed/node/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpnodev1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/node/v1beta1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -42,21 +42,21 @@ func (c *NodeV1beta1ClusterClient) Cluster(clusterPath logicalcluster.Path) node } func (c *NodeV1beta1ClusterClient) RuntimeClasses() kcpnodev1beta1.RuntimeClassClusterInterface { - return &runtimeClassesClusterClient{Fake: c.Fake} + return newFakeRuntimeClassClusterClient(c) } -var _ nodev1beta1.NodeV1beta1Interface = (*NodeV1beta1Client)(nil) - type NodeV1beta1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } +func (c *NodeV1beta1Client) RuntimeClasses() nodev1beta1.RuntimeClassInterface { + return newFakeRuntimeClassClient(c.Fake, c.ClusterPath) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. func (c *NodeV1beta1Client) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } - -func (c *NodeV1beta1Client) RuntimeClasses() nodev1beta1.RuntimeClassInterface { - return &runtimeClassesClient{Fake: c.Fake, ClusterPath: c.ClusterPath} -} diff --git a/kubernetes/typed/node/v1beta1/fake/runtimeclass.go b/kubernetes/typed/node/v1beta1/fake/runtimeclass.go index aebe19a57..f642b2684 100644 --- a/kubernetes/typed/node/v1beta1/fake/runtimeclass.go +++ b/kubernetes/typed/node/v1beta1/fake/runtimeclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" nodev1beta1 "k8s.io/api/node/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsnodev1beta1 "k8s.io/client-go/applyconfigurations/node/v1beta1" - nodev1beta1client "k8s.io/client-go/kubernetes/typed/node/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/node/v1beta1" + typednodev1beta1 "k8s.io/client-go/kubernetes/typed/node/v1beta1" + typedkcpnodev1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/node/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var runtimeClassesResource = schema.GroupVersionResource{Group: "node.k8s.io", Version: "v1beta1", Resource: "runtimeclasses"} -var runtimeClassesKind = schema.GroupVersionKind{Group: "node.k8s.io", Version: "v1beta1", Kind: "RuntimeClass"} - -type runtimeClassesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *runtimeClassesClusterClient) Cluster(clusterPath logicalcluster.Path) nodev1beta1client.RuntimeClassInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &runtimeClassesClient{Fake: c.Fake, ClusterPath: clusterPath} +// runtimeClassClusterClient implements RuntimeClassClusterInterface +type runtimeClassClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*nodev1beta1.RuntimeClass, *nodev1beta1.RuntimeClassList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of RuntimeClasses that match those selectors across all clusters. -func (c *runtimeClassesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*nodev1beta1.RuntimeClassList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(runtimeClassesResource, runtimeClassesKind, logicalcluster.Wildcard, opts), &nodev1beta1.RuntimeClassList{}) - if obj == nil { - return nil, err +func newFakeRuntimeClassClusterClient(fake *NodeV1beta1ClusterClient) typedkcpnodev1beta1.RuntimeClassClusterInterface { + return &runtimeClassClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*nodev1beta1.RuntimeClass, *nodev1beta1.RuntimeClassList]( + fake.Fake, + nodev1beta1.SchemeGroupVersion.WithResource("runtimeclasses"), + nodev1beta1.SchemeGroupVersion.WithKind("RuntimeClass"), + func() *nodev1beta1.RuntimeClass { return &nodev1beta1.RuntimeClass{} }, + func() *nodev1beta1.RuntimeClassList { return &nodev1beta1.RuntimeClassList{} }, + func(dst, src *nodev1beta1.RuntimeClassList) { dst.ListMeta = src.ListMeta }, + func(list *nodev1beta1.RuntimeClassList) []*nodev1beta1.RuntimeClass { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *nodev1beta1.RuntimeClassList, items []*nodev1beta1.RuntimeClass) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &nodev1beta1.RuntimeClassList{ListMeta: obj.(*nodev1beta1.RuntimeClassList).ListMeta} - for _, item := range obj.(*nodev1beta1.RuntimeClassList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested RuntimeClasses across all clusters. -func (c *runtimeClassesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(runtimeClassesResource, logicalcluster.Wildcard, opts)) +func (c *runtimeClassClusterClient) Cluster(cluster logicalcluster.Path) typednodev1beta1.RuntimeClassInterface { + return newFakeRuntimeClassClient(c.Fake, cluster) } -type runtimeClassesClient struct { - *kcptesting.Fake +// runtimeClassScopedClient implements RuntimeClassInterface +type runtimeClassScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*nodev1beta1.RuntimeClass, *nodev1beta1.RuntimeClassList, *v1beta1.RuntimeClassApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *runtimeClassesClient) Create(ctx context.Context, runtimeClass *nodev1beta1.RuntimeClass, opts metav1.CreateOptions) (*nodev1beta1.RuntimeClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(runtimeClassesResource, c.ClusterPath, runtimeClass), &nodev1beta1.RuntimeClass{}) - if obj == nil { - return nil, err - } - return obj.(*nodev1beta1.RuntimeClass), err -} - -func (c *runtimeClassesClient) Update(ctx context.Context, runtimeClass *nodev1beta1.RuntimeClass, opts metav1.UpdateOptions) (*nodev1beta1.RuntimeClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(runtimeClassesResource, c.ClusterPath, runtimeClass), &nodev1beta1.RuntimeClass{}) - if obj == nil { - return nil, err - } - return obj.(*nodev1beta1.RuntimeClass), err -} - -func (c *runtimeClassesClient) UpdateStatus(ctx context.Context, runtimeClass *nodev1beta1.RuntimeClass, opts metav1.UpdateOptions) (*nodev1beta1.RuntimeClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(runtimeClassesResource, c.ClusterPath, "status", runtimeClass), &nodev1beta1.RuntimeClass{}) - if obj == nil { - return nil, err - } - return obj.(*nodev1beta1.RuntimeClass), err -} - -func (c *runtimeClassesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(runtimeClassesResource, c.ClusterPath, name, opts), &nodev1beta1.RuntimeClass{}) - return err -} - -func (c *runtimeClassesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(runtimeClassesResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &nodev1beta1.RuntimeClassList{}) - return err -} - -func (c *runtimeClassesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*nodev1beta1.RuntimeClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(runtimeClassesResource, c.ClusterPath, name), &nodev1beta1.RuntimeClass{}) - if obj == nil { - return nil, err - } - return obj.(*nodev1beta1.RuntimeClass), err -} - -// List takes label and field selectors, and returns the list of RuntimeClasses that match those selectors. -func (c *runtimeClassesClient) List(ctx context.Context, opts metav1.ListOptions) (*nodev1beta1.RuntimeClassList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(runtimeClassesResource, runtimeClassesKind, c.ClusterPath, opts), &nodev1beta1.RuntimeClassList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &nodev1beta1.RuntimeClassList{ListMeta: obj.(*nodev1beta1.RuntimeClassList).ListMeta} - for _, item := range obj.(*nodev1beta1.RuntimeClassList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *runtimeClassesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(runtimeClassesResource, c.ClusterPath, opts)) -} - -func (c *runtimeClassesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*nodev1beta1.RuntimeClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(runtimeClassesResource, c.ClusterPath, name, pt, data, subresources...), &nodev1beta1.RuntimeClass{}) - if obj == nil { - return nil, err - } - return obj.(*nodev1beta1.RuntimeClass), err -} - -func (c *runtimeClassesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsnodev1beta1.RuntimeClassApplyConfiguration, opts metav1.ApplyOptions) (*nodev1beta1.RuntimeClass, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(runtimeClassesResource, c.ClusterPath, *name, types.ApplyPatchType, data), &nodev1beta1.RuntimeClass{}) - if obj == nil { - return nil, err - } - return obj.(*nodev1beta1.RuntimeClass), err -} - -func (c *runtimeClassesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsnodev1beta1.RuntimeClassApplyConfiguration, opts metav1.ApplyOptions) (*nodev1beta1.RuntimeClass, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(runtimeClassesResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &nodev1beta1.RuntimeClass{}) - if obj == nil { - return nil, err +func newFakeRuntimeClassClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typednodev1beta1.RuntimeClassInterface { + return &runtimeClassScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*nodev1beta1.RuntimeClass, *nodev1beta1.RuntimeClassList, *v1beta1.RuntimeClassApplyConfiguration]( + fake, + clusterPath, + "", + nodev1beta1.SchemeGroupVersion.WithResource("runtimeclasses"), + nodev1beta1.SchemeGroupVersion.WithKind("RuntimeClass"), + func() *nodev1beta1.RuntimeClass { return &nodev1beta1.RuntimeClass{} }, + func() *nodev1beta1.RuntimeClassList { return &nodev1beta1.RuntimeClassList{} }, + func(dst, src *nodev1beta1.RuntimeClassList) { dst.ListMeta = src.ListMeta }, + func(list *nodev1beta1.RuntimeClassList) []*nodev1beta1.RuntimeClass { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *nodev1beta1.RuntimeClassList, items []*nodev1beta1.RuntimeClass) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*nodev1beta1.RuntimeClass), err } diff --git a/kubernetes/typed/node/v1beta1/generated_expansion.go b/kubernetes/typed/node/v1beta1/generated_expansion.go new file mode 100644 index 000000000..4d52810aa --- /dev/null +++ b/kubernetes/typed/node/v1beta1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1beta1 + +type RuntimeClassClusterExpansion interface{} diff --git a/kubernetes/typed/node/v1beta1/node_client.go b/kubernetes/typed/node/v1beta1/node_client.go index 33de13b6f..90df45e01 100644 --- a/kubernetes/typed/node/v1beta1/node_client.go +++ b/kubernetes/typed/node/v1beta1/node_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apinodev1beta1 "k8s.io/api/node/v1beta1" nodev1beta1 "k8s.io/client-go/kubernetes/typed/node/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type NodeV1beta1ClusterInterface interface { @@ -37,6 +40,7 @@ type NodeV1beta1ClusterScoper interface { Cluster(logicalcluster.Path) nodev1beta1.NodeV1beta1Interface } +// NodeV1beta1ClusterClient is used to interact with features provided by the node.k8s.io group. type NodeV1beta1ClusterClient struct { clientCache kcpclient.Cache[*nodev1beta1.NodeV1beta1Client] } @@ -56,11 +60,13 @@ func (c *NodeV1beta1ClusterClient) RuntimeClasses() RuntimeClassClusterInterface // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*NodeV1beta1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new NodeV1beta1ClusterClient for the given config and http client. @@ -72,6 +78,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*NodeV1beta1ClusterC if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &NodeV1beta1ClusterClient{clientCache: cache}, nil } @@ -84,3 +91,14 @@ func NewForConfigOrDie(c *rest.Config) *NodeV1beta1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apinodev1beta1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/node/v1beta1/runtimeclass.go b/kubernetes/typed/node/v1beta1/runtimeclass.go index ef3f34597..1c1a1221c 100644 --- a/kubernetes/typed/node/v1beta1/runtimeclass.go +++ b/kubernetes/typed/node/v1beta1/runtimeclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - nodev1beta1 "k8s.io/api/node/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - nodev1beta1client "k8s.io/client-go/kubernetes/typed/node/v1beta1" + apinodev1beta1 "k8s.io/api/node/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + nodev1beta1 "k8s.io/client-go/kubernetes/typed/node/v1beta1" ) // RuntimeClassesClusterGetter has a method to return a RuntimeClassClusterInterface. @@ -37,19 +37,20 @@ type RuntimeClassesClusterGetter interface { } // RuntimeClassClusterInterface can operate on RuntimeClasses across all clusters, -// or scope down to one cluster and return a nodev1beta1client.RuntimeClassInterface. +// or scope down to one cluster and return a nodev1beta1.RuntimeClassInterface. type RuntimeClassClusterInterface interface { - Cluster(logicalcluster.Path) nodev1beta1client.RuntimeClassInterface - List(ctx context.Context, opts metav1.ListOptions) (*nodev1beta1.RuntimeClassList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) nodev1beta1.RuntimeClassInterface + List(ctx context.Context, opts v1.ListOptions) (*apinodev1beta1.RuntimeClassList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + RuntimeClassClusterExpansion } type runtimeClassesClusterInterface struct { - clientCache kcpclient.Cache[*nodev1beta1client.NodeV1beta1Client] + clientCache kcpclient.Cache[*nodev1beta1.NodeV1beta1Client] } // Cluster scopes the client down to a particular cluster. -func (c *runtimeClassesClusterInterface) Cluster(clusterPath logicalcluster.Path) nodev1beta1client.RuntimeClassInterface { +func (c *runtimeClassesClusterInterface) Cluster(clusterPath logicalcluster.Path) nodev1beta1.RuntimeClassInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *runtimeClassesClusterInterface) Cluster(clusterPath logicalcluster.Path } // List returns the entire collection of all RuntimeClasses across all clusters. -func (c *runtimeClassesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*nodev1beta1.RuntimeClassList, error) { +func (c *runtimeClassesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apinodev1beta1.RuntimeClassList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).RuntimeClasses().List(ctx, opts) } // Watch begins to watch all RuntimeClasses across all clusters. -func (c *runtimeClassesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *runtimeClassesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).RuntimeClasses().Watch(ctx, opts) } diff --git a/kubernetes/typed/policy/v1/doc.go b/kubernetes/typed/policy/v1/doc.go new file mode 100644 index 000000000..d2f3412ab --- /dev/null +++ b/kubernetes/typed/policy/v1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1 diff --git a/kubernetes/typed/policy/v1/eviction.go b/kubernetes/typed/policy/v1/eviction.go index b9669abc7..afe87ff23 100644 --- a/kubernetes/typed/policy/v1/eviction.go +++ b/kubernetes/typed/policy/v1/eviction.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 @@ -22,7 +22,7 @@ import ( kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - policyv1client "k8s.io/client-go/kubernetes/typed/policy/v1" + policyv1 "k8s.io/client-go/kubernetes/typed/policy/v1" ) // EvictionsClusterGetter has a method to return a EvictionClusterInterface. @@ -34,10 +34,12 @@ type EvictionsClusterGetter interface { // EvictionClusterInterface can scope down to one cluster and return a EvictionsNamespacer. type EvictionClusterInterface interface { Cluster(logicalcluster.Path) EvictionsNamespacer + + EvictionClusterExpansion } type evictionsClusterInterface struct { - clientCache kcpclient.Cache[*policyv1client.PolicyV1Client] + clientCache kcpclient.Cache[*policyv1.PolicyV1Client] } // Cluster scopes the client down to a particular cluster. @@ -49,16 +51,16 @@ func (c *evictionsClusterInterface) Cluster(clusterPath logicalcluster.Path) Evi return &evictionsNamespacer{clientCache: c.clientCache, clusterPath: clusterPath} } -// EvictionsNamespacer can scope to objects within a namespace, returning a policyv1client.EvictionInterface. +// EvictionsNamespacer can scope to objects within a namespace, returning a policyv1.EvictionInterface. type EvictionsNamespacer interface { - Namespace(string) policyv1client.EvictionInterface + Namespace(string) policyv1.EvictionInterface } type evictionsNamespacer struct { - clientCache kcpclient.Cache[*policyv1client.PolicyV1Client] + clientCache kcpclient.Cache[*policyv1.PolicyV1Client] clusterPath logicalcluster.Path } -func (n *evictionsNamespacer) Namespace(namespace string) policyv1client.EvictionInterface { +func (n *evictionsNamespacer) Namespace(namespace string) policyv1.EvictionInterface { return n.clientCache.ClusterOrDie(n.clusterPath).Evictions(namespace) } diff --git a/kubernetes/typed/policy/v1/fake/doc.go b/kubernetes/typed/policy/v1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/policy/v1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/policy/v1/fake/eviction.go b/kubernetes/typed/policy/v1/fake/eviction.go index 5f95d16be..cdb85134d 100644 --- a/kubernetes/typed/policy/v1/fake/eviction.go +++ b/kubernetes/typed/policy/v1/fake/eviction.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,47 +14,70 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( "github.com/kcp-dev/logicalcluster/v3" - "k8s.io/apimachinery/pkg/runtime/schema" - policyv1client "k8s.io/client-go/kubernetes/typed/policy/v1" + policyv1 "k8s.io/api/policy/v1" + typedpolicyv1 "k8s.io/client-go/kubernetes/typed/policy/v1" - kcppolicyv1 "github.com/kcp-dev/client-go/kubernetes/typed/policy/v1" + typedkcppolicyv1 "github.com/kcp-dev/client-go/kubernetes/typed/policy/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var evictionsResource = schema.GroupVersionResource{Group: "policy", Version: "v1", Resource: "evictions"} -var evictionsKind = schema.GroupVersionKind{Group: "policy", Version: "v1", Kind: "Eviction"} - -type evictionsClusterClient struct { - *kcptesting.Fake +// evictionClusterClient implements EvictionClusterInterface +type evictionClusterClient struct { + *kcpgentype.FakeClusterClient[*policyv1.Eviction] + Fake *kcptesting.Fake } -// Cluster scopes the client down to a particular cluster. -func (c *evictionsClusterClient) Cluster(clusterPath logicalcluster.Path) kcppolicyv1.EvictionsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") +func newFakeEvictionClusterClient(fake *PolicyV1ClusterClient) typedkcppolicyv1.EvictionClusterInterface { + return &evictionClusterClient{ + kcpgentype.NewFakeClusterClient[*policyv1.Eviction]( + fake.Fake, + policyv1.SchemeGroupVersion.WithResource("evictions"), + policyv1.SchemeGroupVersion.WithKind("Eviction"), + func() *policyv1.Eviction { return &policyv1.Eviction{} }, + ), + fake.Fake, } +} - return &evictionsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +func (c *evictionClusterClient) Cluster(cluster logicalcluster.Path) typedkcppolicyv1.EvictionsNamespacer { + return &evictionNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type evictionsNamespacer struct { +type evictionNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *evictionsNamespacer) Namespace(namespace string) policyv1client.EvictionInterface { - return &evictionsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *evictionNamespacer) Namespace(namespace string) typedpolicyv1.EvictionInterface { + return newFakeEvictionClient(n.Fake, namespace, n.ClusterPath) } -type evictionsClient struct { - *kcptesting.Fake +// evictionScopedClient implements EvictionInterface +type evictionScopedClient struct { + *kcpgentype.FakeClient[*policyv1.Eviction] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string +} + +func newFakeEvictionClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedpolicyv1.EvictionInterface { + return &evictionScopedClient{ + kcpgentype.NewFakeClient[*policyv1.Eviction]( + fake, + clusterPath, + namespace, + policyv1.SchemeGroupVersion.WithResource("evictions"), + policyv1.SchemeGroupVersion.WithKind("Eviction"), + func() *policyv1.Eviction { return &policyv1.Eviction{} }, + ), + fake, + clusterPath, + } } diff --git a/kubernetes/typed/policy/v1/fake/fake_eviction_expansion.go b/kubernetes/typed/policy/v1/fake/fake_eviction_expansion.go index 49a77864e..9b981e9e2 100644 --- a/kubernetes/typed/policy/v1/fake/fake_eviction_expansion.go +++ b/kubernetes/typed/policy/v1/fake/fake_eviction_expansion.go @@ -26,10 +26,10 @@ import ( core "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -func (c *evictionsClient) Evict(ctx context.Context, eviction *policy.Eviction) error { +func (c *evictionScopedClient) Evict(ctx context.Context, eviction *policy.Eviction) error { action := core.CreateActionImpl{} action.Verb = "create" - action.Namespace = c.Namespace + action.Namespace = c.Namespace() action.ClusterPath = c.ClusterPath action.Resource = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "pods"} action.Subresource = "eviction" diff --git a/kubernetes/typed/policy/v1/fake/poddisruptionbudget.go b/kubernetes/typed/policy/v1/fake/poddisruptionbudget.go index 8d065a153..98361d57e 100644 --- a/kubernetes/typed/policy/v1/fake/poddisruptionbudget.go +++ b/kubernetes/typed/policy/v1/fake/poddisruptionbudget.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" policyv1 "k8s.io/api/policy/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationspolicyv1 "k8s.io/client-go/applyconfigurations/policy/v1" - policyv1client "k8s.io/client-go/kubernetes/typed/policy/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/policy/v1" + typedpolicyv1 "k8s.io/client-go/kubernetes/typed/policy/v1" - kcppolicyv1 "github.com/kcp-dev/client-go/kubernetes/typed/policy/v1" + typedkcppolicyv1 "github.com/kcp-dev/client-go/kubernetes/typed/policy/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var podDisruptionBudgetsResource = schema.GroupVersionResource{Group: "policy", Version: "v1", Resource: "poddisruptionbudgets"} -var podDisruptionBudgetsKind = schema.GroupVersionKind{Group: "policy", Version: "v1", Kind: "PodDisruptionBudget"} - -type podDisruptionBudgetsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *podDisruptionBudgetsClusterClient) Cluster(clusterPath logicalcluster.Path) kcppolicyv1.PodDisruptionBudgetsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &podDisruptionBudgetsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// podDisruptionBudgetClusterClient implements PodDisruptionBudgetClusterInterface +type podDisruptionBudgetClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*policyv1.PodDisruptionBudget, *policyv1.PodDisruptionBudgetList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of PodDisruptionBudgets that match those selectors across all clusters. -func (c *podDisruptionBudgetsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*policyv1.PodDisruptionBudgetList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(podDisruptionBudgetsResource, podDisruptionBudgetsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &policyv1.PodDisruptionBudgetList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakePodDisruptionBudgetClusterClient(fake *PolicyV1ClusterClient) typedkcppolicyv1.PodDisruptionBudgetClusterInterface { + return &podDisruptionBudgetClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*policyv1.PodDisruptionBudget, *policyv1.PodDisruptionBudgetList]( + fake.Fake, + policyv1.SchemeGroupVersion.WithResource("poddisruptionbudgets"), + policyv1.SchemeGroupVersion.WithKind("PodDisruptionBudget"), + func() *policyv1.PodDisruptionBudget { return &policyv1.PodDisruptionBudget{} }, + func() *policyv1.PodDisruptionBudgetList { return &policyv1.PodDisruptionBudgetList{} }, + func(dst, src *policyv1.PodDisruptionBudgetList) { dst.ListMeta = src.ListMeta }, + func(list *policyv1.PodDisruptionBudgetList) []*policyv1.PodDisruptionBudget { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *policyv1.PodDisruptionBudgetList, items []*policyv1.PodDisruptionBudget) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &policyv1.PodDisruptionBudgetList{ListMeta: obj.(*policyv1.PodDisruptionBudgetList).ListMeta} - for _, item := range obj.(*policyv1.PodDisruptionBudgetList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested PodDisruptionBudgets across all clusters. -func (c *podDisruptionBudgetsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(podDisruptionBudgetsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *podDisruptionBudgetClusterClient) Cluster(cluster logicalcluster.Path) typedkcppolicyv1.PodDisruptionBudgetsNamespacer { + return &podDisruptionBudgetNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type podDisruptionBudgetsNamespacer struct { +type podDisruptionBudgetNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *podDisruptionBudgetsNamespacer) Namespace(namespace string) policyv1client.PodDisruptionBudgetInterface { - return &podDisruptionBudgetsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *podDisruptionBudgetNamespacer) Namespace(namespace string) typedpolicyv1.PodDisruptionBudgetInterface { + return newFakePodDisruptionBudgetClient(n.Fake, namespace, n.ClusterPath) } -type podDisruptionBudgetsClient struct { - *kcptesting.Fake +// podDisruptionBudgetScopedClient implements PodDisruptionBudgetInterface +type podDisruptionBudgetScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*policyv1.PodDisruptionBudget, *policyv1.PodDisruptionBudgetList, *v1.PodDisruptionBudgetApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *podDisruptionBudgetsClient) Create(ctx context.Context, podDisruptionBudget *policyv1.PodDisruptionBudget, opts metav1.CreateOptions) (*policyv1.PodDisruptionBudget, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(podDisruptionBudgetsResource, c.ClusterPath, c.Namespace, podDisruptionBudget), &policyv1.PodDisruptionBudget{}) - if obj == nil { - return nil, err - } - return obj.(*policyv1.PodDisruptionBudget), err -} - -func (c *podDisruptionBudgetsClient) Update(ctx context.Context, podDisruptionBudget *policyv1.PodDisruptionBudget, opts metav1.UpdateOptions) (*policyv1.PodDisruptionBudget, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(podDisruptionBudgetsResource, c.ClusterPath, c.Namespace, podDisruptionBudget), &policyv1.PodDisruptionBudget{}) - if obj == nil { - return nil, err - } - return obj.(*policyv1.PodDisruptionBudget), err -} - -func (c *podDisruptionBudgetsClient) UpdateStatus(ctx context.Context, podDisruptionBudget *policyv1.PodDisruptionBudget, opts metav1.UpdateOptions) (*policyv1.PodDisruptionBudget, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(podDisruptionBudgetsResource, c.ClusterPath, "status", c.Namespace, podDisruptionBudget), &policyv1.PodDisruptionBudget{}) - if obj == nil { - return nil, err - } - return obj.(*policyv1.PodDisruptionBudget), err -} - -func (c *podDisruptionBudgetsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(podDisruptionBudgetsResource, c.ClusterPath, c.Namespace, name, opts), &policyv1.PodDisruptionBudget{}) - return err -} - -func (c *podDisruptionBudgetsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(podDisruptionBudgetsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &policyv1.PodDisruptionBudgetList{}) - return err -} - -func (c *podDisruptionBudgetsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*policyv1.PodDisruptionBudget, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(podDisruptionBudgetsResource, c.ClusterPath, c.Namespace, name), &policyv1.PodDisruptionBudget{}) - if obj == nil { - return nil, err - } - return obj.(*policyv1.PodDisruptionBudget), err -} - -// List takes label and field selectors, and returns the list of PodDisruptionBudgets that match those selectors. -func (c *podDisruptionBudgetsClient) List(ctx context.Context, opts metav1.ListOptions) (*policyv1.PodDisruptionBudgetList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(podDisruptionBudgetsResource, podDisruptionBudgetsKind, c.ClusterPath, c.Namespace, opts), &policyv1.PodDisruptionBudgetList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &policyv1.PodDisruptionBudgetList{ListMeta: obj.(*policyv1.PodDisruptionBudgetList).ListMeta} - for _, item := range obj.(*policyv1.PodDisruptionBudgetList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *podDisruptionBudgetsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(podDisruptionBudgetsResource, c.ClusterPath, c.Namespace, opts)) } -func (c *podDisruptionBudgetsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*policyv1.PodDisruptionBudget, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(podDisruptionBudgetsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &policyv1.PodDisruptionBudget{}) - if obj == nil { - return nil, err - } - return obj.(*policyv1.PodDisruptionBudget), err -} - -func (c *podDisruptionBudgetsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationspolicyv1.PodDisruptionBudgetApplyConfiguration, opts metav1.ApplyOptions) (*policyv1.PodDisruptionBudget, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(podDisruptionBudgetsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &policyv1.PodDisruptionBudget{}) - if obj == nil { - return nil, err - } - return obj.(*policyv1.PodDisruptionBudget), err -} - -func (c *podDisruptionBudgetsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationspolicyv1.PodDisruptionBudgetApplyConfiguration, opts metav1.ApplyOptions) (*policyv1.PodDisruptionBudget, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(podDisruptionBudgetsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &policyv1.PodDisruptionBudget{}) - if obj == nil { - return nil, err +func newFakePodDisruptionBudgetClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedpolicyv1.PodDisruptionBudgetInterface { + return &podDisruptionBudgetScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*policyv1.PodDisruptionBudget, *policyv1.PodDisruptionBudgetList, *v1.PodDisruptionBudgetApplyConfiguration]( + fake, + clusterPath, + namespace, + policyv1.SchemeGroupVersion.WithResource("poddisruptionbudgets"), + policyv1.SchemeGroupVersion.WithKind("PodDisruptionBudget"), + func() *policyv1.PodDisruptionBudget { return &policyv1.PodDisruptionBudget{} }, + func() *policyv1.PodDisruptionBudgetList { return &policyv1.PodDisruptionBudgetList{} }, + func(dst, src *policyv1.PodDisruptionBudgetList) { dst.ListMeta = src.ListMeta }, + func(list *policyv1.PodDisruptionBudgetList) []*policyv1.PodDisruptionBudget { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *policyv1.PodDisruptionBudgetList, items []*policyv1.PodDisruptionBudget) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*policyv1.PodDisruptionBudget), err } diff --git a/kubernetes/typed/policy/v1/fake/policy_client.go b/kubernetes/typed/policy/v1/fake/policy_client.go index 65486016a..be75b40ca 100644 --- a/kubernetes/typed/policy/v1/fake/policy_client.go +++ b/kubernetes/typed/policy/v1/fake/policy_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" policyv1 "k8s.io/client-go/kubernetes/typed/policy/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcppolicyv1 "github.com/kcp-dev/client-go/kubernetes/typed/policy/v1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -41,30 +41,30 @@ func (c *PolicyV1ClusterClient) Cluster(clusterPath logicalcluster.Path) policyv return &PolicyV1Client{Fake: c.Fake, ClusterPath: clusterPath} } -func (c *PolicyV1ClusterClient) PodDisruptionBudgets() kcppolicyv1.PodDisruptionBudgetClusterInterface { - return &podDisruptionBudgetsClusterClient{Fake: c.Fake} -} - func (c *PolicyV1ClusterClient) Evictions() kcppolicyv1.EvictionClusterInterface { - return &evictionsClusterClient{Fake: c.Fake} + return newFakeEvictionClusterClient(c) } -var _ policyv1.PolicyV1Interface = (*PolicyV1Client)(nil) +func (c *PolicyV1ClusterClient) PodDisruptionBudgets() kcppolicyv1.PodDisruptionBudgetClusterInterface { + return newFakePodDisruptionBudgetClusterClient(c) +} type PolicyV1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *PolicyV1Client) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret +func (c *PolicyV1Client) Evictions(namespace string) policyv1.EvictionInterface { + return newFakeEvictionClient(c.Fake, namespace, c.ClusterPath) } func (c *PolicyV1Client) PodDisruptionBudgets(namespace string) policyv1.PodDisruptionBudgetInterface { - return &podDisruptionBudgetsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} + return newFakePodDisruptionBudgetClient(c.Fake, namespace, c.ClusterPath) } -func (c *PolicyV1Client) Evictions(namespace string) policyv1.EvictionInterface { - return &evictionsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *PolicyV1Client) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret } diff --git a/kubernetes/typed/policy/v1/generated_expansion.go b/kubernetes/typed/policy/v1/generated_expansion.go new file mode 100644 index 000000000..c2df4356b --- /dev/null +++ b/kubernetes/typed/policy/v1/generated_expansion.go @@ -0,0 +1,23 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1 + +type EvictionClusterExpansion interface{} + +type PodDisruptionBudgetClusterExpansion interface{} diff --git a/kubernetes/typed/policy/v1/poddisruptionbudget.go b/kubernetes/typed/policy/v1/poddisruptionbudget.go index d5e626234..d9cde3c93 100644 --- a/kubernetes/typed/policy/v1/poddisruptionbudget.go +++ b/kubernetes/typed/policy/v1/poddisruptionbudget.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" policyv1 "k8s.io/api/policy/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - policyv1client "k8s.io/client-go/kubernetes/typed/policy/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedpolicyv1 "k8s.io/client-go/kubernetes/typed/policy/v1" ) // PodDisruptionBudgetsClusterGetter has a method to return a PodDisruptionBudgetClusterInterface. @@ -42,10 +42,11 @@ type PodDisruptionBudgetClusterInterface interface { Cluster(logicalcluster.Path) PodDisruptionBudgetsNamespacer List(ctx context.Context, opts metav1.ListOptions) (*policyv1.PodDisruptionBudgetList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + PodDisruptionBudgetClusterExpansion } type podDisruptionBudgetsClusterInterface struct { - clientCache kcpclient.Cache[*policyv1client.PolicyV1Client] + clientCache kcpclient.Cache[*typedpolicyv1.PolicyV1Client] } // Cluster scopes the client down to a particular cluster. @@ -67,16 +68,16 @@ func (c *podDisruptionBudgetsClusterInterface) Watch(ctx context.Context, opts m return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).PodDisruptionBudgets(metav1.NamespaceAll).Watch(ctx, opts) } -// PodDisruptionBudgetsNamespacer can scope to objects within a namespace, returning a policyv1client.PodDisruptionBudgetInterface. +// PodDisruptionBudgetsNamespacer can scope to objects within a namespace, returning a typedpolicyv1.PodDisruptionBudgetInterface. type PodDisruptionBudgetsNamespacer interface { - Namespace(string) policyv1client.PodDisruptionBudgetInterface + Namespace(string) typedpolicyv1.PodDisruptionBudgetInterface } type podDisruptionBudgetsNamespacer struct { - clientCache kcpclient.Cache[*policyv1client.PolicyV1Client] + clientCache kcpclient.Cache[*typedpolicyv1.PolicyV1Client] clusterPath logicalcluster.Path } -func (n *podDisruptionBudgetsNamespacer) Namespace(namespace string) policyv1client.PodDisruptionBudgetInterface { +func (n *podDisruptionBudgetsNamespacer) Namespace(namespace string) typedpolicyv1.PodDisruptionBudgetInterface { return n.clientCache.ClusterOrDie(n.clusterPath).PodDisruptionBudgets(namespace) } diff --git a/kubernetes/typed/policy/v1/policy_client.go b/kubernetes/typed/policy/v1/policy_client.go index 014c33dbf..5813bab45 100644 --- a/kubernetes/typed/policy/v1/policy_client.go +++ b/kubernetes/typed/policy/v1/policy_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,30 +14,34 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apipolicyv1 "k8s.io/api/policy/v1" policyv1 "k8s.io/client-go/kubernetes/typed/policy/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type PolicyV1ClusterInterface interface { PolicyV1ClusterScoper - PodDisruptionBudgetsClusterGetter EvictionsClusterGetter + PodDisruptionBudgetsClusterGetter } type PolicyV1ClusterScoper interface { Cluster(logicalcluster.Path) policyv1.PolicyV1Interface } +// PolicyV1ClusterClient is used to interact with features provided by the policy group. type PolicyV1ClusterClient struct { clientCache kcpclient.Cache[*policyv1.PolicyV1Client] } @@ -49,23 +53,25 @@ func (c *PolicyV1ClusterClient) Cluster(clusterPath logicalcluster.Path) policyv return c.clientCache.ClusterOrDie(clusterPath) } -func (c *PolicyV1ClusterClient) PodDisruptionBudgets() PodDisruptionBudgetClusterInterface { - return &podDisruptionBudgetsClusterInterface{clientCache: c.clientCache} -} - func (c *PolicyV1ClusterClient) Evictions() EvictionClusterInterface { return &evictionsClusterInterface{clientCache: c.clientCache} } +func (c *PolicyV1ClusterClient) PodDisruptionBudgets() PodDisruptionBudgetClusterInterface { + return &podDisruptionBudgetsClusterInterface{clientCache: c.clientCache} +} + // NewForConfig creates a new PolicyV1ClusterClient for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*PolicyV1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new PolicyV1ClusterClient for the given config and http client. @@ -77,6 +83,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*PolicyV1ClusterClie if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &PolicyV1ClusterClient{clientCache: cache}, nil } @@ -89,3 +96,14 @@ func NewForConfigOrDie(c *rest.Config) *PolicyV1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apipolicyv1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/policy/v1beta1/doc.go b/kubernetes/typed/policy/v1beta1/doc.go new file mode 100644 index 000000000..541e9d258 --- /dev/null +++ b/kubernetes/typed/policy/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1beta1 diff --git a/kubernetes/typed/policy/v1beta1/eviction.go b/kubernetes/typed/policy/v1beta1/eviction.go index e964c8813..c70656d0b 100644 --- a/kubernetes/typed/policy/v1beta1/eviction.go +++ b/kubernetes/typed/policy/v1beta1/eviction.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 @@ -22,7 +22,7 @@ import ( kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - policyv1beta1client "k8s.io/client-go/kubernetes/typed/policy/v1beta1" + policyv1beta1 "k8s.io/client-go/kubernetes/typed/policy/v1beta1" ) // EvictionsClusterGetter has a method to return a EvictionClusterInterface. @@ -34,10 +34,12 @@ type EvictionsClusterGetter interface { // EvictionClusterInterface can scope down to one cluster and return a EvictionsNamespacer. type EvictionClusterInterface interface { Cluster(logicalcluster.Path) EvictionsNamespacer + + EvictionClusterExpansion } type evictionsClusterInterface struct { - clientCache kcpclient.Cache[*policyv1beta1client.PolicyV1beta1Client] + clientCache kcpclient.Cache[*policyv1beta1.PolicyV1beta1Client] } // Cluster scopes the client down to a particular cluster. @@ -49,16 +51,16 @@ func (c *evictionsClusterInterface) Cluster(clusterPath logicalcluster.Path) Evi return &evictionsNamespacer{clientCache: c.clientCache, clusterPath: clusterPath} } -// EvictionsNamespacer can scope to objects within a namespace, returning a policyv1beta1client.EvictionInterface. +// EvictionsNamespacer can scope to objects within a namespace, returning a policyv1beta1.EvictionInterface. type EvictionsNamespacer interface { - Namespace(string) policyv1beta1client.EvictionInterface + Namespace(string) policyv1beta1.EvictionInterface } type evictionsNamespacer struct { - clientCache kcpclient.Cache[*policyv1beta1client.PolicyV1beta1Client] + clientCache kcpclient.Cache[*policyv1beta1.PolicyV1beta1Client] clusterPath logicalcluster.Path } -func (n *evictionsNamespacer) Namespace(namespace string) policyv1beta1client.EvictionInterface { +func (n *evictionsNamespacer) Namespace(namespace string) policyv1beta1.EvictionInterface { return n.clientCache.ClusterOrDie(n.clusterPath).Evictions(namespace) } diff --git a/kubernetes/typed/policy/v1beta1/fake/doc.go b/kubernetes/typed/policy/v1beta1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/policy/v1beta1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/policy/v1beta1/fake/eviction.go b/kubernetes/typed/policy/v1beta1/fake/eviction.go index 6c9ca4f86..5ececa758 100644 --- a/kubernetes/typed/policy/v1beta1/fake/eviction.go +++ b/kubernetes/typed/policy/v1beta1/fake/eviction.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,47 +14,70 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( "github.com/kcp-dev/logicalcluster/v3" - "k8s.io/apimachinery/pkg/runtime/schema" - policyv1beta1client "k8s.io/client-go/kubernetes/typed/policy/v1beta1" + policyv1beta1 "k8s.io/api/policy/v1beta1" + typedpolicyv1beta1 "k8s.io/client-go/kubernetes/typed/policy/v1beta1" - kcppolicyv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/policy/v1beta1" + typedkcppolicyv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/policy/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var evictionsResource = schema.GroupVersionResource{Group: "policy", Version: "v1beta1", Resource: "evictions"} -var evictionsKind = schema.GroupVersionKind{Group: "policy", Version: "v1beta1", Kind: "Eviction"} - -type evictionsClusterClient struct { - *kcptesting.Fake +// evictionClusterClient implements EvictionClusterInterface +type evictionClusterClient struct { + *kcpgentype.FakeClusterClient[*policyv1beta1.Eviction] + Fake *kcptesting.Fake } -// Cluster scopes the client down to a particular cluster. -func (c *evictionsClusterClient) Cluster(clusterPath logicalcluster.Path) kcppolicyv1beta1.EvictionsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") +func newFakeEvictionClusterClient(fake *PolicyV1beta1ClusterClient) typedkcppolicyv1beta1.EvictionClusterInterface { + return &evictionClusterClient{ + kcpgentype.NewFakeClusterClient[*policyv1beta1.Eviction]( + fake.Fake, + policyv1beta1.SchemeGroupVersion.WithResource("evictions"), + policyv1beta1.SchemeGroupVersion.WithKind("Eviction"), + func() *policyv1beta1.Eviction { return &policyv1beta1.Eviction{} }, + ), + fake.Fake, } +} - return &evictionsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +func (c *evictionClusterClient) Cluster(cluster logicalcluster.Path) typedkcppolicyv1beta1.EvictionsNamespacer { + return &evictionNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type evictionsNamespacer struct { +type evictionNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *evictionsNamespacer) Namespace(namespace string) policyv1beta1client.EvictionInterface { - return &evictionsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *evictionNamespacer) Namespace(namespace string) typedpolicyv1beta1.EvictionInterface { + return newFakeEvictionClient(n.Fake, namespace, n.ClusterPath) } -type evictionsClient struct { - *kcptesting.Fake +// evictionScopedClient implements EvictionInterface +type evictionScopedClient struct { + *kcpgentype.FakeClient[*policyv1beta1.Eviction] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string +} + +func newFakeEvictionClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedpolicyv1beta1.EvictionInterface { + return &evictionScopedClient{ + kcpgentype.NewFakeClient[*policyv1beta1.Eviction]( + fake, + clusterPath, + namespace, + policyv1beta1.SchemeGroupVersion.WithResource("evictions"), + policyv1beta1.SchemeGroupVersion.WithKind("Eviction"), + func() *policyv1beta1.Eviction { return &policyv1beta1.Eviction{} }, + ), + fake, + clusterPath, + } } diff --git a/kubernetes/typed/policy/v1beta1/fake/fake_eviction_expansion.go b/kubernetes/typed/policy/v1beta1/fake/fake_eviction_expansion.go index e3cfd40ac..1199d32a0 100644 --- a/kubernetes/typed/policy/v1beta1/fake/fake_eviction_expansion.go +++ b/kubernetes/typed/policy/v1beta1/fake/fake_eviction_expansion.go @@ -26,10 +26,10 @@ import ( core "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -func (c *evictionsClient) Evict(ctx context.Context, eviction *policy.Eviction) error { +func (c *evictionScopedClient) Evict(ctx context.Context, eviction *policy.Eviction) error { action := core.CreateActionImpl{} action.Verb = "create" - action.Namespace = c.Namespace + action.Namespace = c.Namespace() action.ClusterPath = c.ClusterPath action.Resource = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "pods"} action.Subresource = "eviction" diff --git a/kubernetes/typed/policy/v1beta1/fake/poddisruptionbudget.go b/kubernetes/typed/policy/v1beta1/fake/poddisruptionbudget.go index 9f12cf7f8..c9763dc2a 100644 --- a/kubernetes/typed/policy/v1beta1/fake/poddisruptionbudget.go +++ b/kubernetes/typed/policy/v1beta1/fake/poddisruptionbudget.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" policyv1beta1 "k8s.io/api/policy/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationspolicyv1beta1 "k8s.io/client-go/applyconfigurations/policy/v1beta1" - policyv1beta1client "k8s.io/client-go/kubernetes/typed/policy/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/policy/v1beta1" + typedpolicyv1beta1 "k8s.io/client-go/kubernetes/typed/policy/v1beta1" - kcppolicyv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/policy/v1beta1" + typedkcppolicyv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/policy/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var podDisruptionBudgetsResource = schema.GroupVersionResource{Group: "policy", Version: "v1beta1", Resource: "poddisruptionbudgets"} -var podDisruptionBudgetsKind = schema.GroupVersionKind{Group: "policy", Version: "v1beta1", Kind: "PodDisruptionBudget"} - -type podDisruptionBudgetsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *podDisruptionBudgetsClusterClient) Cluster(clusterPath logicalcluster.Path) kcppolicyv1beta1.PodDisruptionBudgetsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &podDisruptionBudgetsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// podDisruptionBudgetClusterClient implements PodDisruptionBudgetClusterInterface +type podDisruptionBudgetClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*policyv1beta1.PodDisruptionBudget, *policyv1beta1.PodDisruptionBudgetList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of PodDisruptionBudgets that match those selectors across all clusters. -func (c *podDisruptionBudgetsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*policyv1beta1.PodDisruptionBudgetList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(podDisruptionBudgetsResource, podDisruptionBudgetsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &policyv1beta1.PodDisruptionBudgetList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakePodDisruptionBudgetClusterClient(fake *PolicyV1beta1ClusterClient) typedkcppolicyv1beta1.PodDisruptionBudgetClusterInterface { + return &podDisruptionBudgetClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*policyv1beta1.PodDisruptionBudget, *policyv1beta1.PodDisruptionBudgetList]( + fake.Fake, + policyv1beta1.SchemeGroupVersion.WithResource("poddisruptionbudgets"), + policyv1beta1.SchemeGroupVersion.WithKind("PodDisruptionBudget"), + func() *policyv1beta1.PodDisruptionBudget { return &policyv1beta1.PodDisruptionBudget{} }, + func() *policyv1beta1.PodDisruptionBudgetList { return &policyv1beta1.PodDisruptionBudgetList{} }, + func(dst, src *policyv1beta1.PodDisruptionBudgetList) { dst.ListMeta = src.ListMeta }, + func(list *policyv1beta1.PodDisruptionBudgetList) []*policyv1beta1.PodDisruptionBudget { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *policyv1beta1.PodDisruptionBudgetList, items []*policyv1beta1.PodDisruptionBudget) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &policyv1beta1.PodDisruptionBudgetList{ListMeta: obj.(*policyv1beta1.PodDisruptionBudgetList).ListMeta} - for _, item := range obj.(*policyv1beta1.PodDisruptionBudgetList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested PodDisruptionBudgets across all clusters. -func (c *podDisruptionBudgetsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(podDisruptionBudgetsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *podDisruptionBudgetClusterClient) Cluster(cluster logicalcluster.Path) typedkcppolicyv1beta1.PodDisruptionBudgetsNamespacer { + return &podDisruptionBudgetNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type podDisruptionBudgetsNamespacer struct { +type podDisruptionBudgetNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *podDisruptionBudgetsNamespacer) Namespace(namespace string) policyv1beta1client.PodDisruptionBudgetInterface { - return &podDisruptionBudgetsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *podDisruptionBudgetNamespacer) Namespace(namespace string) typedpolicyv1beta1.PodDisruptionBudgetInterface { + return newFakePodDisruptionBudgetClient(n.Fake, namespace, n.ClusterPath) } -type podDisruptionBudgetsClient struct { - *kcptesting.Fake +// podDisruptionBudgetScopedClient implements PodDisruptionBudgetInterface +type podDisruptionBudgetScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*policyv1beta1.PodDisruptionBudget, *policyv1beta1.PodDisruptionBudgetList, *v1beta1.PodDisruptionBudgetApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *podDisruptionBudgetsClient) Create(ctx context.Context, podDisruptionBudget *policyv1beta1.PodDisruptionBudget, opts metav1.CreateOptions) (*policyv1beta1.PodDisruptionBudget, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(podDisruptionBudgetsResource, c.ClusterPath, c.Namespace, podDisruptionBudget), &policyv1beta1.PodDisruptionBudget{}) - if obj == nil { - return nil, err - } - return obj.(*policyv1beta1.PodDisruptionBudget), err -} - -func (c *podDisruptionBudgetsClient) Update(ctx context.Context, podDisruptionBudget *policyv1beta1.PodDisruptionBudget, opts metav1.UpdateOptions) (*policyv1beta1.PodDisruptionBudget, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(podDisruptionBudgetsResource, c.ClusterPath, c.Namespace, podDisruptionBudget), &policyv1beta1.PodDisruptionBudget{}) - if obj == nil { - return nil, err - } - return obj.(*policyv1beta1.PodDisruptionBudget), err -} - -func (c *podDisruptionBudgetsClient) UpdateStatus(ctx context.Context, podDisruptionBudget *policyv1beta1.PodDisruptionBudget, opts metav1.UpdateOptions) (*policyv1beta1.PodDisruptionBudget, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(podDisruptionBudgetsResource, c.ClusterPath, "status", c.Namespace, podDisruptionBudget), &policyv1beta1.PodDisruptionBudget{}) - if obj == nil { - return nil, err - } - return obj.(*policyv1beta1.PodDisruptionBudget), err -} - -func (c *podDisruptionBudgetsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(podDisruptionBudgetsResource, c.ClusterPath, c.Namespace, name, opts), &policyv1beta1.PodDisruptionBudget{}) - return err -} - -func (c *podDisruptionBudgetsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(podDisruptionBudgetsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &policyv1beta1.PodDisruptionBudgetList{}) - return err -} - -func (c *podDisruptionBudgetsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*policyv1beta1.PodDisruptionBudget, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(podDisruptionBudgetsResource, c.ClusterPath, c.Namespace, name), &policyv1beta1.PodDisruptionBudget{}) - if obj == nil { - return nil, err - } - return obj.(*policyv1beta1.PodDisruptionBudget), err -} - -// List takes label and field selectors, and returns the list of PodDisruptionBudgets that match those selectors. -func (c *podDisruptionBudgetsClient) List(ctx context.Context, opts metav1.ListOptions) (*policyv1beta1.PodDisruptionBudgetList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(podDisruptionBudgetsResource, podDisruptionBudgetsKind, c.ClusterPath, c.Namespace, opts), &policyv1beta1.PodDisruptionBudgetList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &policyv1beta1.PodDisruptionBudgetList{ListMeta: obj.(*policyv1beta1.PodDisruptionBudgetList).ListMeta} - for _, item := range obj.(*policyv1beta1.PodDisruptionBudgetList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *podDisruptionBudgetsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(podDisruptionBudgetsResource, c.ClusterPath, c.Namespace, opts)) } -func (c *podDisruptionBudgetsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*policyv1beta1.PodDisruptionBudget, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(podDisruptionBudgetsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &policyv1beta1.PodDisruptionBudget{}) - if obj == nil { - return nil, err - } - return obj.(*policyv1beta1.PodDisruptionBudget), err -} - -func (c *podDisruptionBudgetsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationspolicyv1beta1.PodDisruptionBudgetApplyConfiguration, opts metav1.ApplyOptions) (*policyv1beta1.PodDisruptionBudget, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(podDisruptionBudgetsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &policyv1beta1.PodDisruptionBudget{}) - if obj == nil { - return nil, err - } - return obj.(*policyv1beta1.PodDisruptionBudget), err -} - -func (c *podDisruptionBudgetsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationspolicyv1beta1.PodDisruptionBudgetApplyConfiguration, opts metav1.ApplyOptions) (*policyv1beta1.PodDisruptionBudget, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(podDisruptionBudgetsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &policyv1beta1.PodDisruptionBudget{}) - if obj == nil { - return nil, err +func newFakePodDisruptionBudgetClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedpolicyv1beta1.PodDisruptionBudgetInterface { + return &podDisruptionBudgetScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*policyv1beta1.PodDisruptionBudget, *policyv1beta1.PodDisruptionBudgetList, *v1beta1.PodDisruptionBudgetApplyConfiguration]( + fake, + clusterPath, + namespace, + policyv1beta1.SchemeGroupVersion.WithResource("poddisruptionbudgets"), + policyv1beta1.SchemeGroupVersion.WithKind("PodDisruptionBudget"), + func() *policyv1beta1.PodDisruptionBudget { return &policyv1beta1.PodDisruptionBudget{} }, + func() *policyv1beta1.PodDisruptionBudgetList { return &policyv1beta1.PodDisruptionBudgetList{} }, + func(dst, src *policyv1beta1.PodDisruptionBudgetList) { dst.ListMeta = src.ListMeta }, + func(list *policyv1beta1.PodDisruptionBudgetList) []*policyv1beta1.PodDisruptionBudget { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *policyv1beta1.PodDisruptionBudgetList, items []*policyv1beta1.PodDisruptionBudget) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*policyv1beta1.PodDisruptionBudget), err } diff --git a/kubernetes/typed/policy/v1beta1/fake/policy_client.go b/kubernetes/typed/policy/v1beta1/fake/policy_client.go index ef87c2a24..275b7d0f7 100644 --- a/kubernetes/typed/policy/v1beta1/fake/policy_client.go +++ b/kubernetes/typed/policy/v1beta1/fake/policy_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" policyv1beta1 "k8s.io/client-go/kubernetes/typed/policy/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcppolicyv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/policy/v1beta1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -41,30 +41,30 @@ func (c *PolicyV1beta1ClusterClient) Cluster(clusterPath logicalcluster.Path) po return &PolicyV1beta1Client{Fake: c.Fake, ClusterPath: clusterPath} } -func (c *PolicyV1beta1ClusterClient) PodDisruptionBudgets() kcppolicyv1beta1.PodDisruptionBudgetClusterInterface { - return &podDisruptionBudgetsClusterClient{Fake: c.Fake} -} - func (c *PolicyV1beta1ClusterClient) Evictions() kcppolicyv1beta1.EvictionClusterInterface { - return &evictionsClusterClient{Fake: c.Fake} + return newFakeEvictionClusterClient(c) } -var _ policyv1beta1.PolicyV1beta1Interface = (*PolicyV1beta1Client)(nil) +func (c *PolicyV1beta1ClusterClient) PodDisruptionBudgets() kcppolicyv1beta1.PodDisruptionBudgetClusterInterface { + return newFakePodDisruptionBudgetClusterClient(c) +} type PolicyV1beta1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *PolicyV1beta1Client) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret +func (c *PolicyV1beta1Client) Evictions(namespace string) policyv1beta1.EvictionInterface { + return newFakeEvictionClient(c.Fake, namespace, c.ClusterPath) } func (c *PolicyV1beta1Client) PodDisruptionBudgets(namespace string) policyv1beta1.PodDisruptionBudgetInterface { - return &podDisruptionBudgetsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} + return newFakePodDisruptionBudgetClient(c.Fake, namespace, c.ClusterPath) } -func (c *PolicyV1beta1Client) Evictions(namespace string) policyv1beta1.EvictionInterface { - return &evictionsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *PolicyV1beta1Client) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret } diff --git a/kubernetes/typed/policy/v1beta1/generated_expansion.go b/kubernetes/typed/policy/v1beta1/generated_expansion.go new file mode 100644 index 000000000..fb03d2192 --- /dev/null +++ b/kubernetes/typed/policy/v1beta1/generated_expansion.go @@ -0,0 +1,23 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1beta1 + +type EvictionClusterExpansion interface{} + +type PodDisruptionBudgetClusterExpansion interface{} diff --git a/kubernetes/typed/policy/v1beta1/poddisruptionbudget.go b/kubernetes/typed/policy/v1beta1/poddisruptionbudget.go index 021fb1bb7..4ea51d783 100644 --- a/kubernetes/typed/policy/v1beta1/poddisruptionbudget.go +++ b/kubernetes/typed/policy/v1beta1/poddisruptionbudget.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" policyv1beta1 "k8s.io/api/policy/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - policyv1beta1client "k8s.io/client-go/kubernetes/typed/policy/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedpolicyv1beta1 "k8s.io/client-go/kubernetes/typed/policy/v1beta1" ) // PodDisruptionBudgetsClusterGetter has a method to return a PodDisruptionBudgetClusterInterface. @@ -40,12 +40,13 @@ type PodDisruptionBudgetsClusterGetter interface { // or scope down to one cluster and return a PodDisruptionBudgetsNamespacer. type PodDisruptionBudgetClusterInterface interface { Cluster(logicalcluster.Path) PodDisruptionBudgetsNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*policyv1beta1.PodDisruptionBudgetList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*policyv1beta1.PodDisruptionBudgetList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + PodDisruptionBudgetClusterExpansion } type podDisruptionBudgetsClusterInterface struct { - clientCache kcpclient.Cache[*policyv1beta1client.PolicyV1beta1Client] + clientCache kcpclient.Cache[*typedpolicyv1beta1.PolicyV1beta1Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *podDisruptionBudgetsClusterInterface) Cluster(clusterPath logicalcluste } // List returns the entire collection of all PodDisruptionBudgets across all clusters. -func (c *podDisruptionBudgetsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*policyv1beta1.PodDisruptionBudgetList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).PodDisruptionBudgets(metav1.NamespaceAll).List(ctx, opts) +func (c *podDisruptionBudgetsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*policyv1beta1.PodDisruptionBudgetList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).PodDisruptionBudgets(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all PodDisruptionBudgets across all clusters. -func (c *podDisruptionBudgetsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).PodDisruptionBudgets(metav1.NamespaceAll).Watch(ctx, opts) +func (c *podDisruptionBudgetsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).PodDisruptionBudgets(v1.NamespaceAll).Watch(ctx, opts) } -// PodDisruptionBudgetsNamespacer can scope to objects within a namespace, returning a policyv1beta1client.PodDisruptionBudgetInterface. +// PodDisruptionBudgetsNamespacer can scope to objects within a namespace, returning a typedpolicyv1beta1.PodDisruptionBudgetInterface. type PodDisruptionBudgetsNamespacer interface { - Namespace(string) policyv1beta1client.PodDisruptionBudgetInterface + Namespace(string) typedpolicyv1beta1.PodDisruptionBudgetInterface } type podDisruptionBudgetsNamespacer struct { - clientCache kcpclient.Cache[*policyv1beta1client.PolicyV1beta1Client] + clientCache kcpclient.Cache[*typedpolicyv1beta1.PolicyV1beta1Client] clusterPath logicalcluster.Path } -func (n *podDisruptionBudgetsNamespacer) Namespace(namespace string) policyv1beta1client.PodDisruptionBudgetInterface { +func (n *podDisruptionBudgetsNamespacer) Namespace(namespace string) typedpolicyv1beta1.PodDisruptionBudgetInterface { return n.clientCache.ClusterOrDie(n.clusterPath).PodDisruptionBudgets(namespace) } diff --git a/kubernetes/typed/policy/v1beta1/policy_client.go b/kubernetes/typed/policy/v1beta1/policy_client.go index 96f2a9827..349a3a17f 100644 --- a/kubernetes/typed/policy/v1beta1/policy_client.go +++ b/kubernetes/typed/policy/v1beta1/policy_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,30 +14,34 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apipolicyv1beta1 "k8s.io/api/policy/v1beta1" policyv1beta1 "k8s.io/client-go/kubernetes/typed/policy/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type PolicyV1beta1ClusterInterface interface { PolicyV1beta1ClusterScoper - PodDisruptionBudgetsClusterGetter EvictionsClusterGetter + PodDisruptionBudgetsClusterGetter } type PolicyV1beta1ClusterScoper interface { Cluster(logicalcluster.Path) policyv1beta1.PolicyV1beta1Interface } +// PolicyV1beta1ClusterClient is used to interact with features provided by the policy group. type PolicyV1beta1ClusterClient struct { clientCache kcpclient.Cache[*policyv1beta1.PolicyV1beta1Client] } @@ -49,23 +53,25 @@ func (c *PolicyV1beta1ClusterClient) Cluster(clusterPath logicalcluster.Path) po return c.clientCache.ClusterOrDie(clusterPath) } -func (c *PolicyV1beta1ClusterClient) PodDisruptionBudgets() PodDisruptionBudgetClusterInterface { - return &podDisruptionBudgetsClusterInterface{clientCache: c.clientCache} -} - func (c *PolicyV1beta1ClusterClient) Evictions() EvictionClusterInterface { return &evictionsClusterInterface{clientCache: c.clientCache} } +func (c *PolicyV1beta1ClusterClient) PodDisruptionBudgets() PodDisruptionBudgetClusterInterface { + return &podDisruptionBudgetsClusterInterface{clientCache: c.clientCache} +} + // NewForConfig creates a new PolicyV1beta1ClusterClient for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*PolicyV1beta1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new PolicyV1beta1ClusterClient for the given config and http client. @@ -77,6 +83,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*PolicyV1beta1Cluste if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &PolicyV1beta1ClusterClient{clientCache: cache}, nil } @@ -89,3 +96,14 @@ func NewForConfigOrDie(c *rest.Config) *PolicyV1beta1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apipolicyv1beta1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/rbac/v1/clusterrole.go b/kubernetes/typed/rbac/v1/clusterrole.go index 5f22fbbdc..d3eeb402f 100644 --- a/kubernetes/typed/rbac/v1/clusterrole.go +++ b/kubernetes/typed/rbac/v1/clusterrole.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - rbacv1 "k8s.io/api/rbac/v1" + apirbacv1 "k8s.io/api/rbac/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - rbacv1client "k8s.io/client-go/kubernetes/typed/rbac/v1" + watch "k8s.io/apimachinery/pkg/watch" + rbacv1 "k8s.io/client-go/kubernetes/typed/rbac/v1" ) // ClusterRolesClusterGetter has a method to return a ClusterRoleClusterInterface. @@ -37,19 +37,20 @@ type ClusterRolesClusterGetter interface { } // ClusterRoleClusterInterface can operate on ClusterRoles across all clusters, -// or scope down to one cluster and return a rbacv1client.ClusterRoleInterface. +// or scope down to one cluster and return a rbacv1.ClusterRoleInterface. type ClusterRoleClusterInterface interface { - Cluster(logicalcluster.Path) rbacv1client.ClusterRoleInterface - List(ctx context.Context, opts metav1.ListOptions) (*rbacv1.ClusterRoleList, error) + Cluster(logicalcluster.Path) rbacv1.ClusterRoleInterface + List(ctx context.Context, opts metav1.ListOptions) (*apirbacv1.ClusterRoleList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + ClusterRoleClusterExpansion } type clusterRolesClusterInterface struct { - clientCache kcpclient.Cache[*rbacv1client.RbacV1Client] + clientCache kcpclient.Cache[*rbacv1.RbacV1Client] } // Cluster scopes the client down to a particular cluster. -func (c *clusterRolesClusterInterface) Cluster(clusterPath logicalcluster.Path) rbacv1client.ClusterRoleInterface { +func (c *clusterRolesClusterInterface) Cluster(clusterPath logicalcluster.Path) rbacv1.ClusterRoleInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,7 +59,7 @@ func (c *clusterRolesClusterInterface) Cluster(clusterPath logicalcluster.Path) } // List returns the entire collection of all ClusterRoles across all clusters. -func (c *clusterRolesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1.ClusterRoleList, error) { +func (c *clusterRolesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*apirbacv1.ClusterRoleList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ClusterRoles().List(ctx, opts) } diff --git a/kubernetes/typed/rbac/v1/clusterrolebinding.go b/kubernetes/typed/rbac/v1/clusterrolebinding.go index 4c8f2a570..a255d893a 100644 --- a/kubernetes/typed/rbac/v1/clusterrolebinding.go +++ b/kubernetes/typed/rbac/v1/clusterrolebinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - rbacv1 "k8s.io/api/rbac/v1" + apirbacv1 "k8s.io/api/rbac/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - rbacv1client "k8s.io/client-go/kubernetes/typed/rbac/v1" + watch "k8s.io/apimachinery/pkg/watch" + rbacv1 "k8s.io/client-go/kubernetes/typed/rbac/v1" ) // ClusterRoleBindingsClusterGetter has a method to return a ClusterRoleBindingClusterInterface. @@ -37,19 +37,20 @@ type ClusterRoleBindingsClusterGetter interface { } // ClusterRoleBindingClusterInterface can operate on ClusterRoleBindings across all clusters, -// or scope down to one cluster and return a rbacv1client.ClusterRoleBindingInterface. +// or scope down to one cluster and return a rbacv1.ClusterRoleBindingInterface. type ClusterRoleBindingClusterInterface interface { - Cluster(logicalcluster.Path) rbacv1client.ClusterRoleBindingInterface - List(ctx context.Context, opts metav1.ListOptions) (*rbacv1.ClusterRoleBindingList, error) + Cluster(logicalcluster.Path) rbacv1.ClusterRoleBindingInterface + List(ctx context.Context, opts metav1.ListOptions) (*apirbacv1.ClusterRoleBindingList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + ClusterRoleBindingClusterExpansion } type clusterRoleBindingsClusterInterface struct { - clientCache kcpclient.Cache[*rbacv1client.RbacV1Client] + clientCache kcpclient.Cache[*rbacv1.RbacV1Client] } // Cluster scopes the client down to a particular cluster. -func (c *clusterRoleBindingsClusterInterface) Cluster(clusterPath logicalcluster.Path) rbacv1client.ClusterRoleBindingInterface { +func (c *clusterRoleBindingsClusterInterface) Cluster(clusterPath logicalcluster.Path) rbacv1.ClusterRoleBindingInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,7 +59,7 @@ func (c *clusterRoleBindingsClusterInterface) Cluster(clusterPath logicalcluster } // List returns the entire collection of all ClusterRoleBindings across all clusters. -func (c *clusterRoleBindingsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1.ClusterRoleBindingList, error) { +func (c *clusterRoleBindingsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*apirbacv1.ClusterRoleBindingList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ClusterRoleBindings().List(ctx, opts) } diff --git a/kubernetes/typed/rbac/v1/doc.go b/kubernetes/typed/rbac/v1/doc.go new file mode 100644 index 000000000..d2f3412ab --- /dev/null +++ b/kubernetes/typed/rbac/v1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1 diff --git a/kubernetes/typed/rbac/v1/fake/clusterrole.go b/kubernetes/typed/rbac/v1/fake/clusterrole.go index 8536d2729..3b36d3732 100644 --- a/kubernetes/typed/rbac/v1/fake/clusterrole.go +++ b/kubernetes/typed/rbac/v1/fake/clusterrole.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,74 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" rbacv1 "k8s.io/api/rbac/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsrbacv1 "k8s.io/client-go/applyconfigurations/rbac/v1" - rbacv1client "k8s.io/client-go/kubernetes/typed/rbac/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/rbac/v1" + typedrbacv1 "k8s.io/client-go/kubernetes/typed/rbac/v1" + typedkcprbacv1 "github.com/kcp-dev/client-go/kubernetes/typed/rbac/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var clusterRolesResource = schema.GroupVersionResource{Group: "rbac.authorization.k8s.io", Version: "v1", Resource: "clusterroles"} -var clusterRolesKind = schema.GroupVersionKind{Group: "rbac.authorization.k8s.io", Version: "v1", Kind: "ClusterRole"} - -type clusterRolesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *clusterRolesClusterClient) Cluster(clusterPath logicalcluster.Path) rbacv1client.ClusterRoleInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &clusterRolesClient{Fake: c.Fake, ClusterPath: clusterPath} +// clusterRoleClusterClient implements ClusterRoleClusterInterface +type clusterRoleClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*rbacv1.ClusterRole, *rbacv1.ClusterRoleList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of ClusterRoles that match those selectors across all clusters. -func (c *clusterRolesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1.ClusterRoleList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(clusterRolesResource, clusterRolesKind, logicalcluster.Wildcard, opts), &rbacv1.ClusterRoleList{}) - if obj == nil { - return nil, err +func newFakeClusterRoleClusterClient(fake *RbacV1ClusterClient) typedkcprbacv1.ClusterRoleClusterInterface { + return &clusterRoleClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*rbacv1.ClusterRole, *rbacv1.ClusterRoleList]( + fake.Fake, + rbacv1.SchemeGroupVersion.WithResource("clusterroles"), + rbacv1.SchemeGroupVersion.WithKind("ClusterRole"), + func() *rbacv1.ClusterRole { return &rbacv1.ClusterRole{} }, + func() *rbacv1.ClusterRoleList { return &rbacv1.ClusterRoleList{} }, + func(dst, src *rbacv1.ClusterRoleList) { dst.ListMeta = src.ListMeta }, + func(list *rbacv1.ClusterRoleList) []*rbacv1.ClusterRole { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *rbacv1.ClusterRoleList, items []*rbacv1.ClusterRole) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &rbacv1.ClusterRoleList{ListMeta: obj.(*rbacv1.ClusterRoleList).ListMeta} - for _, item := range obj.(*rbacv1.ClusterRoleList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested ClusterRoles across all clusters. -func (c *clusterRolesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(clusterRolesResource, logicalcluster.Wildcard, opts)) +func (c *clusterRoleClusterClient) Cluster(cluster logicalcluster.Path) typedrbacv1.ClusterRoleInterface { + return newFakeClusterRoleClient(c.Fake, cluster) } -type clusterRolesClient struct { - *kcptesting.Fake +// clusterRoleScopedClient implements ClusterRoleInterface +type clusterRoleScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*rbacv1.ClusterRole, *rbacv1.ClusterRoleList, *v1.ClusterRoleApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *clusterRolesClient) Create(ctx context.Context, clusterRole *rbacv1.ClusterRole, opts metav1.CreateOptions) (*rbacv1.ClusterRole, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(clusterRolesResource, c.ClusterPath, clusterRole), &rbacv1.ClusterRole{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1.ClusterRole), err -} - -func (c *clusterRolesClient) Update(ctx context.Context, clusterRole *rbacv1.ClusterRole, opts metav1.UpdateOptions) (*rbacv1.ClusterRole, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(clusterRolesResource, c.ClusterPath, clusterRole), &rbacv1.ClusterRole{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1.ClusterRole), err -} - -func (c *clusterRolesClient) UpdateStatus(ctx context.Context, clusterRole *rbacv1.ClusterRole, opts metav1.UpdateOptions) (*rbacv1.ClusterRole, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(clusterRolesResource, c.ClusterPath, "status", clusterRole), &rbacv1.ClusterRole{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1.ClusterRole), err -} - -func (c *clusterRolesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(clusterRolesResource, c.ClusterPath, name, opts), &rbacv1.ClusterRole{}) - return err -} - -func (c *clusterRolesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(clusterRolesResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &rbacv1.ClusterRoleList{}) - return err -} - -func (c *clusterRolesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*rbacv1.ClusterRole, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(clusterRolesResource, c.ClusterPath, name), &rbacv1.ClusterRole{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1.ClusterRole), err -} - -// List takes label and field selectors, and returns the list of ClusterRoles that match those selectors. -func (c *clusterRolesClient) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1.ClusterRoleList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(clusterRolesResource, clusterRolesKind, c.ClusterPath, opts), &rbacv1.ClusterRoleList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &rbacv1.ClusterRoleList{ListMeta: obj.(*rbacv1.ClusterRoleList).ListMeta} - for _, item := range obj.(*rbacv1.ClusterRoleList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *clusterRolesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(clusterRolesResource, c.ClusterPath, opts)) -} - -func (c *clusterRolesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*rbacv1.ClusterRole, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(clusterRolesResource, c.ClusterPath, name, pt, data, subresources...), &rbacv1.ClusterRole{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1.ClusterRole), err -} - -func (c *clusterRolesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsrbacv1.ClusterRoleApplyConfiguration, opts metav1.ApplyOptions) (*rbacv1.ClusterRole, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(clusterRolesResource, c.ClusterPath, *name, types.ApplyPatchType, data), &rbacv1.ClusterRole{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1.ClusterRole), err -} - -func (c *clusterRolesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsrbacv1.ClusterRoleApplyConfiguration, opts metav1.ApplyOptions) (*rbacv1.ClusterRole, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(clusterRolesResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &rbacv1.ClusterRole{}) - if obj == nil { - return nil, err +func newFakeClusterRoleClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedrbacv1.ClusterRoleInterface { + return &clusterRoleScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*rbacv1.ClusterRole, *rbacv1.ClusterRoleList, *v1.ClusterRoleApplyConfiguration]( + fake, + clusterPath, + "", + rbacv1.SchemeGroupVersion.WithResource("clusterroles"), + rbacv1.SchemeGroupVersion.WithKind("ClusterRole"), + func() *rbacv1.ClusterRole { return &rbacv1.ClusterRole{} }, + func() *rbacv1.ClusterRoleList { return &rbacv1.ClusterRoleList{} }, + func(dst, src *rbacv1.ClusterRoleList) { dst.ListMeta = src.ListMeta }, + func(list *rbacv1.ClusterRoleList) []*rbacv1.ClusterRole { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *rbacv1.ClusterRoleList, items []*rbacv1.ClusterRole) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*rbacv1.ClusterRole), err } diff --git a/kubernetes/typed/rbac/v1/fake/clusterrolebinding.go b/kubernetes/typed/rbac/v1/fake/clusterrolebinding.go index 3ff870757..d43fd7f33 100644 --- a/kubernetes/typed/rbac/v1/fake/clusterrolebinding.go +++ b/kubernetes/typed/rbac/v1/fake/clusterrolebinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" rbacv1 "k8s.io/api/rbac/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsrbacv1 "k8s.io/client-go/applyconfigurations/rbac/v1" - rbacv1client "k8s.io/client-go/kubernetes/typed/rbac/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/rbac/v1" + typedrbacv1 "k8s.io/client-go/kubernetes/typed/rbac/v1" + typedkcprbacv1 "github.com/kcp-dev/client-go/kubernetes/typed/rbac/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var clusterRoleBindingsResource = schema.GroupVersionResource{Group: "rbac.authorization.k8s.io", Version: "v1", Resource: "clusterrolebindings"} -var clusterRoleBindingsKind = schema.GroupVersionKind{Group: "rbac.authorization.k8s.io", Version: "v1", Kind: "ClusterRoleBinding"} - -type clusterRoleBindingsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *clusterRoleBindingsClusterClient) Cluster(clusterPath logicalcluster.Path) rbacv1client.ClusterRoleBindingInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &clusterRoleBindingsClient{Fake: c.Fake, ClusterPath: clusterPath} +// clusterRoleBindingClusterClient implements ClusterRoleBindingClusterInterface +type clusterRoleBindingClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*rbacv1.ClusterRoleBinding, *rbacv1.ClusterRoleBindingList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of ClusterRoleBindings that match those selectors across all clusters. -func (c *clusterRoleBindingsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1.ClusterRoleBindingList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(clusterRoleBindingsResource, clusterRoleBindingsKind, logicalcluster.Wildcard, opts), &rbacv1.ClusterRoleBindingList{}) - if obj == nil { - return nil, err +func newFakeClusterRoleBindingClusterClient(fake *RbacV1ClusterClient) typedkcprbacv1.ClusterRoleBindingClusterInterface { + return &clusterRoleBindingClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*rbacv1.ClusterRoleBinding, *rbacv1.ClusterRoleBindingList]( + fake.Fake, + rbacv1.SchemeGroupVersion.WithResource("clusterrolebindings"), + rbacv1.SchemeGroupVersion.WithKind("ClusterRoleBinding"), + func() *rbacv1.ClusterRoleBinding { return &rbacv1.ClusterRoleBinding{} }, + func() *rbacv1.ClusterRoleBindingList { return &rbacv1.ClusterRoleBindingList{} }, + func(dst, src *rbacv1.ClusterRoleBindingList) { dst.ListMeta = src.ListMeta }, + func(list *rbacv1.ClusterRoleBindingList) []*rbacv1.ClusterRoleBinding { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *rbacv1.ClusterRoleBindingList, items []*rbacv1.ClusterRoleBinding) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &rbacv1.ClusterRoleBindingList{ListMeta: obj.(*rbacv1.ClusterRoleBindingList).ListMeta} - for _, item := range obj.(*rbacv1.ClusterRoleBindingList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested ClusterRoleBindings across all clusters. -func (c *clusterRoleBindingsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(clusterRoleBindingsResource, logicalcluster.Wildcard, opts)) +func (c *clusterRoleBindingClusterClient) Cluster(cluster logicalcluster.Path) typedrbacv1.ClusterRoleBindingInterface { + return newFakeClusterRoleBindingClient(c.Fake, cluster) } -type clusterRoleBindingsClient struct { - *kcptesting.Fake +// clusterRoleBindingScopedClient implements ClusterRoleBindingInterface +type clusterRoleBindingScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*rbacv1.ClusterRoleBinding, *rbacv1.ClusterRoleBindingList, *v1.ClusterRoleBindingApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *clusterRoleBindingsClient) Create(ctx context.Context, clusterRoleBinding *rbacv1.ClusterRoleBinding, opts metav1.CreateOptions) (*rbacv1.ClusterRoleBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(clusterRoleBindingsResource, c.ClusterPath, clusterRoleBinding), &rbacv1.ClusterRoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1.ClusterRoleBinding), err -} - -func (c *clusterRoleBindingsClient) Update(ctx context.Context, clusterRoleBinding *rbacv1.ClusterRoleBinding, opts metav1.UpdateOptions) (*rbacv1.ClusterRoleBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(clusterRoleBindingsResource, c.ClusterPath, clusterRoleBinding), &rbacv1.ClusterRoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1.ClusterRoleBinding), err -} - -func (c *clusterRoleBindingsClient) UpdateStatus(ctx context.Context, clusterRoleBinding *rbacv1.ClusterRoleBinding, opts metav1.UpdateOptions) (*rbacv1.ClusterRoleBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(clusterRoleBindingsResource, c.ClusterPath, "status", clusterRoleBinding), &rbacv1.ClusterRoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1.ClusterRoleBinding), err -} - -func (c *clusterRoleBindingsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(clusterRoleBindingsResource, c.ClusterPath, name, opts), &rbacv1.ClusterRoleBinding{}) - return err -} - -func (c *clusterRoleBindingsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(clusterRoleBindingsResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &rbacv1.ClusterRoleBindingList{}) - return err -} - -func (c *clusterRoleBindingsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*rbacv1.ClusterRoleBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(clusterRoleBindingsResource, c.ClusterPath, name), &rbacv1.ClusterRoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1.ClusterRoleBinding), err -} - -// List takes label and field selectors, and returns the list of ClusterRoleBindings that match those selectors. -func (c *clusterRoleBindingsClient) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1.ClusterRoleBindingList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(clusterRoleBindingsResource, clusterRoleBindingsKind, c.ClusterPath, opts), &rbacv1.ClusterRoleBindingList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &rbacv1.ClusterRoleBindingList{ListMeta: obj.(*rbacv1.ClusterRoleBindingList).ListMeta} - for _, item := range obj.(*rbacv1.ClusterRoleBindingList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *clusterRoleBindingsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(clusterRoleBindingsResource, c.ClusterPath, opts)) -} - -func (c *clusterRoleBindingsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*rbacv1.ClusterRoleBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(clusterRoleBindingsResource, c.ClusterPath, name, pt, data, subresources...), &rbacv1.ClusterRoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1.ClusterRoleBinding), err -} - -func (c *clusterRoleBindingsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsrbacv1.ClusterRoleBindingApplyConfiguration, opts metav1.ApplyOptions) (*rbacv1.ClusterRoleBinding, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(clusterRoleBindingsResource, c.ClusterPath, *name, types.ApplyPatchType, data), &rbacv1.ClusterRoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1.ClusterRoleBinding), err -} - -func (c *clusterRoleBindingsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsrbacv1.ClusterRoleBindingApplyConfiguration, opts metav1.ApplyOptions) (*rbacv1.ClusterRoleBinding, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(clusterRoleBindingsResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &rbacv1.ClusterRoleBinding{}) - if obj == nil { - return nil, err +func newFakeClusterRoleBindingClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedrbacv1.ClusterRoleBindingInterface { + return &clusterRoleBindingScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*rbacv1.ClusterRoleBinding, *rbacv1.ClusterRoleBindingList, *v1.ClusterRoleBindingApplyConfiguration]( + fake, + clusterPath, + "", + rbacv1.SchemeGroupVersion.WithResource("clusterrolebindings"), + rbacv1.SchemeGroupVersion.WithKind("ClusterRoleBinding"), + func() *rbacv1.ClusterRoleBinding { return &rbacv1.ClusterRoleBinding{} }, + func() *rbacv1.ClusterRoleBindingList { return &rbacv1.ClusterRoleBindingList{} }, + func(dst, src *rbacv1.ClusterRoleBindingList) { dst.ListMeta = src.ListMeta }, + func(list *rbacv1.ClusterRoleBindingList) []*rbacv1.ClusterRoleBinding { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *rbacv1.ClusterRoleBindingList, items []*rbacv1.ClusterRoleBinding) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*rbacv1.ClusterRoleBinding), err } diff --git a/kubernetes/typed/rbac/v1/fake/doc.go b/kubernetes/typed/rbac/v1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/rbac/v1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/rbac/v1/fake/rbac_client.go b/kubernetes/typed/rbac/v1/fake/rbac_client.go index a0c005a2d..47743160f 100644 --- a/kubernetes/typed/rbac/v1/fake/rbac_client.go +++ b/kubernetes/typed/rbac/v1/fake/rbac_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" rbacv1 "k8s.io/client-go/kubernetes/typed/rbac/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcprbacv1 "github.com/kcp-dev/client-go/kubernetes/typed/rbac/v1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -41,46 +41,46 @@ func (c *RbacV1ClusterClient) Cluster(clusterPath logicalcluster.Path) rbacv1.Rb return &RbacV1Client{Fake: c.Fake, ClusterPath: clusterPath} } -func (c *RbacV1ClusterClient) Roles() kcprbacv1.RoleClusterInterface { - return &rolesClusterClient{Fake: c.Fake} +func (c *RbacV1ClusterClient) ClusterRoles() kcprbacv1.ClusterRoleClusterInterface { + return newFakeClusterRoleClusterClient(c) } -func (c *RbacV1ClusterClient) RoleBindings() kcprbacv1.RoleBindingClusterInterface { - return &roleBindingsClusterClient{Fake: c.Fake} +func (c *RbacV1ClusterClient) ClusterRoleBindings() kcprbacv1.ClusterRoleBindingClusterInterface { + return newFakeClusterRoleBindingClusterClient(c) } -func (c *RbacV1ClusterClient) ClusterRoles() kcprbacv1.ClusterRoleClusterInterface { - return &clusterRolesClusterClient{Fake: c.Fake} +func (c *RbacV1ClusterClient) Roles() kcprbacv1.RoleClusterInterface { + return newFakeRoleClusterClient(c) } -func (c *RbacV1ClusterClient) ClusterRoleBindings() kcprbacv1.ClusterRoleBindingClusterInterface { - return &clusterRoleBindingsClusterClient{Fake: c.Fake} +func (c *RbacV1ClusterClient) RoleBindings() kcprbacv1.RoleBindingClusterInterface { + return newFakeRoleBindingClusterClient(c) } -var _ rbacv1.RbacV1Interface = (*RbacV1Client)(nil) - type RbacV1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *RbacV1Client) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret +func (c *RbacV1Client) ClusterRoles() rbacv1.ClusterRoleInterface { + return newFakeClusterRoleClient(c.Fake, c.ClusterPath) } -func (c *RbacV1Client) Roles(namespace string) rbacv1.RoleInterface { - return &rolesClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *RbacV1Client) ClusterRoleBindings() rbacv1.ClusterRoleBindingInterface { + return newFakeClusterRoleBindingClient(c.Fake, c.ClusterPath) } -func (c *RbacV1Client) RoleBindings(namespace string) rbacv1.RoleBindingInterface { - return &roleBindingsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *RbacV1Client) Roles(namespace string) rbacv1.RoleInterface { + return newFakeRoleClient(c.Fake, namespace, c.ClusterPath) } -func (c *RbacV1Client) ClusterRoles() rbacv1.ClusterRoleInterface { - return &clusterRolesClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +func (c *RbacV1Client) RoleBindings(namespace string) rbacv1.RoleBindingInterface { + return newFakeRoleBindingClient(c.Fake, namespace, c.ClusterPath) } -func (c *RbacV1Client) ClusterRoleBindings() rbacv1.ClusterRoleBindingInterface { - return &clusterRoleBindingsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *RbacV1Client) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret } diff --git a/kubernetes/typed/rbac/v1/fake/role.go b/kubernetes/typed/rbac/v1/fake/role.go index af2905f54..11471dc06 100644 --- a/kubernetes/typed/rbac/v1/fake/role.go +++ b/kubernetes/typed/rbac/v1/fake/role.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" rbacv1 "k8s.io/api/rbac/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsrbacv1 "k8s.io/client-go/applyconfigurations/rbac/v1" - rbacv1client "k8s.io/client-go/kubernetes/typed/rbac/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/rbac/v1" + typedrbacv1 "k8s.io/client-go/kubernetes/typed/rbac/v1" - kcprbacv1 "github.com/kcp-dev/client-go/kubernetes/typed/rbac/v1" + typedkcprbacv1 "github.com/kcp-dev/client-go/kubernetes/typed/rbac/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var rolesResource = schema.GroupVersionResource{Group: "rbac.authorization.k8s.io", Version: "v1", Resource: "roles"} -var rolesKind = schema.GroupVersionKind{Group: "rbac.authorization.k8s.io", Version: "v1", Kind: "Role"} - -type rolesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *rolesClusterClient) Cluster(clusterPath logicalcluster.Path) kcprbacv1.RolesNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &rolesNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// roleClusterClient implements RoleClusterInterface +type roleClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*rbacv1.Role, *rbacv1.RoleList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of Roles that match those selectors across all clusters. -func (c *rolesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1.RoleList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(rolesResource, rolesKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &rbacv1.RoleList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeRoleClusterClient(fake *RbacV1ClusterClient) typedkcprbacv1.RoleClusterInterface { + return &roleClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*rbacv1.Role, *rbacv1.RoleList]( + fake.Fake, + rbacv1.SchemeGroupVersion.WithResource("roles"), + rbacv1.SchemeGroupVersion.WithKind("Role"), + func() *rbacv1.Role { return &rbacv1.Role{} }, + func() *rbacv1.RoleList { return &rbacv1.RoleList{} }, + func(dst, src *rbacv1.RoleList) { dst.ListMeta = src.ListMeta }, + func(list *rbacv1.RoleList) []*rbacv1.Role { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *rbacv1.RoleList, items []*rbacv1.Role) { list.Items = kcpgentype.FromPointerSlice(items) }, + ), + fake.Fake, } - list := &rbacv1.RoleList{ListMeta: obj.(*rbacv1.RoleList).ListMeta} - for _, item := range obj.(*rbacv1.RoleList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested Roles across all clusters. -func (c *rolesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(rolesResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *roleClusterClient) Cluster(cluster logicalcluster.Path) typedkcprbacv1.RolesNamespacer { + return &roleNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type rolesNamespacer struct { +type roleNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *rolesNamespacer) Namespace(namespace string) rbacv1client.RoleInterface { - return &rolesClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *roleNamespacer) Namespace(namespace string) typedrbacv1.RoleInterface { + return newFakeRoleClient(n.Fake, namespace, n.ClusterPath) } -type rolesClient struct { - *kcptesting.Fake +// roleScopedClient implements RoleInterface +type roleScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*rbacv1.Role, *rbacv1.RoleList, *v1.RoleApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *rolesClient) Create(ctx context.Context, role *rbacv1.Role, opts metav1.CreateOptions) (*rbacv1.Role, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(rolesResource, c.ClusterPath, c.Namespace, role), &rbacv1.Role{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1.Role), err -} - -func (c *rolesClient) Update(ctx context.Context, role *rbacv1.Role, opts metav1.UpdateOptions) (*rbacv1.Role, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(rolesResource, c.ClusterPath, c.Namespace, role), &rbacv1.Role{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1.Role), err -} - -func (c *rolesClient) UpdateStatus(ctx context.Context, role *rbacv1.Role, opts metav1.UpdateOptions) (*rbacv1.Role, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(rolesResource, c.ClusterPath, "status", c.Namespace, role), &rbacv1.Role{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1.Role), err -} - -func (c *rolesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(rolesResource, c.ClusterPath, c.Namespace, name, opts), &rbacv1.Role{}) - return err -} - -func (c *rolesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(rolesResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &rbacv1.RoleList{}) - return err -} - -func (c *rolesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*rbacv1.Role, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(rolesResource, c.ClusterPath, c.Namespace, name), &rbacv1.Role{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1.Role), err -} - -// List takes label and field selectors, and returns the list of Roles that match those selectors. -func (c *rolesClient) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1.RoleList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(rolesResource, rolesKind, c.ClusterPath, c.Namespace, opts), &rbacv1.RoleList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &rbacv1.RoleList{ListMeta: obj.(*rbacv1.RoleList).ListMeta} - for _, item := range obj.(*rbacv1.RoleList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *rolesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(rolesResource, c.ClusterPath, c.Namespace, opts)) } -func (c *rolesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*rbacv1.Role, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(rolesResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &rbacv1.Role{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1.Role), err -} - -func (c *rolesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsrbacv1.RoleApplyConfiguration, opts metav1.ApplyOptions) (*rbacv1.Role, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(rolesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &rbacv1.Role{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1.Role), err -} - -func (c *rolesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsrbacv1.RoleApplyConfiguration, opts metav1.ApplyOptions) (*rbacv1.Role, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(rolesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &rbacv1.Role{}) - if obj == nil { - return nil, err +func newFakeRoleClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedrbacv1.RoleInterface { + return &roleScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*rbacv1.Role, *rbacv1.RoleList, *v1.RoleApplyConfiguration]( + fake, + clusterPath, + namespace, + rbacv1.SchemeGroupVersion.WithResource("roles"), + rbacv1.SchemeGroupVersion.WithKind("Role"), + func() *rbacv1.Role { return &rbacv1.Role{} }, + func() *rbacv1.RoleList { return &rbacv1.RoleList{} }, + func(dst, src *rbacv1.RoleList) { dst.ListMeta = src.ListMeta }, + func(list *rbacv1.RoleList) []*rbacv1.Role { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *rbacv1.RoleList, items []*rbacv1.Role) { list.Items = kcpgentype.FromPointerSlice(items) }, + ), + fake, + clusterPath, } - return obj.(*rbacv1.Role), err } diff --git a/kubernetes/typed/rbac/v1/fake/rolebinding.go b/kubernetes/typed/rbac/v1/fake/rolebinding.go index 3ace9251a..bba12c153 100644 --- a/kubernetes/typed/rbac/v1/fake/rolebinding.go +++ b/kubernetes/typed/rbac/v1/fake/rolebinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,83 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" rbacv1 "k8s.io/api/rbac/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsrbacv1 "k8s.io/client-go/applyconfigurations/rbac/v1" - rbacv1client "k8s.io/client-go/kubernetes/typed/rbac/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/rbac/v1" + typedrbacv1 "k8s.io/client-go/kubernetes/typed/rbac/v1" - kcprbacv1 "github.com/kcp-dev/client-go/kubernetes/typed/rbac/v1" + typedkcprbacv1 "github.com/kcp-dev/client-go/kubernetes/typed/rbac/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var roleBindingsResource = schema.GroupVersionResource{Group: "rbac.authorization.k8s.io", Version: "v1", Resource: "rolebindings"} -var roleBindingsKind = schema.GroupVersionKind{Group: "rbac.authorization.k8s.io", Version: "v1", Kind: "RoleBinding"} - -type roleBindingsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *roleBindingsClusterClient) Cluster(clusterPath logicalcluster.Path) kcprbacv1.RoleBindingsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &roleBindingsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// roleBindingClusterClient implements RoleBindingClusterInterface +type roleBindingClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*rbacv1.RoleBinding, *rbacv1.RoleBindingList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of RoleBindings that match those selectors across all clusters. -func (c *roleBindingsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1.RoleBindingList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(roleBindingsResource, roleBindingsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &rbacv1.RoleBindingList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeRoleBindingClusterClient(fake *RbacV1ClusterClient) typedkcprbacv1.RoleBindingClusterInterface { + return &roleBindingClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*rbacv1.RoleBinding, *rbacv1.RoleBindingList]( + fake.Fake, + rbacv1.SchemeGroupVersion.WithResource("rolebindings"), + rbacv1.SchemeGroupVersion.WithKind("RoleBinding"), + func() *rbacv1.RoleBinding { return &rbacv1.RoleBinding{} }, + func() *rbacv1.RoleBindingList { return &rbacv1.RoleBindingList{} }, + func(dst, src *rbacv1.RoleBindingList) { dst.ListMeta = src.ListMeta }, + func(list *rbacv1.RoleBindingList) []*rbacv1.RoleBinding { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *rbacv1.RoleBindingList, items []*rbacv1.RoleBinding) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &rbacv1.RoleBindingList{ListMeta: obj.(*rbacv1.RoleBindingList).ListMeta} - for _, item := range obj.(*rbacv1.RoleBindingList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested RoleBindings across all clusters. -func (c *roleBindingsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(roleBindingsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *roleBindingClusterClient) Cluster(cluster logicalcluster.Path) typedkcprbacv1.RoleBindingsNamespacer { + return &roleBindingNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type roleBindingsNamespacer struct { +type roleBindingNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *roleBindingsNamespacer) Namespace(namespace string) rbacv1client.RoleBindingInterface { - return &roleBindingsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *roleBindingNamespacer) Namespace(namespace string) typedrbacv1.RoleBindingInterface { + return newFakeRoleBindingClient(n.Fake, namespace, n.ClusterPath) } -type roleBindingsClient struct { - *kcptesting.Fake +// roleBindingScopedClient implements RoleBindingInterface +type roleBindingScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*rbacv1.RoleBinding, *rbacv1.RoleBindingList, *v1.RoleBindingApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *roleBindingsClient) Create(ctx context.Context, roleBinding *rbacv1.RoleBinding, opts metav1.CreateOptions) (*rbacv1.RoleBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(roleBindingsResource, c.ClusterPath, c.Namespace, roleBinding), &rbacv1.RoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1.RoleBinding), err -} - -func (c *roleBindingsClient) Update(ctx context.Context, roleBinding *rbacv1.RoleBinding, opts metav1.UpdateOptions) (*rbacv1.RoleBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(roleBindingsResource, c.ClusterPath, c.Namespace, roleBinding), &rbacv1.RoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1.RoleBinding), err -} - -func (c *roleBindingsClient) UpdateStatus(ctx context.Context, roleBinding *rbacv1.RoleBinding, opts metav1.UpdateOptions) (*rbacv1.RoleBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(roleBindingsResource, c.ClusterPath, "status", c.Namespace, roleBinding), &rbacv1.RoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1.RoleBinding), err -} - -func (c *roleBindingsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(roleBindingsResource, c.ClusterPath, c.Namespace, name, opts), &rbacv1.RoleBinding{}) - return err -} - -func (c *roleBindingsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(roleBindingsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &rbacv1.RoleBindingList{}) - return err -} - -func (c *roleBindingsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*rbacv1.RoleBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(roleBindingsResource, c.ClusterPath, c.Namespace, name), &rbacv1.RoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1.RoleBinding), err -} - -// List takes label and field selectors, and returns the list of RoleBindings that match those selectors. -func (c *roleBindingsClient) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1.RoleBindingList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(roleBindingsResource, roleBindingsKind, c.ClusterPath, c.Namespace, opts), &rbacv1.RoleBindingList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &rbacv1.RoleBindingList{ListMeta: obj.(*rbacv1.RoleBindingList).ListMeta} - for _, item := range obj.(*rbacv1.RoleBindingList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *roleBindingsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(roleBindingsResource, c.ClusterPath, c.Namespace, opts)) } -func (c *roleBindingsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*rbacv1.RoleBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(roleBindingsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &rbacv1.RoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1.RoleBinding), err -} - -func (c *roleBindingsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsrbacv1.RoleBindingApplyConfiguration, opts metav1.ApplyOptions) (*rbacv1.RoleBinding, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(roleBindingsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &rbacv1.RoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1.RoleBinding), err -} - -func (c *roleBindingsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsrbacv1.RoleBindingApplyConfiguration, opts metav1.ApplyOptions) (*rbacv1.RoleBinding, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(roleBindingsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &rbacv1.RoleBinding{}) - if obj == nil { - return nil, err +func newFakeRoleBindingClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedrbacv1.RoleBindingInterface { + return &roleBindingScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*rbacv1.RoleBinding, *rbacv1.RoleBindingList, *v1.RoleBindingApplyConfiguration]( + fake, + clusterPath, + namespace, + rbacv1.SchemeGroupVersion.WithResource("rolebindings"), + rbacv1.SchemeGroupVersion.WithKind("RoleBinding"), + func() *rbacv1.RoleBinding { return &rbacv1.RoleBinding{} }, + func() *rbacv1.RoleBindingList { return &rbacv1.RoleBindingList{} }, + func(dst, src *rbacv1.RoleBindingList) { dst.ListMeta = src.ListMeta }, + func(list *rbacv1.RoleBindingList) []*rbacv1.RoleBinding { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *rbacv1.RoleBindingList, items []*rbacv1.RoleBinding) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*rbacv1.RoleBinding), err } diff --git a/kubernetes/typed/rbac/v1/generated_expansion.go b/kubernetes/typed/rbac/v1/generated_expansion.go new file mode 100644 index 000000000..89a3a52c2 --- /dev/null +++ b/kubernetes/typed/rbac/v1/generated_expansion.go @@ -0,0 +1,27 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1 + +type ClusterRoleClusterExpansion interface{} + +type ClusterRoleBindingClusterExpansion interface{} + +type RoleClusterExpansion interface{} + +type RoleBindingClusterExpansion interface{} diff --git a/kubernetes/typed/rbac/v1/rbac_client.go b/kubernetes/typed/rbac/v1/rbac_client.go index e44f2fd19..3efa001b8 100644 --- a/kubernetes/typed/rbac/v1/rbac_client.go +++ b/kubernetes/typed/rbac/v1/rbac_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,32 +14,36 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apirbacv1 "k8s.io/api/rbac/v1" rbacv1 "k8s.io/client-go/kubernetes/typed/rbac/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type RbacV1ClusterInterface interface { RbacV1ClusterScoper - RolesClusterGetter - RoleBindingsClusterGetter ClusterRolesClusterGetter ClusterRoleBindingsClusterGetter + RolesClusterGetter + RoleBindingsClusterGetter } type RbacV1ClusterScoper interface { Cluster(logicalcluster.Path) rbacv1.RbacV1Interface } +// RbacV1ClusterClient is used to interact with features provided by the rbac.authorization.k8s.io group. type RbacV1ClusterClient struct { clientCache kcpclient.Cache[*rbacv1.RbacV1Client] } @@ -51,14 +55,6 @@ func (c *RbacV1ClusterClient) Cluster(clusterPath logicalcluster.Path) rbacv1.Rb return c.clientCache.ClusterOrDie(clusterPath) } -func (c *RbacV1ClusterClient) Roles() RoleClusterInterface { - return &rolesClusterInterface{clientCache: c.clientCache} -} - -func (c *RbacV1ClusterClient) RoleBindings() RoleBindingClusterInterface { - return &roleBindingsClusterInterface{clientCache: c.clientCache} -} - func (c *RbacV1ClusterClient) ClusterRoles() ClusterRoleClusterInterface { return &clusterRolesClusterInterface{clientCache: c.clientCache} } @@ -67,15 +63,25 @@ func (c *RbacV1ClusterClient) ClusterRoleBindings() ClusterRoleBindingClusterInt return &clusterRoleBindingsClusterInterface{clientCache: c.clientCache} } +func (c *RbacV1ClusterClient) Roles() RoleClusterInterface { + return &rolesClusterInterface{clientCache: c.clientCache} +} + +func (c *RbacV1ClusterClient) RoleBindings() RoleBindingClusterInterface { + return &roleBindingsClusterInterface{clientCache: c.clientCache} +} + // NewForConfig creates a new RbacV1ClusterClient for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*RbacV1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new RbacV1ClusterClient for the given config and http client. @@ -87,6 +93,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*RbacV1ClusterClient if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &RbacV1ClusterClient{clientCache: cache}, nil } @@ -99,3 +106,14 @@ func NewForConfigOrDie(c *rest.Config) *RbacV1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apirbacv1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/rbac/v1/role.go b/kubernetes/typed/rbac/v1/role.go index 977e61ece..6b960c2e5 100644 --- a/kubernetes/typed/rbac/v1/role.go +++ b/kubernetes/typed/rbac/v1/role.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" rbacv1 "k8s.io/api/rbac/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - rbacv1client "k8s.io/client-go/kubernetes/typed/rbac/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedrbacv1 "k8s.io/client-go/kubernetes/typed/rbac/v1" ) // RolesClusterGetter has a method to return a RoleClusterInterface. @@ -42,10 +42,11 @@ type RoleClusterInterface interface { Cluster(logicalcluster.Path) RolesNamespacer List(ctx context.Context, opts metav1.ListOptions) (*rbacv1.RoleList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + RoleClusterExpansion } type rolesClusterInterface struct { - clientCache kcpclient.Cache[*rbacv1client.RbacV1Client] + clientCache kcpclient.Cache[*typedrbacv1.RbacV1Client] } // Cluster scopes the client down to a particular cluster. @@ -67,16 +68,16 @@ func (c *rolesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptio return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Roles(metav1.NamespaceAll).Watch(ctx, opts) } -// RolesNamespacer can scope to objects within a namespace, returning a rbacv1client.RoleInterface. +// RolesNamespacer can scope to objects within a namespace, returning a typedrbacv1.RoleInterface. type RolesNamespacer interface { - Namespace(string) rbacv1client.RoleInterface + Namespace(string) typedrbacv1.RoleInterface } type rolesNamespacer struct { - clientCache kcpclient.Cache[*rbacv1client.RbacV1Client] + clientCache kcpclient.Cache[*typedrbacv1.RbacV1Client] clusterPath logicalcluster.Path } -func (n *rolesNamespacer) Namespace(namespace string) rbacv1client.RoleInterface { +func (n *rolesNamespacer) Namespace(namespace string) typedrbacv1.RoleInterface { return n.clientCache.ClusterOrDie(n.clusterPath).Roles(namespace) } diff --git a/kubernetes/typed/rbac/v1/rolebinding.go b/kubernetes/typed/rbac/v1/rolebinding.go index ca707233d..fe1c8c146 100644 --- a/kubernetes/typed/rbac/v1/rolebinding.go +++ b/kubernetes/typed/rbac/v1/rolebinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" rbacv1 "k8s.io/api/rbac/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - rbacv1client "k8s.io/client-go/kubernetes/typed/rbac/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedrbacv1 "k8s.io/client-go/kubernetes/typed/rbac/v1" ) // RoleBindingsClusterGetter has a method to return a RoleBindingClusterInterface. @@ -42,10 +42,11 @@ type RoleBindingClusterInterface interface { Cluster(logicalcluster.Path) RoleBindingsNamespacer List(ctx context.Context, opts metav1.ListOptions) (*rbacv1.RoleBindingList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + RoleBindingClusterExpansion } type roleBindingsClusterInterface struct { - clientCache kcpclient.Cache[*rbacv1client.RbacV1Client] + clientCache kcpclient.Cache[*typedrbacv1.RbacV1Client] } // Cluster scopes the client down to a particular cluster. @@ -67,16 +68,16 @@ func (c *roleBindingsClusterInterface) Watch(ctx context.Context, opts metav1.Li return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).RoleBindings(metav1.NamespaceAll).Watch(ctx, opts) } -// RoleBindingsNamespacer can scope to objects within a namespace, returning a rbacv1client.RoleBindingInterface. +// RoleBindingsNamespacer can scope to objects within a namespace, returning a typedrbacv1.RoleBindingInterface. type RoleBindingsNamespacer interface { - Namespace(string) rbacv1client.RoleBindingInterface + Namespace(string) typedrbacv1.RoleBindingInterface } type roleBindingsNamespacer struct { - clientCache kcpclient.Cache[*rbacv1client.RbacV1Client] + clientCache kcpclient.Cache[*typedrbacv1.RbacV1Client] clusterPath logicalcluster.Path } -func (n *roleBindingsNamespacer) Namespace(namespace string) rbacv1client.RoleBindingInterface { +func (n *roleBindingsNamespacer) Namespace(namespace string) typedrbacv1.RoleBindingInterface { return n.clientCache.ClusterOrDie(n.clusterPath).RoleBindings(namespace) } diff --git a/kubernetes/typed/rbac/v1alpha1/clusterrole.go b/kubernetes/typed/rbac/v1alpha1/clusterrole.go index ef2a4180a..ceb5e2718 100644 --- a/kubernetes/typed/rbac/v1alpha1/clusterrole.go +++ b/kubernetes/typed/rbac/v1alpha1/clusterrole.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - rbacv1alpha1 "k8s.io/api/rbac/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - rbacv1alpha1client "k8s.io/client-go/kubernetes/typed/rbac/v1alpha1" + apirbacv1alpha1 "k8s.io/api/rbac/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + rbacv1alpha1 "k8s.io/client-go/kubernetes/typed/rbac/v1alpha1" ) // ClusterRolesClusterGetter has a method to return a ClusterRoleClusterInterface. @@ -37,19 +37,20 @@ type ClusterRolesClusterGetter interface { } // ClusterRoleClusterInterface can operate on ClusterRoles across all clusters, -// or scope down to one cluster and return a rbacv1alpha1client.ClusterRoleInterface. +// or scope down to one cluster and return a rbacv1alpha1.ClusterRoleInterface. type ClusterRoleClusterInterface interface { - Cluster(logicalcluster.Path) rbacv1alpha1client.ClusterRoleInterface - List(ctx context.Context, opts metav1.ListOptions) (*rbacv1alpha1.ClusterRoleList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) rbacv1alpha1.ClusterRoleInterface + List(ctx context.Context, opts v1.ListOptions) (*apirbacv1alpha1.ClusterRoleList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + ClusterRoleClusterExpansion } type clusterRolesClusterInterface struct { - clientCache kcpclient.Cache[*rbacv1alpha1client.RbacV1alpha1Client] + clientCache kcpclient.Cache[*rbacv1alpha1.RbacV1alpha1Client] } // Cluster scopes the client down to a particular cluster. -func (c *clusterRolesClusterInterface) Cluster(clusterPath logicalcluster.Path) rbacv1alpha1client.ClusterRoleInterface { +func (c *clusterRolesClusterInterface) Cluster(clusterPath logicalcluster.Path) rbacv1alpha1.ClusterRoleInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *clusterRolesClusterInterface) Cluster(clusterPath logicalcluster.Path) } // List returns the entire collection of all ClusterRoles across all clusters. -func (c *clusterRolesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1alpha1.ClusterRoleList, error) { +func (c *clusterRolesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apirbacv1alpha1.ClusterRoleList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ClusterRoles().List(ctx, opts) } // Watch begins to watch all ClusterRoles across all clusters. -func (c *clusterRolesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *clusterRolesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ClusterRoles().Watch(ctx, opts) } diff --git a/kubernetes/typed/rbac/v1alpha1/clusterrolebinding.go b/kubernetes/typed/rbac/v1alpha1/clusterrolebinding.go index 80a1c2620..d5a18bdc2 100644 --- a/kubernetes/typed/rbac/v1alpha1/clusterrolebinding.go +++ b/kubernetes/typed/rbac/v1alpha1/clusterrolebinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - rbacv1alpha1 "k8s.io/api/rbac/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - rbacv1alpha1client "k8s.io/client-go/kubernetes/typed/rbac/v1alpha1" + apirbacv1alpha1 "k8s.io/api/rbac/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + rbacv1alpha1 "k8s.io/client-go/kubernetes/typed/rbac/v1alpha1" ) // ClusterRoleBindingsClusterGetter has a method to return a ClusterRoleBindingClusterInterface. @@ -37,19 +37,20 @@ type ClusterRoleBindingsClusterGetter interface { } // ClusterRoleBindingClusterInterface can operate on ClusterRoleBindings across all clusters, -// or scope down to one cluster and return a rbacv1alpha1client.ClusterRoleBindingInterface. +// or scope down to one cluster and return a rbacv1alpha1.ClusterRoleBindingInterface. type ClusterRoleBindingClusterInterface interface { - Cluster(logicalcluster.Path) rbacv1alpha1client.ClusterRoleBindingInterface - List(ctx context.Context, opts metav1.ListOptions) (*rbacv1alpha1.ClusterRoleBindingList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) rbacv1alpha1.ClusterRoleBindingInterface + List(ctx context.Context, opts v1.ListOptions) (*apirbacv1alpha1.ClusterRoleBindingList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + ClusterRoleBindingClusterExpansion } type clusterRoleBindingsClusterInterface struct { - clientCache kcpclient.Cache[*rbacv1alpha1client.RbacV1alpha1Client] + clientCache kcpclient.Cache[*rbacv1alpha1.RbacV1alpha1Client] } // Cluster scopes the client down to a particular cluster. -func (c *clusterRoleBindingsClusterInterface) Cluster(clusterPath logicalcluster.Path) rbacv1alpha1client.ClusterRoleBindingInterface { +func (c *clusterRoleBindingsClusterInterface) Cluster(clusterPath logicalcluster.Path) rbacv1alpha1.ClusterRoleBindingInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *clusterRoleBindingsClusterInterface) Cluster(clusterPath logicalcluster } // List returns the entire collection of all ClusterRoleBindings across all clusters. -func (c *clusterRoleBindingsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1alpha1.ClusterRoleBindingList, error) { +func (c *clusterRoleBindingsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apirbacv1alpha1.ClusterRoleBindingList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ClusterRoleBindings().List(ctx, opts) } // Watch begins to watch all ClusterRoleBindings across all clusters. -func (c *clusterRoleBindingsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *clusterRoleBindingsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ClusterRoleBindings().Watch(ctx, opts) } diff --git a/kubernetes/typed/rbac/v1alpha1/doc.go b/kubernetes/typed/rbac/v1alpha1/doc.go new file mode 100644 index 000000000..08b80237c --- /dev/null +++ b/kubernetes/typed/rbac/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/kubernetes/typed/rbac/v1alpha1/fake/clusterrole.go b/kubernetes/typed/rbac/v1alpha1/fake/clusterrole.go index 71325f090..2cca2f2f0 100644 --- a/kubernetes/typed/rbac/v1alpha1/fake/clusterrole.go +++ b/kubernetes/typed/rbac/v1alpha1/fake/clusterrole.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" rbacv1alpha1 "k8s.io/api/rbac/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsrbacv1alpha1 "k8s.io/client-go/applyconfigurations/rbac/v1alpha1" - rbacv1alpha1client "k8s.io/client-go/kubernetes/typed/rbac/v1alpha1" - "k8s.io/client-go/testing" + v1alpha1 "k8s.io/client-go/applyconfigurations/rbac/v1alpha1" + typedrbacv1alpha1 "k8s.io/client-go/kubernetes/typed/rbac/v1alpha1" + typedkcprbacv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/rbac/v1alpha1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var clusterRolesResource = schema.GroupVersionResource{Group: "rbac.authorization.k8s.io", Version: "v1alpha1", Resource: "clusterroles"} -var clusterRolesKind = schema.GroupVersionKind{Group: "rbac.authorization.k8s.io", Version: "v1alpha1", Kind: "ClusterRole"} - -type clusterRolesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *clusterRolesClusterClient) Cluster(clusterPath logicalcluster.Path) rbacv1alpha1client.ClusterRoleInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &clusterRolesClient{Fake: c.Fake, ClusterPath: clusterPath} +// clusterRoleClusterClient implements ClusterRoleClusterInterface +type clusterRoleClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*rbacv1alpha1.ClusterRole, *rbacv1alpha1.ClusterRoleList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of ClusterRoles that match those selectors across all clusters. -func (c *clusterRolesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1alpha1.ClusterRoleList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(clusterRolesResource, clusterRolesKind, logicalcluster.Wildcard, opts), &rbacv1alpha1.ClusterRoleList{}) - if obj == nil { - return nil, err +func newFakeClusterRoleClusterClient(fake *RbacV1alpha1ClusterClient) typedkcprbacv1alpha1.ClusterRoleClusterInterface { + return &clusterRoleClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*rbacv1alpha1.ClusterRole, *rbacv1alpha1.ClusterRoleList]( + fake.Fake, + rbacv1alpha1.SchemeGroupVersion.WithResource("clusterroles"), + rbacv1alpha1.SchemeGroupVersion.WithKind("ClusterRole"), + func() *rbacv1alpha1.ClusterRole { return &rbacv1alpha1.ClusterRole{} }, + func() *rbacv1alpha1.ClusterRoleList { return &rbacv1alpha1.ClusterRoleList{} }, + func(dst, src *rbacv1alpha1.ClusterRoleList) { dst.ListMeta = src.ListMeta }, + func(list *rbacv1alpha1.ClusterRoleList) []*rbacv1alpha1.ClusterRole { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *rbacv1alpha1.ClusterRoleList, items []*rbacv1alpha1.ClusterRole) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &rbacv1alpha1.ClusterRoleList{ListMeta: obj.(*rbacv1alpha1.ClusterRoleList).ListMeta} - for _, item := range obj.(*rbacv1alpha1.ClusterRoleList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested ClusterRoles across all clusters. -func (c *clusterRolesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(clusterRolesResource, logicalcluster.Wildcard, opts)) +func (c *clusterRoleClusterClient) Cluster(cluster logicalcluster.Path) typedrbacv1alpha1.ClusterRoleInterface { + return newFakeClusterRoleClient(c.Fake, cluster) } -type clusterRolesClient struct { - *kcptesting.Fake +// clusterRoleScopedClient implements ClusterRoleInterface +type clusterRoleScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*rbacv1alpha1.ClusterRole, *rbacv1alpha1.ClusterRoleList, *v1alpha1.ClusterRoleApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *clusterRolesClient) Create(ctx context.Context, clusterRole *rbacv1alpha1.ClusterRole, opts metav1.CreateOptions) (*rbacv1alpha1.ClusterRole, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(clusterRolesResource, c.ClusterPath, clusterRole), &rbacv1alpha1.ClusterRole{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1alpha1.ClusterRole), err -} - -func (c *clusterRolesClient) Update(ctx context.Context, clusterRole *rbacv1alpha1.ClusterRole, opts metav1.UpdateOptions) (*rbacv1alpha1.ClusterRole, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(clusterRolesResource, c.ClusterPath, clusterRole), &rbacv1alpha1.ClusterRole{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1alpha1.ClusterRole), err -} - -func (c *clusterRolesClient) UpdateStatus(ctx context.Context, clusterRole *rbacv1alpha1.ClusterRole, opts metav1.UpdateOptions) (*rbacv1alpha1.ClusterRole, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(clusterRolesResource, c.ClusterPath, "status", clusterRole), &rbacv1alpha1.ClusterRole{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1alpha1.ClusterRole), err -} - -func (c *clusterRolesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(clusterRolesResource, c.ClusterPath, name, opts), &rbacv1alpha1.ClusterRole{}) - return err -} - -func (c *clusterRolesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(clusterRolesResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &rbacv1alpha1.ClusterRoleList{}) - return err -} - -func (c *clusterRolesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*rbacv1alpha1.ClusterRole, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(clusterRolesResource, c.ClusterPath, name), &rbacv1alpha1.ClusterRole{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1alpha1.ClusterRole), err -} - -// List takes label and field selectors, and returns the list of ClusterRoles that match those selectors. -func (c *clusterRolesClient) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1alpha1.ClusterRoleList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(clusterRolesResource, clusterRolesKind, c.ClusterPath, opts), &rbacv1alpha1.ClusterRoleList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &rbacv1alpha1.ClusterRoleList{ListMeta: obj.(*rbacv1alpha1.ClusterRoleList).ListMeta} - for _, item := range obj.(*rbacv1alpha1.ClusterRoleList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *clusterRolesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(clusterRolesResource, c.ClusterPath, opts)) -} - -func (c *clusterRolesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*rbacv1alpha1.ClusterRole, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(clusterRolesResource, c.ClusterPath, name, pt, data, subresources...), &rbacv1alpha1.ClusterRole{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1alpha1.ClusterRole), err -} - -func (c *clusterRolesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsrbacv1alpha1.ClusterRoleApplyConfiguration, opts metav1.ApplyOptions) (*rbacv1alpha1.ClusterRole, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(clusterRolesResource, c.ClusterPath, *name, types.ApplyPatchType, data), &rbacv1alpha1.ClusterRole{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1alpha1.ClusterRole), err -} - -func (c *clusterRolesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsrbacv1alpha1.ClusterRoleApplyConfiguration, opts metav1.ApplyOptions) (*rbacv1alpha1.ClusterRole, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(clusterRolesResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &rbacv1alpha1.ClusterRole{}) - if obj == nil { - return nil, err +func newFakeClusterRoleClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedrbacv1alpha1.ClusterRoleInterface { + return &clusterRoleScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*rbacv1alpha1.ClusterRole, *rbacv1alpha1.ClusterRoleList, *v1alpha1.ClusterRoleApplyConfiguration]( + fake, + clusterPath, + "", + rbacv1alpha1.SchemeGroupVersion.WithResource("clusterroles"), + rbacv1alpha1.SchemeGroupVersion.WithKind("ClusterRole"), + func() *rbacv1alpha1.ClusterRole { return &rbacv1alpha1.ClusterRole{} }, + func() *rbacv1alpha1.ClusterRoleList { return &rbacv1alpha1.ClusterRoleList{} }, + func(dst, src *rbacv1alpha1.ClusterRoleList) { dst.ListMeta = src.ListMeta }, + func(list *rbacv1alpha1.ClusterRoleList) []*rbacv1alpha1.ClusterRole { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *rbacv1alpha1.ClusterRoleList, items []*rbacv1alpha1.ClusterRole) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*rbacv1alpha1.ClusterRole), err } diff --git a/kubernetes/typed/rbac/v1alpha1/fake/clusterrolebinding.go b/kubernetes/typed/rbac/v1alpha1/fake/clusterrolebinding.go index d4b32ac4b..99c12c1ff 100644 --- a/kubernetes/typed/rbac/v1alpha1/fake/clusterrolebinding.go +++ b/kubernetes/typed/rbac/v1alpha1/fake/clusterrolebinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" rbacv1alpha1 "k8s.io/api/rbac/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsrbacv1alpha1 "k8s.io/client-go/applyconfigurations/rbac/v1alpha1" - rbacv1alpha1client "k8s.io/client-go/kubernetes/typed/rbac/v1alpha1" - "k8s.io/client-go/testing" + v1alpha1 "k8s.io/client-go/applyconfigurations/rbac/v1alpha1" + typedrbacv1alpha1 "k8s.io/client-go/kubernetes/typed/rbac/v1alpha1" + typedkcprbacv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/rbac/v1alpha1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var clusterRoleBindingsResource = schema.GroupVersionResource{Group: "rbac.authorization.k8s.io", Version: "v1alpha1", Resource: "clusterrolebindings"} -var clusterRoleBindingsKind = schema.GroupVersionKind{Group: "rbac.authorization.k8s.io", Version: "v1alpha1", Kind: "ClusterRoleBinding"} - -type clusterRoleBindingsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *clusterRoleBindingsClusterClient) Cluster(clusterPath logicalcluster.Path) rbacv1alpha1client.ClusterRoleBindingInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &clusterRoleBindingsClient{Fake: c.Fake, ClusterPath: clusterPath} +// clusterRoleBindingClusterClient implements ClusterRoleBindingClusterInterface +type clusterRoleBindingClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*rbacv1alpha1.ClusterRoleBinding, *rbacv1alpha1.ClusterRoleBindingList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of ClusterRoleBindings that match those selectors across all clusters. -func (c *clusterRoleBindingsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1alpha1.ClusterRoleBindingList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(clusterRoleBindingsResource, clusterRoleBindingsKind, logicalcluster.Wildcard, opts), &rbacv1alpha1.ClusterRoleBindingList{}) - if obj == nil { - return nil, err +func newFakeClusterRoleBindingClusterClient(fake *RbacV1alpha1ClusterClient) typedkcprbacv1alpha1.ClusterRoleBindingClusterInterface { + return &clusterRoleBindingClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*rbacv1alpha1.ClusterRoleBinding, *rbacv1alpha1.ClusterRoleBindingList]( + fake.Fake, + rbacv1alpha1.SchemeGroupVersion.WithResource("clusterrolebindings"), + rbacv1alpha1.SchemeGroupVersion.WithKind("ClusterRoleBinding"), + func() *rbacv1alpha1.ClusterRoleBinding { return &rbacv1alpha1.ClusterRoleBinding{} }, + func() *rbacv1alpha1.ClusterRoleBindingList { return &rbacv1alpha1.ClusterRoleBindingList{} }, + func(dst, src *rbacv1alpha1.ClusterRoleBindingList) { dst.ListMeta = src.ListMeta }, + func(list *rbacv1alpha1.ClusterRoleBindingList) []*rbacv1alpha1.ClusterRoleBinding { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *rbacv1alpha1.ClusterRoleBindingList, items []*rbacv1alpha1.ClusterRoleBinding) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &rbacv1alpha1.ClusterRoleBindingList{ListMeta: obj.(*rbacv1alpha1.ClusterRoleBindingList).ListMeta} - for _, item := range obj.(*rbacv1alpha1.ClusterRoleBindingList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested ClusterRoleBindings across all clusters. -func (c *clusterRoleBindingsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(clusterRoleBindingsResource, logicalcluster.Wildcard, opts)) +func (c *clusterRoleBindingClusterClient) Cluster(cluster logicalcluster.Path) typedrbacv1alpha1.ClusterRoleBindingInterface { + return newFakeClusterRoleBindingClient(c.Fake, cluster) } -type clusterRoleBindingsClient struct { - *kcptesting.Fake +// clusterRoleBindingScopedClient implements ClusterRoleBindingInterface +type clusterRoleBindingScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*rbacv1alpha1.ClusterRoleBinding, *rbacv1alpha1.ClusterRoleBindingList, *v1alpha1.ClusterRoleBindingApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *clusterRoleBindingsClient) Create(ctx context.Context, clusterRoleBinding *rbacv1alpha1.ClusterRoleBinding, opts metav1.CreateOptions) (*rbacv1alpha1.ClusterRoleBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(clusterRoleBindingsResource, c.ClusterPath, clusterRoleBinding), &rbacv1alpha1.ClusterRoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1alpha1.ClusterRoleBinding), err -} - -func (c *clusterRoleBindingsClient) Update(ctx context.Context, clusterRoleBinding *rbacv1alpha1.ClusterRoleBinding, opts metav1.UpdateOptions) (*rbacv1alpha1.ClusterRoleBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(clusterRoleBindingsResource, c.ClusterPath, clusterRoleBinding), &rbacv1alpha1.ClusterRoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1alpha1.ClusterRoleBinding), err -} - -func (c *clusterRoleBindingsClient) UpdateStatus(ctx context.Context, clusterRoleBinding *rbacv1alpha1.ClusterRoleBinding, opts metav1.UpdateOptions) (*rbacv1alpha1.ClusterRoleBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(clusterRoleBindingsResource, c.ClusterPath, "status", clusterRoleBinding), &rbacv1alpha1.ClusterRoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1alpha1.ClusterRoleBinding), err -} - -func (c *clusterRoleBindingsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(clusterRoleBindingsResource, c.ClusterPath, name, opts), &rbacv1alpha1.ClusterRoleBinding{}) - return err -} - -func (c *clusterRoleBindingsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(clusterRoleBindingsResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &rbacv1alpha1.ClusterRoleBindingList{}) - return err -} - -func (c *clusterRoleBindingsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*rbacv1alpha1.ClusterRoleBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(clusterRoleBindingsResource, c.ClusterPath, name), &rbacv1alpha1.ClusterRoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1alpha1.ClusterRoleBinding), err -} - -// List takes label and field selectors, and returns the list of ClusterRoleBindings that match those selectors. -func (c *clusterRoleBindingsClient) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1alpha1.ClusterRoleBindingList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(clusterRoleBindingsResource, clusterRoleBindingsKind, c.ClusterPath, opts), &rbacv1alpha1.ClusterRoleBindingList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &rbacv1alpha1.ClusterRoleBindingList{ListMeta: obj.(*rbacv1alpha1.ClusterRoleBindingList).ListMeta} - for _, item := range obj.(*rbacv1alpha1.ClusterRoleBindingList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *clusterRoleBindingsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(clusterRoleBindingsResource, c.ClusterPath, opts)) -} - -func (c *clusterRoleBindingsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*rbacv1alpha1.ClusterRoleBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(clusterRoleBindingsResource, c.ClusterPath, name, pt, data, subresources...), &rbacv1alpha1.ClusterRoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1alpha1.ClusterRoleBinding), err -} - -func (c *clusterRoleBindingsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsrbacv1alpha1.ClusterRoleBindingApplyConfiguration, opts metav1.ApplyOptions) (*rbacv1alpha1.ClusterRoleBinding, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(clusterRoleBindingsResource, c.ClusterPath, *name, types.ApplyPatchType, data), &rbacv1alpha1.ClusterRoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1alpha1.ClusterRoleBinding), err -} - -func (c *clusterRoleBindingsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsrbacv1alpha1.ClusterRoleBindingApplyConfiguration, opts metav1.ApplyOptions) (*rbacv1alpha1.ClusterRoleBinding, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(clusterRoleBindingsResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &rbacv1alpha1.ClusterRoleBinding{}) - if obj == nil { - return nil, err +func newFakeClusterRoleBindingClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedrbacv1alpha1.ClusterRoleBindingInterface { + return &clusterRoleBindingScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*rbacv1alpha1.ClusterRoleBinding, *rbacv1alpha1.ClusterRoleBindingList, *v1alpha1.ClusterRoleBindingApplyConfiguration]( + fake, + clusterPath, + "", + rbacv1alpha1.SchemeGroupVersion.WithResource("clusterrolebindings"), + rbacv1alpha1.SchemeGroupVersion.WithKind("ClusterRoleBinding"), + func() *rbacv1alpha1.ClusterRoleBinding { return &rbacv1alpha1.ClusterRoleBinding{} }, + func() *rbacv1alpha1.ClusterRoleBindingList { return &rbacv1alpha1.ClusterRoleBindingList{} }, + func(dst, src *rbacv1alpha1.ClusterRoleBindingList) { dst.ListMeta = src.ListMeta }, + func(list *rbacv1alpha1.ClusterRoleBindingList) []*rbacv1alpha1.ClusterRoleBinding { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *rbacv1alpha1.ClusterRoleBindingList, items []*rbacv1alpha1.ClusterRoleBinding) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*rbacv1alpha1.ClusterRoleBinding), err } diff --git a/kubernetes/typed/rbac/v1alpha1/fake/doc.go b/kubernetes/typed/rbac/v1alpha1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/rbac/v1alpha1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/rbac/v1alpha1/fake/rbac_client.go b/kubernetes/typed/rbac/v1alpha1/fake/rbac_client.go index 3e640ac25..8b3e7025b 100644 --- a/kubernetes/typed/rbac/v1alpha1/fake/rbac_client.go +++ b/kubernetes/typed/rbac/v1alpha1/fake/rbac_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" rbacv1alpha1 "k8s.io/client-go/kubernetes/typed/rbac/v1alpha1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcprbacv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/rbac/v1alpha1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -41,46 +41,46 @@ func (c *RbacV1alpha1ClusterClient) Cluster(clusterPath logicalcluster.Path) rba return &RbacV1alpha1Client{Fake: c.Fake, ClusterPath: clusterPath} } -func (c *RbacV1alpha1ClusterClient) Roles() kcprbacv1alpha1.RoleClusterInterface { - return &rolesClusterClient{Fake: c.Fake} +func (c *RbacV1alpha1ClusterClient) ClusterRoles() kcprbacv1alpha1.ClusterRoleClusterInterface { + return newFakeClusterRoleClusterClient(c) } -func (c *RbacV1alpha1ClusterClient) RoleBindings() kcprbacv1alpha1.RoleBindingClusterInterface { - return &roleBindingsClusterClient{Fake: c.Fake} +func (c *RbacV1alpha1ClusterClient) ClusterRoleBindings() kcprbacv1alpha1.ClusterRoleBindingClusterInterface { + return newFakeClusterRoleBindingClusterClient(c) } -func (c *RbacV1alpha1ClusterClient) ClusterRoles() kcprbacv1alpha1.ClusterRoleClusterInterface { - return &clusterRolesClusterClient{Fake: c.Fake} +func (c *RbacV1alpha1ClusterClient) Roles() kcprbacv1alpha1.RoleClusterInterface { + return newFakeRoleClusterClient(c) } -func (c *RbacV1alpha1ClusterClient) ClusterRoleBindings() kcprbacv1alpha1.ClusterRoleBindingClusterInterface { - return &clusterRoleBindingsClusterClient{Fake: c.Fake} +func (c *RbacV1alpha1ClusterClient) RoleBindings() kcprbacv1alpha1.RoleBindingClusterInterface { + return newFakeRoleBindingClusterClient(c) } -var _ rbacv1alpha1.RbacV1alpha1Interface = (*RbacV1alpha1Client)(nil) - type RbacV1alpha1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *RbacV1alpha1Client) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret +func (c *RbacV1alpha1Client) ClusterRoles() rbacv1alpha1.ClusterRoleInterface { + return newFakeClusterRoleClient(c.Fake, c.ClusterPath) } -func (c *RbacV1alpha1Client) Roles(namespace string) rbacv1alpha1.RoleInterface { - return &rolesClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *RbacV1alpha1Client) ClusterRoleBindings() rbacv1alpha1.ClusterRoleBindingInterface { + return newFakeClusterRoleBindingClient(c.Fake, c.ClusterPath) } -func (c *RbacV1alpha1Client) RoleBindings(namespace string) rbacv1alpha1.RoleBindingInterface { - return &roleBindingsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *RbacV1alpha1Client) Roles(namespace string) rbacv1alpha1.RoleInterface { + return newFakeRoleClient(c.Fake, namespace, c.ClusterPath) } -func (c *RbacV1alpha1Client) ClusterRoles() rbacv1alpha1.ClusterRoleInterface { - return &clusterRolesClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +func (c *RbacV1alpha1Client) RoleBindings(namespace string) rbacv1alpha1.RoleBindingInterface { + return newFakeRoleBindingClient(c.Fake, namespace, c.ClusterPath) } -func (c *RbacV1alpha1Client) ClusterRoleBindings() rbacv1alpha1.ClusterRoleBindingInterface { - return &clusterRoleBindingsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *RbacV1alpha1Client) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret } diff --git a/kubernetes/typed/rbac/v1alpha1/fake/role.go b/kubernetes/typed/rbac/v1alpha1/fake/role.go index 390f0a107..251e3304b 100644 --- a/kubernetes/typed/rbac/v1alpha1/fake/role.go +++ b/kubernetes/typed/rbac/v1alpha1/fake/role.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,83 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" rbacv1alpha1 "k8s.io/api/rbac/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsrbacv1alpha1 "k8s.io/client-go/applyconfigurations/rbac/v1alpha1" - rbacv1alpha1client "k8s.io/client-go/kubernetes/typed/rbac/v1alpha1" - "k8s.io/client-go/testing" + v1alpha1 "k8s.io/client-go/applyconfigurations/rbac/v1alpha1" + typedrbacv1alpha1 "k8s.io/client-go/kubernetes/typed/rbac/v1alpha1" - kcprbacv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/rbac/v1alpha1" + typedkcprbacv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/rbac/v1alpha1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var rolesResource = schema.GroupVersionResource{Group: "rbac.authorization.k8s.io", Version: "v1alpha1", Resource: "roles"} -var rolesKind = schema.GroupVersionKind{Group: "rbac.authorization.k8s.io", Version: "v1alpha1", Kind: "Role"} - -type rolesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *rolesClusterClient) Cluster(clusterPath logicalcluster.Path) kcprbacv1alpha1.RolesNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &rolesNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// roleClusterClient implements RoleClusterInterface +type roleClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*rbacv1alpha1.Role, *rbacv1alpha1.RoleList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of Roles that match those selectors across all clusters. -func (c *rolesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1alpha1.RoleList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(rolesResource, rolesKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &rbacv1alpha1.RoleList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeRoleClusterClient(fake *RbacV1alpha1ClusterClient) typedkcprbacv1alpha1.RoleClusterInterface { + return &roleClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*rbacv1alpha1.Role, *rbacv1alpha1.RoleList]( + fake.Fake, + rbacv1alpha1.SchemeGroupVersion.WithResource("roles"), + rbacv1alpha1.SchemeGroupVersion.WithKind("Role"), + func() *rbacv1alpha1.Role { return &rbacv1alpha1.Role{} }, + func() *rbacv1alpha1.RoleList { return &rbacv1alpha1.RoleList{} }, + func(dst, src *rbacv1alpha1.RoleList) { dst.ListMeta = src.ListMeta }, + func(list *rbacv1alpha1.RoleList) []*rbacv1alpha1.Role { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *rbacv1alpha1.RoleList, items []*rbacv1alpha1.Role) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &rbacv1alpha1.RoleList{ListMeta: obj.(*rbacv1alpha1.RoleList).ListMeta} - for _, item := range obj.(*rbacv1alpha1.RoleList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested Roles across all clusters. -func (c *rolesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(rolesResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *roleClusterClient) Cluster(cluster logicalcluster.Path) typedkcprbacv1alpha1.RolesNamespacer { + return &roleNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type rolesNamespacer struct { +type roleNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *rolesNamespacer) Namespace(namespace string) rbacv1alpha1client.RoleInterface { - return &rolesClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *roleNamespacer) Namespace(namespace string) typedrbacv1alpha1.RoleInterface { + return newFakeRoleClient(n.Fake, namespace, n.ClusterPath) } -type rolesClient struct { - *kcptesting.Fake +// roleScopedClient implements RoleInterface +type roleScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*rbacv1alpha1.Role, *rbacv1alpha1.RoleList, *v1alpha1.RoleApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *rolesClient) Create(ctx context.Context, role *rbacv1alpha1.Role, opts metav1.CreateOptions) (*rbacv1alpha1.Role, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(rolesResource, c.ClusterPath, c.Namespace, role), &rbacv1alpha1.Role{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1alpha1.Role), err -} - -func (c *rolesClient) Update(ctx context.Context, role *rbacv1alpha1.Role, opts metav1.UpdateOptions) (*rbacv1alpha1.Role, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(rolesResource, c.ClusterPath, c.Namespace, role), &rbacv1alpha1.Role{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1alpha1.Role), err -} - -func (c *rolesClient) UpdateStatus(ctx context.Context, role *rbacv1alpha1.Role, opts metav1.UpdateOptions) (*rbacv1alpha1.Role, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(rolesResource, c.ClusterPath, "status", c.Namespace, role), &rbacv1alpha1.Role{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1alpha1.Role), err -} - -func (c *rolesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(rolesResource, c.ClusterPath, c.Namespace, name, opts), &rbacv1alpha1.Role{}) - return err -} - -func (c *rolesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(rolesResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &rbacv1alpha1.RoleList{}) - return err -} - -func (c *rolesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*rbacv1alpha1.Role, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(rolesResource, c.ClusterPath, c.Namespace, name), &rbacv1alpha1.Role{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1alpha1.Role), err -} - -// List takes label and field selectors, and returns the list of Roles that match those selectors. -func (c *rolesClient) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1alpha1.RoleList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(rolesResource, rolesKind, c.ClusterPath, c.Namespace, opts), &rbacv1alpha1.RoleList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &rbacv1alpha1.RoleList{ListMeta: obj.(*rbacv1alpha1.RoleList).ListMeta} - for _, item := range obj.(*rbacv1alpha1.RoleList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *rolesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(rolesResource, c.ClusterPath, c.Namespace, opts)) } -func (c *rolesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*rbacv1alpha1.Role, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(rolesResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &rbacv1alpha1.Role{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1alpha1.Role), err -} - -func (c *rolesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsrbacv1alpha1.RoleApplyConfiguration, opts metav1.ApplyOptions) (*rbacv1alpha1.Role, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(rolesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &rbacv1alpha1.Role{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1alpha1.Role), err -} - -func (c *rolesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsrbacv1alpha1.RoleApplyConfiguration, opts metav1.ApplyOptions) (*rbacv1alpha1.Role, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(rolesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &rbacv1alpha1.Role{}) - if obj == nil { - return nil, err +func newFakeRoleClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedrbacv1alpha1.RoleInterface { + return &roleScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*rbacv1alpha1.Role, *rbacv1alpha1.RoleList, *v1alpha1.RoleApplyConfiguration]( + fake, + clusterPath, + namespace, + rbacv1alpha1.SchemeGroupVersion.WithResource("roles"), + rbacv1alpha1.SchemeGroupVersion.WithKind("Role"), + func() *rbacv1alpha1.Role { return &rbacv1alpha1.Role{} }, + func() *rbacv1alpha1.RoleList { return &rbacv1alpha1.RoleList{} }, + func(dst, src *rbacv1alpha1.RoleList) { dst.ListMeta = src.ListMeta }, + func(list *rbacv1alpha1.RoleList) []*rbacv1alpha1.Role { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *rbacv1alpha1.RoleList, items []*rbacv1alpha1.Role) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*rbacv1alpha1.Role), err } diff --git a/kubernetes/typed/rbac/v1alpha1/fake/rolebinding.go b/kubernetes/typed/rbac/v1alpha1/fake/rolebinding.go index 931bf35e0..3c60c85e7 100644 --- a/kubernetes/typed/rbac/v1alpha1/fake/rolebinding.go +++ b/kubernetes/typed/rbac/v1alpha1/fake/rolebinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" rbacv1alpha1 "k8s.io/api/rbac/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsrbacv1alpha1 "k8s.io/client-go/applyconfigurations/rbac/v1alpha1" - rbacv1alpha1client "k8s.io/client-go/kubernetes/typed/rbac/v1alpha1" - "k8s.io/client-go/testing" + v1alpha1 "k8s.io/client-go/applyconfigurations/rbac/v1alpha1" + typedrbacv1alpha1 "k8s.io/client-go/kubernetes/typed/rbac/v1alpha1" - kcprbacv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/rbac/v1alpha1" + typedkcprbacv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/rbac/v1alpha1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var roleBindingsResource = schema.GroupVersionResource{Group: "rbac.authorization.k8s.io", Version: "v1alpha1", Resource: "rolebindings"} -var roleBindingsKind = schema.GroupVersionKind{Group: "rbac.authorization.k8s.io", Version: "v1alpha1", Kind: "RoleBinding"} - -type roleBindingsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *roleBindingsClusterClient) Cluster(clusterPath logicalcluster.Path) kcprbacv1alpha1.RoleBindingsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &roleBindingsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// roleBindingClusterClient implements RoleBindingClusterInterface +type roleBindingClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*rbacv1alpha1.RoleBinding, *rbacv1alpha1.RoleBindingList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of RoleBindings that match those selectors across all clusters. -func (c *roleBindingsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1alpha1.RoleBindingList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(roleBindingsResource, roleBindingsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &rbacv1alpha1.RoleBindingList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeRoleBindingClusterClient(fake *RbacV1alpha1ClusterClient) typedkcprbacv1alpha1.RoleBindingClusterInterface { + return &roleBindingClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*rbacv1alpha1.RoleBinding, *rbacv1alpha1.RoleBindingList]( + fake.Fake, + rbacv1alpha1.SchemeGroupVersion.WithResource("rolebindings"), + rbacv1alpha1.SchemeGroupVersion.WithKind("RoleBinding"), + func() *rbacv1alpha1.RoleBinding { return &rbacv1alpha1.RoleBinding{} }, + func() *rbacv1alpha1.RoleBindingList { return &rbacv1alpha1.RoleBindingList{} }, + func(dst, src *rbacv1alpha1.RoleBindingList) { dst.ListMeta = src.ListMeta }, + func(list *rbacv1alpha1.RoleBindingList) []*rbacv1alpha1.RoleBinding { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *rbacv1alpha1.RoleBindingList, items []*rbacv1alpha1.RoleBinding) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &rbacv1alpha1.RoleBindingList{ListMeta: obj.(*rbacv1alpha1.RoleBindingList).ListMeta} - for _, item := range obj.(*rbacv1alpha1.RoleBindingList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested RoleBindings across all clusters. -func (c *roleBindingsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(roleBindingsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *roleBindingClusterClient) Cluster(cluster logicalcluster.Path) typedkcprbacv1alpha1.RoleBindingsNamespacer { + return &roleBindingNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type roleBindingsNamespacer struct { +type roleBindingNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *roleBindingsNamespacer) Namespace(namespace string) rbacv1alpha1client.RoleBindingInterface { - return &roleBindingsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *roleBindingNamespacer) Namespace(namespace string) typedrbacv1alpha1.RoleBindingInterface { + return newFakeRoleBindingClient(n.Fake, namespace, n.ClusterPath) } -type roleBindingsClient struct { - *kcptesting.Fake +// roleBindingScopedClient implements RoleBindingInterface +type roleBindingScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*rbacv1alpha1.RoleBinding, *rbacv1alpha1.RoleBindingList, *v1alpha1.RoleBindingApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *roleBindingsClient) Create(ctx context.Context, roleBinding *rbacv1alpha1.RoleBinding, opts metav1.CreateOptions) (*rbacv1alpha1.RoleBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(roleBindingsResource, c.ClusterPath, c.Namespace, roleBinding), &rbacv1alpha1.RoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1alpha1.RoleBinding), err -} - -func (c *roleBindingsClient) Update(ctx context.Context, roleBinding *rbacv1alpha1.RoleBinding, opts metav1.UpdateOptions) (*rbacv1alpha1.RoleBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(roleBindingsResource, c.ClusterPath, c.Namespace, roleBinding), &rbacv1alpha1.RoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1alpha1.RoleBinding), err -} - -func (c *roleBindingsClient) UpdateStatus(ctx context.Context, roleBinding *rbacv1alpha1.RoleBinding, opts metav1.UpdateOptions) (*rbacv1alpha1.RoleBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(roleBindingsResource, c.ClusterPath, "status", c.Namespace, roleBinding), &rbacv1alpha1.RoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1alpha1.RoleBinding), err -} - -func (c *roleBindingsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(roleBindingsResource, c.ClusterPath, c.Namespace, name, opts), &rbacv1alpha1.RoleBinding{}) - return err -} - -func (c *roleBindingsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(roleBindingsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &rbacv1alpha1.RoleBindingList{}) - return err -} - -func (c *roleBindingsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*rbacv1alpha1.RoleBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(roleBindingsResource, c.ClusterPath, c.Namespace, name), &rbacv1alpha1.RoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1alpha1.RoleBinding), err -} - -// List takes label and field selectors, and returns the list of RoleBindings that match those selectors. -func (c *roleBindingsClient) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1alpha1.RoleBindingList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(roleBindingsResource, roleBindingsKind, c.ClusterPath, c.Namespace, opts), &rbacv1alpha1.RoleBindingList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &rbacv1alpha1.RoleBindingList{ListMeta: obj.(*rbacv1alpha1.RoleBindingList).ListMeta} - for _, item := range obj.(*rbacv1alpha1.RoleBindingList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *roleBindingsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(roleBindingsResource, c.ClusterPath, c.Namespace, opts)) } -func (c *roleBindingsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*rbacv1alpha1.RoleBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(roleBindingsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &rbacv1alpha1.RoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1alpha1.RoleBinding), err -} - -func (c *roleBindingsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsrbacv1alpha1.RoleBindingApplyConfiguration, opts metav1.ApplyOptions) (*rbacv1alpha1.RoleBinding, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(roleBindingsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &rbacv1alpha1.RoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1alpha1.RoleBinding), err -} - -func (c *roleBindingsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsrbacv1alpha1.RoleBindingApplyConfiguration, opts metav1.ApplyOptions) (*rbacv1alpha1.RoleBinding, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(roleBindingsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &rbacv1alpha1.RoleBinding{}) - if obj == nil { - return nil, err +func newFakeRoleBindingClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedrbacv1alpha1.RoleBindingInterface { + return &roleBindingScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*rbacv1alpha1.RoleBinding, *rbacv1alpha1.RoleBindingList, *v1alpha1.RoleBindingApplyConfiguration]( + fake, + clusterPath, + namespace, + rbacv1alpha1.SchemeGroupVersion.WithResource("rolebindings"), + rbacv1alpha1.SchemeGroupVersion.WithKind("RoleBinding"), + func() *rbacv1alpha1.RoleBinding { return &rbacv1alpha1.RoleBinding{} }, + func() *rbacv1alpha1.RoleBindingList { return &rbacv1alpha1.RoleBindingList{} }, + func(dst, src *rbacv1alpha1.RoleBindingList) { dst.ListMeta = src.ListMeta }, + func(list *rbacv1alpha1.RoleBindingList) []*rbacv1alpha1.RoleBinding { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *rbacv1alpha1.RoleBindingList, items []*rbacv1alpha1.RoleBinding) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*rbacv1alpha1.RoleBinding), err } diff --git a/kubernetes/typed/rbac/v1alpha1/generated_expansion.go b/kubernetes/typed/rbac/v1alpha1/generated_expansion.go new file mode 100644 index 000000000..6705c7cbd --- /dev/null +++ b/kubernetes/typed/rbac/v1alpha1/generated_expansion.go @@ -0,0 +1,27 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1alpha1 + +type ClusterRoleClusterExpansion interface{} + +type ClusterRoleBindingClusterExpansion interface{} + +type RoleClusterExpansion interface{} + +type RoleBindingClusterExpansion interface{} diff --git a/kubernetes/typed/rbac/v1alpha1/rbac_client.go b/kubernetes/typed/rbac/v1alpha1/rbac_client.go index a168294a0..e40d9350c 100644 --- a/kubernetes/typed/rbac/v1alpha1/rbac_client.go +++ b/kubernetes/typed/rbac/v1alpha1/rbac_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,32 +14,36 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apirbacv1alpha1 "k8s.io/api/rbac/v1alpha1" rbacv1alpha1 "k8s.io/client-go/kubernetes/typed/rbac/v1alpha1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type RbacV1alpha1ClusterInterface interface { RbacV1alpha1ClusterScoper - RolesClusterGetter - RoleBindingsClusterGetter ClusterRolesClusterGetter ClusterRoleBindingsClusterGetter + RolesClusterGetter + RoleBindingsClusterGetter } type RbacV1alpha1ClusterScoper interface { Cluster(logicalcluster.Path) rbacv1alpha1.RbacV1alpha1Interface } +// RbacV1alpha1ClusterClient is used to interact with features provided by the rbac.authorization.k8s.io group. type RbacV1alpha1ClusterClient struct { clientCache kcpclient.Cache[*rbacv1alpha1.RbacV1alpha1Client] } @@ -51,14 +55,6 @@ func (c *RbacV1alpha1ClusterClient) Cluster(clusterPath logicalcluster.Path) rba return c.clientCache.ClusterOrDie(clusterPath) } -func (c *RbacV1alpha1ClusterClient) Roles() RoleClusterInterface { - return &rolesClusterInterface{clientCache: c.clientCache} -} - -func (c *RbacV1alpha1ClusterClient) RoleBindings() RoleBindingClusterInterface { - return &roleBindingsClusterInterface{clientCache: c.clientCache} -} - func (c *RbacV1alpha1ClusterClient) ClusterRoles() ClusterRoleClusterInterface { return &clusterRolesClusterInterface{clientCache: c.clientCache} } @@ -67,15 +63,25 @@ func (c *RbacV1alpha1ClusterClient) ClusterRoleBindings() ClusterRoleBindingClus return &clusterRoleBindingsClusterInterface{clientCache: c.clientCache} } +func (c *RbacV1alpha1ClusterClient) Roles() RoleClusterInterface { + return &rolesClusterInterface{clientCache: c.clientCache} +} + +func (c *RbacV1alpha1ClusterClient) RoleBindings() RoleBindingClusterInterface { + return &roleBindingsClusterInterface{clientCache: c.clientCache} +} + // NewForConfig creates a new RbacV1alpha1ClusterClient for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*RbacV1alpha1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new RbacV1alpha1ClusterClient for the given config and http client. @@ -87,6 +93,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*RbacV1alpha1Cluster if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &RbacV1alpha1ClusterClient{clientCache: cache}, nil } @@ -99,3 +106,14 @@ func NewForConfigOrDie(c *rest.Config) *RbacV1alpha1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apirbacv1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/rbac/v1alpha1/role.go b/kubernetes/typed/rbac/v1alpha1/role.go index ff621574f..1fd1dab06 100644 --- a/kubernetes/typed/rbac/v1alpha1/role.go +++ b/kubernetes/typed/rbac/v1alpha1/role.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" rbacv1alpha1 "k8s.io/api/rbac/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - rbacv1alpha1client "k8s.io/client-go/kubernetes/typed/rbac/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedrbacv1alpha1 "k8s.io/client-go/kubernetes/typed/rbac/v1alpha1" ) // RolesClusterGetter has a method to return a RoleClusterInterface. @@ -40,12 +40,13 @@ type RolesClusterGetter interface { // or scope down to one cluster and return a RolesNamespacer. type RoleClusterInterface interface { Cluster(logicalcluster.Path) RolesNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*rbacv1alpha1.RoleList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*rbacv1alpha1.RoleList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + RoleClusterExpansion } type rolesClusterInterface struct { - clientCache kcpclient.Cache[*rbacv1alpha1client.RbacV1alpha1Client] + clientCache kcpclient.Cache[*typedrbacv1alpha1.RbacV1alpha1Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *rolesClusterInterface) Cluster(clusterPath logicalcluster.Path) RolesNa } // List returns the entire collection of all Roles across all clusters. -func (c *rolesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1alpha1.RoleList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Roles(metav1.NamespaceAll).List(ctx, opts) +func (c *rolesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*rbacv1alpha1.RoleList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Roles(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all Roles across all clusters. -func (c *rolesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Roles(metav1.NamespaceAll).Watch(ctx, opts) +func (c *rolesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Roles(v1.NamespaceAll).Watch(ctx, opts) } -// RolesNamespacer can scope to objects within a namespace, returning a rbacv1alpha1client.RoleInterface. +// RolesNamespacer can scope to objects within a namespace, returning a typedrbacv1alpha1.RoleInterface. type RolesNamespacer interface { - Namespace(string) rbacv1alpha1client.RoleInterface + Namespace(string) typedrbacv1alpha1.RoleInterface } type rolesNamespacer struct { - clientCache kcpclient.Cache[*rbacv1alpha1client.RbacV1alpha1Client] + clientCache kcpclient.Cache[*typedrbacv1alpha1.RbacV1alpha1Client] clusterPath logicalcluster.Path } -func (n *rolesNamespacer) Namespace(namespace string) rbacv1alpha1client.RoleInterface { +func (n *rolesNamespacer) Namespace(namespace string) typedrbacv1alpha1.RoleInterface { return n.clientCache.ClusterOrDie(n.clusterPath).Roles(namespace) } diff --git a/kubernetes/typed/rbac/v1alpha1/rolebinding.go b/kubernetes/typed/rbac/v1alpha1/rolebinding.go index 89a275f95..5ebf17cfb 100644 --- a/kubernetes/typed/rbac/v1alpha1/rolebinding.go +++ b/kubernetes/typed/rbac/v1alpha1/rolebinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" rbacv1alpha1 "k8s.io/api/rbac/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - rbacv1alpha1client "k8s.io/client-go/kubernetes/typed/rbac/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedrbacv1alpha1 "k8s.io/client-go/kubernetes/typed/rbac/v1alpha1" ) // RoleBindingsClusterGetter has a method to return a RoleBindingClusterInterface. @@ -40,12 +40,13 @@ type RoleBindingsClusterGetter interface { // or scope down to one cluster and return a RoleBindingsNamespacer. type RoleBindingClusterInterface interface { Cluster(logicalcluster.Path) RoleBindingsNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*rbacv1alpha1.RoleBindingList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*rbacv1alpha1.RoleBindingList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + RoleBindingClusterExpansion } type roleBindingsClusterInterface struct { - clientCache kcpclient.Cache[*rbacv1alpha1client.RbacV1alpha1Client] + clientCache kcpclient.Cache[*typedrbacv1alpha1.RbacV1alpha1Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *roleBindingsClusterInterface) Cluster(clusterPath logicalcluster.Path) } // List returns the entire collection of all RoleBindings across all clusters. -func (c *roleBindingsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1alpha1.RoleBindingList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).RoleBindings(metav1.NamespaceAll).List(ctx, opts) +func (c *roleBindingsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*rbacv1alpha1.RoleBindingList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).RoleBindings(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all RoleBindings across all clusters. -func (c *roleBindingsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).RoleBindings(metav1.NamespaceAll).Watch(ctx, opts) +func (c *roleBindingsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).RoleBindings(v1.NamespaceAll).Watch(ctx, opts) } -// RoleBindingsNamespacer can scope to objects within a namespace, returning a rbacv1alpha1client.RoleBindingInterface. +// RoleBindingsNamespacer can scope to objects within a namespace, returning a typedrbacv1alpha1.RoleBindingInterface. type RoleBindingsNamespacer interface { - Namespace(string) rbacv1alpha1client.RoleBindingInterface + Namespace(string) typedrbacv1alpha1.RoleBindingInterface } type roleBindingsNamespacer struct { - clientCache kcpclient.Cache[*rbacv1alpha1client.RbacV1alpha1Client] + clientCache kcpclient.Cache[*typedrbacv1alpha1.RbacV1alpha1Client] clusterPath logicalcluster.Path } -func (n *roleBindingsNamespacer) Namespace(namespace string) rbacv1alpha1client.RoleBindingInterface { +func (n *roleBindingsNamespacer) Namespace(namespace string) typedrbacv1alpha1.RoleBindingInterface { return n.clientCache.ClusterOrDie(n.clusterPath).RoleBindings(namespace) } diff --git a/kubernetes/typed/rbac/v1beta1/clusterrole.go b/kubernetes/typed/rbac/v1beta1/clusterrole.go index 25b7a5d10..e4cc9f236 100644 --- a/kubernetes/typed/rbac/v1beta1/clusterrole.go +++ b/kubernetes/typed/rbac/v1beta1/clusterrole.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - rbacv1beta1 "k8s.io/api/rbac/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - rbacv1beta1client "k8s.io/client-go/kubernetes/typed/rbac/v1beta1" + apirbacv1beta1 "k8s.io/api/rbac/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + rbacv1beta1 "k8s.io/client-go/kubernetes/typed/rbac/v1beta1" ) // ClusterRolesClusterGetter has a method to return a ClusterRoleClusterInterface. @@ -37,19 +37,20 @@ type ClusterRolesClusterGetter interface { } // ClusterRoleClusterInterface can operate on ClusterRoles across all clusters, -// or scope down to one cluster and return a rbacv1beta1client.ClusterRoleInterface. +// or scope down to one cluster and return a rbacv1beta1.ClusterRoleInterface. type ClusterRoleClusterInterface interface { - Cluster(logicalcluster.Path) rbacv1beta1client.ClusterRoleInterface - List(ctx context.Context, opts metav1.ListOptions) (*rbacv1beta1.ClusterRoleList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) rbacv1beta1.ClusterRoleInterface + List(ctx context.Context, opts v1.ListOptions) (*apirbacv1beta1.ClusterRoleList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + ClusterRoleClusterExpansion } type clusterRolesClusterInterface struct { - clientCache kcpclient.Cache[*rbacv1beta1client.RbacV1beta1Client] + clientCache kcpclient.Cache[*rbacv1beta1.RbacV1beta1Client] } // Cluster scopes the client down to a particular cluster. -func (c *clusterRolesClusterInterface) Cluster(clusterPath logicalcluster.Path) rbacv1beta1client.ClusterRoleInterface { +func (c *clusterRolesClusterInterface) Cluster(clusterPath logicalcluster.Path) rbacv1beta1.ClusterRoleInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *clusterRolesClusterInterface) Cluster(clusterPath logicalcluster.Path) } // List returns the entire collection of all ClusterRoles across all clusters. -func (c *clusterRolesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1beta1.ClusterRoleList, error) { +func (c *clusterRolesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apirbacv1beta1.ClusterRoleList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ClusterRoles().List(ctx, opts) } // Watch begins to watch all ClusterRoles across all clusters. -func (c *clusterRolesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *clusterRolesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ClusterRoles().Watch(ctx, opts) } diff --git a/kubernetes/typed/rbac/v1beta1/clusterrolebinding.go b/kubernetes/typed/rbac/v1beta1/clusterrolebinding.go index 7b8e8872e..877024ac4 100644 --- a/kubernetes/typed/rbac/v1beta1/clusterrolebinding.go +++ b/kubernetes/typed/rbac/v1beta1/clusterrolebinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - rbacv1beta1 "k8s.io/api/rbac/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - rbacv1beta1client "k8s.io/client-go/kubernetes/typed/rbac/v1beta1" + apirbacv1beta1 "k8s.io/api/rbac/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + rbacv1beta1 "k8s.io/client-go/kubernetes/typed/rbac/v1beta1" ) // ClusterRoleBindingsClusterGetter has a method to return a ClusterRoleBindingClusterInterface. @@ -37,19 +37,20 @@ type ClusterRoleBindingsClusterGetter interface { } // ClusterRoleBindingClusterInterface can operate on ClusterRoleBindings across all clusters, -// or scope down to one cluster and return a rbacv1beta1client.ClusterRoleBindingInterface. +// or scope down to one cluster and return a rbacv1beta1.ClusterRoleBindingInterface. type ClusterRoleBindingClusterInterface interface { - Cluster(logicalcluster.Path) rbacv1beta1client.ClusterRoleBindingInterface - List(ctx context.Context, opts metav1.ListOptions) (*rbacv1beta1.ClusterRoleBindingList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) rbacv1beta1.ClusterRoleBindingInterface + List(ctx context.Context, opts v1.ListOptions) (*apirbacv1beta1.ClusterRoleBindingList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + ClusterRoleBindingClusterExpansion } type clusterRoleBindingsClusterInterface struct { - clientCache kcpclient.Cache[*rbacv1beta1client.RbacV1beta1Client] + clientCache kcpclient.Cache[*rbacv1beta1.RbacV1beta1Client] } // Cluster scopes the client down to a particular cluster. -func (c *clusterRoleBindingsClusterInterface) Cluster(clusterPath logicalcluster.Path) rbacv1beta1client.ClusterRoleBindingInterface { +func (c *clusterRoleBindingsClusterInterface) Cluster(clusterPath logicalcluster.Path) rbacv1beta1.ClusterRoleBindingInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *clusterRoleBindingsClusterInterface) Cluster(clusterPath logicalcluster } // List returns the entire collection of all ClusterRoleBindings across all clusters. -func (c *clusterRoleBindingsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1beta1.ClusterRoleBindingList, error) { +func (c *clusterRoleBindingsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apirbacv1beta1.ClusterRoleBindingList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ClusterRoleBindings().List(ctx, opts) } // Watch begins to watch all ClusterRoleBindings across all clusters. -func (c *clusterRoleBindingsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *clusterRoleBindingsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ClusterRoleBindings().Watch(ctx, opts) } diff --git a/kubernetes/typed/rbac/v1beta1/doc.go b/kubernetes/typed/rbac/v1beta1/doc.go new file mode 100644 index 000000000..541e9d258 --- /dev/null +++ b/kubernetes/typed/rbac/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1beta1 diff --git a/kubernetes/typed/rbac/v1beta1/fake/clusterrole.go b/kubernetes/typed/rbac/v1beta1/fake/clusterrole.go index 5fcc8d18a..58cfefc89 100644 --- a/kubernetes/typed/rbac/v1beta1/fake/clusterrole.go +++ b/kubernetes/typed/rbac/v1beta1/fake/clusterrole.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" rbacv1beta1 "k8s.io/api/rbac/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsrbacv1beta1 "k8s.io/client-go/applyconfigurations/rbac/v1beta1" - rbacv1beta1client "k8s.io/client-go/kubernetes/typed/rbac/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/rbac/v1beta1" + typedrbacv1beta1 "k8s.io/client-go/kubernetes/typed/rbac/v1beta1" + typedkcprbacv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/rbac/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var clusterRolesResource = schema.GroupVersionResource{Group: "rbac.authorization.k8s.io", Version: "v1beta1", Resource: "clusterroles"} -var clusterRolesKind = schema.GroupVersionKind{Group: "rbac.authorization.k8s.io", Version: "v1beta1", Kind: "ClusterRole"} - -type clusterRolesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *clusterRolesClusterClient) Cluster(clusterPath logicalcluster.Path) rbacv1beta1client.ClusterRoleInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &clusterRolesClient{Fake: c.Fake, ClusterPath: clusterPath} +// clusterRoleClusterClient implements ClusterRoleClusterInterface +type clusterRoleClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*rbacv1beta1.ClusterRole, *rbacv1beta1.ClusterRoleList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of ClusterRoles that match those selectors across all clusters. -func (c *clusterRolesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1beta1.ClusterRoleList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(clusterRolesResource, clusterRolesKind, logicalcluster.Wildcard, opts), &rbacv1beta1.ClusterRoleList{}) - if obj == nil { - return nil, err +func newFakeClusterRoleClusterClient(fake *RbacV1beta1ClusterClient) typedkcprbacv1beta1.ClusterRoleClusterInterface { + return &clusterRoleClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*rbacv1beta1.ClusterRole, *rbacv1beta1.ClusterRoleList]( + fake.Fake, + rbacv1beta1.SchemeGroupVersion.WithResource("clusterroles"), + rbacv1beta1.SchemeGroupVersion.WithKind("ClusterRole"), + func() *rbacv1beta1.ClusterRole { return &rbacv1beta1.ClusterRole{} }, + func() *rbacv1beta1.ClusterRoleList { return &rbacv1beta1.ClusterRoleList{} }, + func(dst, src *rbacv1beta1.ClusterRoleList) { dst.ListMeta = src.ListMeta }, + func(list *rbacv1beta1.ClusterRoleList) []*rbacv1beta1.ClusterRole { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *rbacv1beta1.ClusterRoleList, items []*rbacv1beta1.ClusterRole) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &rbacv1beta1.ClusterRoleList{ListMeta: obj.(*rbacv1beta1.ClusterRoleList).ListMeta} - for _, item := range obj.(*rbacv1beta1.ClusterRoleList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested ClusterRoles across all clusters. -func (c *clusterRolesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(clusterRolesResource, logicalcluster.Wildcard, opts)) +func (c *clusterRoleClusterClient) Cluster(cluster logicalcluster.Path) typedrbacv1beta1.ClusterRoleInterface { + return newFakeClusterRoleClient(c.Fake, cluster) } -type clusterRolesClient struct { - *kcptesting.Fake +// clusterRoleScopedClient implements ClusterRoleInterface +type clusterRoleScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*rbacv1beta1.ClusterRole, *rbacv1beta1.ClusterRoleList, *v1beta1.ClusterRoleApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *clusterRolesClient) Create(ctx context.Context, clusterRole *rbacv1beta1.ClusterRole, opts metav1.CreateOptions) (*rbacv1beta1.ClusterRole, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(clusterRolesResource, c.ClusterPath, clusterRole), &rbacv1beta1.ClusterRole{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1beta1.ClusterRole), err -} - -func (c *clusterRolesClient) Update(ctx context.Context, clusterRole *rbacv1beta1.ClusterRole, opts metav1.UpdateOptions) (*rbacv1beta1.ClusterRole, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(clusterRolesResource, c.ClusterPath, clusterRole), &rbacv1beta1.ClusterRole{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1beta1.ClusterRole), err -} - -func (c *clusterRolesClient) UpdateStatus(ctx context.Context, clusterRole *rbacv1beta1.ClusterRole, opts metav1.UpdateOptions) (*rbacv1beta1.ClusterRole, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(clusterRolesResource, c.ClusterPath, "status", clusterRole), &rbacv1beta1.ClusterRole{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1beta1.ClusterRole), err -} - -func (c *clusterRolesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(clusterRolesResource, c.ClusterPath, name, opts), &rbacv1beta1.ClusterRole{}) - return err -} - -func (c *clusterRolesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(clusterRolesResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &rbacv1beta1.ClusterRoleList{}) - return err -} - -func (c *clusterRolesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*rbacv1beta1.ClusterRole, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(clusterRolesResource, c.ClusterPath, name), &rbacv1beta1.ClusterRole{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1beta1.ClusterRole), err -} - -// List takes label and field selectors, and returns the list of ClusterRoles that match those selectors. -func (c *clusterRolesClient) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1beta1.ClusterRoleList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(clusterRolesResource, clusterRolesKind, c.ClusterPath, opts), &rbacv1beta1.ClusterRoleList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &rbacv1beta1.ClusterRoleList{ListMeta: obj.(*rbacv1beta1.ClusterRoleList).ListMeta} - for _, item := range obj.(*rbacv1beta1.ClusterRoleList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *clusterRolesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(clusterRolesResource, c.ClusterPath, opts)) -} - -func (c *clusterRolesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*rbacv1beta1.ClusterRole, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(clusterRolesResource, c.ClusterPath, name, pt, data, subresources...), &rbacv1beta1.ClusterRole{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1beta1.ClusterRole), err -} - -func (c *clusterRolesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsrbacv1beta1.ClusterRoleApplyConfiguration, opts metav1.ApplyOptions) (*rbacv1beta1.ClusterRole, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(clusterRolesResource, c.ClusterPath, *name, types.ApplyPatchType, data), &rbacv1beta1.ClusterRole{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1beta1.ClusterRole), err -} - -func (c *clusterRolesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsrbacv1beta1.ClusterRoleApplyConfiguration, opts metav1.ApplyOptions) (*rbacv1beta1.ClusterRole, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(clusterRolesResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &rbacv1beta1.ClusterRole{}) - if obj == nil { - return nil, err +func newFakeClusterRoleClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedrbacv1beta1.ClusterRoleInterface { + return &clusterRoleScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*rbacv1beta1.ClusterRole, *rbacv1beta1.ClusterRoleList, *v1beta1.ClusterRoleApplyConfiguration]( + fake, + clusterPath, + "", + rbacv1beta1.SchemeGroupVersion.WithResource("clusterroles"), + rbacv1beta1.SchemeGroupVersion.WithKind("ClusterRole"), + func() *rbacv1beta1.ClusterRole { return &rbacv1beta1.ClusterRole{} }, + func() *rbacv1beta1.ClusterRoleList { return &rbacv1beta1.ClusterRoleList{} }, + func(dst, src *rbacv1beta1.ClusterRoleList) { dst.ListMeta = src.ListMeta }, + func(list *rbacv1beta1.ClusterRoleList) []*rbacv1beta1.ClusterRole { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *rbacv1beta1.ClusterRoleList, items []*rbacv1beta1.ClusterRole) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*rbacv1beta1.ClusterRole), err } diff --git a/kubernetes/typed/rbac/v1beta1/fake/clusterrolebinding.go b/kubernetes/typed/rbac/v1beta1/fake/clusterrolebinding.go index 93e8e7125..e5f43f7ab 100644 --- a/kubernetes/typed/rbac/v1beta1/fake/clusterrolebinding.go +++ b/kubernetes/typed/rbac/v1beta1/fake/clusterrolebinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" rbacv1beta1 "k8s.io/api/rbac/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsrbacv1beta1 "k8s.io/client-go/applyconfigurations/rbac/v1beta1" - rbacv1beta1client "k8s.io/client-go/kubernetes/typed/rbac/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/rbac/v1beta1" + typedrbacv1beta1 "k8s.io/client-go/kubernetes/typed/rbac/v1beta1" + typedkcprbacv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/rbac/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var clusterRoleBindingsResource = schema.GroupVersionResource{Group: "rbac.authorization.k8s.io", Version: "v1beta1", Resource: "clusterrolebindings"} -var clusterRoleBindingsKind = schema.GroupVersionKind{Group: "rbac.authorization.k8s.io", Version: "v1beta1", Kind: "ClusterRoleBinding"} - -type clusterRoleBindingsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *clusterRoleBindingsClusterClient) Cluster(clusterPath logicalcluster.Path) rbacv1beta1client.ClusterRoleBindingInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &clusterRoleBindingsClient{Fake: c.Fake, ClusterPath: clusterPath} +// clusterRoleBindingClusterClient implements ClusterRoleBindingClusterInterface +type clusterRoleBindingClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*rbacv1beta1.ClusterRoleBinding, *rbacv1beta1.ClusterRoleBindingList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of ClusterRoleBindings that match those selectors across all clusters. -func (c *clusterRoleBindingsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1beta1.ClusterRoleBindingList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(clusterRoleBindingsResource, clusterRoleBindingsKind, logicalcluster.Wildcard, opts), &rbacv1beta1.ClusterRoleBindingList{}) - if obj == nil { - return nil, err +func newFakeClusterRoleBindingClusterClient(fake *RbacV1beta1ClusterClient) typedkcprbacv1beta1.ClusterRoleBindingClusterInterface { + return &clusterRoleBindingClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*rbacv1beta1.ClusterRoleBinding, *rbacv1beta1.ClusterRoleBindingList]( + fake.Fake, + rbacv1beta1.SchemeGroupVersion.WithResource("clusterrolebindings"), + rbacv1beta1.SchemeGroupVersion.WithKind("ClusterRoleBinding"), + func() *rbacv1beta1.ClusterRoleBinding { return &rbacv1beta1.ClusterRoleBinding{} }, + func() *rbacv1beta1.ClusterRoleBindingList { return &rbacv1beta1.ClusterRoleBindingList{} }, + func(dst, src *rbacv1beta1.ClusterRoleBindingList) { dst.ListMeta = src.ListMeta }, + func(list *rbacv1beta1.ClusterRoleBindingList) []*rbacv1beta1.ClusterRoleBinding { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *rbacv1beta1.ClusterRoleBindingList, items []*rbacv1beta1.ClusterRoleBinding) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &rbacv1beta1.ClusterRoleBindingList{ListMeta: obj.(*rbacv1beta1.ClusterRoleBindingList).ListMeta} - for _, item := range obj.(*rbacv1beta1.ClusterRoleBindingList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested ClusterRoleBindings across all clusters. -func (c *clusterRoleBindingsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(clusterRoleBindingsResource, logicalcluster.Wildcard, opts)) +func (c *clusterRoleBindingClusterClient) Cluster(cluster logicalcluster.Path) typedrbacv1beta1.ClusterRoleBindingInterface { + return newFakeClusterRoleBindingClient(c.Fake, cluster) } -type clusterRoleBindingsClient struct { - *kcptesting.Fake +// clusterRoleBindingScopedClient implements ClusterRoleBindingInterface +type clusterRoleBindingScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*rbacv1beta1.ClusterRoleBinding, *rbacv1beta1.ClusterRoleBindingList, *v1beta1.ClusterRoleBindingApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *clusterRoleBindingsClient) Create(ctx context.Context, clusterRoleBinding *rbacv1beta1.ClusterRoleBinding, opts metav1.CreateOptions) (*rbacv1beta1.ClusterRoleBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(clusterRoleBindingsResource, c.ClusterPath, clusterRoleBinding), &rbacv1beta1.ClusterRoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1beta1.ClusterRoleBinding), err -} - -func (c *clusterRoleBindingsClient) Update(ctx context.Context, clusterRoleBinding *rbacv1beta1.ClusterRoleBinding, opts metav1.UpdateOptions) (*rbacv1beta1.ClusterRoleBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(clusterRoleBindingsResource, c.ClusterPath, clusterRoleBinding), &rbacv1beta1.ClusterRoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1beta1.ClusterRoleBinding), err -} - -func (c *clusterRoleBindingsClient) UpdateStatus(ctx context.Context, clusterRoleBinding *rbacv1beta1.ClusterRoleBinding, opts metav1.UpdateOptions) (*rbacv1beta1.ClusterRoleBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(clusterRoleBindingsResource, c.ClusterPath, "status", clusterRoleBinding), &rbacv1beta1.ClusterRoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1beta1.ClusterRoleBinding), err -} - -func (c *clusterRoleBindingsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(clusterRoleBindingsResource, c.ClusterPath, name, opts), &rbacv1beta1.ClusterRoleBinding{}) - return err -} - -func (c *clusterRoleBindingsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(clusterRoleBindingsResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &rbacv1beta1.ClusterRoleBindingList{}) - return err -} - -func (c *clusterRoleBindingsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*rbacv1beta1.ClusterRoleBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(clusterRoleBindingsResource, c.ClusterPath, name), &rbacv1beta1.ClusterRoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1beta1.ClusterRoleBinding), err -} - -// List takes label and field selectors, and returns the list of ClusterRoleBindings that match those selectors. -func (c *clusterRoleBindingsClient) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1beta1.ClusterRoleBindingList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(clusterRoleBindingsResource, clusterRoleBindingsKind, c.ClusterPath, opts), &rbacv1beta1.ClusterRoleBindingList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &rbacv1beta1.ClusterRoleBindingList{ListMeta: obj.(*rbacv1beta1.ClusterRoleBindingList).ListMeta} - for _, item := range obj.(*rbacv1beta1.ClusterRoleBindingList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *clusterRoleBindingsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(clusterRoleBindingsResource, c.ClusterPath, opts)) -} - -func (c *clusterRoleBindingsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*rbacv1beta1.ClusterRoleBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(clusterRoleBindingsResource, c.ClusterPath, name, pt, data, subresources...), &rbacv1beta1.ClusterRoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1beta1.ClusterRoleBinding), err -} - -func (c *clusterRoleBindingsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsrbacv1beta1.ClusterRoleBindingApplyConfiguration, opts metav1.ApplyOptions) (*rbacv1beta1.ClusterRoleBinding, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(clusterRoleBindingsResource, c.ClusterPath, *name, types.ApplyPatchType, data), &rbacv1beta1.ClusterRoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1beta1.ClusterRoleBinding), err -} - -func (c *clusterRoleBindingsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsrbacv1beta1.ClusterRoleBindingApplyConfiguration, opts metav1.ApplyOptions) (*rbacv1beta1.ClusterRoleBinding, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(clusterRoleBindingsResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &rbacv1beta1.ClusterRoleBinding{}) - if obj == nil { - return nil, err +func newFakeClusterRoleBindingClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedrbacv1beta1.ClusterRoleBindingInterface { + return &clusterRoleBindingScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*rbacv1beta1.ClusterRoleBinding, *rbacv1beta1.ClusterRoleBindingList, *v1beta1.ClusterRoleBindingApplyConfiguration]( + fake, + clusterPath, + "", + rbacv1beta1.SchemeGroupVersion.WithResource("clusterrolebindings"), + rbacv1beta1.SchemeGroupVersion.WithKind("ClusterRoleBinding"), + func() *rbacv1beta1.ClusterRoleBinding { return &rbacv1beta1.ClusterRoleBinding{} }, + func() *rbacv1beta1.ClusterRoleBindingList { return &rbacv1beta1.ClusterRoleBindingList{} }, + func(dst, src *rbacv1beta1.ClusterRoleBindingList) { dst.ListMeta = src.ListMeta }, + func(list *rbacv1beta1.ClusterRoleBindingList) []*rbacv1beta1.ClusterRoleBinding { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *rbacv1beta1.ClusterRoleBindingList, items []*rbacv1beta1.ClusterRoleBinding) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*rbacv1beta1.ClusterRoleBinding), err } diff --git a/kubernetes/typed/rbac/v1beta1/fake/doc.go b/kubernetes/typed/rbac/v1beta1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/rbac/v1beta1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/rbac/v1beta1/fake/rbac_client.go b/kubernetes/typed/rbac/v1beta1/fake/rbac_client.go index 98d00c1f7..d480039f8 100644 --- a/kubernetes/typed/rbac/v1beta1/fake/rbac_client.go +++ b/kubernetes/typed/rbac/v1beta1/fake/rbac_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" rbacv1beta1 "k8s.io/client-go/kubernetes/typed/rbac/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcprbacv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/rbac/v1beta1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -41,46 +41,46 @@ func (c *RbacV1beta1ClusterClient) Cluster(clusterPath logicalcluster.Path) rbac return &RbacV1beta1Client{Fake: c.Fake, ClusterPath: clusterPath} } -func (c *RbacV1beta1ClusterClient) Roles() kcprbacv1beta1.RoleClusterInterface { - return &rolesClusterClient{Fake: c.Fake} +func (c *RbacV1beta1ClusterClient) ClusterRoles() kcprbacv1beta1.ClusterRoleClusterInterface { + return newFakeClusterRoleClusterClient(c) } -func (c *RbacV1beta1ClusterClient) RoleBindings() kcprbacv1beta1.RoleBindingClusterInterface { - return &roleBindingsClusterClient{Fake: c.Fake} +func (c *RbacV1beta1ClusterClient) ClusterRoleBindings() kcprbacv1beta1.ClusterRoleBindingClusterInterface { + return newFakeClusterRoleBindingClusterClient(c) } -func (c *RbacV1beta1ClusterClient) ClusterRoles() kcprbacv1beta1.ClusterRoleClusterInterface { - return &clusterRolesClusterClient{Fake: c.Fake} +func (c *RbacV1beta1ClusterClient) Roles() kcprbacv1beta1.RoleClusterInterface { + return newFakeRoleClusterClient(c) } -func (c *RbacV1beta1ClusterClient) ClusterRoleBindings() kcprbacv1beta1.ClusterRoleBindingClusterInterface { - return &clusterRoleBindingsClusterClient{Fake: c.Fake} +func (c *RbacV1beta1ClusterClient) RoleBindings() kcprbacv1beta1.RoleBindingClusterInterface { + return newFakeRoleBindingClusterClient(c) } -var _ rbacv1beta1.RbacV1beta1Interface = (*RbacV1beta1Client)(nil) - type RbacV1beta1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *RbacV1beta1Client) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret +func (c *RbacV1beta1Client) ClusterRoles() rbacv1beta1.ClusterRoleInterface { + return newFakeClusterRoleClient(c.Fake, c.ClusterPath) } -func (c *RbacV1beta1Client) Roles(namespace string) rbacv1beta1.RoleInterface { - return &rolesClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *RbacV1beta1Client) ClusterRoleBindings() rbacv1beta1.ClusterRoleBindingInterface { + return newFakeClusterRoleBindingClient(c.Fake, c.ClusterPath) } -func (c *RbacV1beta1Client) RoleBindings(namespace string) rbacv1beta1.RoleBindingInterface { - return &roleBindingsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *RbacV1beta1Client) Roles(namespace string) rbacv1beta1.RoleInterface { + return newFakeRoleClient(c.Fake, namespace, c.ClusterPath) } -func (c *RbacV1beta1Client) ClusterRoles() rbacv1beta1.ClusterRoleInterface { - return &clusterRolesClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +func (c *RbacV1beta1Client) RoleBindings(namespace string) rbacv1beta1.RoleBindingInterface { + return newFakeRoleBindingClient(c.Fake, namespace, c.ClusterPath) } -func (c *RbacV1beta1Client) ClusterRoleBindings() rbacv1beta1.ClusterRoleBindingInterface { - return &clusterRoleBindingsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *RbacV1beta1Client) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret } diff --git a/kubernetes/typed/rbac/v1beta1/fake/role.go b/kubernetes/typed/rbac/v1beta1/fake/role.go index 71979f6f4..f0ad67c83 100644 --- a/kubernetes/typed/rbac/v1beta1/fake/role.go +++ b/kubernetes/typed/rbac/v1beta1/fake/role.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,83 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" rbacv1beta1 "k8s.io/api/rbac/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsrbacv1beta1 "k8s.io/client-go/applyconfigurations/rbac/v1beta1" - rbacv1beta1client "k8s.io/client-go/kubernetes/typed/rbac/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/rbac/v1beta1" + typedrbacv1beta1 "k8s.io/client-go/kubernetes/typed/rbac/v1beta1" - kcprbacv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/rbac/v1beta1" + typedkcprbacv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/rbac/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var rolesResource = schema.GroupVersionResource{Group: "rbac.authorization.k8s.io", Version: "v1beta1", Resource: "roles"} -var rolesKind = schema.GroupVersionKind{Group: "rbac.authorization.k8s.io", Version: "v1beta1", Kind: "Role"} - -type rolesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *rolesClusterClient) Cluster(clusterPath logicalcluster.Path) kcprbacv1beta1.RolesNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &rolesNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// roleClusterClient implements RoleClusterInterface +type roleClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*rbacv1beta1.Role, *rbacv1beta1.RoleList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of Roles that match those selectors across all clusters. -func (c *rolesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1beta1.RoleList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(rolesResource, rolesKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &rbacv1beta1.RoleList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeRoleClusterClient(fake *RbacV1beta1ClusterClient) typedkcprbacv1beta1.RoleClusterInterface { + return &roleClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*rbacv1beta1.Role, *rbacv1beta1.RoleList]( + fake.Fake, + rbacv1beta1.SchemeGroupVersion.WithResource("roles"), + rbacv1beta1.SchemeGroupVersion.WithKind("Role"), + func() *rbacv1beta1.Role { return &rbacv1beta1.Role{} }, + func() *rbacv1beta1.RoleList { return &rbacv1beta1.RoleList{} }, + func(dst, src *rbacv1beta1.RoleList) { dst.ListMeta = src.ListMeta }, + func(list *rbacv1beta1.RoleList) []*rbacv1beta1.Role { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *rbacv1beta1.RoleList, items []*rbacv1beta1.Role) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &rbacv1beta1.RoleList{ListMeta: obj.(*rbacv1beta1.RoleList).ListMeta} - for _, item := range obj.(*rbacv1beta1.RoleList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested Roles across all clusters. -func (c *rolesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(rolesResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *roleClusterClient) Cluster(cluster logicalcluster.Path) typedkcprbacv1beta1.RolesNamespacer { + return &roleNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type rolesNamespacer struct { +type roleNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *rolesNamespacer) Namespace(namespace string) rbacv1beta1client.RoleInterface { - return &rolesClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *roleNamespacer) Namespace(namespace string) typedrbacv1beta1.RoleInterface { + return newFakeRoleClient(n.Fake, namespace, n.ClusterPath) } -type rolesClient struct { - *kcptesting.Fake +// roleScopedClient implements RoleInterface +type roleScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*rbacv1beta1.Role, *rbacv1beta1.RoleList, *v1beta1.RoleApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *rolesClient) Create(ctx context.Context, role *rbacv1beta1.Role, opts metav1.CreateOptions) (*rbacv1beta1.Role, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(rolesResource, c.ClusterPath, c.Namespace, role), &rbacv1beta1.Role{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1beta1.Role), err -} - -func (c *rolesClient) Update(ctx context.Context, role *rbacv1beta1.Role, opts metav1.UpdateOptions) (*rbacv1beta1.Role, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(rolesResource, c.ClusterPath, c.Namespace, role), &rbacv1beta1.Role{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1beta1.Role), err -} - -func (c *rolesClient) UpdateStatus(ctx context.Context, role *rbacv1beta1.Role, opts metav1.UpdateOptions) (*rbacv1beta1.Role, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(rolesResource, c.ClusterPath, "status", c.Namespace, role), &rbacv1beta1.Role{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1beta1.Role), err -} - -func (c *rolesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(rolesResource, c.ClusterPath, c.Namespace, name, opts), &rbacv1beta1.Role{}) - return err -} - -func (c *rolesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(rolesResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &rbacv1beta1.RoleList{}) - return err -} - -func (c *rolesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*rbacv1beta1.Role, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(rolesResource, c.ClusterPath, c.Namespace, name), &rbacv1beta1.Role{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1beta1.Role), err -} - -// List takes label and field selectors, and returns the list of Roles that match those selectors. -func (c *rolesClient) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1beta1.RoleList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(rolesResource, rolesKind, c.ClusterPath, c.Namespace, opts), &rbacv1beta1.RoleList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &rbacv1beta1.RoleList{ListMeta: obj.(*rbacv1beta1.RoleList).ListMeta} - for _, item := range obj.(*rbacv1beta1.RoleList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *rolesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(rolesResource, c.ClusterPath, c.Namespace, opts)) } -func (c *rolesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*rbacv1beta1.Role, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(rolesResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &rbacv1beta1.Role{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1beta1.Role), err -} - -func (c *rolesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsrbacv1beta1.RoleApplyConfiguration, opts metav1.ApplyOptions) (*rbacv1beta1.Role, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(rolesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &rbacv1beta1.Role{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1beta1.Role), err -} - -func (c *rolesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsrbacv1beta1.RoleApplyConfiguration, opts metav1.ApplyOptions) (*rbacv1beta1.Role, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(rolesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &rbacv1beta1.Role{}) - if obj == nil { - return nil, err +func newFakeRoleClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedrbacv1beta1.RoleInterface { + return &roleScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*rbacv1beta1.Role, *rbacv1beta1.RoleList, *v1beta1.RoleApplyConfiguration]( + fake, + clusterPath, + namespace, + rbacv1beta1.SchemeGroupVersion.WithResource("roles"), + rbacv1beta1.SchemeGroupVersion.WithKind("Role"), + func() *rbacv1beta1.Role { return &rbacv1beta1.Role{} }, + func() *rbacv1beta1.RoleList { return &rbacv1beta1.RoleList{} }, + func(dst, src *rbacv1beta1.RoleList) { dst.ListMeta = src.ListMeta }, + func(list *rbacv1beta1.RoleList) []*rbacv1beta1.Role { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *rbacv1beta1.RoleList, items []*rbacv1beta1.Role) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*rbacv1beta1.Role), err } diff --git a/kubernetes/typed/rbac/v1beta1/fake/rolebinding.go b/kubernetes/typed/rbac/v1beta1/fake/rolebinding.go index c09d98ff8..e93432637 100644 --- a/kubernetes/typed/rbac/v1beta1/fake/rolebinding.go +++ b/kubernetes/typed/rbac/v1beta1/fake/rolebinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" rbacv1beta1 "k8s.io/api/rbac/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsrbacv1beta1 "k8s.io/client-go/applyconfigurations/rbac/v1beta1" - rbacv1beta1client "k8s.io/client-go/kubernetes/typed/rbac/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/rbac/v1beta1" + typedrbacv1beta1 "k8s.io/client-go/kubernetes/typed/rbac/v1beta1" - kcprbacv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/rbac/v1beta1" + typedkcprbacv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/rbac/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var roleBindingsResource = schema.GroupVersionResource{Group: "rbac.authorization.k8s.io", Version: "v1beta1", Resource: "rolebindings"} -var roleBindingsKind = schema.GroupVersionKind{Group: "rbac.authorization.k8s.io", Version: "v1beta1", Kind: "RoleBinding"} - -type roleBindingsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *roleBindingsClusterClient) Cluster(clusterPath logicalcluster.Path) kcprbacv1beta1.RoleBindingsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &roleBindingsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// roleBindingClusterClient implements RoleBindingClusterInterface +type roleBindingClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*rbacv1beta1.RoleBinding, *rbacv1beta1.RoleBindingList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of RoleBindings that match those selectors across all clusters. -func (c *roleBindingsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1beta1.RoleBindingList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(roleBindingsResource, roleBindingsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &rbacv1beta1.RoleBindingList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeRoleBindingClusterClient(fake *RbacV1beta1ClusterClient) typedkcprbacv1beta1.RoleBindingClusterInterface { + return &roleBindingClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*rbacv1beta1.RoleBinding, *rbacv1beta1.RoleBindingList]( + fake.Fake, + rbacv1beta1.SchemeGroupVersion.WithResource("rolebindings"), + rbacv1beta1.SchemeGroupVersion.WithKind("RoleBinding"), + func() *rbacv1beta1.RoleBinding { return &rbacv1beta1.RoleBinding{} }, + func() *rbacv1beta1.RoleBindingList { return &rbacv1beta1.RoleBindingList{} }, + func(dst, src *rbacv1beta1.RoleBindingList) { dst.ListMeta = src.ListMeta }, + func(list *rbacv1beta1.RoleBindingList) []*rbacv1beta1.RoleBinding { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *rbacv1beta1.RoleBindingList, items []*rbacv1beta1.RoleBinding) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &rbacv1beta1.RoleBindingList{ListMeta: obj.(*rbacv1beta1.RoleBindingList).ListMeta} - for _, item := range obj.(*rbacv1beta1.RoleBindingList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested RoleBindings across all clusters. -func (c *roleBindingsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(roleBindingsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *roleBindingClusterClient) Cluster(cluster logicalcluster.Path) typedkcprbacv1beta1.RoleBindingsNamespacer { + return &roleBindingNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type roleBindingsNamespacer struct { +type roleBindingNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *roleBindingsNamespacer) Namespace(namespace string) rbacv1beta1client.RoleBindingInterface { - return &roleBindingsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *roleBindingNamespacer) Namespace(namespace string) typedrbacv1beta1.RoleBindingInterface { + return newFakeRoleBindingClient(n.Fake, namespace, n.ClusterPath) } -type roleBindingsClient struct { - *kcptesting.Fake +// roleBindingScopedClient implements RoleBindingInterface +type roleBindingScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*rbacv1beta1.RoleBinding, *rbacv1beta1.RoleBindingList, *v1beta1.RoleBindingApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *roleBindingsClient) Create(ctx context.Context, roleBinding *rbacv1beta1.RoleBinding, opts metav1.CreateOptions) (*rbacv1beta1.RoleBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(roleBindingsResource, c.ClusterPath, c.Namespace, roleBinding), &rbacv1beta1.RoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1beta1.RoleBinding), err -} - -func (c *roleBindingsClient) Update(ctx context.Context, roleBinding *rbacv1beta1.RoleBinding, opts metav1.UpdateOptions) (*rbacv1beta1.RoleBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(roleBindingsResource, c.ClusterPath, c.Namespace, roleBinding), &rbacv1beta1.RoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1beta1.RoleBinding), err -} - -func (c *roleBindingsClient) UpdateStatus(ctx context.Context, roleBinding *rbacv1beta1.RoleBinding, opts metav1.UpdateOptions) (*rbacv1beta1.RoleBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(roleBindingsResource, c.ClusterPath, "status", c.Namespace, roleBinding), &rbacv1beta1.RoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1beta1.RoleBinding), err -} - -func (c *roleBindingsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(roleBindingsResource, c.ClusterPath, c.Namespace, name, opts), &rbacv1beta1.RoleBinding{}) - return err -} - -func (c *roleBindingsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(roleBindingsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &rbacv1beta1.RoleBindingList{}) - return err -} - -func (c *roleBindingsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*rbacv1beta1.RoleBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(roleBindingsResource, c.ClusterPath, c.Namespace, name), &rbacv1beta1.RoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1beta1.RoleBinding), err -} - -// List takes label and field selectors, and returns the list of RoleBindings that match those selectors. -func (c *roleBindingsClient) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1beta1.RoleBindingList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(roleBindingsResource, roleBindingsKind, c.ClusterPath, c.Namespace, opts), &rbacv1beta1.RoleBindingList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &rbacv1beta1.RoleBindingList{ListMeta: obj.(*rbacv1beta1.RoleBindingList).ListMeta} - for _, item := range obj.(*rbacv1beta1.RoleBindingList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *roleBindingsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(roleBindingsResource, c.ClusterPath, c.Namespace, opts)) } -func (c *roleBindingsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*rbacv1beta1.RoleBinding, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(roleBindingsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &rbacv1beta1.RoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1beta1.RoleBinding), err -} - -func (c *roleBindingsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsrbacv1beta1.RoleBindingApplyConfiguration, opts metav1.ApplyOptions) (*rbacv1beta1.RoleBinding, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(roleBindingsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &rbacv1beta1.RoleBinding{}) - if obj == nil { - return nil, err - } - return obj.(*rbacv1beta1.RoleBinding), err -} - -func (c *roleBindingsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsrbacv1beta1.RoleBindingApplyConfiguration, opts metav1.ApplyOptions) (*rbacv1beta1.RoleBinding, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(roleBindingsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &rbacv1beta1.RoleBinding{}) - if obj == nil { - return nil, err +func newFakeRoleBindingClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedrbacv1beta1.RoleBindingInterface { + return &roleBindingScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*rbacv1beta1.RoleBinding, *rbacv1beta1.RoleBindingList, *v1beta1.RoleBindingApplyConfiguration]( + fake, + clusterPath, + namespace, + rbacv1beta1.SchemeGroupVersion.WithResource("rolebindings"), + rbacv1beta1.SchemeGroupVersion.WithKind("RoleBinding"), + func() *rbacv1beta1.RoleBinding { return &rbacv1beta1.RoleBinding{} }, + func() *rbacv1beta1.RoleBindingList { return &rbacv1beta1.RoleBindingList{} }, + func(dst, src *rbacv1beta1.RoleBindingList) { dst.ListMeta = src.ListMeta }, + func(list *rbacv1beta1.RoleBindingList) []*rbacv1beta1.RoleBinding { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *rbacv1beta1.RoleBindingList, items []*rbacv1beta1.RoleBinding) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*rbacv1beta1.RoleBinding), err } diff --git a/kubernetes/typed/rbac/v1beta1/generated_expansion.go b/kubernetes/typed/rbac/v1beta1/generated_expansion.go new file mode 100644 index 000000000..6993dc2f3 --- /dev/null +++ b/kubernetes/typed/rbac/v1beta1/generated_expansion.go @@ -0,0 +1,27 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1beta1 + +type ClusterRoleClusterExpansion interface{} + +type ClusterRoleBindingClusterExpansion interface{} + +type RoleClusterExpansion interface{} + +type RoleBindingClusterExpansion interface{} diff --git a/kubernetes/typed/rbac/v1beta1/rbac_client.go b/kubernetes/typed/rbac/v1beta1/rbac_client.go index 5245f1841..e0fa1d416 100644 --- a/kubernetes/typed/rbac/v1beta1/rbac_client.go +++ b/kubernetes/typed/rbac/v1beta1/rbac_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,32 +14,36 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apirbacv1beta1 "k8s.io/api/rbac/v1beta1" rbacv1beta1 "k8s.io/client-go/kubernetes/typed/rbac/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type RbacV1beta1ClusterInterface interface { RbacV1beta1ClusterScoper - RolesClusterGetter - RoleBindingsClusterGetter ClusterRolesClusterGetter ClusterRoleBindingsClusterGetter + RolesClusterGetter + RoleBindingsClusterGetter } type RbacV1beta1ClusterScoper interface { Cluster(logicalcluster.Path) rbacv1beta1.RbacV1beta1Interface } +// RbacV1beta1ClusterClient is used to interact with features provided by the rbac.authorization.k8s.io group. type RbacV1beta1ClusterClient struct { clientCache kcpclient.Cache[*rbacv1beta1.RbacV1beta1Client] } @@ -51,14 +55,6 @@ func (c *RbacV1beta1ClusterClient) Cluster(clusterPath logicalcluster.Path) rbac return c.clientCache.ClusterOrDie(clusterPath) } -func (c *RbacV1beta1ClusterClient) Roles() RoleClusterInterface { - return &rolesClusterInterface{clientCache: c.clientCache} -} - -func (c *RbacV1beta1ClusterClient) RoleBindings() RoleBindingClusterInterface { - return &roleBindingsClusterInterface{clientCache: c.clientCache} -} - func (c *RbacV1beta1ClusterClient) ClusterRoles() ClusterRoleClusterInterface { return &clusterRolesClusterInterface{clientCache: c.clientCache} } @@ -67,15 +63,25 @@ func (c *RbacV1beta1ClusterClient) ClusterRoleBindings() ClusterRoleBindingClust return &clusterRoleBindingsClusterInterface{clientCache: c.clientCache} } +func (c *RbacV1beta1ClusterClient) Roles() RoleClusterInterface { + return &rolesClusterInterface{clientCache: c.clientCache} +} + +func (c *RbacV1beta1ClusterClient) RoleBindings() RoleBindingClusterInterface { + return &roleBindingsClusterInterface{clientCache: c.clientCache} +} + // NewForConfig creates a new RbacV1beta1ClusterClient for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*RbacV1beta1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new RbacV1beta1ClusterClient for the given config and http client. @@ -87,6 +93,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*RbacV1beta1ClusterC if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &RbacV1beta1ClusterClient{clientCache: cache}, nil } @@ -99,3 +106,14 @@ func NewForConfigOrDie(c *rest.Config) *RbacV1beta1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apirbacv1beta1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/rbac/v1beta1/role.go b/kubernetes/typed/rbac/v1beta1/role.go index 209db7bbe..9137ebc1e 100644 --- a/kubernetes/typed/rbac/v1beta1/role.go +++ b/kubernetes/typed/rbac/v1beta1/role.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" rbacv1beta1 "k8s.io/api/rbac/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - rbacv1beta1client "k8s.io/client-go/kubernetes/typed/rbac/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedrbacv1beta1 "k8s.io/client-go/kubernetes/typed/rbac/v1beta1" ) // RolesClusterGetter has a method to return a RoleClusterInterface. @@ -40,12 +40,13 @@ type RolesClusterGetter interface { // or scope down to one cluster and return a RolesNamespacer. type RoleClusterInterface interface { Cluster(logicalcluster.Path) RolesNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*rbacv1beta1.RoleList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*rbacv1beta1.RoleList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + RoleClusterExpansion } type rolesClusterInterface struct { - clientCache kcpclient.Cache[*rbacv1beta1client.RbacV1beta1Client] + clientCache kcpclient.Cache[*typedrbacv1beta1.RbacV1beta1Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *rolesClusterInterface) Cluster(clusterPath logicalcluster.Path) RolesNa } // List returns the entire collection of all Roles across all clusters. -func (c *rolesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1beta1.RoleList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Roles(metav1.NamespaceAll).List(ctx, opts) +func (c *rolesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*rbacv1beta1.RoleList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Roles(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all Roles across all clusters. -func (c *rolesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Roles(metav1.NamespaceAll).Watch(ctx, opts) +func (c *rolesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).Roles(v1.NamespaceAll).Watch(ctx, opts) } -// RolesNamespacer can scope to objects within a namespace, returning a rbacv1beta1client.RoleInterface. +// RolesNamespacer can scope to objects within a namespace, returning a typedrbacv1beta1.RoleInterface. type RolesNamespacer interface { - Namespace(string) rbacv1beta1client.RoleInterface + Namespace(string) typedrbacv1beta1.RoleInterface } type rolesNamespacer struct { - clientCache kcpclient.Cache[*rbacv1beta1client.RbacV1beta1Client] + clientCache kcpclient.Cache[*typedrbacv1beta1.RbacV1beta1Client] clusterPath logicalcluster.Path } -func (n *rolesNamespacer) Namespace(namespace string) rbacv1beta1client.RoleInterface { +func (n *rolesNamespacer) Namespace(namespace string) typedrbacv1beta1.RoleInterface { return n.clientCache.ClusterOrDie(n.clusterPath).Roles(namespace) } diff --git a/kubernetes/typed/rbac/v1beta1/rolebinding.go b/kubernetes/typed/rbac/v1beta1/rolebinding.go index e5931d719..5fa01d693 100644 --- a/kubernetes/typed/rbac/v1beta1/rolebinding.go +++ b/kubernetes/typed/rbac/v1beta1/rolebinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" rbacv1beta1 "k8s.io/api/rbac/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - rbacv1beta1client "k8s.io/client-go/kubernetes/typed/rbac/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedrbacv1beta1 "k8s.io/client-go/kubernetes/typed/rbac/v1beta1" ) // RoleBindingsClusterGetter has a method to return a RoleBindingClusterInterface. @@ -40,12 +40,13 @@ type RoleBindingsClusterGetter interface { // or scope down to one cluster and return a RoleBindingsNamespacer. type RoleBindingClusterInterface interface { Cluster(logicalcluster.Path) RoleBindingsNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*rbacv1beta1.RoleBindingList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*rbacv1beta1.RoleBindingList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + RoleBindingClusterExpansion } type roleBindingsClusterInterface struct { - clientCache kcpclient.Cache[*rbacv1beta1client.RbacV1beta1Client] + clientCache kcpclient.Cache[*typedrbacv1beta1.RbacV1beta1Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *roleBindingsClusterInterface) Cluster(clusterPath logicalcluster.Path) } // List returns the entire collection of all RoleBindings across all clusters. -func (c *roleBindingsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*rbacv1beta1.RoleBindingList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).RoleBindings(metav1.NamespaceAll).List(ctx, opts) +func (c *roleBindingsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*rbacv1beta1.RoleBindingList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).RoleBindings(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all RoleBindings across all clusters. -func (c *roleBindingsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).RoleBindings(metav1.NamespaceAll).Watch(ctx, opts) +func (c *roleBindingsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).RoleBindings(v1.NamespaceAll).Watch(ctx, opts) } -// RoleBindingsNamespacer can scope to objects within a namespace, returning a rbacv1beta1client.RoleBindingInterface. +// RoleBindingsNamespacer can scope to objects within a namespace, returning a typedrbacv1beta1.RoleBindingInterface. type RoleBindingsNamespacer interface { - Namespace(string) rbacv1beta1client.RoleBindingInterface + Namespace(string) typedrbacv1beta1.RoleBindingInterface } type roleBindingsNamespacer struct { - clientCache kcpclient.Cache[*rbacv1beta1client.RbacV1beta1Client] + clientCache kcpclient.Cache[*typedrbacv1beta1.RbacV1beta1Client] clusterPath logicalcluster.Path } -func (n *roleBindingsNamespacer) Namespace(namespace string) rbacv1beta1client.RoleBindingInterface { +func (n *roleBindingsNamespacer) Namespace(namespace string) typedrbacv1beta1.RoleBindingInterface { return n.clientCache.ClusterOrDie(n.clusterPath).RoleBindings(namespace) } diff --git a/kubernetes/typed/resource/v1alpha3/deviceclass.go b/kubernetes/typed/resource/v1alpha3/deviceclass.go index 966755957..f00de888a 100644 --- a/kubernetes/typed/resource/v1alpha3/deviceclass.go +++ b/kubernetes/typed/resource/v1alpha3/deviceclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha3 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - resourcev1alpha3 "k8s.io/api/resource/v1alpha3" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - resourcev1alpha3client "k8s.io/client-go/kubernetes/typed/resource/v1alpha3" + apiresourcev1alpha3 "k8s.io/api/resource/v1alpha3" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + resourcev1alpha3 "k8s.io/client-go/kubernetes/typed/resource/v1alpha3" ) // DeviceClassesClusterGetter has a method to return a DeviceClassClusterInterface. @@ -37,19 +37,20 @@ type DeviceClassesClusterGetter interface { } // DeviceClassClusterInterface can operate on DeviceClasses across all clusters, -// or scope down to one cluster and return a resourcev1alpha3client.DeviceClassInterface. +// or scope down to one cluster and return a resourcev1alpha3.DeviceClassInterface. type DeviceClassClusterInterface interface { - Cluster(logicalcluster.Path) resourcev1alpha3client.DeviceClassInterface - List(ctx context.Context, opts metav1.ListOptions) (*resourcev1alpha3.DeviceClassList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) resourcev1alpha3.DeviceClassInterface + List(ctx context.Context, opts v1.ListOptions) (*apiresourcev1alpha3.DeviceClassList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + DeviceClassClusterExpansion } type deviceClassesClusterInterface struct { - clientCache kcpclient.Cache[*resourcev1alpha3client.ResourceV1alpha3Client] + clientCache kcpclient.Cache[*resourcev1alpha3.ResourceV1alpha3Client] } // Cluster scopes the client down to a particular cluster. -func (c *deviceClassesClusterInterface) Cluster(clusterPath logicalcluster.Path) resourcev1alpha3client.DeviceClassInterface { +func (c *deviceClassesClusterInterface) Cluster(clusterPath logicalcluster.Path) resourcev1alpha3.DeviceClassInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *deviceClassesClusterInterface) Cluster(clusterPath logicalcluster.Path) } // List returns the entire collection of all DeviceClasses across all clusters. -func (c *deviceClassesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*resourcev1alpha3.DeviceClassList, error) { +func (c *deviceClassesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apiresourcev1alpha3.DeviceClassList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).DeviceClasses().List(ctx, opts) } // Watch begins to watch all DeviceClasses across all clusters. -func (c *deviceClassesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *deviceClassesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).DeviceClasses().Watch(ctx, opts) } diff --git a/kubernetes/typed/resource/v1alpha3/doc.go b/kubernetes/typed/resource/v1alpha3/doc.go new file mode 100644 index 000000000..2170a4a57 --- /dev/null +++ b/kubernetes/typed/resource/v1alpha3/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha3 diff --git a/kubernetes/typed/resource/v1alpha3/fake/deviceclass.go b/kubernetes/typed/resource/v1alpha3/fake/deviceclass.go index 0b5bbf0b0..8d52d9bba 100644 --- a/kubernetes/typed/resource/v1alpha3/fake/deviceclass.go +++ b/kubernetes/typed/resource/v1alpha3/fake/deviceclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" resourcev1alpha3 "k8s.io/api/resource/v1alpha3" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsresourcev1alpha3 "k8s.io/client-go/applyconfigurations/resource/v1alpha3" - resourcev1alpha3client "k8s.io/client-go/kubernetes/typed/resource/v1alpha3" - "k8s.io/client-go/testing" + v1alpha3 "k8s.io/client-go/applyconfigurations/resource/v1alpha3" + typedresourcev1alpha3 "k8s.io/client-go/kubernetes/typed/resource/v1alpha3" + typedkcpresourcev1alpha3 "github.com/kcp-dev/client-go/kubernetes/typed/resource/v1alpha3" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var deviceClassesResource = schema.GroupVersionResource{Group: "resource.k8s.io", Version: "v1alpha3", Resource: "deviceclasses"} -var deviceClassesKind = schema.GroupVersionKind{Group: "resource.k8s.io", Version: "v1alpha3", Kind: "DeviceClass"} - -type deviceClassesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *deviceClassesClusterClient) Cluster(clusterPath logicalcluster.Path) resourcev1alpha3client.DeviceClassInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &deviceClassesClient{Fake: c.Fake, ClusterPath: clusterPath} +// deviceClassClusterClient implements DeviceClassClusterInterface +type deviceClassClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*resourcev1alpha3.DeviceClass, *resourcev1alpha3.DeviceClassList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of DeviceClasses that match those selectors across all clusters. -func (c *deviceClassesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*resourcev1alpha3.DeviceClassList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(deviceClassesResource, deviceClassesKind, logicalcluster.Wildcard, opts), &resourcev1alpha3.DeviceClassList{}) - if obj == nil { - return nil, err +func newFakeDeviceClassClusterClient(fake *ResourceV1alpha3ClusterClient) typedkcpresourcev1alpha3.DeviceClassClusterInterface { + return &deviceClassClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*resourcev1alpha3.DeviceClass, *resourcev1alpha3.DeviceClassList]( + fake.Fake, + resourcev1alpha3.SchemeGroupVersion.WithResource("deviceclasses"), + resourcev1alpha3.SchemeGroupVersion.WithKind("DeviceClass"), + func() *resourcev1alpha3.DeviceClass { return &resourcev1alpha3.DeviceClass{} }, + func() *resourcev1alpha3.DeviceClassList { return &resourcev1alpha3.DeviceClassList{} }, + func(dst, src *resourcev1alpha3.DeviceClassList) { dst.ListMeta = src.ListMeta }, + func(list *resourcev1alpha3.DeviceClassList) []*resourcev1alpha3.DeviceClass { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *resourcev1alpha3.DeviceClassList, items []*resourcev1alpha3.DeviceClass) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &resourcev1alpha3.DeviceClassList{ListMeta: obj.(*resourcev1alpha3.DeviceClassList).ListMeta} - for _, item := range obj.(*resourcev1alpha3.DeviceClassList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested DeviceClasses across all clusters. -func (c *deviceClassesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(deviceClassesResource, logicalcluster.Wildcard, opts)) +func (c *deviceClassClusterClient) Cluster(cluster logicalcluster.Path) typedresourcev1alpha3.DeviceClassInterface { + return newFakeDeviceClassClient(c.Fake, cluster) } -type deviceClassesClient struct { - *kcptesting.Fake +// deviceClassScopedClient implements DeviceClassInterface +type deviceClassScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*resourcev1alpha3.DeviceClass, *resourcev1alpha3.DeviceClassList, *v1alpha3.DeviceClassApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *deviceClassesClient) Create(ctx context.Context, deviceClass *resourcev1alpha3.DeviceClass, opts metav1.CreateOptions) (*resourcev1alpha3.DeviceClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(deviceClassesResource, c.ClusterPath, deviceClass), &resourcev1alpha3.DeviceClass{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1alpha3.DeviceClass), err -} - -func (c *deviceClassesClient) Update(ctx context.Context, deviceClass *resourcev1alpha3.DeviceClass, opts metav1.UpdateOptions) (*resourcev1alpha3.DeviceClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(deviceClassesResource, c.ClusterPath, deviceClass), &resourcev1alpha3.DeviceClass{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1alpha3.DeviceClass), err -} - -func (c *deviceClassesClient) UpdateStatus(ctx context.Context, deviceClass *resourcev1alpha3.DeviceClass, opts metav1.UpdateOptions) (*resourcev1alpha3.DeviceClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(deviceClassesResource, c.ClusterPath, "status", deviceClass), &resourcev1alpha3.DeviceClass{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1alpha3.DeviceClass), err -} - -func (c *deviceClassesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(deviceClassesResource, c.ClusterPath, name, opts), &resourcev1alpha3.DeviceClass{}) - return err -} - -func (c *deviceClassesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(deviceClassesResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &resourcev1alpha3.DeviceClassList{}) - return err -} - -func (c *deviceClassesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*resourcev1alpha3.DeviceClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(deviceClassesResource, c.ClusterPath, name), &resourcev1alpha3.DeviceClass{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1alpha3.DeviceClass), err -} - -// List takes label and field selectors, and returns the list of DeviceClasses that match those selectors. -func (c *deviceClassesClient) List(ctx context.Context, opts metav1.ListOptions) (*resourcev1alpha3.DeviceClassList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(deviceClassesResource, deviceClassesKind, c.ClusterPath, opts), &resourcev1alpha3.DeviceClassList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &resourcev1alpha3.DeviceClassList{ListMeta: obj.(*resourcev1alpha3.DeviceClassList).ListMeta} - for _, item := range obj.(*resourcev1alpha3.DeviceClassList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *deviceClassesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(deviceClassesResource, c.ClusterPath, opts)) -} - -func (c *deviceClassesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*resourcev1alpha3.DeviceClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(deviceClassesResource, c.ClusterPath, name, pt, data, subresources...), &resourcev1alpha3.DeviceClass{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1alpha3.DeviceClass), err -} - -func (c *deviceClassesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsresourcev1alpha3.DeviceClassApplyConfiguration, opts metav1.ApplyOptions) (*resourcev1alpha3.DeviceClass, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(deviceClassesResource, c.ClusterPath, *name, types.ApplyPatchType, data), &resourcev1alpha3.DeviceClass{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1alpha3.DeviceClass), err -} - -func (c *deviceClassesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsresourcev1alpha3.DeviceClassApplyConfiguration, opts metav1.ApplyOptions) (*resourcev1alpha3.DeviceClass, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(deviceClassesResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &resourcev1alpha3.DeviceClass{}) - if obj == nil { - return nil, err +func newFakeDeviceClassClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedresourcev1alpha3.DeviceClassInterface { + return &deviceClassScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*resourcev1alpha3.DeviceClass, *resourcev1alpha3.DeviceClassList, *v1alpha3.DeviceClassApplyConfiguration]( + fake, + clusterPath, + "", + resourcev1alpha3.SchemeGroupVersion.WithResource("deviceclasses"), + resourcev1alpha3.SchemeGroupVersion.WithKind("DeviceClass"), + func() *resourcev1alpha3.DeviceClass { return &resourcev1alpha3.DeviceClass{} }, + func() *resourcev1alpha3.DeviceClassList { return &resourcev1alpha3.DeviceClassList{} }, + func(dst, src *resourcev1alpha3.DeviceClassList) { dst.ListMeta = src.ListMeta }, + func(list *resourcev1alpha3.DeviceClassList) []*resourcev1alpha3.DeviceClass { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *resourcev1alpha3.DeviceClassList, items []*resourcev1alpha3.DeviceClass) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*resourcev1alpha3.DeviceClass), err } diff --git a/kubernetes/typed/resource/v1alpha3/fake/doc.go b/kubernetes/typed/resource/v1alpha3/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/resource/v1alpha3/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/resource/v1alpha3/fake/resource_client.go b/kubernetes/typed/resource/v1alpha3/fake/resource_client.go index 26d9ac861..db71116a2 100644 --- a/kubernetes/typed/resource/v1alpha3/fake/resource_client.go +++ b/kubernetes/typed/resource/v1alpha3/fake/resource_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" resourcev1alpha3 "k8s.io/client-go/kubernetes/typed/resource/v1alpha3" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpresourcev1alpha3 "github.com/kcp-dev/client-go/kubernetes/typed/resource/v1alpha3" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -41,46 +41,46 @@ func (c *ResourceV1alpha3ClusterClient) Cluster(clusterPath logicalcluster.Path) return &ResourceV1alpha3Client{Fake: c.Fake, ClusterPath: clusterPath} } -func (c *ResourceV1alpha3ClusterClient) ResourceSlices() kcpresourcev1alpha3.ResourceSliceClusterInterface { - return &resourceSlicesClusterClient{Fake: c.Fake} +func (c *ResourceV1alpha3ClusterClient) DeviceClasses() kcpresourcev1alpha3.DeviceClassClusterInterface { + return newFakeDeviceClassClusterClient(c) } func (c *ResourceV1alpha3ClusterClient) ResourceClaims() kcpresourcev1alpha3.ResourceClaimClusterInterface { - return &resourceClaimsClusterClient{Fake: c.Fake} -} - -func (c *ResourceV1alpha3ClusterClient) DeviceClasses() kcpresourcev1alpha3.DeviceClassClusterInterface { - return &deviceClassesClusterClient{Fake: c.Fake} + return newFakeResourceClaimClusterClient(c) } func (c *ResourceV1alpha3ClusterClient) ResourceClaimTemplates() kcpresourcev1alpha3.ResourceClaimTemplateClusterInterface { - return &resourceClaimTemplatesClusterClient{Fake: c.Fake} + return newFakeResourceClaimTemplateClusterClient(c) } -var _ resourcev1alpha3.ResourceV1alpha3Interface = (*ResourceV1alpha3Client)(nil) +func (c *ResourceV1alpha3ClusterClient) ResourceSlices() kcpresourcev1alpha3.ResourceSliceClusterInterface { + return newFakeResourceSliceClusterClient(c) +} type ResourceV1alpha3Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *ResourceV1alpha3Client) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret +func (c *ResourceV1alpha3Client) DeviceClasses() resourcev1alpha3.DeviceClassInterface { + return newFakeDeviceClassClient(c.Fake, c.ClusterPath) } -func (c *ResourceV1alpha3Client) ResourceSlices() resourcev1alpha3.ResourceSliceInterface { - return &resourceSlicesClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +func (c *ResourceV1alpha3Client) ResourceClaims(namespace string) resourcev1alpha3.ResourceClaimInterface { + return newFakeResourceClaimClient(c.Fake, namespace, c.ClusterPath) } -func (c *ResourceV1alpha3Client) ResourceClaims(namespace string) resourcev1alpha3.ResourceClaimInterface { - return &resourceClaimsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *ResourceV1alpha3Client) ResourceClaimTemplates(namespace string) resourcev1alpha3.ResourceClaimTemplateInterface { + return newFakeResourceClaimTemplateClient(c.Fake, namespace, c.ClusterPath) } -func (c *ResourceV1alpha3Client) DeviceClasses() resourcev1alpha3.DeviceClassInterface { - return &deviceClassesClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +func (c *ResourceV1alpha3Client) ResourceSlices() resourcev1alpha3.ResourceSliceInterface { + return newFakeResourceSliceClient(c.Fake, c.ClusterPath) } -func (c *ResourceV1alpha3Client) ResourceClaimTemplates(namespace string) resourcev1alpha3.ResourceClaimTemplateInterface { - return &resourceClaimTemplatesClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *ResourceV1alpha3Client) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret } diff --git a/kubernetes/typed/resource/v1alpha3/fake/resourceclaim.go b/kubernetes/typed/resource/v1alpha3/fake/resourceclaim.go index 64db0daf5..4ef079d98 100644 --- a/kubernetes/typed/resource/v1alpha3/fake/resourceclaim.go +++ b/kubernetes/typed/resource/v1alpha3/fake/resourceclaim.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" resourcev1alpha3 "k8s.io/api/resource/v1alpha3" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsresourcev1alpha3 "k8s.io/client-go/applyconfigurations/resource/v1alpha3" - resourcev1alpha3client "k8s.io/client-go/kubernetes/typed/resource/v1alpha3" - "k8s.io/client-go/testing" + v1alpha3 "k8s.io/client-go/applyconfigurations/resource/v1alpha3" + typedresourcev1alpha3 "k8s.io/client-go/kubernetes/typed/resource/v1alpha3" - kcpresourcev1alpha3 "github.com/kcp-dev/client-go/kubernetes/typed/resource/v1alpha3" + typedkcpresourcev1alpha3 "github.com/kcp-dev/client-go/kubernetes/typed/resource/v1alpha3" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var resourceClaimsResource = schema.GroupVersionResource{Group: "resource.k8s.io", Version: "v1alpha3", Resource: "resourceclaims"} -var resourceClaimsKind = schema.GroupVersionKind{Group: "resource.k8s.io", Version: "v1alpha3", Kind: "ResourceClaim"} - -type resourceClaimsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *resourceClaimsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpresourcev1alpha3.ResourceClaimsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &resourceClaimsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// resourceClaimClusterClient implements ResourceClaimClusterInterface +type resourceClaimClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*resourcev1alpha3.ResourceClaim, *resourcev1alpha3.ResourceClaimList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of ResourceClaims that match those selectors across all clusters. -func (c *resourceClaimsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*resourcev1alpha3.ResourceClaimList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(resourceClaimsResource, resourceClaimsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &resourcev1alpha3.ResourceClaimList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeResourceClaimClusterClient(fake *ResourceV1alpha3ClusterClient) typedkcpresourcev1alpha3.ResourceClaimClusterInterface { + return &resourceClaimClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*resourcev1alpha3.ResourceClaim, *resourcev1alpha3.ResourceClaimList]( + fake.Fake, + resourcev1alpha3.SchemeGroupVersion.WithResource("resourceclaims"), + resourcev1alpha3.SchemeGroupVersion.WithKind("ResourceClaim"), + func() *resourcev1alpha3.ResourceClaim { return &resourcev1alpha3.ResourceClaim{} }, + func() *resourcev1alpha3.ResourceClaimList { return &resourcev1alpha3.ResourceClaimList{} }, + func(dst, src *resourcev1alpha3.ResourceClaimList) { dst.ListMeta = src.ListMeta }, + func(list *resourcev1alpha3.ResourceClaimList) []*resourcev1alpha3.ResourceClaim { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *resourcev1alpha3.ResourceClaimList, items []*resourcev1alpha3.ResourceClaim) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &resourcev1alpha3.ResourceClaimList{ListMeta: obj.(*resourcev1alpha3.ResourceClaimList).ListMeta} - for _, item := range obj.(*resourcev1alpha3.ResourceClaimList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested ResourceClaims across all clusters. -func (c *resourceClaimsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(resourceClaimsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *resourceClaimClusterClient) Cluster(cluster logicalcluster.Path) typedkcpresourcev1alpha3.ResourceClaimsNamespacer { + return &resourceClaimNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type resourceClaimsNamespacer struct { +type resourceClaimNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *resourceClaimsNamespacer) Namespace(namespace string) resourcev1alpha3client.ResourceClaimInterface { - return &resourceClaimsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *resourceClaimNamespacer) Namespace(namespace string) typedresourcev1alpha3.ResourceClaimInterface { + return newFakeResourceClaimClient(n.Fake, namespace, n.ClusterPath) } -type resourceClaimsClient struct { - *kcptesting.Fake +// resourceClaimScopedClient implements ResourceClaimInterface +type resourceClaimScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*resourcev1alpha3.ResourceClaim, *resourcev1alpha3.ResourceClaimList, *v1alpha3.ResourceClaimApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *resourceClaimsClient) Create(ctx context.Context, resourceClaim *resourcev1alpha3.ResourceClaim, opts metav1.CreateOptions) (*resourcev1alpha3.ResourceClaim, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(resourceClaimsResource, c.ClusterPath, c.Namespace, resourceClaim), &resourcev1alpha3.ResourceClaim{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1alpha3.ResourceClaim), err -} - -func (c *resourceClaimsClient) Update(ctx context.Context, resourceClaim *resourcev1alpha3.ResourceClaim, opts metav1.UpdateOptions) (*resourcev1alpha3.ResourceClaim, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(resourceClaimsResource, c.ClusterPath, c.Namespace, resourceClaim), &resourcev1alpha3.ResourceClaim{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1alpha3.ResourceClaim), err -} - -func (c *resourceClaimsClient) UpdateStatus(ctx context.Context, resourceClaim *resourcev1alpha3.ResourceClaim, opts metav1.UpdateOptions) (*resourcev1alpha3.ResourceClaim, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(resourceClaimsResource, c.ClusterPath, "status", c.Namespace, resourceClaim), &resourcev1alpha3.ResourceClaim{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1alpha3.ResourceClaim), err -} - -func (c *resourceClaimsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(resourceClaimsResource, c.ClusterPath, c.Namespace, name, opts), &resourcev1alpha3.ResourceClaim{}) - return err -} - -func (c *resourceClaimsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(resourceClaimsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &resourcev1alpha3.ResourceClaimList{}) - return err -} - -func (c *resourceClaimsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*resourcev1alpha3.ResourceClaim, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(resourceClaimsResource, c.ClusterPath, c.Namespace, name), &resourcev1alpha3.ResourceClaim{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1alpha3.ResourceClaim), err -} - -// List takes label and field selectors, and returns the list of ResourceClaims that match those selectors. -func (c *resourceClaimsClient) List(ctx context.Context, opts metav1.ListOptions) (*resourcev1alpha3.ResourceClaimList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(resourceClaimsResource, resourceClaimsKind, c.ClusterPath, c.Namespace, opts), &resourcev1alpha3.ResourceClaimList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &resourcev1alpha3.ResourceClaimList{ListMeta: obj.(*resourcev1alpha3.ResourceClaimList).ListMeta} - for _, item := range obj.(*resourcev1alpha3.ResourceClaimList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *resourceClaimsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(resourceClaimsResource, c.ClusterPath, c.Namespace, opts)) } -func (c *resourceClaimsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*resourcev1alpha3.ResourceClaim, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(resourceClaimsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &resourcev1alpha3.ResourceClaim{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1alpha3.ResourceClaim), err -} - -func (c *resourceClaimsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsresourcev1alpha3.ResourceClaimApplyConfiguration, opts metav1.ApplyOptions) (*resourcev1alpha3.ResourceClaim, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(resourceClaimsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &resourcev1alpha3.ResourceClaim{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1alpha3.ResourceClaim), err -} - -func (c *resourceClaimsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsresourcev1alpha3.ResourceClaimApplyConfiguration, opts metav1.ApplyOptions) (*resourcev1alpha3.ResourceClaim, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(resourceClaimsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &resourcev1alpha3.ResourceClaim{}) - if obj == nil { - return nil, err +func newFakeResourceClaimClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedresourcev1alpha3.ResourceClaimInterface { + return &resourceClaimScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*resourcev1alpha3.ResourceClaim, *resourcev1alpha3.ResourceClaimList, *v1alpha3.ResourceClaimApplyConfiguration]( + fake, + clusterPath, + namespace, + resourcev1alpha3.SchemeGroupVersion.WithResource("resourceclaims"), + resourcev1alpha3.SchemeGroupVersion.WithKind("ResourceClaim"), + func() *resourcev1alpha3.ResourceClaim { return &resourcev1alpha3.ResourceClaim{} }, + func() *resourcev1alpha3.ResourceClaimList { return &resourcev1alpha3.ResourceClaimList{} }, + func(dst, src *resourcev1alpha3.ResourceClaimList) { dst.ListMeta = src.ListMeta }, + func(list *resourcev1alpha3.ResourceClaimList) []*resourcev1alpha3.ResourceClaim { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *resourcev1alpha3.ResourceClaimList, items []*resourcev1alpha3.ResourceClaim) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*resourcev1alpha3.ResourceClaim), err } diff --git a/kubernetes/typed/resource/v1alpha3/fake/resourceclaimtemplate.go b/kubernetes/typed/resource/v1alpha3/fake/resourceclaimtemplate.go index 47f1007e4..aebfa6b4f 100644 --- a/kubernetes/typed/resource/v1alpha3/fake/resourceclaimtemplate.go +++ b/kubernetes/typed/resource/v1alpha3/fake/resourceclaimtemplate.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,91 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" resourcev1alpha3 "k8s.io/api/resource/v1alpha3" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsresourcev1alpha3 "k8s.io/client-go/applyconfigurations/resource/v1alpha3" - resourcev1alpha3client "k8s.io/client-go/kubernetes/typed/resource/v1alpha3" - "k8s.io/client-go/testing" + v1alpha3 "k8s.io/client-go/applyconfigurations/resource/v1alpha3" + typedresourcev1alpha3 "k8s.io/client-go/kubernetes/typed/resource/v1alpha3" - kcpresourcev1alpha3 "github.com/kcp-dev/client-go/kubernetes/typed/resource/v1alpha3" + typedkcpresourcev1alpha3 "github.com/kcp-dev/client-go/kubernetes/typed/resource/v1alpha3" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var resourceClaimTemplatesResource = schema.GroupVersionResource{Group: "resource.k8s.io", Version: "v1alpha3", Resource: "resourceclaimtemplates"} -var resourceClaimTemplatesKind = schema.GroupVersionKind{Group: "resource.k8s.io", Version: "v1alpha3", Kind: "ResourceClaimTemplate"} - -type resourceClaimTemplatesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *resourceClaimTemplatesClusterClient) Cluster(clusterPath logicalcluster.Path) kcpresourcev1alpha3.ResourceClaimTemplatesNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &resourceClaimTemplatesNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// resourceClaimTemplateClusterClient implements ResourceClaimTemplateClusterInterface +type resourceClaimTemplateClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*resourcev1alpha3.ResourceClaimTemplate, *resourcev1alpha3.ResourceClaimTemplateList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of ResourceClaimTemplates that match those selectors across all clusters. -func (c *resourceClaimTemplatesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*resourcev1alpha3.ResourceClaimTemplateList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(resourceClaimTemplatesResource, resourceClaimTemplatesKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &resourcev1alpha3.ResourceClaimTemplateList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeResourceClaimTemplateClusterClient(fake *ResourceV1alpha3ClusterClient) typedkcpresourcev1alpha3.ResourceClaimTemplateClusterInterface { + return &resourceClaimTemplateClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*resourcev1alpha3.ResourceClaimTemplate, *resourcev1alpha3.ResourceClaimTemplateList]( + fake.Fake, + resourcev1alpha3.SchemeGroupVersion.WithResource("resourceclaimtemplates"), + resourcev1alpha3.SchemeGroupVersion.WithKind("ResourceClaimTemplate"), + func() *resourcev1alpha3.ResourceClaimTemplate { return &resourcev1alpha3.ResourceClaimTemplate{} }, + func() *resourcev1alpha3.ResourceClaimTemplateList { + return &resourcev1alpha3.ResourceClaimTemplateList{} + }, + func(dst, src *resourcev1alpha3.ResourceClaimTemplateList) { dst.ListMeta = src.ListMeta }, + func(list *resourcev1alpha3.ResourceClaimTemplateList) []*resourcev1alpha3.ResourceClaimTemplate { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *resourcev1alpha3.ResourceClaimTemplateList, items []*resourcev1alpha3.ResourceClaimTemplate) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &resourcev1alpha3.ResourceClaimTemplateList{ListMeta: obj.(*resourcev1alpha3.ResourceClaimTemplateList).ListMeta} - for _, item := range obj.(*resourcev1alpha3.ResourceClaimTemplateList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested ResourceClaimTemplates across all clusters. -func (c *resourceClaimTemplatesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(resourceClaimTemplatesResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *resourceClaimTemplateClusterClient) Cluster(cluster logicalcluster.Path) typedkcpresourcev1alpha3.ResourceClaimTemplatesNamespacer { + return &resourceClaimTemplateNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type resourceClaimTemplatesNamespacer struct { +type resourceClaimTemplateNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *resourceClaimTemplatesNamespacer) Namespace(namespace string) resourcev1alpha3client.ResourceClaimTemplateInterface { - return &resourceClaimTemplatesClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *resourceClaimTemplateNamespacer) Namespace(namespace string) typedresourcev1alpha3.ResourceClaimTemplateInterface { + return newFakeResourceClaimTemplateClient(n.Fake, namespace, n.ClusterPath) } -type resourceClaimTemplatesClient struct { - *kcptesting.Fake +// resourceClaimTemplateScopedClient implements ResourceClaimTemplateInterface +type resourceClaimTemplateScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*resourcev1alpha3.ResourceClaimTemplate, *resourcev1alpha3.ResourceClaimTemplateList, *v1alpha3.ResourceClaimTemplateApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *resourceClaimTemplatesClient) Create(ctx context.Context, resourceClaimTemplate *resourcev1alpha3.ResourceClaimTemplate, opts metav1.CreateOptions) (*resourcev1alpha3.ResourceClaimTemplate, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(resourceClaimTemplatesResource, c.ClusterPath, c.Namespace, resourceClaimTemplate), &resourcev1alpha3.ResourceClaimTemplate{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1alpha3.ResourceClaimTemplate), err -} - -func (c *resourceClaimTemplatesClient) Update(ctx context.Context, resourceClaimTemplate *resourcev1alpha3.ResourceClaimTemplate, opts metav1.UpdateOptions) (*resourcev1alpha3.ResourceClaimTemplate, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(resourceClaimTemplatesResource, c.ClusterPath, c.Namespace, resourceClaimTemplate), &resourcev1alpha3.ResourceClaimTemplate{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1alpha3.ResourceClaimTemplate), err -} - -func (c *resourceClaimTemplatesClient) UpdateStatus(ctx context.Context, resourceClaimTemplate *resourcev1alpha3.ResourceClaimTemplate, opts metav1.UpdateOptions) (*resourcev1alpha3.ResourceClaimTemplate, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(resourceClaimTemplatesResource, c.ClusterPath, "status", c.Namespace, resourceClaimTemplate), &resourcev1alpha3.ResourceClaimTemplate{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1alpha3.ResourceClaimTemplate), err -} - -func (c *resourceClaimTemplatesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(resourceClaimTemplatesResource, c.ClusterPath, c.Namespace, name, opts), &resourcev1alpha3.ResourceClaimTemplate{}) - return err -} - -func (c *resourceClaimTemplatesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(resourceClaimTemplatesResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &resourcev1alpha3.ResourceClaimTemplateList{}) - return err -} - -func (c *resourceClaimTemplatesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*resourcev1alpha3.ResourceClaimTemplate, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(resourceClaimTemplatesResource, c.ClusterPath, c.Namespace, name), &resourcev1alpha3.ResourceClaimTemplate{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1alpha3.ResourceClaimTemplate), err -} - -// List takes label and field selectors, and returns the list of ResourceClaimTemplates that match those selectors. -func (c *resourceClaimTemplatesClient) List(ctx context.Context, opts metav1.ListOptions) (*resourcev1alpha3.ResourceClaimTemplateList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(resourceClaimTemplatesResource, resourceClaimTemplatesKind, c.ClusterPath, c.Namespace, opts), &resourcev1alpha3.ResourceClaimTemplateList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &resourcev1alpha3.ResourceClaimTemplateList{ListMeta: obj.(*resourcev1alpha3.ResourceClaimTemplateList).ListMeta} - for _, item := range obj.(*resourcev1alpha3.ResourceClaimTemplateList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *resourceClaimTemplatesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(resourceClaimTemplatesResource, c.ClusterPath, c.Namespace, opts)) } -func (c *resourceClaimTemplatesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*resourcev1alpha3.ResourceClaimTemplate, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(resourceClaimTemplatesResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &resourcev1alpha3.ResourceClaimTemplate{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1alpha3.ResourceClaimTemplate), err -} - -func (c *resourceClaimTemplatesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsresourcev1alpha3.ResourceClaimTemplateApplyConfiguration, opts metav1.ApplyOptions) (*resourcev1alpha3.ResourceClaimTemplate, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(resourceClaimTemplatesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &resourcev1alpha3.ResourceClaimTemplate{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1alpha3.ResourceClaimTemplate), err -} - -func (c *resourceClaimTemplatesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsresourcev1alpha3.ResourceClaimTemplateApplyConfiguration, opts metav1.ApplyOptions) (*resourcev1alpha3.ResourceClaimTemplate, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(resourceClaimTemplatesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &resourcev1alpha3.ResourceClaimTemplate{}) - if obj == nil { - return nil, err +func newFakeResourceClaimTemplateClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedresourcev1alpha3.ResourceClaimTemplateInterface { + return &resourceClaimTemplateScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*resourcev1alpha3.ResourceClaimTemplate, *resourcev1alpha3.ResourceClaimTemplateList, *v1alpha3.ResourceClaimTemplateApplyConfiguration]( + fake, + clusterPath, + namespace, + resourcev1alpha3.SchemeGroupVersion.WithResource("resourceclaimtemplates"), + resourcev1alpha3.SchemeGroupVersion.WithKind("ResourceClaimTemplate"), + func() *resourcev1alpha3.ResourceClaimTemplate { return &resourcev1alpha3.ResourceClaimTemplate{} }, + func() *resourcev1alpha3.ResourceClaimTemplateList { + return &resourcev1alpha3.ResourceClaimTemplateList{} + }, + func(dst, src *resourcev1alpha3.ResourceClaimTemplateList) { dst.ListMeta = src.ListMeta }, + func(list *resourcev1alpha3.ResourceClaimTemplateList) []*resourcev1alpha3.ResourceClaimTemplate { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *resourcev1alpha3.ResourceClaimTemplateList, items []*resourcev1alpha3.ResourceClaimTemplate) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*resourcev1alpha3.ResourceClaimTemplate), err } diff --git a/kubernetes/typed/resource/v1alpha3/fake/resourceslice.go b/kubernetes/typed/resource/v1alpha3/fake/resourceslice.go index c74a1283d..7f69657a7 100644 --- a/kubernetes/typed/resource/v1alpha3/fake/resourceslice.go +++ b/kubernetes/typed/resource/v1alpha3/fake/resourceslice.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" resourcev1alpha3 "k8s.io/api/resource/v1alpha3" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsresourcev1alpha3 "k8s.io/client-go/applyconfigurations/resource/v1alpha3" - resourcev1alpha3client "k8s.io/client-go/kubernetes/typed/resource/v1alpha3" - "k8s.io/client-go/testing" + v1alpha3 "k8s.io/client-go/applyconfigurations/resource/v1alpha3" + typedresourcev1alpha3 "k8s.io/client-go/kubernetes/typed/resource/v1alpha3" + typedkcpresourcev1alpha3 "github.com/kcp-dev/client-go/kubernetes/typed/resource/v1alpha3" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var resourceSlicesResource = schema.GroupVersionResource{Group: "resource.k8s.io", Version: "v1alpha3", Resource: "resourceslices"} -var resourceSlicesKind = schema.GroupVersionKind{Group: "resource.k8s.io", Version: "v1alpha3", Kind: "ResourceSlice"} - -type resourceSlicesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *resourceSlicesClusterClient) Cluster(clusterPath logicalcluster.Path) resourcev1alpha3client.ResourceSliceInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &resourceSlicesClient{Fake: c.Fake, ClusterPath: clusterPath} +// resourceSliceClusterClient implements ResourceSliceClusterInterface +type resourceSliceClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*resourcev1alpha3.ResourceSlice, *resourcev1alpha3.ResourceSliceList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of ResourceSlices that match those selectors across all clusters. -func (c *resourceSlicesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*resourcev1alpha3.ResourceSliceList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(resourceSlicesResource, resourceSlicesKind, logicalcluster.Wildcard, opts), &resourcev1alpha3.ResourceSliceList{}) - if obj == nil { - return nil, err +func newFakeResourceSliceClusterClient(fake *ResourceV1alpha3ClusterClient) typedkcpresourcev1alpha3.ResourceSliceClusterInterface { + return &resourceSliceClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*resourcev1alpha3.ResourceSlice, *resourcev1alpha3.ResourceSliceList]( + fake.Fake, + resourcev1alpha3.SchemeGroupVersion.WithResource("resourceslices"), + resourcev1alpha3.SchemeGroupVersion.WithKind("ResourceSlice"), + func() *resourcev1alpha3.ResourceSlice { return &resourcev1alpha3.ResourceSlice{} }, + func() *resourcev1alpha3.ResourceSliceList { return &resourcev1alpha3.ResourceSliceList{} }, + func(dst, src *resourcev1alpha3.ResourceSliceList) { dst.ListMeta = src.ListMeta }, + func(list *resourcev1alpha3.ResourceSliceList) []*resourcev1alpha3.ResourceSlice { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *resourcev1alpha3.ResourceSliceList, items []*resourcev1alpha3.ResourceSlice) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &resourcev1alpha3.ResourceSliceList{ListMeta: obj.(*resourcev1alpha3.ResourceSliceList).ListMeta} - for _, item := range obj.(*resourcev1alpha3.ResourceSliceList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested ResourceSlices across all clusters. -func (c *resourceSlicesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(resourceSlicesResource, logicalcluster.Wildcard, opts)) +func (c *resourceSliceClusterClient) Cluster(cluster logicalcluster.Path) typedresourcev1alpha3.ResourceSliceInterface { + return newFakeResourceSliceClient(c.Fake, cluster) } -type resourceSlicesClient struct { - *kcptesting.Fake +// resourceSliceScopedClient implements ResourceSliceInterface +type resourceSliceScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*resourcev1alpha3.ResourceSlice, *resourcev1alpha3.ResourceSliceList, *v1alpha3.ResourceSliceApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *resourceSlicesClient) Create(ctx context.Context, resourceSlice *resourcev1alpha3.ResourceSlice, opts metav1.CreateOptions) (*resourcev1alpha3.ResourceSlice, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(resourceSlicesResource, c.ClusterPath, resourceSlice), &resourcev1alpha3.ResourceSlice{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1alpha3.ResourceSlice), err -} - -func (c *resourceSlicesClient) Update(ctx context.Context, resourceSlice *resourcev1alpha3.ResourceSlice, opts metav1.UpdateOptions) (*resourcev1alpha3.ResourceSlice, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(resourceSlicesResource, c.ClusterPath, resourceSlice), &resourcev1alpha3.ResourceSlice{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1alpha3.ResourceSlice), err -} - -func (c *resourceSlicesClient) UpdateStatus(ctx context.Context, resourceSlice *resourcev1alpha3.ResourceSlice, opts metav1.UpdateOptions) (*resourcev1alpha3.ResourceSlice, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(resourceSlicesResource, c.ClusterPath, "status", resourceSlice), &resourcev1alpha3.ResourceSlice{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1alpha3.ResourceSlice), err -} - -func (c *resourceSlicesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(resourceSlicesResource, c.ClusterPath, name, opts), &resourcev1alpha3.ResourceSlice{}) - return err -} - -func (c *resourceSlicesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(resourceSlicesResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &resourcev1alpha3.ResourceSliceList{}) - return err -} - -func (c *resourceSlicesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*resourcev1alpha3.ResourceSlice, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(resourceSlicesResource, c.ClusterPath, name), &resourcev1alpha3.ResourceSlice{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1alpha3.ResourceSlice), err -} - -// List takes label and field selectors, and returns the list of ResourceSlices that match those selectors. -func (c *resourceSlicesClient) List(ctx context.Context, opts metav1.ListOptions) (*resourcev1alpha3.ResourceSliceList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(resourceSlicesResource, resourceSlicesKind, c.ClusterPath, opts), &resourcev1alpha3.ResourceSliceList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &resourcev1alpha3.ResourceSliceList{ListMeta: obj.(*resourcev1alpha3.ResourceSliceList).ListMeta} - for _, item := range obj.(*resourcev1alpha3.ResourceSliceList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *resourceSlicesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(resourceSlicesResource, c.ClusterPath, opts)) -} - -func (c *resourceSlicesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*resourcev1alpha3.ResourceSlice, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(resourceSlicesResource, c.ClusterPath, name, pt, data, subresources...), &resourcev1alpha3.ResourceSlice{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1alpha3.ResourceSlice), err -} - -func (c *resourceSlicesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsresourcev1alpha3.ResourceSliceApplyConfiguration, opts metav1.ApplyOptions) (*resourcev1alpha3.ResourceSlice, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(resourceSlicesResource, c.ClusterPath, *name, types.ApplyPatchType, data), &resourcev1alpha3.ResourceSlice{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1alpha3.ResourceSlice), err -} - -func (c *resourceSlicesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsresourcev1alpha3.ResourceSliceApplyConfiguration, opts metav1.ApplyOptions) (*resourcev1alpha3.ResourceSlice, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(resourceSlicesResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &resourcev1alpha3.ResourceSlice{}) - if obj == nil { - return nil, err +func newFakeResourceSliceClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedresourcev1alpha3.ResourceSliceInterface { + return &resourceSliceScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*resourcev1alpha3.ResourceSlice, *resourcev1alpha3.ResourceSliceList, *v1alpha3.ResourceSliceApplyConfiguration]( + fake, + clusterPath, + "", + resourcev1alpha3.SchemeGroupVersion.WithResource("resourceslices"), + resourcev1alpha3.SchemeGroupVersion.WithKind("ResourceSlice"), + func() *resourcev1alpha3.ResourceSlice { return &resourcev1alpha3.ResourceSlice{} }, + func() *resourcev1alpha3.ResourceSliceList { return &resourcev1alpha3.ResourceSliceList{} }, + func(dst, src *resourcev1alpha3.ResourceSliceList) { dst.ListMeta = src.ListMeta }, + func(list *resourcev1alpha3.ResourceSliceList) []*resourcev1alpha3.ResourceSlice { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *resourcev1alpha3.ResourceSliceList, items []*resourcev1alpha3.ResourceSlice) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*resourcev1alpha3.ResourceSlice), err } diff --git a/kubernetes/typed/resource/v1alpha3/generated_expansion.go b/kubernetes/typed/resource/v1alpha3/generated_expansion.go new file mode 100644 index 000000000..d48d61bab --- /dev/null +++ b/kubernetes/typed/resource/v1alpha3/generated_expansion.go @@ -0,0 +1,27 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1alpha3 + +type DeviceClassClusterExpansion interface{} + +type ResourceClaimClusterExpansion interface{} + +type ResourceClaimTemplateClusterExpansion interface{} + +type ResourceSliceClusterExpansion interface{} diff --git a/kubernetes/typed/resource/v1alpha3/resource_client.go b/kubernetes/typed/resource/v1alpha3/resource_client.go index 655573331..745429ef9 100644 --- a/kubernetes/typed/resource/v1alpha3/resource_client.go +++ b/kubernetes/typed/resource/v1alpha3/resource_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,32 +14,36 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha3 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apiresourcev1alpha3 "k8s.io/api/resource/v1alpha3" resourcev1alpha3 "k8s.io/client-go/kubernetes/typed/resource/v1alpha3" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type ResourceV1alpha3ClusterInterface interface { ResourceV1alpha3ClusterScoper - ResourceSlicesClusterGetter - ResourceClaimsClusterGetter DeviceClassesClusterGetter + ResourceClaimsClusterGetter ResourceClaimTemplatesClusterGetter + ResourceSlicesClusterGetter } type ResourceV1alpha3ClusterScoper interface { Cluster(logicalcluster.Path) resourcev1alpha3.ResourceV1alpha3Interface } +// ResourceV1alpha3ClusterClient is used to interact with features provided by the resource.k8s.io group. type ResourceV1alpha3ClusterClient struct { clientCache kcpclient.Cache[*resourcev1alpha3.ResourceV1alpha3Client] } @@ -51,31 +55,33 @@ func (c *ResourceV1alpha3ClusterClient) Cluster(clusterPath logicalcluster.Path) return c.clientCache.ClusterOrDie(clusterPath) } -func (c *ResourceV1alpha3ClusterClient) ResourceSlices() ResourceSliceClusterInterface { - return &resourceSlicesClusterInterface{clientCache: c.clientCache} +func (c *ResourceV1alpha3ClusterClient) DeviceClasses() DeviceClassClusterInterface { + return &deviceClassesClusterInterface{clientCache: c.clientCache} } func (c *ResourceV1alpha3ClusterClient) ResourceClaims() ResourceClaimClusterInterface { return &resourceClaimsClusterInterface{clientCache: c.clientCache} } -func (c *ResourceV1alpha3ClusterClient) DeviceClasses() DeviceClassClusterInterface { - return &deviceClassesClusterInterface{clientCache: c.clientCache} -} - func (c *ResourceV1alpha3ClusterClient) ResourceClaimTemplates() ResourceClaimTemplateClusterInterface { return &resourceClaimTemplatesClusterInterface{clientCache: c.clientCache} } +func (c *ResourceV1alpha3ClusterClient) ResourceSlices() ResourceSliceClusterInterface { + return &resourceSlicesClusterInterface{clientCache: c.clientCache} +} + // NewForConfig creates a new ResourceV1alpha3ClusterClient for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*ResourceV1alpha3ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new ResourceV1alpha3ClusterClient for the given config and http client. @@ -87,6 +93,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*ResourceV1alpha3Clu if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &ResourceV1alpha3ClusterClient{clientCache: cache}, nil } @@ -99,3 +106,14 @@ func NewForConfigOrDie(c *rest.Config) *ResourceV1alpha3ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apiresourcev1alpha3.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/resource/v1alpha3/resourceclaim.go b/kubernetes/typed/resource/v1alpha3/resourceclaim.go index e9f942f70..22ca0b990 100644 --- a/kubernetes/typed/resource/v1alpha3/resourceclaim.go +++ b/kubernetes/typed/resource/v1alpha3/resourceclaim.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha3 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" resourcev1alpha3 "k8s.io/api/resource/v1alpha3" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - resourcev1alpha3client "k8s.io/client-go/kubernetes/typed/resource/v1alpha3" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedresourcev1alpha3 "k8s.io/client-go/kubernetes/typed/resource/v1alpha3" ) // ResourceClaimsClusterGetter has a method to return a ResourceClaimClusterInterface. @@ -40,12 +40,13 @@ type ResourceClaimsClusterGetter interface { // or scope down to one cluster and return a ResourceClaimsNamespacer. type ResourceClaimClusterInterface interface { Cluster(logicalcluster.Path) ResourceClaimsNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*resourcev1alpha3.ResourceClaimList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*resourcev1alpha3.ResourceClaimList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + ResourceClaimClusterExpansion } type resourceClaimsClusterInterface struct { - clientCache kcpclient.Cache[*resourcev1alpha3client.ResourceV1alpha3Client] + clientCache kcpclient.Cache[*typedresourcev1alpha3.ResourceV1alpha3Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *resourceClaimsClusterInterface) Cluster(clusterPath logicalcluster.Path } // List returns the entire collection of all ResourceClaims across all clusters. -func (c *resourceClaimsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*resourcev1alpha3.ResourceClaimList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ResourceClaims(metav1.NamespaceAll).List(ctx, opts) +func (c *resourceClaimsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*resourcev1alpha3.ResourceClaimList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ResourceClaims(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all ResourceClaims across all clusters. -func (c *resourceClaimsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ResourceClaims(metav1.NamespaceAll).Watch(ctx, opts) +func (c *resourceClaimsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ResourceClaims(v1.NamespaceAll).Watch(ctx, opts) } -// ResourceClaimsNamespacer can scope to objects within a namespace, returning a resourcev1alpha3client.ResourceClaimInterface. +// ResourceClaimsNamespacer can scope to objects within a namespace, returning a typedresourcev1alpha3.ResourceClaimInterface. type ResourceClaimsNamespacer interface { - Namespace(string) resourcev1alpha3client.ResourceClaimInterface + Namespace(string) typedresourcev1alpha3.ResourceClaimInterface } type resourceClaimsNamespacer struct { - clientCache kcpclient.Cache[*resourcev1alpha3client.ResourceV1alpha3Client] + clientCache kcpclient.Cache[*typedresourcev1alpha3.ResourceV1alpha3Client] clusterPath logicalcluster.Path } -func (n *resourceClaimsNamespacer) Namespace(namespace string) resourcev1alpha3client.ResourceClaimInterface { +func (n *resourceClaimsNamespacer) Namespace(namespace string) typedresourcev1alpha3.ResourceClaimInterface { return n.clientCache.ClusterOrDie(n.clusterPath).ResourceClaims(namespace) } diff --git a/kubernetes/typed/resource/v1alpha3/resourceclaimtemplate.go b/kubernetes/typed/resource/v1alpha3/resourceclaimtemplate.go index 89f619e17..e9becb5bf 100644 --- a/kubernetes/typed/resource/v1alpha3/resourceclaimtemplate.go +++ b/kubernetes/typed/resource/v1alpha3/resourceclaimtemplate.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha3 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" resourcev1alpha3 "k8s.io/api/resource/v1alpha3" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - resourcev1alpha3client "k8s.io/client-go/kubernetes/typed/resource/v1alpha3" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedresourcev1alpha3 "k8s.io/client-go/kubernetes/typed/resource/v1alpha3" ) // ResourceClaimTemplatesClusterGetter has a method to return a ResourceClaimTemplateClusterInterface. @@ -40,12 +40,13 @@ type ResourceClaimTemplatesClusterGetter interface { // or scope down to one cluster and return a ResourceClaimTemplatesNamespacer. type ResourceClaimTemplateClusterInterface interface { Cluster(logicalcluster.Path) ResourceClaimTemplatesNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*resourcev1alpha3.ResourceClaimTemplateList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*resourcev1alpha3.ResourceClaimTemplateList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + ResourceClaimTemplateClusterExpansion } type resourceClaimTemplatesClusterInterface struct { - clientCache kcpclient.Cache[*resourcev1alpha3client.ResourceV1alpha3Client] + clientCache kcpclient.Cache[*typedresourcev1alpha3.ResourceV1alpha3Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *resourceClaimTemplatesClusterInterface) Cluster(clusterPath logicalclus } // List returns the entire collection of all ResourceClaimTemplates across all clusters. -func (c *resourceClaimTemplatesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*resourcev1alpha3.ResourceClaimTemplateList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ResourceClaimTemplates(metav1.NamespaceAll).List(ctx, opts) +func (c *resourceClaimTemplatesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*resourcev1alpha3.ResourceClaimTemplateList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ResourceClaimTemplates(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all ResourceClaimTemplates across all clusters. -func (c *resourceClaimTemplatesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ResourceClaimTemplates(metav1.NamespaceAll).Watch(ctx, opts) +func (c *resourceClaimTemplatesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ResourceClaimTemplates(v1.NamespaceAll).Watch(ctx, opts) } -// ResourceClaimTemplatesNamespacer can scope to objects within a namespace, returning a resourcev1alpha3client.ResourceClaimTemplateInterface. +// ResourceClaimTemplatesNamespacer can scope to objects within a namespace, returning a typedresourcev1alpha3.ResourceClaimTemplateInterface. type ResourceClaimTemplatesNamespacer interface { - Namespace(string) resourcev1alpha3client.ResourceClaimTemplateInterface + Namespace(string) typedresourcev1alpha3.ResourceClaimTemplateInterface } type resourceClaimTemplatesNamespacer struct { - clientCache kcpclient.Cache[*resourcev1alpha3client.ResourceV1alpha3Client] + clientCache kcpclient.Cache[*typedresourcev1alpha3.ResourceV1alpha3Client] clusterPath logicalcluster.Path } -func (n *resourceClaimTemplatesNamespacer) Namespace(namespace string) resourcev1alpha3client.ResourceClaimTemplateInterface { +func (n *resourceClaimTemplatesNamespacer) Namespace(namespace string) typedresourcev1alpha3.ResourceClaimTemplateInterface { return n.clientCache.ClusterOrDie(n.clusterPath).ResourceClaimTemplates(namespace) } diff --git a/kubernetes/typed/resource/v1alpha3/resourceslice.go b/kubernetes/typed/resource/v1alpha3/resourceslice.go index 98293dddc..d9e43254e 100644 --- a/kubernetes/typed/resource/v1alpha3/resourceslice.go +++ b/kubernetes/typed/resource/v1alpha3/resourceslice.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha3 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - resourcev1alpha3 "k8s.io/api/resource/v1alpha3" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - resourcev1alpha3client "k8s.io/client-go/kubernetes/typed/resource/v1alpha3" + apiresourcev1alpha3 "k8s.io/api/resource/v1alpha3" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + resourcev1alpha3 "k8s.io/client-go/kubernetes/typed/resource/v1alpha3" ) // ResourceSlicesClusterGetter has a method to return a ResourceSliceClusterInterface. @@ -37,19 +37,20 @@ type ResourceSlicesClusterGetter interface { } // ResourceSliceClusterInterface can operate on ResourceSlices across all clusters, -// or scope down to one cluster and return a resourcev1alpha3client.ResourceSliceInterface. +// or scope down to one cluster and return a resourcev1alpha3.ResourceSliceInterface. type ResourceSliceClusterInterface interface { - Cluster(logicalcluster.Path) resourcev1alpha3client.ResourceSliceInterface - List(ctx context.Context, opts metav1.ListOptions) (*resourcev1alpha3.ResourceSliceList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) resourcev1alpha3.ResourceSliceInterface + List(ctx context.Context, opts v1.ListOptions) (*apiresourcev1alpha3.ResourceSliceList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + ResourceSliceClusterExpansion } type resourceSlicesClusterInterface struct { - clientCache kcpclient.Cache[*resourcev1alpha3client.ResourceV1alpha3Client] + clientCache kcpclient.Cache[*resourcev1alpha3.ResourceV1alpha3Client] } // Cluster scopes the client down to a particular cluster. -func (c *resourceSlicesClusterInterface) Cluster(clusterPath logicalcluster.Path) resourcev1alpha3client.ResourceSliceInterface { +func (c *resourceSlicesClusterInterface) Cluster(clusterPath logicalcluster.Path) resourcev1alpha3.ResourceSliceInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *resourceSlicesClusterInterface) Cluster(clusterPath logicalcluster.Path } // List returns the entire collection of all ResourceSlices across all clusters. -func (c *resourceSlicesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*resourcev1alpha3.ResourceSliceList, error) { +func (c *resourceSlicesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apiresourcev1alpha3.ResourceSliceList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ResourceSlices().List(ctx, opts) } // Watch begins to watch all ResourceSlices across all clusters. -func (c *resourceSlicesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *resourceSlicesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ResourceSlices().Watch(ctx, opts) } diff --git a/kubernetes/typed/resource/v1beta1/deviceclass.go b/kubernetes/typed/resource/v1beta1/deviceclass.go index e6ebe014d..e22c14fc6 100644 --- a/kubernetes/typed/resource/v1beta1/deviceclass.go +++ b/kubernetes/typed/resource/v1beta1/deviceclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - resourcev1beta1 "k8s.io/api/resource/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - resourcev1beta1client "k8s.io/client-go/kubernetes/typed/resource/v1beta1" + apiresourcev1beta1 "k8s.io/api/resource/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + resourcev1beta1 "k8s.io/client-go/kubernetes/typed/resource/v1beta1" ) // DeviceClassesClusterGetter has a method to return a DeviceClassClusterInterface. @@ -37,19 +37,20 @@ type DeviceClassesClusterGetter interface { } // DeviceClassClusterInterface can operate on DeviceClasses across all clusters, -// or scope down to one cluster and return a resourcev1beta1client.DeviceClassInterface. +// or scope down to one cluster and return a resourcev1beta1.DeviceClassInterface. type DeviceClassClusterInterface interface { - Cluster(logicalcluster.Path) resourcev1beta1client.DeviceClassInterface - List(ctx context.Context, opts metav1.ListOptions) (*resourcev1beta1.DeviceClassList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) resourcev1beta1.DeviceClassInterface + List(ctx context.Context, opts v1.ListOptions) (*apiresourcev1beta1.DeviceClassList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + DeviceClassClusterExpansion } type deviceClassesClusterInterface struct { - clientCache kcpclient.Cache[*resourcev1beta1client.ResourceV1beta1Client] + clientCache kcpclient.Cache[*resourcev1beta1.ResourceV1beta1Client] } // Cluster scopes the client down to a particular cluster. -func (c *deviceClassesClusterInterface) Cluster(clusterPath logicalcluster.Path) resourcev1beta1client.DeviceClassInterface { +func (c *deviceClassesClusterInterface) Cluster(clusterPath logicalcluster.Path) resourcev1beta1.DeviceClassInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *deviceClassesClusterInterface) Cluster(clusterPath logicalcluster.Path) } // List returns the entire collection of all DeviceClasses across all clusters. -func (c *deviceClassesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*resourcev1beta1.DeviceClassList, error) { +func (c *deviceClassesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apiresourcev1beta1.DeviceClassList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).DeviceClasses().List(ctx, opts) } // Watch begins to watch all DeviceClasses across all clusters. -func (c *deviceClassesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *deviceClassesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).DeviceClasses().Watch(ctx, opts) } diff --git a/kubernetes/typed/resource/v1beta1/doc.go b/kubernetes/typed/resource/v1beta1/doc.go new file mode 100644 index 000000000..541e9d258 --- /dev/null +++ b/kubernetes/typed/resource/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1beta1 diff --git a/kubernetes/typed/resource/v1beta1/fake/deviceclass.go b/kubernetes/typed/resource/v1beta1/fake/deviceclass.go index b64a51cff..68fac50bb 100644 --- a/kubernetes/typed/resource/v1beta1/fake/deviceclass.go +++ b/kubernetes/typed/resource/v1beta1/fake/deviceclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" resourcev1beta1 "k8s.io/api/resource/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsresourcev1beta1 "k8s.io/client-go/applyconfigurations/resource/v1beta1" - resourcev1beta1client "k8s.io/client-go/kubernetes/typed/resource/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/resource/v1beta1" + typedresourcev1beta1 "k8s.io/client-go/kubernetes/typed/resource/v1beta1" + typedkcpresourcev1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/resource/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var deviceClassesResource = schema.GroupVersionResource{Group: "resource.k8s.io", Version: "v1beta1", Resource: "deviceclasses"} -var deviceClassesKind = schema.GroupVersionKind{Group: "resource.k8s.io", Version: "v1beta1", Kind: "DeviceClass"} - -type deviceClassesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *deviceClassesClusterClient) Cluster(clusterPath logicalcluster.Path) resourcev1beta1client.DeviceClassInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &deviceClassesClient{Fake: c.Fake, ClusterPath: clusterPath} +// deviceClassClusterClient implements DeviceClassClusterInterface +type deviceClassClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*resourcev1beta1.DeviceClass, *resourcev1beta1.DeviceClassList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of DeviceClasses that match those selectors across all clusters. -func (c *deviceClassesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*resourcev1beta1.DeviceClassList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(deviceClassesResource, deviceClassesKind, logicalcluster.Wildcard, opts), &resourcev1beta1.DeviceClassList{}) - if obj == nil { - return nil, err +func newFakeDeviceClassClusterClient(fake *ResourceV1beta1ClusterClient) typedkcpresourcev1beta1.DeviceClassClusterInterface { + return &deviceClassClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*resourcev1beta1.DeviceClass, *resourcev1beta1.DeviceClassList]( + fake.Fake, + resourcev1beta1.SchemeGroupVersion.WithResource("deviceclasses"), + resourcev1beta1.SchemeGroupVersion.WithKind("DeviceClass"), + func() *resourcev1beta1.DeviceClass { return &resourcev1beta1.DeviceClass{} }, + func() *resourcev1beta1.DeviceClassList { return &resourcev1beta1.DeviceClassList{} }, + func(dst, src *resourcev1beta1.DeviceClassList) { dst.ListMeta = src.ListMeta }, + func(list *resourcev1beta1.DeviceClassList) []*resourcev1beta1.DeviceClass { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *resourcev1beta1.DeviceClassList, items []*resourcev1beta1.DeviceClass) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &resourcev1beta1.DeviceClassList{ListMeta: obj.(*resourcev1beta1.DeviceClassList).ListMeta} - for _, item := range obj.(*resourcev1beta1.DeviceClassList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested DeviceClasses across all clusters. -func (c *deviceClassesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(deviceClassesResource, logicalcluster.Wildcard, opts)) +func (c *deviceClassClusterClient) Cluster(cluster logicalcluster.Path) typedresourcev1beta1.DeviceClassInterface { + return newFakeDeviceClassClient(c.Fake, cluster) } -type deviceClassesClient struct { - *kcptesting.Fake +// deviceClassScopedClient implements DeviceClassInterface +type deviceClassScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*resourcev1beta1.DeviceClass, *resourcev1beta1.DeviceClassList, *v1beta1.DeviceClassApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *deviceClassesClient) Create(ctx context.Context, deviceClass *resourcev1beta1.DeviceClass, opts metav1.CreateOptions) (*resourcev1beta1.DeviceClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(deviceClassesResource, c.ClusterPath, deviceClass), &resourcev1beta1.DeviceClass{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1beta1.DeviceClass), err -} - -func (c *deviceClassesClient) Update(ctx context.Context, deviceClass *resourcev1beta1.DeviceClass, opts metav1.UpdateOptions) (*resourcev1beta1.DeviceClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(deviceClassesResource, c.ClusterPath, deviceClass), &resourcev1beta1.DeviceClass{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1beta1.DeviceClass), err -} - -func (c *deviceClassesClient) UpdateStatus(ctx context.Context, deviceClass *resourcev1beta1.DeviceClass, opts metav1.UpdateOptions) (*resourcev1beta1.DeviceClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(deviceClassesResource, c.ClusterPath, "status", deviceClass), &resourcev1beta1.DeviceClass{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1beta1.DeviceClass), err -} - -func (c *deviceClassesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(deviceClassesResource, c.ClusterPath, name, opts), &resourcev1beta1.DeviceClass{}) - return err -} - -func (c *deviceClassesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(deviceClassesResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &resourcev1beta1.DeviceClassList{}) - return err -} - -func (c *deviceClassesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*resourcev1beta1.DeviceClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(deviceClassesResource, c.ClusterPath, name), &resourcev1beta1.DeviceClass{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1beta1.DeviceClass), err -} - -// List takes label and field selectors, and returns the list of DeviceClasses that match those selectors. -func (c *deviceClassesClient) List(ctx context.Context, opts metav1.ListOptions) (*resourcev1beta1.DeviceClassList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(deviceClassesResource, deviceClassesKind, c.ClusterPath, opts), &resourcev1beta1.DeviceClassList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &resourcev1beta1.DeviceClassList{ListMeta: obj.(*resourcev1beta1.DeviceClassList).ListMeta} - for _, item := range obj.(*resourcev1beta1.DeviceClassList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *deviceClassesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(deviceClassesResource, c.ClusterPath, opts)) -} - -func (c *deviceClassesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*resourcev1beta1.DeviceClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(deviceClassesResource, c.ClusterPath, name, pt, data, subresources...), &resourcev1beta1.DeviceClass{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1beta1.DeviceClass), err -} - -func (c *deviceClassesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsresourcev1beta1.DeviceClassApplyConfiguration, opts metav1.ApplyOptions) (*resourcev1beta1.DeviceClass, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(deviceClassesResource, c.ClusterPath, *name, types.ApplyPatchType, data), &resourcev1beta1.DeviceClass{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1beta1.DeviceClass), err -} - -func (c *deviceClassesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsresourcev1beta1.DeviceClassApplyConfiguration, opts metav1.ApplyOptions) (*resourcev1beta1.DeviceClass, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(deviceClassesResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &resourcev1beta1.DeviceClass{}) - if obj == nil { - return nil, err +func newFakeDeviceClassClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedresourcev1beta1.DeviceClassInterface { + return &deviceClassScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*resourcev1beta1.DeviceClass, *resourcev1beta1.DeviceClassList, *v1beta1.DeviceClassApplyConfiguration]( + fake, + clusterPath, + "", + resourcev1beta1.SchemeGroupVersion.WithResource("deviceclasses"), + resourcev1beta1.SchemeGroupVersion.WithKind("DeviceClass"), + func() *resourcev1beta1.DeviceClass { return &resourcev1beta1.DeviceClass{} }, + func() *resourcev1beta1.DeviceClassList { return &resourcev1beta1.DeviceClassList{} }, + func(dst, src *resourcev1beta1.DeviceClassList) { dst.ListMeta = src.ListMeta }, + func(list *resourcev1beta1.DeviceClassList) []*resourcev1beta1.DeviceClass { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *resourcev1beta1.DeviceClassList, items []*resourcev1beta1.DeviceClass) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*resourcev1beta1.DeviceClass), err } diff --git a/kubernetes/typed/resource/v1beta1/fake/doc.go b/kubernetes/typed/resource/v1beta1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/resource/v1beta1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/resource/v1beta1/fake/resource_client.go b/kubernetes/typed/resource/v1beta1/fake/resource_client.go index f65f2118b..1f18a0fc1 100644 --- a/kubernetes/typed/resource/v1beta1/fake/resource_client.go +++ b/kubernetes/typed/resource/v1beta1/fake/resource_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" resourcev1beta1 "k8s.io/client-go/kubernetes/typed/resource/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpresourcev1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/resource/v1beta1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -41,46 +41,46 @@ func (c *ResourceV1beta1ClusterClient) Cluster(clusterPath logicalcluster.Path) return &ResourceV1beta1Client{Fake: c.Fake, ClusterPath: clusterPath} } -func (c *ResourceV1beta1ClusterClient) ResourceSlices() kcpresourcev1beta1.ResourceSliceClusterInterface { - return &resourceSlicesClusterClient{Fake: c.Fake} +func (c *ResourceV1beta1ClusterClient) DeviceClasses() kcpresourcev1beta1.DeviceClassClusterInterface { + return newFakeDeviceClassClusterClient(c) } func (c *ResourceV1beta1ClusterClient) ResourceClaims() kcpresourcev1beta1.ResourceClaimClusterInterface { - return &resourceClaimsClusterClient{Fake: c.Fake} -} - -func (c *ResourceV1beta1ClusterClient) DeviceClasses() kcpresourcev1beta1.DeviceClassClusterInterface { - return &deviceClassesClusterClient{Fake: c.Fake} + return newFakeResourceClaimClusterClient(c) } func (c *ResourceV1beta1ClusterClient) ResourceClaimTemplates() kcpresourcev1beta1.ResourceClaimTemplateClusterInterface { - return &resourceClaimTemplatesClusterClient{Fake: c.Fake} + return newFakeResourceClaimTemplateClusterClient(c) } -var _ resourcev1beta1.ResourceV1beta1Interface = (*ResourceV1beta1Client)(nil) +func (c *ResourceV1beta1ClusterClient) ResourceSlices() kcpresourcev1beta1.ResourceSliceClusterInterface { + return newFakeResourceSliceClusterClient(c) +} type ResourceV1beta1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *ResourceV1beta1Client) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret +func (c *ResourceV1beta1Client) DeviceClasses() resourcev1beta1.DeviceClassInterface { + return newFakeDeviceClassClient(c.Fake, c.ClusterPath) } -func (c *ResourceV1beta1Client) ResourceSlices() resourcev1beta1.ResourceSliceInterface { - return &resourceSlicesClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +func (c *ResourceV1beta1Client) ResourceClaims(namespace string) resourcev1beta1.ResourceClaimInterface { + return newFakeResourceClaimClient(c.Fake, namespace, c.ClusterPath) } -func (c *ResourceV1beta1Client) ResourceClaims(namespace string) resourcev1beta1.ResourceClaimInterface { - return &resourceClaimsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *ResourceV1beta1Client) ResourceClaimTemplates(namespace string) resourcev1beta1.ResourceClaimTemplateInterface { + return newFakeResourceClaimTemplateClient(c.Fake, namespace, c.ClusterPath) } -func (c *ResourceV1beta1Client) DeviceClasses() resourcev1beta1.DeviceClassInterface { - return &deviceClassesClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +func (c *ResourceV1beta1Client) ResourceSlices() resourcev1beta1.ResourceSliceInterface { + return newFakeResourceSliceClient(c.Fake, c.ClusterPath) } -func (c *ResourceV1beta1Client) ResourceClaimTemplates(namespace string) resourcev1beta1.ResourceClaimTemplateInterface { - return &resourceClaimTemplatesClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *ResourceV1beta1Client) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret } diff --git a/kubernetes/typed/resource/v1beta1/fake/resourceclaim.go b/kubernetes/typed/resource/v1beta1/fake/resourceclaim.go index d7c7d98fe..4d62996a1 100644 --- a/kubernetes/typed/resource/v1beta1/fake/resourceclaim.go +++ b/kubernetes/typed/resource/v1beta1/fake/resourceclaim.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" resourcev1beta1 "k8s.io/api/resource/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsresourcev1beta1 "k8s.io/client-go/applyconfigurations/resource/v1beta1" - resourcev1beta1client "k8s.io/client-go/kubernetes/typed/resource/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/resource/v1beta1" + typedresourcev1beta1 "k8s.io/client-go/kubernetes/typed/resource/v1beta1" - kcpresourcev1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/resource/v1beta1" + typedkcpresourcev1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/resource/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var resourceClaimsResource = schema.GroupVersionResource{Group: "resource.k8s.io", Version: "v1beta1", Resource: "resourceclaims"} -var resourceClaimsKind = schema.GroupVersionKind{Group: "resource.k8s.io", Version: "v1beta1", Kind: "ResourceClaim"} - -type resourceClaimsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *resourceClaimsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpresourcev1beta1.ResourceClaimsNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &resourceClaimsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// resourceClaimClusterClient implements ResourceClaimClusterInterface +type resourceClaimClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*resourcev1beta1.ResourceClaim, *resourcev1beta1.ResourceClaimList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of ResourceClaims that match those selectors across all clusters. -func (c *resourceClaimsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*resourcev1beta1.ResourceClaimList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(resourceClaimsResource, resourceClaimsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &resourcev1beta1.ResourceClaimList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeResourceClaimClusterClient(fake *ResourceV1beta1ClusterClient) typedkcpresourcev1beta1.ResourceClaimClusterInterface { + return &resourceClaimClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*resourcev1beta1.ResourceClaim, *resourcev1beta1.ResourceClaimList]( + fake.Fake, + resourcev1beta1.SchemeGroupVersion.WithResource("resourceclaims"), + resourcev1beta1.SchemeGroupVersion.WithKind("ResourceClaim"), + func() *resourcev1beta1.ResourceClaim { return &resourcev1beta1.ResourceClaim{} }, + func() *resourcev1beta1.ResourceClaimList { return &resourcev1beta1.ResourceClaimList{} }, + func(dst, src *resourcev1beta1.ResourceClaimList) { dst.ListMeta = src.ListMeta }, + func(list *resourcev1beta1.ResourceClaimList) []*resourcev1beta1.ResourceClaim { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *resourcev1beta1.ResourceClaimList, items []*resourcev1beta1.ResourceClaim) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &resourcev1beta1.ResourceClaimList{ListMeta: obj.(*resourcev1beta1.ResourceClaimList).ListMeta} - for _, item := range obj.(*resourcev1beta1.ResourceClaimList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested ResourceClaims across all clusters. -func (c *resourceClaimsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(resourceClaimsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *resourceClaimClusterClient) Cluster(cluster logicalcluster.Path) typedkcpresourcev1beta1.ResourceClaimsNamespacer { + return &resourceClaimNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type resourceClaimsNamespacer struct { +type resourceClaimNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *resourceClaimsNamespacer) Namespace(namespace string) resourcev1beta1client.ResourceClaimInterface { - return &resourceClaimsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *resourceClaimNamespacer) Namespace(namespace string) typedresourcev1beta1.ResourceClaimInterface { + return newFakeResourceClaimClient(n.Fake, namespace, n.ClusterPath) } -type resourceClaimsClient struct { - *kcptesting.Fake +// resourceClaimScopedClient implements ResourceClaimInterface +type resourceClaimScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*resourcev1beta1.ResourceClaim, *resourcev1beta1.ResourceClaimList, *v1beta1.ResourceClaimApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *resourceClaimsClient) Create(ctx context.Context, resourceClaim *resourcev1beta1.ResourceClaim, opts metav1.CreateOptions) (*resourcev1beta1.ResourceClaim, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(resourceClaimsResource, c.ClusterPath, c.Namespace, resourceClaim), &resourcev1beta1.ResourceClaim{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1beta1.ResourceClaim), err -} - -func (c *resourceClaimsClient) Update(ctx context.Context, resourceClaim *resourcev1beta1.ResourceClaim, opts metav1.UpdateOptions) (*resourcev1beta1.ResourceClaim, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(resourceClaimsResource, c.ClusterPath, c.Namespace, resourceClaim), &resourcev1beta1.ResourceClaim{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1beta1.ResourceClaim), err -} - -func (c *resourceClaimsClient) UpdateStatus(ctx context.Context, resourceClaim *resourcev1beta1.ResourceClaim, opts metav1.UpdateOptions) (*resourcev1beta1.ResourceClaim, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(resourceClaimsResource, c.ClusterPath, "status", c.Namespace, resourceClaim), &resourcev1beta1.ResourceClaim{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1beta1.ResourceClaim), err -} - -func (c *resourceClaimsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(resourceClaimsResource, c.ClusterPath, c.Namespace, name, opts), &resourcev1beta1.ResourceClaim{}) - return err -} - -func (c *resourceClaimsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(resourceClaimsResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &resourcev1beta1.ResourceClaimList{}) - return err -} - -func (c *resourceClaimsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*resourcev1beta1.ResourceClaim, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(resourceClaimsResource, c.ClusterPath, c.Namespace, name), &resourcev1beta1.ResourceClaim{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1beta1.ResourceClaim), err -} - -// List takes label and field selectors, and returns the list of ResourceClaims that match those selectors. -func (c *resourceClaimsClient) List(ctx context.Context, opts metav1.ListOptions) (*resourcev1beta1.ResourceClaimList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(resourceClaimsResource, resourceClaimsKind, c.ClusterPath, c.Namespace, opts), &resourcev1beta1.ResourceClaimList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &resourcev1beta1.ResourceClaimList{ListMeta: obj.(*resourcev1beta1.ResourceClaimList).ListMeta} - for _, item := range obj.(*resourcev1beta1.ResourceClaimList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *resourceClaimsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(resourceClaimsResource, c.ClusterPath, c.Namespace, opts)) } -func (c *resourceClaimsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*resourcev1beta1.ResourceClaim, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(resourceClaimsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &resourcev1beta1.ResourceClaim{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1beta1.ResourceClaim), err -} - -func (c *resourceClaimsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsresourcev1beta1.ResourceClaimApplyConfiguration, opts metav1.ApplyOptions) (*resourcev1beta1.ResourceClaim, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(resourceClaimsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &resourcev1beta1.ResourceClaim{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1beta1.ResourceClaim), err -} - -func (c *resourceClaimsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsresourcev1beta1.ResourceClaimApplyConfiguration, opts metav1.ApplyOptions) (*resourcev1beta1.ResourceClaim, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(resourceClaimsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &resourcev1beta1.ResourceClaim{}) - if obj == nil { - return nil, err +func newFakeResourceClaimClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedresourcev1beta1.ResourceClaimInterface { + return &resourceClaimScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*resourcev1beta1.ResourceClaim, *resourcev1beta1.ResourceClaimList, *v1beta1.ResourceClaimApplyConfiguration]( + fake, + clusterPath, + namespace, + resourcev1beta1.SchemeGroupVersion.WithResource("resourceclaims"), + resourcev1beta1.SchemeGroupVersion.WithKind("ResourceClaim"), + func() *resourcev1beta1.ResourceClaim { return &resourcev1beta1.ResourceClaim{} }, + func() *resourcev1beta1.ResourceClaimList { return &resourcev1beta1.ResourceClaimList{} }, + func(dst, src *resourcev1beta1.ResourceClaimList) { dst.ListMeta = src.ListMeta }, + func(list *resourcev1beta1.ResourceClaimList) []*resourcev1beta1.ResourceClaim { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *resourcev1beta1.ResourceClaimList, items []*resourcev1beta1.ResourceClaim) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*resourcev1beta1.ResourceClaim), err } diff --git a/kubernetes/typed/resource/v1beta1/fake/resourceclaimtemplate.go b/kubernetes/typed/resource/v1beta1/fake/resourceclaimtemplate.go index c17473b27..92e03b4ef 100644 --- a/kubernetes/typed/resource/v1beta1/fake/resourceclaimtemplate.go +++ b/kubernetes/typed/resource/v1beta1/fake/resourceclaimtemplate.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" resourcev1beta1 "k8s.io/api/resource/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsresourcev1beta1 "k8s.io/client-go/applyconfigurations/resource/v1beta1" - resourcev1beta1client "k8s.io/client-go/kubernetes/typed/resource/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/resource/v1beta1" + typedresourcev1beta1 "k8s.io/client-go/kubernetes/typed/resource/v1beta1" - kcpresourcev1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/resource/v1beta1" + typedkcpresourcev1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/resource/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var resourceClaimTemplatesResource = schema.GroupVersionResource{Group: "resource.k8s.io", Version: "v1beta1", Resource: "resourceclaimtemplates"} -var resourceClaimTemplatesKind = schema.GroupVersionKind{Group: "resource.k8s.io", Version: "v1beta1", Kind: "ResourceClaimTemplate"} - -type resourceClaimTemplatesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *resourceClaimTemplatesClusterClient) Cluster(clusterPath logicalcluster.Path) kcpresourcev1beta1.ResourceClaimTemplatesNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &resourceClaimTemplatesNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// resourceClaimTemplateClusterClient implements ResourceClaimTemplateClusterInterface +type resourceClaimTemplateClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*resourcev1beta1.ResourceClaimTemplate, *resourcev1beta1.ResourceClaimTemplateList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of ResourceClaimTemplates that match those selectors across all clusters. -func (c *resourceClaimTemplatesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*resourcev1beta1.ResourceClaimTemplateList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(resourceClaimTemplatesResource, resourceClaimTemplatesKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &resourcev1beta1.ResourceClaimTemplateList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeResourceClaimTemplateClusterClient(fake *ResourceV1beta1ClusterClient) typedkcpresourcev1beta1.ResourceClaimTemplateClusterInterface { + return &resourceClaimTemplateClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*resourcev1beta1.ResourceClaimTemplate, *resourcev1beta1.ResourceClaimTemplateList]( + fake.Fake, + resourcev1beta1.SchemeGroupVersion.WithResource("resourceclaimtemplates"), + resourcev1beta1.SchemeGroupVersion.WithKind("ResourceClaimTemplate"), + func() *resourcev1beta1.ResourceClaimTemplate { return &resourcev1beta1.ResourceClaimTemplate{} }, + func() *resourcev1beta1.ResourceClaimTemplateList { return &resourcev1beta1.ResourceClaimTemplateList{} }, + func(dst, src *resourcev1beta1.ResourceClaimTemplateList) { dst.ListMeta = src.ListMeta }, + func(list *resourcev1beta1.ResourceClaimTemplateList) []*resourcev1beta1.ResourceClaimTemplate { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *resourcev1beta1.ResourceClaimTemplateList, items []*resourcev1beta1.ResourceClaimTemplate) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &resourcev1beta1.ResourceClaimTemplateList{ListMeta: obj.(*resourcev1beta1.ResourceClaimTemplateList).ListMeta} - for _, item := range obj.(*resourcev1beta1.ResourceClaimTemplateList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested ResourceClaimTemplates across all clusters. -func (c *resourceClaimTemplatesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(resourceClaimTemplatesResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *resourceClaimTemplateClusterClient) Cluster(cluster logicalcluster.Path) typedkcpresourcev1beta1.ResourceClaimTemplatesNamespacer { + return &resourceClaimTemplateNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type resourceClaimTemplatesNamespacer struct { +type resourceClaimTemplateNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *resourceClaimTemplatesNamespacer) Namespace(namespace string) resourcev1beta1client.ResourceClaimTemplateInterface { - return &resourceClaimTemplatesClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *resourceClaimTemplateNamespacer) Namespace(namespace string) typedresourcev1beta1.ResourceClaimTemplateInterface { + return newFakeResourceClaimTemplateClient(n.Fake, namespace, n.ClusterPath) } -type resourceClaimTemplatesClient struct { - *kcptesting.Fake +// resourceClaimTemplateScopedClient implements ResourceClaimTemplateInterface +type resourceClaimTemplateScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*resourcev1beta1.ResourceClaimTemplate, *resourcev1beta1.ResourceClaimTemplateList, *v1beta1.ResourceClaimTemplateApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *resourceClaimTemplatesClient) Create(ctx context.Context, resourceClaimTemplate *resourcev1beta1.ResourceClaimTemplate, opts metav1.CreateOptions) (*resourcev1beta1.ResourceClaimTemplate, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(resourceClaimTemplatesResource, c.ClusterPath, c.Namespace, resourceClaimTemplate), &resourcev1beta1.ResourceClaimTemplate{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1beta1.ResourceClaimTemplate), err -} - -func (c *resourceClaimTemplatesClient) Update(ctx context.Context, resourceClaimTemplate *resourcev1beta1.ResourceClaimTemplate, opts metav1.UpdateOptions) (*resourcev1beta1.ResourceClaimTemplate, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(resourceClaimTemplatesResource, c.ClusterPath, c.Namespace, resourceClaimTemplate), &resourcev1beta1.ResourceClaimTemplate{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1beta1.ResourceClaimTemplate), err -} - -func (c *resourceClaimTemplatesClient) UpdateStatus(ctx context.Context, resourceClaimTemplate *resourcev1beta1.ResourceClaimTemplate, opts metav1.UpdateOptions) (*resourcev1beta1.ResourceClaimTemplate, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(resourceClaimTemplatesResource, c.ClusterPath, "status", c.Namespace, resourceClaimTemplate), &resourcev1beta1.ResourceClaimTemplate{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1beta1.ResourceClaimTemplate), err -} - -func (c *resourceClaimTemplatesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(resourceClaimTemplatesResource, c.ClusterPath, c.Namespace, name, opts), &resourcev1beta1.ResourceClaimTemplate{}) - return err -} - -func (c *resourceClaimTemplatesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(resourceClaimTemplatesResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &resourcev1beta1.ResourceClaimTemplateList{}) - return err -} - -func (c *resourceClaimTemplatesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*resourcev1beta1.ResourceClaimTemplate, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(resourceClaimTemplatesResource, c.ClusterPath, c.Namespace, name), &resourcev1beta1.ResourceClaimTemplate{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1beta1.ResourceClaimTemplate), err -} - -// List takes label and field selectors, and returns the list of ResourceClaimTemplates that match those selectors. -func (c *resourceClaimTemplatesClient) List(ctx context.Context, opts metav1.ListOptions) (*resourcev1beta1.ResourceClaimTemplateList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(resourceClaimTemplatesResource, resourceClaimTemplatesKind, c.ClusterPath, c.Namespace, opts), &resourcev1beta1.ResourceClaimTemplateList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &resourcev1beta1.ResourceClaimTemplateList{ListMeta: obj.(*resourcev1beta1.ResourceClaimTemplateList).ListMeta} - for _, item := range obj.(*resourcev1beta1.ResourceClaimTemplateList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *resourceClaimTemplatesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(resourceClaimTemplatesResource, c.ClusterPath, c.Namespace, opts)) } -func (c *resourceClaimTemplatesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*resourcev1beta1.ResourceClaimTemplate, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(resourceClaimTemplatesResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &resourcev1beta1.ResourceClaimTemplate{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1beta1.ResourceClaimTemplate), err -} - -func (c *resourceClaimTemplatesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsresourcev1beta1.ResourceClaimTemplateApplyConfiguration, opts metav1.ApplyOptions) (*resourcev1beta1.ResourceClaimTemplate, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(resourceClaimTemplatesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &resourcev1beta1.ResourceClaimTemplate{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1beta1.ResourceClaimTemplate), err -} - -func (c *resourceClaimTemplatesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsresourcev1beta1.ResourceClaimTemplateApplyConfiguration, opts metav1.ApplyOptions) (*resourcev1beta1.ResourceClaimTemplate, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(resourceClaimTemplatesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &resourcev1beta1.ResourceClaimTemplate{}) - if obj == nil { - return nil, err +func newFakeResourceClaimTemplateClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedresourcev1beta1.ResourceClaimTemplateInterface { + return &resourceClaimTemplateScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*resourcev1beta1.ResourceClaimTemplate, *resourcev1beta1.ResourceClaimTemplateList, *v1beta1.ResourceClaimTemplateApplyConfiguration]( + fake, + clusterPath, + namespace, + resourcev1beta1.SchemeGroupVersion.WithResource("resourceclaimtemplates"), + resourcev1beta1.SchemeGroupVersion.WithKind("ResourceClaimTemplate"), + func() *resourcev1beta1.ResourceClaimTemplate { return &resourcev1beta1.ResourceClaimTemplate{} }, + func() *resourcev1beta1.ResourceClaimTemplateList { return &resourcev1beta1.ResourceClaimTemplateList{} }, + func(dst, src *resourcev1beta1.ResourceClaimTemplateList) { dst.ListMeta = src.ListMeta }, + func(list *resourcev1beta1.ResourceClaimTemplateList) []*resourcev1beta1.ResourceClaimTemplate { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *resourcev1beta1.ResourceClaimTemplateList, items []*resourcev1beta1.ResourceClaimTemplate) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*resourcev1beta1.ResourceClaimTemplate), err } diff --git a/kubernetes/typed/resource/v1beta1/fake/resourceslice.go b/kubernetes/typed/resource/v1beta1/fake/resourceslice.go index 3870fdf50..fb224b628 100644 --- a/kubernetes/typed/resource/v1beta1/fake/resourceslice.go +++ b/kubernetes/typed/resource/v1beta1/fake/resourceslice.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" resourcev1beta1 "k8s.io/api/resource/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsresourcev1beta1 "k8s.io/client-go/applyconfigurations/resource/v1beta1" - resourcev1beta1client "k8s.io/client-go/kubernetes/typed/resource/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/resource/v1beta1" + typedresourcev1beta1 "k8s.io/client-go/kubernetes/typed/resource/v1beta1" + typedkcpresourcev1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/resource/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var resourceSlicesResource = schema.GroupVersionResource{Group: "resource.k8s.io", Version: "v1beta1", Resource: "resourceslices"} -var resourceSlicesKind = schema.GroupVersionKind{Group: "resource.k8s.io", Version: "v1beta1", Kind: "ResourceSlice"} - -type resourceSlicesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *resourceSlicesClusterClient) Cluster(clusterPath logicalcluster.Path) resourcev1beta1client.ResourceSliceInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &resourceSlicesClient{Fake: c.Fake, ClusterPath: clusterPath} +// resourceSliceClusterClient implements ResourceSliceClusterInterface +type resourceSliceClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*resourcev1beta1.ResourceSlice, *resourcev1beta1.ResourceSliceList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of ResourceSlices that match those selectors across all clusters. -func (c *resourceSlicesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*resourcev1beta1.ResourceSliceList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(resourceSlicesResource, resourceSlicesKind, logicalcluster.Wildcard, opts), &resourcev1beta1.ResourceSliceList{}) - if obj == nil { - return nil, err +func newFakeResourceSliceClusterClient(fake *ResourceV1beta1ClusterClient) typedkcpresourcev1beta1.ResourceSliceClusterInterface { + return &resourceSliceClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*resourcev1beta1.ResourceSlice, *resourcev1beta1.ResourceSliceList]( + fake.Fake, + resourcev1beta1.SchemeGroupVersion.WithResource("resourceslices"), + resourcev1beta1.SchemeGroupVersion.WithKind("ResourceSlice"), + func() *resourcev1beta1.ResourceSlice { return &resourcev1beta1.ResourceSlice{} }, + func() *resourcev1beta1.ResourceSliceList { return &resourcev1beta1.ResourceSliceList{} }, + func(dst, src *resourcev1beta1.ResourceSliceList) { dst.ListMeta = src.ListMeta }, + func(list *resourcev1beta1.ResourceSliceList) []*resourcev1beta1.ResourceSlice { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *resourcev1beta1.ResourceSliceList, items []*resourcev1beta1.ResourceSlice) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &resourcev1beta1.ResourceSliceList{ListMeta: obj.(*resourcev1beta1.ResourceSliceList).ListMeta} - for _, item := range obj.(*resourcev1beta1.ResourceSliceList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested ResourceSlices across all clusters. -func (c *resourceSlicesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(resourceSlicesResource, logicalcluster.Wildcard, opts)) +func (c *resourceSliceClusterClient) Cluster(cluster logicalcluster.Path) typedresourcev1beta1.ResourceSliceInterface { + return newFakeResourceSliceClient(c.Fake, cluster) } -type resourceSlicesClient struct { - *kcptesting.Fake +// resourceSliceScopedClient implements ResourceSliceInterface +type resourceSliceScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*resourcev1beta1.ResourceSlice, *resourcev1beta1.ResourceSliceList, *v1beta1.ResourceSliceApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *resourceSlicesClient) Create(ctx context.Context, resourceSlice *resourcev1beta1.ResourceSlice, opts metav1.CreateOptions) (*resourcev1beta1.ResourceSlice, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(resourceSlicesResource, c.ClusterPath, resourceSlice), &resourcev1beta1.ResourceSlice{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1beta1.ResourceSlice), err -} - -func (c *resourceSlicesClient) Update(ctx context.Context, resourceSlice *resourcev1beta1.ResourceSlice, opts metav1.UpdateOptions) (*resourcev1beta1.ResourceSlice, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(resourceSlicesResource, c.ClusterPath, resourceSlice), &resourcev1beta1.ResourceSlice{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1beta1.ResourceSlice), err -} - -func (c *resourceSlicesClient) UpdateStatus(ctx context.Context, resourceSlice *resourcev1beta1.ResourceSlice, opts metav1.UpdateOptions) (*resourcev1beta1.ResourceSlice, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(resourceSlicesResource, c.ClusterPath, "status", resourceSlice), &resourcev1beta1.ResourceSlice{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1beta1.ResourceSlice), err -} - -func (c *resourceSlicesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(resourceSlicesResource, c.ClusterPath, name, opts), &resourcev1beta1.ResourceSlice{}) - return err -} - -func (c *resourceSlicesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(resourceSlicesResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &resourcev1beta1.ResourceSliceList{}) - return err -} - -func (c *resourceSlicesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*resourcev1beta1.ResourceSlice, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(resourceSlicesResource, c.ClusterPath, name), &resourcev1beta1.ResourceSlice{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1beta1.ResourceSlice), err -} - -// List takes label and field selectors, and returns the list of ResourceSlices that match those selectors. -func (c *resourceSlicesClient) List(ctx context.Context, opts metav1.ListOptions) (*resourcev1beta1.ResourceSliceList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(resourceSlicesResource, resourceSlicesKind, c.ClusterPath, opts), &resourcev1beta1.ResourceSliceList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &resourcev1beta1.ResourceSliceList{ListMeta: obj.(*resourcev1beta1.ResourceSliceList).ListMeta} - for _, item := range obj.(*resourcev1beta1.ResourceSliceList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *resourceSlicesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(resourceSlicesResource, c.ClusterPath, opts)) -} - -func (c *resourceSlicesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*resourcev1beta1.ResourceSlice, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(resourceSlicesResource, c.ClusterPath, name, pt, data, subresources...), &resourcev1beta1.ResourceSlice{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1beta1.ResourceSlice), err -} - -func (c *resourceSlicesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsresourcev1beta1.ResourceSliceApplyConfiguration, opts metav1.ApplyOptions) (*resourcev1beta1.ResourceSlice, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(resourceSlicesResource, c.ClusterPath, *name, types.ApplyPatchType, data), &resourcev1beta1.ResourceSlice{}) - if obj == nil { - return nil, err - } - return obj.(*resourcev1beta1.ResourceSlice), err -} - -func (c *resourceSlicesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsresourcev1beta1.ResourceSliceApplyConfiguration, opts metav1.ApplyOptions) (*resourcev1beta1.ResourceSlice, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(resourceSlicesResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &resourcev1beta1.ResourceSlice{}) - if obj == nil { - return nil, err +func newFakeResourceSliceClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedresourcev1beta1.ResourceSliceInterface { + return &resourceSliceScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*resourcev1beta1.ResourceSlice, *resourcev1beta1.ResourceSliceList, *v1beta1.ResourceSliceApplyConfiguration]( + fake, + clusterPath, + "", + resourcev1beta1.SchemeGroupVersion.WithResource("resourceslices"), + resourcev1beta1.SchemeGroupVersion.WithKind("ResourceSlice"), + func() *resourcev1beta1.ResourceSlice { return &resourcev1beta1.ResourceSlice{} }, + func() *resourcev1beta1.ResourceSliceList { return &resourcev1beta1.ResourceSliceList{} }, + func(dst, src *resourcev1beta1.ResourceSliceList) { dst.ListMeta = src.ListMeta }, + func(list *resourcev1beta1.ResourceSliceList) []*resourcev1beta1.ResourceSlice { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *resourcev1beta1.ResourceSliceList, items []*resourcev1beta1.ResourceSlice) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*resourcev1beta1.ResourceSlice), err } diff --git a/kubernetes/typed/resource/v1beta1/generated_expansion.go b/kubernetes/typed/resource/v1beta1/generated_expansion.go new file mode 100644 index 000000000..6c77c2efb --- /dev/null +++ b/kubernetes/typed/resource/v1beta1/generated_expansion.go @@ -0,0 +1,27 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1beta1 + +type DeviceClassClusterExpansion interface{} + +type ResourceClaimClusterExpansion interface{} + +type ResourceClaimTemplateClusterExpansion interface{} + +type ResourceSliceClusterExpansion interface{} diff --git a/kubernetes/typed/resource/v1beta1/resource_client.go b/kubernetes/typed/resource/v1beta1/resource_client.go index 99b247244..f159710d7 100644 --- a/kubernetes/typed/resource/v1beta1/resource_client.go +++ b/kubernetes/typed/resource/v1beta1/resource_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,32 +14,36 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apiresourcev1beta1 "k8s.io/api/resource/v1beta1" resourcev1beta1 "k8s.io/client-go/kubernetes/typed/resource/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type ResourceV1beta1ClusterInterface interface { ResourceV1beta1ClusterScoper - ResourceSlicesClusterGetter - ResourceClaimsClusterGetter DeviceClassesClusterGetter + ResourceClaimsClusterGetter ResourceClaimTemplatesClusterGetter + ResourceSlicesClusterGetter } type ResourceV1beta1ClusterScoper interface { Cluster(logicalcluster.Path) resourcev1beta1.ResourceV1beta1Interface } +// ResourceV1beta1ClusterClient is used to interact with features provided by the resource.k8s.io group. type ResourceV1beta1ClusterClient struct { clientCache kcpclient.Cache[*resourcev1beta1.ResourceV1beta1Client] } @@ -51,31 +55,33 @@ func (c *ResourceV1beta1ClusterClient) Cluster(clusterPath logicalcluster.Path) return c.clientCache.ClusterOrDie(clusterPath) } -func (c *ResourceV1beta1ClusterClient) ResourceSlices() ResourceSliceClusterInterface { - return &resourceSlicesClusterInterface{clientCache: c.clientCache} +func (c *ResourceV1beta1ClusterClient) DeviceClasses() DeviceClassClusterInterface { + return &deviceClassesClusterInterface{clientCache: c.clientCache} } func (c *ResourceV1beta1ClusterClient) ResourceClaims() ResourceClaimClusterInterface { return &resourceClaimsClusterInterface{clientCache: c.clientCache} } -func (c *ResourceV1beta1ClusterClient) DeviceClasses() DeviceClassClusterInterface { - return &deviceClassesClusterInterface{clientCache: c.clientCache} -} - func (c *ResourceV1beta1ClusterClient) ResourceClaimTemplates() ResourceClaimTemplateClusterInterface { return &resourceClaimTemplatesClusterInterface{clientCache: c.clientCache} } +func (c *ResourceV1beta1ClusterClient) ResourceSlices() ResourceSliceClusterInterface { + return &resourceSlicesClusterInterface{clientCache: c.clientCache} +} + // NewForConfig creates a new ResourceV1beta1ClusterClient for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*ResourceV1beta1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new ResourceV1beta1ClusterClient for the given config and http client. @@ -87,6 +93,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*ResourceV1beta1Clus if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &ResourceV1beta1ClusterClient{clientCache: cache}, nil } @@ -99,3 +106,14 @@ func NewForConfigOrDie(c *rest.Config) *ResourceV1beta1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apiresourcev1beta1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/resource/v1beta1/resourceclaim.go b/kubernetes/typed/resource/v1beta1/resourceclaim.go index 096d479f6..538a8b99e 100644 --- a/kubernetes/typed/resource/v1beta1/resourceclaim.go +++ b/kubernetes/typed/resource/v1beta1/resourceclaim.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" resourcev1beta1 "k8s.io/api/resource/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - resourcev1beta1client "k8s.io/client-go/kubernetes/typed/resource/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedresourcev1beta1 "k8s.io/client-go/kubernetes/typed/resource/v1beta1" ) // ResourceClaimsClusterGetter has a method to return a ResourceClaimClusterInterface. @@ -40,12 +40,13 @@ type ResourceClaimsClusterGetter interface { // or scope down to one cluster and return a ResourceClaimsNamespacer. type ResourceClaimClusterInterface interface { Cluster(logicalcluster.Path) ResourceClaimsNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*resourcev1beta1.ResourceClaimList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*resourcev1beta1.ResourceClaimList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + ResourceClaimClusterExpansion } type resourceClaimsClusterInterface struct { - clientCache kcpclient.Cache[*resourcev1beta1client.ResourceV1beta1Client] + clientCache kcpclient.Cache[*typedresourcev1beta1.ResourceV1beta1Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *resourceClaimsClusterInterface) Cluster(clusterPath logicalcluster.Path } // List returns the entire collection of all ResourceClaims across all clusters. -func (c *resourceClaimsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*resourcev1beta1.ResourceClaimList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ResourceClaims(metav1.NamespaceAll).List(ctx, opts) +func (c *resourceClaimsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*resourcev1beta1.ResourceClaimList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ResourceClaims(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all ResourceClaims across all clusters. -func (c *resourceClaimsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ResourceClaims(metav1.NamespaceAll).Watch(ctx, opts) +func (c *resourceClaimsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ResourceClaims(v1.NamespaceAll).Watch(ctx, opts) } -// ResourceClaimsNamespacer can scope to objects within a namespace, returning a resourcev1beta1client.ResourceClaimInterface. +// ResourceClaimsNamespacer can scope to objects within a namespace, returning a typedresourcev1beta1.ResourceClaimInterface. type ResourceClaimsNamespacer interface { - Namespace(string) resourcev1beta1client.ResourceClaimInterface + Namespace(string) typedresourcev1beta1.ResourceClaimInterface } type resourceClaimsNamespacer struct { - clientCache kcpclient.Cache[*resourcev1beta1client.ResourceV1beta1Client] + clientCache kcpclient.Cache[*typedresourcev1beta1.ResourceV1beta1Client] clusterPath logicalcluster.Path } -func (n *resourceClaimsNamespacer) Namespace(namespace string) resourcev1beta1client.ResourceClaimInterface { +func (n *resourceClaimsNamespacer) Namespace(namespace string) typedresourcev1beta1.ResourceClaimInterface { return n.clientCache.ClusterOrDie(n.clusterPath).ResourceClaims(namespace) } diff --git a/kubernetes/typed/resource/v1beta1/resourceclaimtemplate.go b/kubernetes/typed/resource/v1beta1/resourceclaimtemplate.go index 086d7d852..4606b4a01 100644 --- a/kubernetes/typed/resource/v1beta1/resourceclaimtemplate.go +++ b/kubernetes/typed/resource/v1beta1/resourceclaimtemplate.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" resourcev1beta1 "k8s.io/api/resource/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - resourcev1beta1client "k8s.io/client-go/kubernetes/typed/resource/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedresourcev1beta1 "k8s.io/client-go/kubernetes/typed/resource/v1beta1" ) // ResourceClaimTemplatesClusterGetter has a method to return a ResourceClaimTemplateClusterInterface. @@ -40,12 +40,13 @@ type ResourceClaimTemplatesClusterGetter interface { // or scope down to one cluster and return a ResourceClaimTemplatesNamespacer. type ResourceClaimTemplateClusterInterface interface { Cluster(logicalcluster.Path) ResourceClaimTemplatesNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*resourcev1beta1.ResourceClaimTemplateList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*resourcev1beta1.ResourceClaimTemplateList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + ResourceClaimTemplateClusterExpansion } type resourceClaimTemplatesClusterInterface struct { - clientCache kcpclient.Cache[*resourcev1beta1client.ResourceV1beta1Client] + clientCache kcpclient.Cache[*typedresourcev1beta1.ResourceV1beta1Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *resourceClaimTemplatesClusterInterface) Cluster(clusterPath logicalclus } // List returns the entire collection of all ResourceClaimTemplates across all clusters. -func (c *resourceClaimTemplatesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*resourcev1beta1.ResourceClaimTemplateList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ResourceClaimTemplates(metav1.NamespaceAll).List(ctx, opts) +func (c *resourceClaimTemplatesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*resourcev1beta1.ResourceClaimTemplateList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ResourceClaimTemplates(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all ResourceClaimTemplates across all clusters. -func (c *resourceClaimTemplatesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ResourceClaimTemplates(metav1.NamespaceAll).Watch(ctx, opts) +func (c *resourceClaimTemplatesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ResourceClaimTemplates(v1.NamespaceAll).Watch(ctx, opts) } -// ResourceClaimTemplatesNamespacer can scope to objects within a namespace, returning a resourcev1beta1client.ResourceClaimTemplateInterface. +// ResourceClaimTemplatesNamespacer can scope to objects within a namespace, returning a typedresourcev1beta1.ResourceClaimTemplateInterface. type ResourceClaimTemplatesNamespacer interface { - Namespace(string) resourcev1beta1client.ResourceClaimTemplateInterface + Namespace(string) typedresourcev1beta1.ResourceClaimTemplateInterface } type resourceClaimTemplatesNamespacer struct { - clientCache kcpclient.Cache[*resourcev1beta1client.ResourceV1beta1Client] + clientCache kcpclient.Cache[*typedresourcev1beta1.ResourceV1beta1Client] clusterPath logicalcluster.Path } -func (n *resourceClaimTemplatesNamespacer) Namespace(namespace string) resourcev1beta1client.ResourceClaimTemplateInterface { +func (n *resourceClaimTemplatesNamespacer) Namespace(namespace string) typedresourcev1beta1.ResourceClaimTemplateInterface { return n.clientCache.ClusterOrDie(n.clusterPath).ResourceClaimTemplates(namespace) } diff --git a/kubernetes/typed/resource/v1beta1/resourceslice.go b/kubernetes/typed/resource/v1beta1/resourceslice.go index 045aef833..0ecb83814 100644 --- a/kubernetes/typed/resource/v1beta1/resourceslice.go +++ b/kubernetes/typed/resource/v1beta1/resourceslice.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - resourcev1beta1 "k8s.io/api/resource/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - resourcev1beta1client "k8s.io/client-go/kubernetes/typed/resource/v1beta1" + apiresourcev1beta1 "k8s.io/api/resource/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + resourcev1beta1 "k8s.io/client-go/kubernetes/typed/resource/v1beta1" ) // ResourceSlicesClusterGetter has a method to return a ResourceSliceClusterInterface. @@ -37,19 +37,20 @@ type ResourceSlicesClusterGetter interface { } // ResourceSliceClusterInterface can operate on ResourceSlices across all clusters, -// or scope down to one cluster and return a resourcev1beta1client.ResourceSliceInterface. +// or scope down to one cluster and return a resourcev1beta1.ResourceSliceInterface. type ResourceSliceClusterInterface interface { - Cluster(logicalcluster.Path) resourcev1beta1client.ResourceSliceInterface - List(ctx context.Context, opts metav1.ListOptions) (*resourcev1beta1.ResourceSliceList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) resourcev1beta1.ResourceSliceInterface + List(ctx context.Context, opts v1.ListOptions) (*apiresourcev1beta1.ResourceSliceList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + ResourceSliceClusterExpansion } type resourceSlicesClusterInterface struct { - clientCache kcpclient.Cache[*resourcev1beta1client.ResourceV1beta1Client] + clientCache kcpclient.Cache[*resourcev1beta1.ResourceV1beta1Client] } // Cluster scopes the client down to a particular cluster. -func (c *resourceSlicesClusterInterface) Cluster(clusterPath logicalcluster.Path) resourcev1beta1client.ResourceSliceInterface { +func (c *resourceSlicesClusterInterface) Cluster(clusterPath logicalcluster.Path) resourcev1beta1.ResourceSliceInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *resourceSlicesClusterInterface) Cluster(clusterPath logicalcluster.Path } // List returns the entire collection of all ResourceSlices across all clusters. -func (c *resourceSlicesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*resourcev1beta1.ResourceSliceList, error) { +func (c *resourceSlicesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apiresourcev1beta1.ResourceSliceList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ResourceSlices().List(ctx, opts) } // Watch begins to watch all ResourceSlices across all clusters. -func (c *resourceSlicesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *resourceSlicesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ResourceSlices().Watch(ctx, opts) } diff --git a/kubernetes/typed/scheduling/v1/doc.go b/kubernetes/typed/scheduling/v1/doc.go new file mode 100644 index 000000000..d2f3412ab --- /dev/null +++ b/kubernetes/typed/scheduling/v1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1 diff --git a/kubernetes/typed/scheduling/v1/fake/doc.go b/kubernetes/typed/scheduling/v1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/scheduling/v1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/scheduling/v1/fake/priorityclass.go b/kubernetes/typed/scheduling/v1/fake/priorityclass.go index d5f0cd01b..bfb0a84cd 100644 --- a/kubernetes/typed/scheduling/v1/fake/priorityclass.go +++ b/kubernetes/typed/scheduling/v1/fake/priorityclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" schedulingv1 "k8s.io/api/scheduling/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsschedulingv1 "k8s.io/client-go/applyconfigurations/scheduling/v1" - schedulingv1client "k8s.io/client-go/kubernetes/typed/scheduling/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/scheduling/v1" + typedschedulingv1 "k8s.io/client-go/kubernetes/typed/scheduling/v1" + typedkcpschedulingv1 "github.com/kcp-dev/client-go/kubernetes/typed/scheduling/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var priorityClassesResource = schema.GroupVersionResource{Group: "scheduling.k8s.io", Version: "v1", Resource: "priorityclasses"} -var priorityClassesKind = schema.GroupVersionKind{Group: "scheduling.k8s.io", Version: "v1", Kind: "PriorityClass"} - -type priorityClassesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *priorityClassesClusterClient) Cluster(clusterPath logicalcluster.Path) schedulingv1client.PriorityClassInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &priorityClassesClient{Fake: c.Fake, ClusterPath: clusterPath} +// priorityClassClusterClient implements PriorityClassClusterInterface +type priorityClassClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*schedulingv1.PriorityClass, *schedulingv1.PriorityClassList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of PriorityClasses that match those selectors across all clusters. -func (c *priorityClassesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*schedulingv1.PriorityClassList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(priorityClassesResource, priorityClassesKind, logicalcluster.Wildcard, opts), &schedulingv1.PriorityClassList{}) - if obj == nil { - return nil, err +func newFakePriorityClassClusterClient(fake *SchedulingV1ClusterClient) typedkcpschedulingv1.PriorityClassClusterInterface { + return &priorityClassClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*schedulingv1.PriorityClass, *schedulingv1.PriorityClassList]( + fake.Fake, + schedulingv1.SchemeGroupVersion.WithResource("priorityclasses"), + schedulingv1.SchemeGroupVersion.WithKind("PriorityClass"), + func() *schedulingv1.PriorityClass { return &schedulingv1.PriorityClass{} }, + func() *schedulingv1.PriorityClassList { return &schedulingv1.PriorityClassList{} }, + func(dst, src *schedulingv1.PriorityClassList) { dst.ListMeta = src.ListMeta }, + func(list *schedulingv1.PriorityClassList) []*schedulingv1.PriorityClass { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *schedulingv1.PriorityClassList, items []*schedulingv1.PriorityClass) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &schedulingv1.PriorityClassList{ListMeta: obj.(*schedulingv1.PriorityClassList).ListMeta} - for _, item := range obj.(*schedulingv1.PriorityClassList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested PriorityClasses across all clusters. -func (c *priorityClassesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(priorityClassesResource, logicalcluster.Wildcard, opts)) +func (c *priorityClassClusterClient) Cluster(cluster logicalcluster.Path) typedschedulingv1.PriorityClassInterface { + return newFakePriorityClassClient(c.Fake, cluster) } -type priorityClassesClient struct { - *kcptesting.Fake +// priorityClassScopedClient implements PriorityClassInterface +type priorityClassScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*schedulingv1.PriorityClass, *schedulingv1.PriorityClassList, *v1.PriorityClassApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *priorityClassesClient) Create(ctx context.Context, priorityClass *schedulingv1.PriorityClass, opts metav1.CreateOptions) (*schedulingv1.PriorityClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(priorityClassesResource, c.ClusterPath, priorityClass), &schedulingv1.PriorityClass{}) - if obj == nil { - return nil, err - } - return obj.(*schedulingv1.PriorityClass), err -} - -func (c *priorityClassesClient) Update(ctx context.Context, priorityClass *schedulingv1.PriorityClass, opts metav1.UpdateOptions) (*schedulingv1.PriorityClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(priorityClassesResource, c.ClusterPath, priorityClass), &schedulingv1.PriorityClass{}) - if obj == nil { - return nil, err - } - return obj.(*schedulingv1.PriorityClass), err -} - -func (c *priorityClassesClient) UpdateStatus(ctx context.Context, priorityClass *schedulingv1.PriorityClass, opts metav1.UpdateOptions) (*schedulingv1.PriorityClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(priorityClassesResource, c.ClusterPath, "status", priorityClass), &schedulingv1.PriorityClass{}) - if obj == nil { - return nil, err - } - return obj.(*schedulingv1.PriorityClass), err -} - -func (c *priorityClassesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(priorityClassesResource, c.ClusterPath, name, opts), &schedulingv1.PriorityClass{}) - return err -} - -func (c *priorityClassesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(priorityClassesResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &schedulingv1.PriorityClassList{}) - return err -} - -func (c *priorityClassesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*schedulingv1.PriorityClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(priorityClassesResource, c.ClusterPath, name), &schedulingv1.PriorityClass{}) - if obj == nil { - return nil, err - } - return obj.(*schedulingv1.PriorityClass), err -} - -// List takes label and field selectors, and returns the list of PriorityClasses that match those selectors. -func (c *priorityClassesClient) List(ctx context.Context, opts metav1.ListOptions) (*schedulingv1.PriorityClassList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(priorityClassesResource, priorityClassesKind, c.ClusterPath, opts), &schedulingv1.PriorityClassList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &schedulingv1.PriorityClassList{ListMeta: obj.(*schedulingv1.PriorityClassList).ListMeta} - for _, item := range obj.(*schedulingv1.PriorityClassList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *priorityClassesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(priorityClassesResource, c.ClusterPath, opts)) -} - -func (c *priorityClassesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*schedulingv1.PriorityClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(priorityClassesResource, c.ClusterPath, name, pt, data, subresources...), &schedulingv1.PriorityClass{}) - if obj == nil { - return nil, err - } - return obj.(*schedulingv1.PriorityClass), err -} - -func (c *priorityClassesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsschedulingv1.PriorityClassApplyConfiguration, opts metav1.ApplyOptions) (*schedulingv1.PriorityClass, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(priorityClassesResource, c.ClusterPath, *name, types.ApplyPatchType, data), &schedulingv1.PriorityClass{}) - if obj == nil { - return nil, err - } - return obj.(*schedulingv1.PriorityClass), err -} - -func (c *priorityClassesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsschedulingv1.PriorityClassApplyConfiguration, opts metav1.ApplyOptions) (*schedulingv1.PriorityClass, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(priorityClassesResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &schedulingv1.PriorityClass{}) - if obj == nil { - return nil, err +func newFakePriorityClassClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedschedulingv1.PriorityClassInterface { + return &priorityClassScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*schedulingv1.PriorityClass, *schedulingv1.PriorityClassList, *v1.PriorityClassApplyConfiguration]( + fake, + clusterPath, + "", + schedulingv1.SchemeGroupVersion.WithResource("priorityclasses"), + schedulingv1.SchemeGroupVersion.WithKind("PriorityClass"), + func() *schedulingv1.PriorityClass { return &schedulingv1.PriorityClass{} }, + func() *schedulingv1.PriorityClassList { return &schedulingv1.PriorityClassList{} }, + func(dst, src *schedulingv1.PriorityClassList) { dst.ListMeta = src.ListMeta }, + func(list *schedulingv1.PriorityClassList) []*schedulingv1.PriorityClass { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *schedulingv1.PriorityClassList, items []*schedulingv1.PriorityClass) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*schedulingv1.PriorityClass), err } diff --git a/kubernetes/typed/scheduling/v1/fake/scheduling_client.go b/kubernetes/typed/scheduling/v1/fake/scheduling_client.go index 10df7cb8c..53b69df3f 100644 --- a/kubernetes/typed/scheduling/v1/fake/scheduling_client.go +++ b/kubernetes/typed/scheduling/v1/fake/scheduling_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" schedulingv1 "k8s.io/client-go/kubernetes/typed/scheduling/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpschedulingv1 "github.com/kcp-dev/client-go/kubernetes/typed/scheduling/v1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -42,21 +42,21 @@ func (c *SchedulingV1ClusterClient) Cluster(clusterPath logicalcluster.Path) sch } func (c *SchedulingV1ClusterClient) PriorityClasses() kcpschedulingv1.PriorityClassClusterInterface { - return &priorityClassesClusterClient{Fake: c.Fake} + return newFakePriorityClassClusterClient(c) } -var _ schedulingv1.SchedulingV1Interface = (*SchedulingV1Client)(nil) - type SchedulingV1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } +func (c *SchedulingV1Client) PriorityClasses() schedulingv1.PriorityClassInterface { + return newFakePriorityClassClient(c.Fake, c.ClusterPath) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. func (c *SchedulingV1Client) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } - -func (c *SchedulingV1Client) PriorityClasses() schedulingv1.PriorityClassInterface { - return &priorityClassesClient{Fake: c.Fake, ClusterPath: c.ClusterPath} -} diff --git a/kubernetes/typed/scheduling/v1/generated_expansion.go b/kubernetes/typed/scheduling/v1/generated_expansion.go new file mode 100644 index 000000000..c8f2aa9db --- /dev/null +++ b/kubernetes/typed/scheduling/v1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1 + +type PriorityClassClusterExpansion interface{} diff --git a/kubernetes/typed/scheduling/v1/priorityclass.go b/kubernetes/typed/scheduling/v1/priorityclass.go index 6838f0734..8bad6cb5e 100644 --- a/kubernetes/typed/scheduling/v1/priorityclass.go +++ b/kubernetes/typed/scheduling/v1/priorityclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - schedulingv1 "k8s.io/api/scheduling/v1" + apischedulingv1 "k8s.io/api/scheduling/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - schedulingv1client "k8s.io/client-go/kubernetes/typed/scheduling/v1" + watch "k8s.io/apimachinery/pkg/watch" + schedulingv1 "k8s.io/client-go/kubernetes/typed/scheduling/v1" ) // PriorityClassesClusterGetter has a method to return a PriorityClassClusterInterface. @@ -37,19 +37,20 @@ type PriorityClassesClusterGetter interface { } // PriorityClassClusterInterface can operate on PriorityClasses across all clusters, -// or scope down to one cluster and return a schedulingv1client.PriorityClassInterface. +// or scope down to one cluster and return a schedulingv1.PriorityClassInterface. type PriorityClassClusterInterface interface { - Cluster(logicalcluster.Path) schedulingv1client.PriorityClassInterface - List(ctx context.Context, opts metav1.ListOptions) (*schedulingv1.PriorityClassList, error) + Cluster(logicalcluster.Path) schedulingv1.PriorityClassInterface + List(ctx context.Context, opts metav1.ListOptions) (*apischedulingv1.PriorityClassList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + PriorityClassClusterExpansion } type priorityClassesClusterInterface struct { - clientCache kcpclient.Cache[*schedulingv1client.SchedulingV1Client] + clientCache kcpclient.Cache[*schedulingv1.SchedulingV1Client] } // Cluster scopes the client down to a particular cluster. -func (c *priorityClassesClusterInterface) Cluster(clusterPath logicalcluster.Path) schedulingv1client.PriorityClassInterface { +func (c *priorityClassesClusterInterface) Cluster(clusterPath logicalcluster.Path) schedulingv1.PriorityClassInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,7 +59,7 @@ func (c *priorityClassesClusterInterface) Cluster(clusterPath logicalcluster.Pat } // List returns the entire collection of all PriorityClasses across all clusters. -func (c *priorityClassesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*schedulingv1.PriorityClassList, error) { +func (c *priorityClassesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*apischedulingv1.PriorityClassList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).PriorityClasses().List(ctx, opts) } diff --git a/kubernetes/typed/scheduling/v1/scheduling_client.go b/kubernetes/typed/scheduling/v1/scheduling_client.go index fbe8270f2..8dd32a8d1 100644 --- a/kubernetes/typed/scheduling/v1/scheduling_client.go +++ b/kubernetes/typed/scheduling/v1/scheduling_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apischedulingv1 "k8s.io/api/scheduling/v1" schedulingv1 "k8s.io/client-go/kubernetes/typed/scheduling/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type SchedulingV1ClusterInterface interface { @@ -37,6 +40,7 @@ type SchedulingV1ClusterScoper interface { Cluster(logicalcluster.Path) schedulingv1.SchedulingV1Interface } +// SchedulingV1ClusterClient is used to interact with features provided by the scheduling.k8s.io group. type SchedulingV1ClusterClient struct { clientCache kcpclient.Cache[*schedulingv1.SchedulingV1Client] } @@ -56,11 +60,13 @@ func (c *SchedulingV1ClusterClient) PriorityClasses() PriorityClassClusterInterf // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*SchedulingV1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new SchedulingV1ClusterClient for the given config and http client. @@ -72,6 +78,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*SchedulingV1Cluster if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &SchedulingV1ClusterClient{clientCache: cache}, nil } @@ -84,3 +91,14 @@ func NewForConfigOrDie(c *rest.Config) *SchedulingV1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apischedulingv1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/scheduling/v1alpha1/doc.go b/kubernetes/typed/scheduling/v1alpha1/doc.go new file mode 100644 index 000000000..08b80237c --- /dev/null +++ b/kubernetes/typed/scheduling/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/kubernetes/typed/scheduling/v1alpha1/fake/doc.go b/kubernetes/typed/scheduling/v1alpha1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/scheduling/v1alpha1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/scheduling/v1alpha1/fake/priorityclass.go b/kubernetes/typed/scheduling/v1alpha1/fake/priorityclass.go index fca138398..700b8b9a4 100644 --- a/kubernetes/typed/scheduling/v1alpha1/fake/priorityclass.go +++ b/kubernetes/typed/scheduling/v1alpha1/fake/priorityclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" schedulingv1alpha1 "k8s.io/api/scheduling/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsschedulingv1alpha1 "k8s.io/client-go/applyconfigurations/scheduling/v1alpha1" - schedulingv1alpha1client "k8s.io/client-go/kubernetes/typed/scheduling/v1alpha1" - "k8s.io/client-go/testing" + v1alpha1 "k8s.io/client-go/applyconfigurations/scheduling/v1alpha1" + typedschedulingv1alpha1 "k8s.io/client-go/kubernetes/typed/scheduling/v1alpha1" + typedkcpschedulingv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/scheduling/v1alpha1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var priorityClassesResource = schema.GroupVersionResource{Group: "scheduling.k8s.io", Version: "v1alpha1", Resource: "priorityclasses"} -var priorityClassesKind = schema.GroupVersionKind{Group: "scheduling.k8s.io", Version: "v1alpha1", Kind: "PriorityClass"} - -type priorityClassesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *priorityClassesClusterClient) Cluster(clusterPath logicalcluster.Path) schedulingv1alpha1client.PriorityClassInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &priorityClassesClient{Fake: c.Fake, ClusterPath: clusterPath} +// priorityClassClusterClient implements PriorityClassClusterInterface +type priorityClassClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*schedulingv1alpha1.PriorityClass, *schedulingv1alpha1.PriorityClassList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of PriorityClasses that match those selectors across all clusters. -func (c *priorityClassesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*schedulingv1alpha1.PriorityClassList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(priorityClassesResource, priorityClassesKind, logicalcluster.Wildcard, opts), &schedulingv1alpha1.PriorityClassList{}) - if obj == nil { - return nil, err +func newFakePriorityClassClusterClient(fake *SchedulingV1alpha1ClusterClient) typedkcpschedulingv1alpha1.PriorityClassClusterInterface { + return &priorityClassClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*schedulingv1alpha1.PriorityClass, *schedulingv1alpha1.PriorityClassList]( + fake.Fake, + schedulingv1alpha1.SchemeGroupVersion.WithResource("priorityclasses"), + schedulingv1alpha1.SchemeGroupVersion.WithKind("PriorityClass"), + func() *schedulingv1alpha1.PriorityClass { return &schedulingv1alpha1.PriorityClass{} }, + func() *schedulingv1alpha1.PriorityClassList { return &schedulingv1alpha1.PriorityClassList{} }, + func(dst, src *schedulingv1alpha1.PriorityClassList) { dst.ListMeta = src.ListMeta }, + func(list *schedulingv1alpha1.PriorityClassList) []*schedulingv1alpha1.PriorityClass { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *schedulingv1alpha1.PriorityClassList, items []*schedulingv1alpha1.PriorityClass) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &schedulingv1alpha1.PriorityClassList{ListMeta: obj.(*schedulingv1alpha1.PriorityClassList).ListMeta} - for _, item := range obj.(*schedulingv1alpha1.PriorityClassList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested PriorityClasses across all clusters. -func (c *priorityClassesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(priorityClassesResource, logicalcluster.Wildcard, opts)) +func (c *priorityClassClusterClient) Cluster(cluster logicalcluster.Path) typedschedulingv1alpha1.PriorityClassInterface { + return newFakePriorityClassClient(c.Fake, cluster) } -type priorityClassesClient struct { - *kcptesting.Fake +// priorityClassScopedClient implements PriorityClassInterface +type priorityClassScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*schedulingv1alpha1.PriorityClass, *schedulingv1alpha1.PriorityClassList, *v1alpha1.PriorityClassApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *priorityClassesClient) Create(ctx context.Context, priorityClass *schedulingv1alpha1.PriorityClass, opts metav1.CreateOptions) (*schedulingv1alpha1.PriorityClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(priorityClassesResource, c.ClusterPath, priorityClass), &schedulingv1alpha1.PriorityClass{}) - if obj == nil { - return nil, err - } - return obj.(*schedulingv1alpha1.PriorityClass), err -} - -func (c *priorityClassesClient) Update(ctx context.Context, priorityClass *schedulingv1alpha1.PriorityClass, opts metav1.UpdateOptions) (*schedulingv1alpha1.PriorityClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(priorityClassesResource, c.ClusterPath, priorityClass), &schedulingv1alpha1.PriorityClass{}) - if obj == nil { - return nil, err - } - return obj.(*schedulingv1alpha1.PriorityClass), err -} - -func (c *priorityClassesClient) UpdateStatus(ctx context.Context, priorityClass *schedulingv1alpha1.PriorityClass, opts metav1.UpdateOptions) (*schedulingv1alpha1.PriorityClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(priorityClassesResource, c.ClusterPath, "status", priorityClass), &schedulingv1alpha1.PriorityClass{}) - if obj == nil { - return nil, err - } - return obj.(*schedulingv1alpha1.PriorityClass), err -} - -func (c *priorityClassesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(priorityClassesResource, c.ClusterPath, name, opts), &schedulingv1alpha1.PriorityClass{}) - return err -} - -func (c *priorityClassesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(priorityClassesResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &schedulingv1alpha1.PriorityClassList{}) - return err -} - -func (c *priorityClassesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*schedulingv1alpha1.PriorityClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(priorityClassesResource, c.ClusterPath, name), &schedulingv1alpha1.PriorityClass{}) - if obj == nil { - return nil, err - } - return obj.(*schedulingv1alpha1.PriorityClass), err -} - -// List takes label and field selectors, and returns the list of PriorityClasses that match those selectors. -func (c *priorityClassesClient) List(ctx context.Context, opts metav1.ListOptions) (*schedulingv1alpha1.PriorityClassList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(priorityClassesResource, priorityClassesKind, c.ClusterPath, opts), &schedulingv1alpha1.PriorityClassList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &schedulingv1alpha1.PriorityClassList{ListMeta: obj.(*schedulingv1alpha1.PriorityClassList).ListMeta} - for _, item := range obj.(*schedulingv1alpha1.PriorityClassList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *priorityClassesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(priorityClassesResource, c.ClusterPath, opts)) -} - -func (c *priorityClassesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*schedulingv1alpha1.PriorityClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(priorityClassesResource, c.ClusterPath, name, pt, data, subresources...), &schedulingv1alpha1.PriorityClass{}) - if obj == nil { - return nil, err - } - return obj.(*schedulingv1alpha1.PriorityClass), err -} - -func (c *priorityClassesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsschedulingv1alpha1.PriorityClassApplyConfiguration, opts metav1.ApplyOptions) (*schedulingv1alpha1.PriorityClass, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(priorityClassesResource, c.ClusterPath, *name, types.ApplyPatchType, data), &schedulingv1alpha1.PriorityClass{}) - if obj == nil { - return nil, err - } - return obj.(*schedulingv1alpha1.PriorityClass), err -} - -func (c *priorityClassesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsschedulingv1alpha1.PriorityClassApplyConfiguration, opts metav1.ApplyOptions) (*schedulingv1alpha1.PriorityClass, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(priorityClassesResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &schedulingv1alpha1.PriorityClass{}) - if obj == nil { - return nil, err +func newFakePriorityClassClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedschedulingv1alpha1.PriorityClassInterface { + return &priorityClassScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*schedulingv1alpha1.PriorityClass, *schedulingv1alpha1.PriorityClassList, *v1alpha1.PriorityClassApplyConfiguration]( + fake, + clusterPath, + "", + schedulingv1alpha1.SchemeGroupVersion.WithResource("priorityclasses"), + schedulingv1alpha1.SchemeGroupVersion.WithKind("PriorityClass"), + func() *schedulingv1alpha1.PriorityClass { return &schedulingv1alpha1.PriorityClass{} }, + func() *schedulingv1alpha1.PriorityClassList { return &schedulingv1alpha1.PriorityClassList{} }, + func(dst, src *schedulingv1alpha1.PriorityClassList) { dst.ListMeta = src.ListMeta }, + func(list *schedulingv1alpha1.PriorityClassList) []*schedulingv1alpha1.PriorityClass { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *schedulingv1alpha1.PriorityClassList, items []*schedulingv1alpha1.PriorityClass) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*schedulingv1alpha1.PriorityClass), err } diff --git a/kubernetes/typed/scheduling/v1alpha1/fake/scheduling_client.go b/kubernetes/typed/scheduling/v1alpha1/fake/scheduling_client.go index 524fdf00a..c9e6d41f3 100644 --- a/kubernetes/typed/scheduling/v1alpha1/fake/scheduling_client.go +++ b/kubernetes/typed/scheduling/v1alpha1/fake/scheduling_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" schedulingv1alpha1 "k8s.io/client-go/kubernetes/typed/scheduling/v1alpha1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpschedulingv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/scheduling/v1alpha1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -42,21 +42,21 @@ func (c *SchedulingV1alpha1ClusterClient) Cluster(clusterPath logicalcluster.Pat } func (c *SchedulingV1alpha1ClusterClient) PriorityClasses() kcpschedulingv1alpha1.PriorityClassClusterInterface { - return &priorityClassesClusterClient{Fake: c.Fake} + return newFakePriorityClassClusterClient(c) } -var _ schedulingv1alpha1.SchedulingV1alpha1Interface = (*SchedulingV1alpha1Client)(nil) - type SchedulingV1alpha1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } +func (c *SchedulingV1alpha1Client) PriorityClasses() schedulingv1alpha1.PriorityClassInterface { + return newFakePriorityClassClient(c.Fake, c.ClusterPath) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. func (c *SchedulingV1alpha1Client) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } - -func (c *SchedulingV1alpha1Client) PriorityClasses() schedulingv1alpha1.PriorityClassInterface { - return &priorityClassesClient{Fake: c.Fake, ClusterPath: c.ClusterPath} -} diff --git a/kubernetes/typed/scheduling/v1alpha1/generated_expansion.go b/kubernetes/typed/scheduling/v1alpha1/generated_expansion.go new file mode 100644 index 000000000..3c3dadfc4 --- /dev/null +++ b/kubernetes/typed/scheduling/v1alpha1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1alpha1 + +type PriorityClassClusterExpansion interface{} diff --git a/kubernetes/typed/scheduling/v1alpha1/priorityclass.go b/kubernetes/typed/scheduling/v1alpha1/priorityclass.go index 2151da138..bfa90325f 100644 --- a/kubernetes/typed/scheduling/v1alpha1/priorityclass.go +++ b/kubernetes/typed/scheduling/v1alpha1/priorityclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - schedulingv1alpha1 "k8s.io/api/scheduling/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - schedulingv1alpha1client "k8s.io/client-go/kubernetes/typed/scheduling/v1alpha1" + apischedulingv1alpha1 "k8s.io/api/scheduling/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + schedulingv1alpha1 "k8s.io/client-go/kubernetes/typed/scheduling/v1alpha1" ) // PriorityClassesClusterGetter has a method to return a PriorityClassClusterInterface. @@ -37,19 +37,20 @@ type PriorityClassesClusterGetter interface { } // PriorityClassClusterInterface can operate on PriorityClasses across all clusters, -// or scope down to one cluster and return a schedulingv1alpha1client.PriorityClassInterface. +// or scope down to one cluster and return a schedulingv1alpha1.PriorityClassInterface. type PriorityClassClusterInterface interface { - Cluster(logicalcluster.Path) schedulingv1alpha1client.PriorityClassInterface - List(ctx context.Context, opts metav1.ListOptions) (*schedulingv1alpha1.PriorityClassList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) schedulingv1alpha1.PriorityClassInterface + List(ctx context.Context, opts v1.ListOptions) (*apischedulingv1alpha1.PriorityClassList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + PriorityClassClusterExpansion } type priorityClassesClusterInterface struct { - clientCache kcpclient.Cache[*schedulingv1alpha1client.SchedulingV1alpha1Client] + clientCache kcpclient.Cache[*schedulingv1alpha1.SchedulingV1alpha1Client] } // Cluster scopes the client down to a particular cluster. -func (c *priorityClassesClusterInterface) Cluster(clusterPath logicalcluster.Path) schedulingv1alpha1client.PriorityClassInterface { +func (c *priorityClassesClusterInterface) Cluster(clusterPath logicalcluster.Path) schedulingv1alpha1.PriorityClassInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *priorityClassesClusterInterface) Cluster(clusterPath logicalcluster.Pat } // List returns the entire collection of all PriorityClasses across all clusters. -func (c *priorityClassesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*schedulingv1alpha1.PriorityClassList, error) { +func (c *priorityClassesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apischedulingv1alpha1.PriorityClassList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).PriorityClasses().List(ctx, opts) } // Watch begins to watch all PriorityClasses across all clusters. -func (c *priorityClassesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *priorityClassesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).PriorityClasses().Watch(ctx, opts) } diff --git a/kubernetes/typed/scheduling/v1alpha1/scheduling_client.go b/kubernetes/typed/scheduling/v1alpha1/scheduling_client.go index 3f7b681a3..c6237eb14 100644 --- a/kubernetes/typed/scheduling/v1alpha1/scheduling_client.go +++ b/kubernetes/typed/scheduling/v1alpha1/scheduling_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apischedulingv1alpha1 "k8s.io/api/scheduling/v1alpha1" schedulingv1alpha1 "k8s.io/client-go/kubernetes/typed/scheduling/v1alpha1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type SchedulingV1alpha1ClusterInterface interface { @@ -37,6 +40,7 @@ type SchedulingV1alpha1ClusterScoper interface { Cluster(logicalcluster.Path) schedulingv1alpha1.SchedulingV1alpha1Interface } +// SchedulingV1alpha1ClusterClient is used to interact with features provided by the scheduling.k8s.io group. type SchedulingV1alpha1ClusterClient struct { clientCache kcpclient.Cache[*schedulingv1alpha1.SchedulingV1alpha1Client] } @@ -56,11 +60,13 @@ func (c *SchedulingV1alpha1ClusterClient) PriorityClasses() PriorityClassCluster // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*SchedulingV1alpha1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new SchedulingV1alpha1ClusterClient for the given config and http client. @@ -72,6 +78,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*SchedulingV1alpha1C if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &SchedulingV1alpha1ClusterClient{clientCache: cache}, nil } @@ -84,3 +91,14 @@ func NewForConfigOrDie(c *rest.Config) *SchedulingV1alpha1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apischedulingv1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/scheduling/v1beta1/doc.go b/kubernetes/typed/scheduling/v1beta1/doc.go new file mode 100644 index 000000000..541e9d258 --- /dev/null +++ b/kubernetes/typed/scheduling/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1beta1 diff --git a/kubernetes/typed/scheduling/v1beta1/fake/doc.go b/kubernetes/typed/scheduling/v1beta1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/scheduling/v1beta1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/scheduling/v1beta1/fake/priorityclass.go b/kubernetes/typed/scheduling/v1beta1/fake/priorityclass.go index de01b2cfd..2d475b075 100644 --- a/kubernetes/typed/scheduling/v1beta1/fake/priorityclass.go +++ b/kubernetes/typed/scheduling/v1beta1/fake/priorityclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" schedulingv1beta1 "k8s.io/api/scheduling/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsschedulingv1beta1 "k8s.io/client-go/applyconfigurations/scheduling/v1beta1" - schedulingv1beta1client "k8s.io/client-go/kubernetes/typed/scheduling/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/scheduling/v1beta1" + typedschedulingv1beta1 "k8s.io/client-go/kubernetes/typed/scheduling/v1beta1" + typedkcpschedulingv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/scheduling/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var priorityClassesResource = schema.GroupVersionResource{Group: "scheduling.k8s.io", Version: "v1beta1", Resource: "priorityclasses"} -var priorityClassesKind = schema.GroupVersionKind{Group: "scheduling.k8s.io", Version: "v1beta1", Kind: "PriorityClass"} - -type priorityClassesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *priorityClassesClusterClient) Cluster(clusterPath logicalcluster.Path) schedulingv1beta1client.PriorityClassInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &priorityClassesClient{Fake: c.Fake, ClusterPath: clusterPath} +// priorityClassClusterClient implements PriorityClassClusterInterface +type priorityClassClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*schedulingv1beta1.PriorityClass, *schedulingv1beta1.PriorityClassList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of PriorityClasses that match those selectors across all clusters. -func (c *priorityClassesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*schedulingv1beta1.PriorityClassList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(priorityClassesResource, priorityClassesKind, logicalcluster.Wildcard, opts), &schedulingv1beta1.PriorityClassList{}) - if obj == nil { - return nil, err +func newFakePriorityClassClusterClient(fake *SchedulingV1beta1ClusterClient) typedkcpschedulingv1beta1.PriorityClassClusterInterface { + return &priorityClassClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*schedulingv1beta1.PriorityClass, *schedulingv1beta1.PriorityClassList]( + fake.Fake, + schedulingv1beta1.SchemeGroupVersion.WithResource("priorityclasses"), + schedulingv1beta1.SchemeGroupVersion.WithKind("PriorityClass"), + func() *schedulingv1beta1.PriorityClass { return &schedulingv1beta1.PriorityClass{} }, + func() *schedulingv1beta1.PriorityClassList { return &schedulingv1beta1.PriorityClassList{} }, + func(dst, src *schedulingv1beta1.PriorityClassList) { dst.ListMeta = src.ListMeta }, + func(list *schedulingv1beta1.PriorityClassList) []*schedulingv1beta1.PriorityClass { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *schedulingv1beta1.PriorityClassList, items []*schedulingv1beta1.PriorityClass) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &schedulingv1beta1.PriorityClassList{ListMeta: obj.(*schedulingv1beta1.PriorityClassList).ListMeta} - for _, item := range obj.(*schedulingv1beta1.PriorityClassList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested PriorityClasses across all clusters. -func (c *priorityClassesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(priorityClassesResource, logicalcluster.Wildcard, opts)) +func (c *priorityClassClusterClient) Cluster(cluster logicalcluster.Path) typedschedulingv1beta1.PriorityClassInterface { + return newFakePriorityClassClient(c.Fake, cluster) } -type priorityClassesClient struct { - *kcptesting.Fake +// priorityClassScopedClient implements PriorityClassInterface +type priorityClassScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*schedulingv1beta1.PriorityClass, *schedulingv1beta1.PriorityClassList, *v1beta1.PriorityClassApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *priorityClassesClient) Create(ctx context.Context, priorityClass *schedulingv1beta1.PriorityClass, opts metav1.CreateOptions) (*schedulingv1beta1.PriorityClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(priorityClassesResource, c.ClusterPath, priorityClass), &schedulingv1beta1.PriorityClass{}) - if obj == nil { - return nil, err - } - return obj.(*schedulingv1beta1.PriorityClass), err -} - -func (c *priorityClassesClient) Update(ctx context.Context, priorityClass *schedulingv1beta1.PriorityClass, opts metav1.UpdateOptions) (*schedulingv1beta1.PriorityClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(priorityClassesResource, c.ClusterPath, priorityClass), &schedulingv1beta1.PriorityClass{}) - if obj == nil { - return nil, err - } - return obj.(*schedulingv1beta1.PriorityClass), err -} - -func (c *priorityClassesClient) UpdateStatus(ctx context.Context, priorityClass *schedulingv1beta1.PriorityClass, opts metav1.UpdateOptions) (*schedulingv1beta1.PriorityClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(priorityClassesResource, c.ClusterPath, "status", priorityClass), &schedulingv1beta1.PriorityClass{}) - if obj == nil { - return nil, err - } - return obj.(*schedulingv1beta1.PriorityClass), err -} - -func (c *priorityClassesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(priorityClassesResource, c.ClusterPath, name, opts), &schedulingv1beta1.PriorityClass{}) - return err -} - -func (c *priorityClassesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(priorityClassesResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &schedulingv1beta1.PriorityClassList{}) - return err -} - -func (c *priorityClassesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*schedulingv1beta1.PriorityClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(priorityClassesResource, c.ClusterPath, name), &schedulingv1beta1.PriorityClass{}) - if obj == nil { - return nil, err - } - return obj.(*schedulingv1beta1.PriorityClass), err -} - -// List takes label and field selectors, and returns the list of PriorityClasses that match those selectors. -func (c *priorityClassesClient) List(ctx context.Context, opts metav1.ListOptions) (*schedulingv1beta1.PriorityClassList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(priorityClassesResource, priorityClassesKind, c.ClusterPath, opts), &schedulingv1beta1.PriorityClassList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &schedulingv1beta1.PriorityClassList{ListMeta: obj.(*schedulingv1beta1.PriorityClassList).ListMeta} - for _, item := range obj.(*schedulingv1beta1.PriorityClassList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *priorityClassesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(priorityClassesResource, c.ClusterPath, opts)) -} - -func (c *priorityClassesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*schedulingv1beta1.PriorityClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(priorityClassesResource, c.ClusterPath, name, pt, data, subresources...), &schedulingv1beta1.PriorityClass{}) - if obj == nil { - return nil, err - } - return obj.(*schedulingv1beta1.PriorityClass), err -} - -func (c *priorityClassesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsschedulingv1beta1.PriorityClassApplyConfiguration, opts metav1.ApplyOptions) (*schedulingv1beta1.PriorityClass, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(priorityClassesResource, c.ClusterPath, *name, types.ApplyPatchType, data), &schedulingv1beta1.PriorityClass{}) - if obj == nil { - return nil, err - } - return obj.(*schedulingv1beta1.PriorityClass), err -} - -func (c *priorityClassesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsschedulingv1beta1.PriorityClassApplyConfiguration, opts metav1.ApplyOptions) (*schedulingv1beta1.PriorityClass, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(priorityClassesResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &schedulingv1beta1.PriorityClass{}) - if obj == nil { - return nil, err +func newFakePriorityClassClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedschedulingv1beta1.PriorityClassInterface { + return &priorityClassScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*schedulingv1beta1.PriorityClass, *schedulingv1beta1.PriorityClassList, *v1beta1.PriorityClassApplyConfiguration]( + fake, + clusterPath, + "", + schedulingv1beta1.SchemeGroupVersion.WithResource("priorityclasses"), + schedulingv1beta1.SchemeGroupVersion.WithKind("PriorityClass"), + func() *schedulingv1beta1.PriorityClass { return &schedulingv1beta1.PriorityClass{} }, + func() *schedulingv1beta1.PriorityClassList { return &schedulingv1beta1.PriorityClassList{} }, + func(dst, src *schedulingv1beta1.PriorityClassList) { dst.ListMeta = src.ListMeta }, + func(list *schedulingv1beta1.PriorityClassList) []*schedulingv1beta1.PriorityClass { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *schedulingv1beta1.PriorityClassList, items []*schedulingv1beta1.PriorityClass) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*schedulingv1beta1.PriorityClass), err } diff --git a/kubernetes/typed/scheduling/v1beta1/fake/scheduling_client.go b/kubernetes/typed/scheduling/v1beta1/fake/scheduling_client.go index 2d8f637b4..a50595d2d 100644 --- a/kubernetes/typed/scheduling/v1beta1/fake/scheduling_client.go +++ b/kubernetes/typed/scheduling/v1beta1/fake/scheduling_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" schedulingv1beta1 "k8s.io/client-go/kubernetes/typed/scheduling/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpschedulingv1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/scheduling/v1beta1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -42,21 +42,21 @@ func (c *SchedulingV1beta1ClusterClient) Cluster(clusterPath logicalcluster.Path } func (c *SchedulingV1beta1ClusterClient) PriorityClasses() kcpschedulingv1beta1.PriorityClassClusterInterface { - return &priorityClassesClusterClient{Fake: c.Fake} + return newFakePriorityClassClusterClient(c) } -var _ schedulingv1beta1.SchedulingV1beta1Interface = (*SchedulingV1beta1Client)(nil) - type SchedulingV1beta1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } +func (c *SchedulingV1beta1Client) PriorityClasses() schedulingv1beta1.PriorityClassInterface { + return newFakePriorityClassClient(c.Fake, c.ClusterPath) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. func (c *SchedulingV1beta1Client) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } - -func (c *SchedulingV1beta1Client) PriorityClasses() schedulingv1beta1.PriorityClassInterface { - return &priorityClassesClient{Fake: c.Fake, ClusterPath: c.ClusterPath} -} diff --git a/kubernetes/typed/scheduling/v1beta1/generated_expansion.go b/kubernetes/typed/scheduling/v1beta1/generated_expansion.go new file mode 100644 index 000000000..da307a5ee --- /dev/null +++ b/kubernetes/typed/scheduling/v1beta1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1beta1 + +type PriorityClassClusterExpansion interface{} diff --git a/kubernetes/typed/scheduling/v1beta1/priorityclass.go b/kubernetes/typed/scheduling/v1beta1/priorityclass.go index 16b7d5def..d7a13ec42 100644 --- a/kubernetes/typed/scheduling/v1beta1/priorityclass.go +++ b/kubernetes/typed/scheduling/v1beta1/priorityclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - schedulingv1beta1 "k8s.io/api/scheduling/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - schedulingv1beta1client "k8s.io/client-go/kubernetes/typed/scheduling/v1beta1" + apischedulingv1beta1 "k8s.io/api/scheduling/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + schedulingv1beta1 "k8s.io/client-go/kubernetes/typed/scheduling/v1beta1" ) // PriorityClassesClusterGetter has a method to return a PriorityClassClusterInterface. @@ -37,19 +37,20 @@ type PriorityClassesClusterGetter interface { } // PriorityClassClusterInterface can operate on PriorityClasses across all clusters, -// or scope down to one cluster and return a schedulingv1beta1client.PriorityClassInterface. +// or scope down to one cluster and return a schedulingv1beta1.PriorityClassInterface. type PriorityClassClusterInterface interface { - Cluster(logicalcluster.Path) schedulingv1beta1client.PriorityClassInterface - List(ctx context.Context, opts metav1.ListOptions) (*schedulingv1beta1.PriorityClassList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) schedulingv1beta1.PriorityClassInterface + List(ctx context.Context, opts v1.ListOptions) (*apischedulingv1beta1.PriorityClassList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + PriorityClassClusterExpansion } type priorityClassesClusterInterface struct { - clientCache kcpclient.Cache[*schedulingv1beta1client.SchedulingV1beta1Client] + clientCache kcpclient.Cache[*schedulingv1beta1.SchedulingV1beta1Client] } // Cluster scopes the client down to a particular cluster. -func (c *priorityClassesClusterInterface) Cluster(clusterPath logicalcluster.Path) schedulingv1beta1client.PriorityClassInterface { +func (c *priorityClassesClusterInterface) Cluster(clusterPath logicalcluster.Path) schedulingv1beta1.PriorityClassInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *priorityClassesClusterInterface) Cluster(clusterPath logicalcluster.Pat } // List returns the entire collection of all PriorityClasses across all clusters. -func (c *priorityClassesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*schedulingv1beta1.PriorityClassList, error) { +func (c *priorityClassesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apischedulingv1beta1.PriorityClassList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).PriorityClasses().List(ctx, opts) } // Watch begins to watch all PriorityClasses across all clusters. -func (c *priorityClassesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *priorityClassesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).PriorityClasses().Watch(ctx, opts) } diff --git a/kubernetes/typed/scheduling/v1beta1/scheduling_client.go b/kubernetes/typed/scheduling/v1beta1/scheduling_client.go index 6295b9945..8a584b049 100644 --- a/kubernetes/typed/scheduling/v1beta1/scheduling_client.go +++ b/kubernetes/typed/scheduling/v1beta1/scheduling_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apischedulingv1beta1 "k8s.io/api/scheduling/v1beta1" schedulingv1beta1 "k8s.io/client-go/kubernetes/typed/scheduling/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type SchedulingV1beta1ClusterInterface interface { @@ -37,6 +40,7 @@ type SchedulingV1beta1ClusterScoper interface { Cluster(logicalcluster.Path) schedulingv1beta1.SchedulingV1beta1Interface } +// SchedulingV1beta1ClusterClient is used to interact with features provided by the scheduling.k8s.io group. type SchedulingV1beta1ClusterClient struct { clientCache kcpclient.Cache[*schedulingv1beta1.SchedulingV1beta1Client] } @@ -56,11 +60,13 @@ func (c *SchedulingV1beta1ClusterClient) PriorityClasses() PriorityClassClusterI // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*SchedulingV1beta1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new SchedulingV1beta1ClusterClient for the given config and http client. @@ -72,6 +78,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*SchedulingV1beta1Cl if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &SchedulingV1beta1ClusterClient{clientCache: cache}, nil } @@ -84,3 +91,14 @@ func NewForConfigOrDie(c *rest.Config) *SchedulingV1beta1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apischedulingv1beta1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/storage/v1/csidriver.go b/kubernetes/typed/storage/v1/csidriver.go index f65017ff0..512bc96fd 100644 --- a/kubernetes/typed/storage/v1/csidriver.go +++ b/kubernetes/typed/storage/v1/csidriver.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - storagev1 "k8s.io/api/storage/v1" + apistoragev1 "k8s.io/api/storage/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - storagev1client "k8s.io/client-go/kubernetes/typed/storage/v1" + watch "k8s.io/apimachinery/pkg/watch" + storagev1 "k8s.io/client-go/kubernetes/typed/storage/v1" ) // CSIDriversClusterGetter has a method to return a CSIDriverClusterInterface. @@ -37,19 +37,20 @@ type CSIDriversClusterGetter interface { } // CSIDriverClusterInterface can operate on CSIDrivers across all clusters, -// or scope down to one cluster and return a storagev1client.CSIDriverInterface. +// or scope down to one cluster and return a storagev1.CSIDriverInterface. type CSIDriverClusterInterface interface { - Cluster(logicalcluster.Path) storagev1client.CSIDriverInterface - List(ctx context.Context, opts metav1.ListOptions) (*storagev1.CSIDriverList, error) + Cluster(logicalcluster.Path) storagev1.CSIDriverInterface + List(ctx context.Context, opts metav1.ListOptions) (*apistoragev1.CSIDriverList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + CSIDriverClusterExpansion } type cSIDriversClusterInterface struct { - clientCache kcpclient.Cache[*storagev1client.StorageV1Client] + clientCache kcpclient.Cache[*storagev1.StorageV1Client] } // Cluster scopes the client down to a particular cluster. -func (c *cSIDriversClusterInterface) Cluster(clusterPath logicalcluster.Path) storagev1client.CSIDriverInterface { +func (c *cSIDriversClusterInterface) Cluster(clusterPath logicalcluster.Path) storagev1.CSIDriverInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,7 +59,7 @@ func (c *cSIDriversClusterInterface) Cluster(clusterPath logicalcluster.Path) st } // List returns the entire collection of all CSIDrivers across all clusters. -func (c *cSIDriversClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*storagev1.CSIDriverList, error) { +func (c *cSIDriversClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*apistoragev1.CSIDriverList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).CSIDrivers().List(ctx, opts) } diff --git a/kubernetes/typed/storage/v1/csinode.go b/kubernetes/typed/storage/v1/csinode.go index 0f0014298..45bcf4b14 100644 --- a/kubernetes/typed/storage/v1/csinode.go +++ b/kubernetes/typed/storage/v1/csinode.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - storagev1 "k8s.io/api/storage/v1" + apistoragev1 "k8s.io/api/storage/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - storagev1client "k8s.io/client-go/kubernetes/typed/storage/v1" + watch "k8s.io/apimachinery/pkg/watch" + storagev1 "k8s.io/client-go/kubernetes/typed/storage/v1" ) // CSINodesClusterGetter has a method to return a CSINodeClusterInterface. @@ -37,19 +37,20 @@ type CSINodesClusterGetter interface { } // CSINodeClusterInterface can operate on CSINodes across all clusters, -// or scope down to one cluster and return a storagev1client.CSINodeInterface. +// or scope down to one cluster and return a storagev1.CSINodeInterface. type CSINodeClusterInterface interface { - Cluster(logicalcluster.Path) storagev1client.CSINodeInterface - List(ctx context.Context, opts metav1.ListOptions) (*storagev1.CSINodeList, error) + Cluster(logicalcluster.Path) storagev1.CSINodeInterface + List(ctx context.Context, opts metav1.ListOptions) (*apistoragev1.CSINodeList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + CSINodeClusterExpansion } type cSINodesClusterInterface struct { - clientCache kcpclient.Cache[*storagev1client.StorageV1Client] + clientCache kcpclient.Cache[*storagev1.StorageV1Client] } // Cluster scopes the client down to a particular cluster. -func (c *cSINodesClusterInterface) Cluster(clusterPath logicalcluster.Path) storagev1client.CSINodeInterface { +func (c *cSINodesClusterInterface) Cluster(clusterPath logicalcluster.Path) storagev1.CSINodeInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,7 +59,7 @@ func (c *cSINodesClusterInterface) Cluster(clusterPath logicalcluster.Path) stor } // List returns the entire collection of all CSINodes across all clusters. -func (c *cSINodesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*storagev1.CSINodeList, error) { +func (c *cSINodesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*apistoragev1.CSINodeList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).CSINodes().List(ctx, opts) } diff --git a/kubernetes/typed/storage/v1/csistoragecapacity.go b/kubernetes/typed/storage/v1/csistoragecapacity.go index 718517ec2..205711cec 100644 --- a/kubernetes/typed/storage/v1/csistoragecapacity.go +++ b/kubernetes/typed/storage/v1/csistoragecapacity.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" storagev1 "k8s.io/api/storage/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - storagev1client "k8s.io/client-go/kubernetes/typed/storage/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedstoragev1 "k8s.io/client-go/kubernetes/typed/storage/v1" ) // CSIStorageCapacitiesClusterGetter has a method to return a CSIStorageCapacityClusterInterface. @@ -42,10 +42,11 @@ type CSIStorageCapacityClusterInterface interface { Cluster(logicalcluster.Path) CSIStorageCapacitiesNamespacer List(ctx context.Context, opts metav1.ListOptions) (*storagev1.CSIStorageCapacityList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + CSIStorageCapacityClusterExpansion } type cSIStorageCapacitiesClusterInterface struct { - clientCache kcpclient.Cache[*storagev1client.StorageV1Client] + clientCache kcpclient.Cache[*typedstoragev1.StorageV1Client] } // Cluster scopes the client down to a particular cluster. @@ -67,16 +68,16 @@ func (c *cSIStorageCapacitiesClusterInterface) Watch(ctx context.Context, opts m return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).CSIStorageCapacities(metav1.NamespaceAll).Watch(ctx, opts) } -// CSIStorageCapacitiesNamespacer can scope to objects within a namespace, returning a storagev1client.CSIStorageCapacityInterface. +// CSIStorageCapacitiesNamespacer can scope to objects within a namespace, returning a typedstoragev1.CSIStorageCapacityInterface. type CSIStorageCapacitiesNamespacer interface { - Namespace(string) storagev1client.CSIStorageCapacityInterface + Namespace(string) typedstoragev1.CSIStorageCapacityInterface } type cSIStorageCapacitiesNamespacer struct { - clientCache kcpclient.Cache[*storagev1client.StorageV1Client] + clientCache kcpclient.Cache[*typedstoragev1.StorageV1Client] clusterPath logicalcluster.Path } -func (n *cSIStorageCapacitiesNamespacer) Namespace(namespace string) storagev1client.CSIStorageCapacityInterface { +func (n *cSIStorageCapacitiesNamespacer) Namespace(namespace string) typedstoragev1.CSIStorageCapacityInterface { return n.clientCache.ClusterOrDie(n.clusterPath).CSIStorageCapacities(namespace) } diff --git a/kubernetes/typed/storage/v1/doc.go b/kubernetes/typed/storage/v1/doc.go new file mode 100644 index 000000000..d2f3412ab --- /dev/null +++ b/kubernetes/typed/storage/v1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1 diff --git a/kubernetes/typed/storage/v1/fake/csidriver.go b/kubernetes/typed/storage/v1/fake/csidriver.go index 3487048a6..071f2fcfe 100644 --- a/kubernetes/typed/storage/v1/fake/csidriver.go +++ b/kubernetes/typed/storage/v1/fake/csidriver.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" storagev1 "k8s.io/api/storage/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsstoragev1 "k8s.io/client-go/applyconfigurations/storage/v1" - storagev1client "k8s.io/client-go/kubernetes/typed/storage/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/storage/v1" + typedstoragev1 "k8s.io/client-go/kubernetes/typed/storage/v1" + typedkcpstoragev1 "github.com/kcp-dev/client-go/kubernetes/typed/storage/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var cSIDriversResource = schema.GroupVersionResource{Group: "storage.k8s.io", Version: "v1", Resource: "csidrivers"} -var cSIDriversKind = schema.GroupVersionKind{Group: "storage.k8s.io", Version: "v1", Kind: "CSIDriver"} - -type cSIDriversClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *cSIDriversClusterClient) Cluster(clusterPath logicalcluster.Path) storagev1client.CSIDriverInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &cSIDriversClient{Fake: c.Fake, ClusterPath: clusterPath} +// cSIDriverClusterClient implements CSIDriverClusterInterface +type cSIDriverClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*storagev1.CSIDriver, *storagev1.CSIDriverList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of CSIDrivers that match those selectors across all clusters. -func (c *cSIDriversClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*storagev1.CSIDriverList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(cSIDriversResource, cSIDriversKind, logicalcluster.Wildcard, opts), &storagev1.CSIDriverList{}) - if obj == nil { - return nil, err +func newFakeCSIDriverClusterClient(fake *StorageV1ClusterClient) typedkcpstoragev1.CSIDriverClusterInterface { + return &cSIDriverClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*storagev1.CSIDriver, *storagev1.CSIDriverList]( + fake.Fake, + storagev1.SchemeGroupVersion.WithResource("csidrivers"), + storagev1.SchemeGroupVersion.WithKind("CSIDriver"), + func() *storagev1.CSIDriver { return &storagev1.CSIDriver{} }, + func() *storagev1.CSIDriverList { return &storagev1.CSIDriverList{} }, + func(dst, src *storagev1.CSIDriverList) { dst.ListMeta = src.ListMeta }, + func(list *storagev1.CSIDriverList) []*storagev1.CSIDriver { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *storagev1.CSIDriverList, items []*storagev1.CSIDriver) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &storagev1.CSIDriverList{ListMeta: obj.(*storagev1.CSIDriverList).ListMeta} - for _, item := range obj.(*storagev1.CSIDriverList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested CSIDrivers across all clusters. -func (c *cSIDriversClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(cSIDriversResource, logicalcluster.Wildcard, opts)) +func (c *cSIDriverClusterClient) Cluster(cluster logicalcluster.Path) typedstoragev1.CSIDriverInterface { + return newFakeCSIDriverClient(c.Fake, cluster) } -type cSIDriversClient struct { - *kcptesting.Fake +// cSIDriverScopedClient implements CSIDriverInterface +type cSIDriverScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*storagev1.CSIDriver, *storagev1.CSIDriverList, *v1.CSIDriverApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *cSIDriversClient) Create(ctx context.Context, cSIDriver *storagev1.CSIDriver, opts metav1.CreateOptions) (*storagev1.CSIDriver, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(cSIDriversResource, c.ClusterPath, cSIDriver), &storagev1.CSIDriver{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1.CSIDriver), err -} - -func (c *cSIDriversClient) Update(ctx context.Context, cSIDriver *storagev1.CSIDriver, opts metav1.UpdateOptions) (*storagev1.CSIDriver, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(cSIDriversResource, c.ClusterPath, cSIDriver), &storagev1.CSIDriver{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1.CSIDriver), err -} - -func (c *cSIDriversClient) UpdateStatus(ctx context.Context, cSIDriver *storagev1.CSIDriver, opts metav1.UpdateOptions) (*storagev1.CSIDriver, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(cSIDriversResource, c.ClusterPath, "status", cSIDriver), &storagev1.CSIDriver{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1.CSIDriver), err -} - -func (c *cSIDriversClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(cSIDriversResource, c.ClusterPath, name, opts), &storagev1.CSIDriver{}) - return err -} - -func (c *cSIDriversClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(cSIDriversResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &storagev1.CSIDriverList{}) - return err -} - -func (c *cSIDriversClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*storagev1.CSIDriver, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(cSIDriversResource, c.ClusterPath, name), &storagev1.CSIDriver{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1.CSIDriver), err -} - -// List takes label and field selectors, and returns the list of CSIDrivers that match those selectors. -func (c *cSIDriversClient) List(ctx context.Context, opts metav1.ListOptions) (*storagev1.CSIDriverList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(cSIDriversResource, cSIDriversKind, c.ClusterPath, opts), &storagev1.CSIDriverList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &storagev1.CSIDriverList{ListMeta: obj.(*storagev1.CSIDriverList).ListMeta} - for _, item := range obj.(*storagev1.CSIDriverList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *cSIDriversClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(cSIDriversResource, c.ClusterPath, opts)) -} - -func (c *cSIDriversClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*storagev1.CSIDriver, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(cSIDriversResource, c.ClusterPath, name, pt, data, subresources...), &storagev1.CSIDriver{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1.CSIDriver), err -} - -func (c *cSIDriversClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsstoragev1.CSIDriverApplyConfiguration, opts metav1.ApplyOptions) (*storagev1.CSIDriver, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(cSIDriversResource, c.ClusterPath, *name, types.ApplyPatchType, data), &storagev1.CSIDriver{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1.CSIDriver), err -} - -func (c *cSIDriversClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsstoragev1.CSIDriverApplyConfiguration, opts metav1.ApplyOptions) (*storagev1.CSIDriver, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(cSIDriversResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &storagev1.CSIDriver{}) - if obj == nil { - return nil, err +func newFakeCSIDriverClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedstoragev1.CSIDriverInterface { + return &cSIDriverScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*storagev1.CSIDriver, *storagev1.CSIDriverList, *v1.CSIDriverApplyConfiguration]( + fake, + clusterPath, + "", + storagev1.SchemeGroupVersion.WithResource("csidrivers"), + storagev1.SchemeGroupVersion.WithKind("CSIDriver"), + func() *storagev1.CSIDriver { return &storagev1.CSIDriver{} }, + func() *storagev1.CSIDriverList { return &storagev1.CSIDriverList{} }, + func(dst, src *storagev1.CSIDriverList) { dst.ListMeta = src.ListMeta }, + func(list *storagev1.CSIDriverList) []*storagev1.CSIDriver { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *storagev1.CSIDriverList, items []*storagev1.CSIDriver) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*storagev1.CSIDriver), err } diff --git a/kubernetes/typed/storage/v1/fake/csinode.go b/kubernetes/typed/storage/v1/fake/csinode.go index 7296f0ccf..2025c2532 100644 --- a/kubernetes/typed/storage/v1/fake/csinode.go +++ b/kubernetes/typed/storage/v1/fake/csinode.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,74 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" storagev1 "k8s.io/api/storage/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsstoragev1 "k8s.io/client-go/applyconfigurations/storage/v1" - storagev1client "k8s.io/client-go/kubernetes/typed/storage/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/storage/v1" + typedstoragev1 "k8s.io/client-go/kubernetes/typed/storage/v1" + typedkcpstoragev1 "github.com/kcp-dev/client-go/kubernetes/typed/storage/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var cSINodesResource = schema.GroupVersionResource{Group: "storage.k8s.io", Version: "v1", Resource: "csinodes"} -var cSINodesKind = schema.GroupVersionKind{Group: "storage.k8s.io", Version: "v1", Kind: "CSINode"} - -type cSINodesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *cSINodesClusterClient) Cluster(clusterPath logicalcluster.Path) storagev1client.CSINodeInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &cSINodesClient{Fake: c.Fake, ClusterPath: clusterPath} +// cSINodeClusterClient implements CSINodeClusterInterface +type cSINodeClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*storagev1.CSINode, *storagev1.CSINodeList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of CSINodes that match those selectors across all clusters. -func (c *cSINodesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*storagev1.CSINodeList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(cSINodesResource, cSINodesKind, logicalcluster.Wildcard, opts), &storagev1.CSINodeList{}) - if obj == nil { - return nil, err +func newFakeCSINodeClusterClient(fake *StorageV1ClusterClient) typedkcpstoragev1.CSINodeClusterInterface { + return &cSINodeClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*storagev1.CSINode, *storagev1.CSINodeList]( + fake.Fake, + storagev1.SchemeGroupVersion.WithResource("csinodes"), + storagev1.SchemeGroupVersion.WithKind("CSINode"), + func() *storagev1.CSINode { return &storagev1.CSINode{} }, + func() *storagev1.CSINodeList { return &storagev1.CSINodeList{} }, + func(dst, src *storagev1.CSINodeList) { dst.ListMeta = src.ListMeta }, + func(list *storagev1.CSINodeList) []*storagev1.CSINode { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *storagev1.CSINodeList, items []*storagev1.CSINode) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &storagev1.CSINodeList{ListMeta: obj.(*storagev1.CSINodeList).ListMeta} - for _, item := range obj.(*storagev1.CSINodeList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested CSINodes across all clusters. -func (c *cSINodesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(cSINodesResource, logicalcluster.Wildcard, opts)) +func (c *cSINodeClusterClient) Cluster(cluster logicalcluster.Path) typedstoragev1.CSINodeInterface { + return newFakeCSINodeClient(c.Fake, cluster) } -type cSINodesClient struct { - *kcptesting.Fake +// cSINodeScopedClient implements CSINodeInterface +type cSINodeScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*storagev1.CSINode, *storagev1.CSINodeList, *v1.CSINodeApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *cSINodesClient) Create(ctx context.Context, cSINode *storagev1.CSINode, opts metav1.CreateOptions) (*storagev1.CSINode, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(cSINodesResource, c.ClusterPath, cSINode), &storagev1.CSINode{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1.CSINode), err -} - -func (c *cSINodesClient) Update(ctx context.Context, cSINode *storagev1.CSINode, opts metav1.UpdateOptions) (*storagev1.CSINode, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(cSINodesResource, c.ClusterPath, cSINode), &storagev1.CSINode{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1.CSINode), err -} - -func (c *cSINodesClient) UpdateStatus(ctx context.Context, cSINode *storagev1.CSINode, opts metav1.UpdateOptions) (*storagev1.CSINode, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(cSINodesResource, c.ClusterPath, "status", cSINode), &storagev1.CSINode{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1.CSINode), err -} - -func (c *cSINodesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(cSINodesResource, c.ClusterPath, name, opts), &storagev1.CSINode{}) - return err -} - -func (c *cSINodesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(cSINodesResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &storagev1.CSINodeList{}) - return err -} - -func (c *cSINodesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*storagev1.CSINode, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(cSINodesResource, c.ClusterPath, name), &storagev1.CSINode{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1.CSINode), err -} - -// List takes label and field selectors, and returns the list of CSINodes that match those selectors. -func (c *cSINodesClient) List(ctx context.Context, opts metav1.ListOptions) (*storagev1.CSINodeList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(cSINodesResource, cSINodesKind, c.ClusterPath, opts), &storagev1.CSINodeList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &storagev1.CSINodeList{ListMeta: obj.(*storagev1.CSINodeList).ListMeta} - for _, item := range obj.(*storagev1.CSINodeList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *cSINodesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(cSINodesResource, c.ClusterPath, opts)) -} - -func (c *cSINodesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*storagev1.CSINode, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(cSINodesResource, c.ClusterPath, name, pt, data, subresources...), &storagev1.CSINode{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1.CSINode), err -} - -func (c *cSINodesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsstoragev1.CSINodeApplyConfiguration, opts metav1.ApplyOptions) (*storagev1.CSINode, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(cSINodesResource, c.ClusterPath, *name, types.ApplyPatchType, data), &storagev1.CSINode{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1.CSINode), err -} - -func (c *cSINodesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsstoragev1.CSINodeApplyConfiguration, opts metav1.ApplyOptions) (*storagev1.CSINode, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(cSINodesResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &storagev1.CSINode{}) - if obj == nil { - return nil, err +func newFakeCSINodeClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedstoragev1.CSINodeInterface { + return &cSINodeScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*storagev1.CSINode, *storagev1.CSINodeList, *v1.CSINodeApplyConfiguration]( + fake, + clusterPath, + "", + storagev1.SchemeGroupVersion.WithResource("csinodes"), + storagev1.SchemeGroupVersion.WithKind("CSINode"), + func() *storagev1.CSINode { return &storagev1.CSINode{} }, + func() *storagev1.CSINodeList { return &storagev1.CSINodeList{} }, + func(dst, src *storagev1.CSINodeList) { dst.ListMeta = src.ListMeta }, + func(list *storagev1.CSINodeList) []*storagev1.CSINode { return kcpgentype.ToPointerSlice(list.Items) }, + func(list *storagev1.CSINodeList, items []*storagev1.CSINode) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*storagev1.CSINode), err } diff --git a/kubernetes/typed/storage/v1/fake/csistoragecapacity.go b/kubernetes/typed/storage/v1/fake/csistoragecapacity.go index edef589f9..57ee38e66 100644 --- a/kubernetes/typed/storage/v1/fake/csistoragecapacity.go +++ b/kubernetes/typed/storage/v1/fake/csistoragecapacity.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" storagev1 "k8s.io/api/storage/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsstoragev1 "k8s.io/client-go/applyconfigurations/storage/v1" - storagev1client "k8s.io/client-go/kubernetes/typed/storage/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/storage/v1" + typedstoragev1 "k8s.io/client-go/kubernetes/typed/storage/v1" - kcpstoragev1 "github.com/kcp-dev/client-go/kubernetes/typed/storage/v1" + typedkcpstoragev1 "github.com/kcp-dev/client-go/kubernetes/typed/storage/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var cSIStorageCapacitiesResource = schema.GroupVersionResource{Group: "storage.k8s.io", Version: "v1", Resource: "csistoragecapacities"} -var cSIStorageCapacitiesKind = schema.GroupVersionKind{Group: "storage.k8s.io", Version: "v1", Kind: "CSIStorageCapacity"} - -type cSIStorageCapacitiesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *cSIStorageCapacitiesClusterClient) Cluster(clusterPath logicalcluster.Path) kcpstoragev1.CSIStorageCapacitiesNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &cSIStorageCapacitiesNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// cSIStorageCapacityClusterClient implements CSIStorageCapacityClusterInterface +type cSIStorageCapacityClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*storagev1.CSIStorageCapacity, *storagev1.CSIStorageCapacityList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of CSIStorageCapacities that match those selectors across all clusters. -func (c *cSIStorageCapacitiesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*storagev1.CSIStorageCapacityList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(cSIStorageCapacitiesResource, cSIStorageCapacitiesKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &storagev1.CSIStorageCapacityList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeCSIStorageCapacityClusterClient(fake *StorageV1ClusterClient) typedkcpstoragev1.CSIStorageCapacityClusterInterface { + return &cSIStorageCapacityClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*storagev1.CSIStorageCapacity, *storagev1.CSIStorageCapacityList]( + fake.Fake, + storagev1.SchemeGroupVersion.WithResource("csistoragecapacities"), + storagev1.SchemeGroupVersion.WithKind("CSIStorageCapacity"), + func() *storagev1.CSIStorageCapacity { return &storagev1.CSIStorageCapacity{} }, + func() *storagev1.CSIStorageCapacityList { return &storagev1.CSIStorageCapacityList{} }, + func(dst, src *storagev1.CSIStorageCapacityList) { dst.ListMeta = src.ListMeta }, + func(list *storagev1.CSIStorageCapacityList) []*storagev1.CSIStorageCapacity { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *storagev1.CSIStorageCapacityList, items []*storagev1.CSIStorageCapacity) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &storagev1.CSIStorageCapacityList{ListMeta: obj.(*storagev1.CSIStorageCapacityList).ListMeta} - for _, item := range obj.(*storagev1.CSIStorageCapacityList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested CSIStorageCapacities across all clusters. -func (c *cSIStorageCapacitiesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(cSIStorageCapacitiesResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *cSIStorageCapacityClusterClient) Cluster(cluster logicalcluster.Path) typedkcpstoragev1.CSIStorageCapacitiesNamespacer { + return &cSIStorageCapacityNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type cSIStorageCapacitiesNamespacer struct { +type cSIStorageCapacityNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *cSIStorageCapacitiesNamespacer) Namespace(namespace string) storagev1client.CSIStorageCapacityInterface { - return &cSIStorageCapacitiesClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *cSIStorageCapacityNamespacer) Namespace(namespace string) typedstoragev1.CSIStorageCapacityInterface { + return newFakeCSIStorageCapacityClient(n.Fake, namespace, n.ClusterPath) } -type cSIStorageCapacitiesClient struct { - *kcptesting.Fake +// cSIStorageCapacityScopedClient implements CSIStorageCapacityInterface +type cSIStorageCapacityScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*storagev1.CSIStorageCapacity, *storagev1.CSIStorageCapacityList, *v1.CSIStorageCapacityApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *cSIStorageCapacitiesClient) Create(ctx context.Context, cSIStorageCapacity *storagev1.CSIStorageCapacity, opts metav1.CreateOptions) (*storagev1.CSIStorageCapacity, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(cSIStorageCapacitiesResource, c.ClusterPath, c.Namespace, cSIStorageCapacity), &storagev1.CSIStorageCapacity{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1.CSIStorageCapacity), err -} - -func (c *cSIStorageCapacitiesClient) Update(ctx context.Context, cSIStorageCapacity *storagev1.CSIStorageCapacity, opts metav1.UpdateOptions) (*storagev1.CSIStorageCapacity, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(cSIStorageCapacitiesResource, c.ClusterPath, c.Namespace, cSIStorageCapacity), &storagev1.CSIStorageCapacity{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1.CSIStorageCapacity), err -} - -func (c *cSIStorageCapacitiesClient) UpdateStatus(ctx context.Context, cSIStorageCapacity *storagev1.CSIStorageCapacity, opts metav1.UpdateOptions) (*storagev1.CSIStorageCapacity, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(cSIStorageCapacitiesResource, c.ClusterPath, "status", c.Namespace, cSIStorageCapacity), &storagev1.CSIStorageCapacity{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1.CSIStorageCapacity), err -} - -func (c *cSIStorageCapacitiesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(cSIStorageCapacitiesResource, c.ClusterPath, c.Namespace, name, opts), &storagev1.CSIStorageCapacity{}) - return err -} - -func (c *cSIStorageCapacitiesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(cSIStorageCapacitiesResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &storagev1.CSIStorageCapacityList{}) - return err -} - -func (c *cSIStorageCapacitiesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*storagev1.CSIStorageCapacity, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(cSIStorageCapacitiesResource, c.ClusterPath, c.Namespace, name), &storagev1.CSIStorageCapacity{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1.CSIStorageCapacity), err -} - -// List takes label and field selectors, and returns the list of CSIStorageCapacities that match those selectors. -func (c *cSIStorageCapacitiesClient) List(ctx context.Context, opts metav1.ListOptions) (*storagev1.CSIStorageCapacityList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(cSIStorageCapacitiesResource, cSIStorageCapacitiesKind, c.ClusterPath, c.Namespace, opts), &storagev1.CSIStorageCapacityList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &storagev1.CSIStorageCapacityList{ListMeta: obj.(*storagev1.CSIStorageCapacityList).ListMeta} - for _, item := range obj.(*storagev1.CSIStorageCapacityList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *cSIStorageCapacitiesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(cSIStorageCapacitiesResource, c.ClusterPath, c.Namespace, opts)) } -func (c *cSIStorageCapacitiesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*storagev1.CSIStorageCapacity, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(cSIStorageCapacitiesResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &storagev1.CSIStorageCapacity{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1.CSIStorageCapacity), err -} - -func (c *cSIStorageCapacitiesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsstoragev1.CSIStorageCapacityApplyConfiguration, opts metav1.ApplyOptions) (*storagev1.CSIStorageCapacity, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(cSIStorageCapacitiesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &storagev1.CSIStorageCapacity{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1.CSIStorageCapacity), err -} - -func (c *cSIStorageCapacitiesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsstoragev1.CSIStorageCapacityApplyConfiguration, opts metav1.ApplyOptions) (*storagev1.CSIStorageCapacity, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(cSIStorageCapacitiesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &storagev1.CSIStorageCapacity{}) - if obj == nil { - return nil, err +func newFakeCSIStorageCapacityClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedstoragev1.CSIStorageCapacityInterface { + return &cSIStorageCapacityScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*storagev1.CSIStorageCapacity, *storagev1.CSIStorageCapacityList, *v1.CSIStorageCapacityApplyConfiguration]( + fake, + clusterPath, + namespace, + storagev1.SchemeGroupVersion.WithResource("csistoragecapacities"), + storagev1.SchemeGroupVersion.WithKind("CSIStorageCapacity"), + func() *storagev1.CSIStorageCapacity { return &storagev1.CSIStorageCapacity{} }, + func() *storagev1.CSIStorageCapacityList { return &storagev1.CSIStorageCapacityList{} }, + func(dst, src *storagev1.CSIStorageCapacityList) { dst.ListMeta = src.ListMeta }, + func(list *storagev1.CSIStorageCapacityList) []*storagev1.CSIStorageCapacity { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *storagev1.CSIStorageCapacityList, items []*storagev1.CSIStorageCapacity) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*storagev1.CSIStorageCapacity), err } diff --git a/kubernetes/typed/storage/v1/fake/doc.go b/kubernetes/typed/storage/v1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/storage/v1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/storage/v1/fake/storage_client.go b/kubernetes/typed/storage/v1/fake/storage_client.go index 7b7cc41ca..1d2d421fc 100644 --- a/kubernetes/typed/storage/v1/fake/storage_client.go +++ b/kubernetes/typed/storage/v1/fake/storage_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" storagev1 "k8s.io/client-go/kubernetes/typed/storage/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpstoragev1 "github.com/kcp-dev/client-go/kubernetes/typed/storage/v1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -41,54 +41,54 @@ func (c *StorageV1ClusterClient) Cluster(clusterPath logicalcluster.Path) storag return &StorageV1Client{Fake: c.Fake, ClusterPath: clusterPath} } -func (c *StorageV1ClusterClient) StorageClasses() kcpstoragev1.StorageClassClusterInterface { - return &storageClassesClusterClient{Fake: c.Fake} -} - -func (c *StorageV1ClusterClient) VolumeAttachments() kcpstoragev1.VolumeAttachmentClusterInterface { - return &volumeAttachmentsClusterClient{Fake: c.Fake} -} - func (c *StorageV1ClusterClient) CSIDrivers() kcpstoragev1.CSIDriverClusterInterface { - return &cSIDriversClusterClient{Fake: c.Fake} + return newFakeCSIDriverClusterClient(c) } func (c *StorageV1ClusterClient) CSINodes() kcpstoragev1.CSINodeClusterInterface { - return &cSINodesClusterClient{Fake: c.Fake} + return newFakeCSINodeClusterClient(c) } func (c *StorageV1ClusterClient) CSIStorageCapacities() kcpstoragev1.CSIStorageCapacityClusterInterface { - return &cSIStorageCapacitiesClusterClient{Fake: c.Fake} + return newFakeCSIStorageCapacityClusterClient(c) +} + +func (c *StorageV1ClusterClient) StorageClasses() kcpstoragev1.StorageClassClusterInterface { + return newFakeStorageClassClusterClient(c) } -var _ storagev1.StorageV1Interface = (*StorageV1Client)(nil) +func (c *StorageV1ClusterClient) VolumeAttachments() kcpstoragev1.VolumeAttachmentClusterInterface { + return newFakeVolumeAttachmentClusterClient(c) +} type StorageV1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *StorageV1Client) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret +func (c *StorageV1Client) CSIDrivers() storagev1.CSIDriverInterface { + return newFakeCSIDriverClient(c.Fake, c.ClusterPath) } -func (c *StorageV1Client) StorageClasses() storagev1.StorageClassInterface { - return &storageClassesClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +func (c *StorageV1Client) CSINodes() storagev1.CSINodeInterface { + return newFakeCSINodeClient(c.Fake, c.ClusterPath) } -func (c *StorageV1Client) VolumeAttachments() storagev1.VolumeAttachmentInterface { - return &volumeAttachmentsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +func (c *StorageV1Client) CSIStorageCapacities(namespace string) storagev1.CSIStorageCapacityInterface { + return newFakeCSIStorageCapacityClient(c.Fake, namespace, c.ClusterPath) } -func (c *StorageV1Client) CSIDrivers() storagev1.CSIDriverInterface { - return &cSIDriversClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +func (c *StorageV1Client) StorageClasses() storagev1.StorageClassInterface { + return newFakeStorageClassClient(c.Fake, c.ClusterPath) } -func (c *StorageV1Client) CSINodes() storagev1.CSINodeInterface { - return &cSINodesClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +func (c *StorageV1Client) VolumeAttachments() storagev1.VolumeAttachmentInterface { + return newFakeVolumeAttachmentClient(c.Fake, c.ClusterPath) } -func (c *StorageV1Client) CSIStorageCapacities(namespace string) storagev1.CSIStorageCapacityInterface { - return &cSIStorageCapacitiesClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *StorageV1Client) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret } diff --git a/kubernetes/typed/storage/v1/fake/storageclass.go b/kubernetes/typed/storage/v1/fake/storageclass.go index 99108a6ed..8b0e56c2c 100644 --- a/kubernetes/typed/storage/v1/fake/storageclass.go +++ b/kubernetes/typed/storage/v1/fake/storageclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" storagev1 "k8s.io/api/storage/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsstoragev1 "k8s.io/client-go/applyconfigurations/storage/v1" - storagev1client "k8s.io/client-go/kubernetes/typed/storage/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/storage/v1" + typedstoragev1 "k8s.io/client-go/kubernetes/typed/storage/v1" + typedkcpstoragev1 "github.com/kcp-dev/client-go/kubernetes/typed/storage/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var storageClassesResource = schema.GroupVersionResource{Group: "storage.k8s.io", Version: "v1", Resource: "storageclasses"} -var storageClassesKind = schema.GroupVersionKind{Group: "storage.k8s.io", Version: "v1", Kind: "StorageClass"} - -type storageClassesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *storageClassesClusterClient) Cluster(clusterPath logicalcluster.Path) storagev1client.StorageClassInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &storageClassesClient{Fake: c.Fake, ClusterPath: clusterPath} +// storageClassClusterClient implements StorageClassClusterInterface +type storageClassClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*storagev1.StorageClass, *storagev1.StorageClassList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of StorageClasses that match those selectors across all clusters. -func (c *storageClassesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*storagev1.StorageClassList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(storageClassesResource, storageClassesKind, logicalcluster.Wildcard, opts), &storagev1.StorageClassList{}) - if obj == nil { - return nil, err +func newFakeStorageClassClusterClient(fake *StorageV1ClusterClient) typedkcpstoragev1.StorageClassClusterInterface { + return &storageClassClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*storagev1.StorageClass, *storagev1.StorageClassList]( + fake.Fake, + storagev1.SchemeGroupVersion.WithResource("storageclasses"), + storagev1.SchemeGroupVersion.WithKind("StorageClass"), + func() *storagev1.StorageClass { return &storagev1.StorageClass{} }, + func() *storagev1.StorageClassList { return &storagev1.StorageClassList{} }, + func(dst, src *storagev1.StorageClassList) { dst.ListMeta = src.ListMeta }, + func(list *storagev1.StorageClassList) []*storagev1.StorageClass { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *storagev1.StorageClassList, items []*storagev1.StorageClass) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &storagev1.StorageClassList{ListMeta: obj.(*storagev1.StorageClassList).ListMeta} - for _, item := range obj.(*storagev1.StorageClassList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested StorageClasses across all clusters. -func (c *storageClassesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(storageClassesResource, logicalcluster.Wildcard, opts)) +func (c *storageClassClusterClient) Cluster(cluster logicalcluster.Path) typedstoragev1.StorageClassInterface { + return newFakeStorageClassClient(c.Fake, cluster) } -type storageClassesClient struct { - *kcptesting.Fake +// storageClassScopedClient implements StorageClassInterface +type storageClassScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*storagev1.StorageClass, *storagev1.StorageClassList, *v1.StorageClassApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *storageClassesClient) Create(ctx context.Context, storageClass *storagev1.StorageClass, opts metav1.CreateOptions) (*storagev1.StorageClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(storageClassesResource, c.ClusterPath, storageClass), &storagev1.StorageClass{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1.StorageClass), err -} - -func (c *storageClassesClient) Update(ctx context.Context, storageClass *storagev1.StorageClass, opts metav1.UpdateOptions) (*storagev1.StorageClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(storageClassesResource, c.ClusterPath, storageClass), &storagev1.StorageClass{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1.StorageClass), err -} - -func (c *storageClassesClient) UpdateStatus(ctx context.Context, storageClass *storagev1.StorageClass, opts metav1.UpdateOptions) (*storagev1.StorageClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(storageClassesResource, c.ClusterPath, "status", storageClass), &storagev1.StorageClass{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1.StorageClass), err -} - -func (c *storageClassesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(storageClassesResource, c.ClusterPath, name, opts), &storagev1.StorageClass{}) - return err -} - -func (c *storageClassesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(storageClassesResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &storagev1.StorageClassList{}) - return err -} - -func (c *storageClassesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*storagev1.StorageClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(storageClassesResource, c.ClusterPath, name), &storagev1.StorageClass{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1.StorageClass), err -} - -// List takes label and field selectors, and returns the list of StorageClasses that match those selectors. -func (c *storageClassesClient) List(ctx context.Context, opts metav1.ListOptions) (*storagev1.StorageClassList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(storageClassesResource, storageClassesKind, c.ClusterPath, opts), &storagev1.StorageClassList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &storagev1.StorageClassList{ListMeta: obj.(*storagev1.StorageClassList).ListMeta} - for _, item := range obj.(*storagev1.StorageClassList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *storageClassesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(storageClassesResource, c.ClusterPath, opts)) -} - -func (c *storageClassesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*storagev1.StorageClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(storageClassesResource, c.ClusterPath, name, pt, data, subresources...), &storagev1.StorageClass{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1.StorageClass), err -} - -func (c *storageClassesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsstoragev1.StorageClassApplyConfiguration, opts metav1.ApplyOptions) (*storagev1.StorageClass, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(storageClassesResource, c.ClusterPath, *name, types.ApplyPatchType, data), &storagev1.StorageClass{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1.StorageClass), err -} - -func (c *storageClassesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsstoragev1.StorageClassApplyConfiguration, opts metav1.ApplyOptions) (*storagev1.StorageClass, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(storageClassesResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &storagev1.StorageClass{}) - if obj == nil { - return nil, err +func newFakeStorageClassClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedstoragev1.StorageClassInterface { + return &storageClassScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*storagev1.StorageClass, *storagev1.StorageClassList, *v1.StorageClassApplyConfiguration]( + fake, + clusterPath, + "", + storagev1.SchemeGroupVersion.WithResource("storageclasses"), + storagev1.SchemeGroupVersion.WithKind("StorageClass"), + func() *storagev1.StorageClass { return &storagev1.StorageClass{} }, + func() *storagev1.StorageClassList { return &storagev1.StorageClassList{} }, + func(dst, src *storagev1.StorageClassList) { dst.ListMeta = src.ListMeta }, + func(list *storagev1.StorageClassList) []*storagev1.StorageClass { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *storagev1.StorageClassList, items []*storagev1.StorageClass) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*storagev1.StorageClass), err } diff --git a/kubernetes/typed/storage/v1/fake/volumeattachment.go b/kubernetes/typed/storage/v1/fake/volumeattachment.go index cb98a57ad..4acf11b19 100644 --- a/kubernetes/typed/storage/v1/fake/volumeattachment.go +++ b/kubernetes/typed/storage/v1/fake/volumeattachment.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" storagev1 "k8s.io/api/storage/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsstoragev1 "k8s.io/client-go/applyconfigurations/storage/v1" - storagev1client "k8s.io/client-go/kubernetes/typed/storage/v1" - "k8s.io/client-go/testing" + v1 "k8s.io/client-go/applyconfigurations/storage/v1" + typedstoragev1 "k8s.io/client-go/kubernetes/typed/storage/v1" + typedkcpstoragev1 "github.com/kcp-dev/client-go/kubernetes/typed/storage/v1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var volumeAttachmentsResource = schema.GroupVersionResource{Group: "storage.k8s.io", Version: "v1", Resource: "volumeattachments"} -var volumeAttachmentsKind = schema.GroupVersionKind{Group: "storage.k8s.io", Version: "v1", Kind: "VolumeAttachment"} - -type volumeAttachmentsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *volumeAttachmentsClusterClient) Cluster(clusterPath logicalcluster.Path) storagev1client.VolumeAttachmentInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &volumeAttachmentsClient{Fake: c.Fake, ClusterPath: clusterPath} +// volumeAttachmentClusterClient implements VolumeAttachmentClusterInterface +type volumeAttachmentClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*storagev1.VolumeAttachment, *storagev1.VolumeAttachmentList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of VolumeAttachments that match those selectors across all clusters. -func (c *volumeAttachmentsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*storagev1.VolumeAttachmentList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(volumeAttachmentsResource, volumeAttachmentsKind, logicalcluster.Wildcard, opts), &storagev1.VolumeAttachmentList{}) - if obj == nil { - return nil, err +func newFakeVolumeAttachmentClusterClient(fake *StorageV1ClusterClient) typedkcpstoragev1.VolumeAttachmentClusterInterface { + return &volumeAttachmentClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*storagev1.VolumeAttachment, *storagev1.VolumeAttachmentList]( + fake.Fake, + storagev1.SchemeGroupVersion.WithResource("volumeattachments"), + storagev1.SchemeGroupVersion.WithKind("VolumeAttachment"), + func() *storagev1.VolumeAttachment { return &storagev1.VolumeAttachment{} }, + func() *storagev1.VolumeAttachmentList { return &storagev1.VolumeAttachmentList{} }, + func(dst, src *storagev1.VolumeAttachmentList) { dst.ListMeta = src.ListMeta }, + func(list *storagev1.VolumeAttachmentList) []*storagev1.VolumeAttachment { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *storagev1.VolumeAttachmentList, items []*storagev1.VolumeAttachment) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &storagev1.VolumeAttachmentList{ListMeta: obj.(*storagev1.VolumeAttachmentList).ListMeta} - for _, item := range obj.(*storagev1.VolumeAttachmentList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested VolumeAttachments across all clusters. -func (c *volumeAttachmentsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(volumeAttachmentsResource, logicalcluster.Wildcard, opts)) +func (c *volumeAttachmentClusterClient) Cluster(cluster logicalcluster.Path) typedstoragev1.VolumeAttachmentInterface { + return newFakeVolumeAttachmentClient(c.Fake, cluster) } -type volumeAttachmentsClient struct { - *kcptesting.Fake +// volumeAttachmentScopedClient implements VolumeAttachmentInterface +type volumeAttachmentScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*storagev1.VolumeAttachment, *storagev1.VolumeAttachmentList, *v1.VolumeAttachmentApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *volumeAttachmentsClient) Create(ctx context.Context, volumeAttachment *storagev1.VolumeAttachment, opts metav1.CreateOptions) (*storagev1.VolumeAttachment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(volumeAttachmentsResource, c.ClusterPath, volumeAttachment), &storagev1.VolumeAttachment{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1.VolumeAttachment), err -} - -func (c *volumeAttachmentsClient) Update(ctx context.Context, volumeAttachment *storagev1.VolumeAttachment, opts metav1.UpdateOptions) (*storagev1.VolumeAttachment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(volumeAttachmentsResource, c.ClusterPath, volumeAttachment), &storagev1.VolumeAttachment{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1.VolumeAttachment), err -} - -func (c *volumeAttachmentsClient) UpdateStatus(ctx context.Context, volumeAttachment *storagev1.VolumeAttachment, opts metav1.UpdateOptions) (*storagev1.VolumeAttachment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(volumeAttachmentsResource, c.ClusterPath, "status", volumeAttachment), &storagev1.VolumeAttachment{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1.VolumeAttachment), err -} - -func (c *volumeAttachmentsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(volumeAttachmentsResource, c.ClusterPath, name, opts), &storagev1.VolumeAttachment{}) - return err -} - -func (c *volumeAttachmentsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(volumeAttachmentsResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &storagev1.VolumeAttachmentList{}) - return err -} - -func (c *volumeAttachmentsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*storagev1.VolumeAttachment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(volumeAttachmentsResource, c.ClusterPath, name), &storagev1.VolumeAttachment{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1.VolumeAttachment), err -} - -// List takes label and field selectors, and returns the list of VolumeAttachments that match those selectors. -func (c *volumeAttachmentsClient) List(ctx context.Context, opts metav1.ListOptions) (*storagev1.VolumeAttachmentList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(volumeAttachmentsResource, volumeAttachmentsKind, c.ClusterPath, opts), &storagev1.VolumeAttachmentList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &storagev1.VolumeAttachmentList{ListMeta: obj.(*storagev1.VolumeAttachmentList).ListMeta} - for _, item := range obj.(*storagev1.VolumeAttachmentList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *volumeAttachmentsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(volumeAttachmentsResource, c.ClusterPath, opts)) -} - -func (c *volumeAttachmentsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*storagev1.VolumeAttachment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(volumeAttachmentsResource, c.ClusterPath, name, pt, data, subresources...), &storagev1.VolumeAttachment{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1.VolumeAttachment), err -} - -func (c *volumeAttachmentsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsstoragev1.VolumeAttachmentApplyConfiguration, opts metav1.ApplyOptions) (*storagev1.VolumeAttachment, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(volumeAttachmentsResource, c.ClusterPath, *name, types.ApplyPatchType, data), &storagev1.VolumeAttachment{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1.VolumeAttachment), err -} - -func (c *volumeAttachmentsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsstoragev1.VolumeAttachmentApplyConfiguration, opts metav1.ApplyOptions) (*storagev1.VolumeAttachment, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(volumeAttachmentsResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &storagev1.VolumeAttachment{}) - if obj == nil { - return nil, err +func newFakeVolumeAttachmentClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedstoragev1.VolumeAttachmentInterface { + return &volumeAttachmentScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*storagev1.VolumeAttachment, *storagev1.VolumeAttachmentList, *v1.VolumeAttachmentApplyConfiguration]( + fake, + clusterPath, + "", + storagev1.SchemeGroupVersion.WithResource("volumeattachments"), + storagev1.SchemeGroupVersion.WithKind("VolumeAttachment"), + func() *storagev1.VolumeAttachment { return &storagev1.VolumeAttachment{} }, + func() *storagev1.VolumeAttachmentList { return &storagev1.VolumeAttachmentList{} }, + func(dst, src *storagev1.VolumeAttachmentList) { dst.ListMeta = src.ListMeta }, + func(list *storagev1.VolumeAttachmentList) []*storagev1.VolumeAttachment { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *storagev1.VolumeAttachmentList, items []*storagev1.VolumeAttachment) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*storagev1.VolumeAttachment), err } diff --git a/kubernetes/typed/storage/v1/generated_expansion.go b/kubernetes/typed/storage/v1/generated_expansion.go new file mode 100644 index 000000000..f1e6323da --- /dev/null +++ b/kubernetes/typed/storage/v1/generated_expansion.go @@ -0,0 +1,29 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1 + +type CSIDriverClusterExpansion interface{} + +type CSINodeClusterExpansion interface{} + +type CSIStorageCapacityClusterExpansion interface{} + +type StorageClassClusterExpansion interface{} + +type VolumeAttachmentClusterExpansion interface{} diff --git a/kubernetes/typed/storage/v1/storage_client.go b/kubernetes/typed/storage/v1/storage_client.go index f8efc6cea..3ac9877ee 100644 --- a/kubernetes/typed/storage/v1/storage_client.go +++ b/kubernetes/typed/storage/v1/storage_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,33 +14,37 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apistoragev1 "k8s.io/api/storage/v1" storagev1 "k8s.io/client-go/kubernetes/typed/storage/v1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type StorageV1ClusterInterface interface { StorageV1ClusterScoper - StorageClassesClusterGetter - VolumeAttachmentsClusterGetter CSIDriversClusterGetter CSINodesClusterGetter CSIStorageCapacitiesClusterGetter + StorageClassesClusterGetter + VolumeAttachmentsClusterGetter } type StorageV1ClusterScoper interface { Cluster(logicalcluster.Path) storagev1.StorageV1Interface } +// StorageV1ClusterClient is used to interact with features provided by the storage.k8s.io group. type StorageV1ClusterClient struct { clientCache kcpclient.Cache[*storagev1.StorageV1Client] } @@ -52,14 +56,6 @@ func (c *StorageV1ClusterClient) Cluster(clusterPath logicalcluster.Path) storag return c.clientCache.ClusterOrDie(clusterPath) } -func (c *StorageV1ClusterClient) StorageClasses() StorageClassClusterInterface { - return &storageClassesClusterInterface{clientCache: c.clientCache} -} - -func (c *StorageV1ClusterClient) VolumeAttachments() VolumeAttachmentClusterInterface { - return &volumeAttachmentsClusterInterface{clientCache: c.clientCache} -} - func (c *StorageV1ClusterClient) CSIDrivers() CSIDriverClusterInterface { return &cSIDriversClusterInterface{clientCache: c.clientCache} } @@ -72,15 +68,25 @@ func (c *StorageV1ClusterClient) CSIStorageCapacities() CSIStorageCapacityCluste return &cSIStorageCapacitiesClusterInterface{clientCache: c.clientCache} } +func (c *StorageV1ClusterClient) StorageClasses() StorageClassClusterInterface { + return &storageClassesClusterInterface{clientCache: c.clientCache} +} + +func (c *StorageV1ClusterClient) VolumeAttachments() VolumeAttachmentClusterInterface { + return &volumeAttachmentsClusterInterface{clientCache: c.clientCache} +} + // NewForConfig creates a new StorageV1ClusterClient for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*StorageV1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new StorageV1ClusterClient for the given config and http client. @@ -92,6 +98,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*StorageV1ClusterCli if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &StorageV1ClusterClient{clientCache: cache}, nil } @@ -104,3 +111,14 @@ func NewForConfigOrDie(c *rest.Config) *StorageV1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apistoragev1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/storage/v1/storageclass.go b/kubernetes/typed/storage/v1/storageclass.go index b1de112c9..0a0c09550 100644 --- a/kubernetes/typed/storage/v1/storageclass.go +++ b/kubernetes/typed/storage/v1/storageclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - storagev1 "k8s.io/api/storage/v1" + apistoragev1 "k8s.io/api/storage/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - storagev1client "k8s.io/client-go/kubernetes/typed/storage/v1" + watch "k8s.io/apimachinery/pkg/watch" + storagev1 "k8s.io/client-go/kubernetes/typed/storage/v1" ) // StorageClassesClusterGetter has a method to return a StorageClassClusterInterface. @@ -37,19 +37,20 @@ type StorageClassesClusterGetter interface { } // StorageClassClusterInterface can operate on StorageClasses across all clusters, -// or scope down to one cluster and return a storagev1client.StorageClassInterface. +// or scope down to one cluster and return a storagev1.StorageClassInterface. type StorageClassClusterInterface interface { - Cluster(logicalcluster.Path) storagev1client.StorageClassInterface - List(ctx context.Context, opts metav1.ListOptions) (*storagev1.StorageClassList, error) + Cluster(logicalcluster.Path) storagev1.StorageClassInterface + List(ctx context.Context, opts metav1.ListOptions) (*apistoragev1.StorageClassList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + StorageClassClusterExpansion } type storageClassesClusterInterface struct { - clientCache kcpclient.Cache[*storagev1client.StorageV1Client] + clientCache kcpclient.Cache[*storagev1.StorageV1Client] } // Cluster scopes the client down to a particular cluster. -func (c *storageClassesClusterInterface) Cluster(clusterPath logicalcluster.Path) storagev1client.StorageClassInterface { +func (c *storageClassesClusterInterface) Cluster(clusterPath logicalcluster.Path) storagev1.StorageClassInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,7 +59,7 @@ func (c *storageClassesClusterInterface) Cluster(clusterPath logicalcluster.Path } // List returns the entire collection of all StorageClasses across all clusters. -func (c *storageClassesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*storagev1.StorageClassList, error) { +func (c *storageClassesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*apistoragev1.StorageClassList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).StorageClasses().List(ctx, opts) } diff --git a/kubernetes/typed/storage/v1/volumeattachment.go b/kubernetes/typed/storage/v1/volumeattachment.go index 86173e5db..6eb7d7387 100644 --- a/kubernetes/typed/storage/v1/volumeattachment.go +++ b/kubernetes/typed/storage/v1/volumeattachment.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - storagev1 "k8s.io/api/storage/v1" + apistoragev1 "k8s.io/api/storage/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - storagev1client "k8s.io/client-go/kubernetes/typed/storage/v1" + watch "k8s.io/apimachinery/pkg/watch" + storagev1 "k8s.io/client-go/kubernetes/typed/storage/v1" ) // VolumeAttachmentsClusterGetter has a method to return a VolumeAttachmentClusterInterface. @@ -37,19 +37,20 @@ type VolumeAttachmentsClusterGetter interface { } // VolumeAttachmentClusterInterface can operate on VolumeAttachments across all clusters, -// or scope down to one cluster and return a storagev1client.VolumeAttachmentInterface. +// or scope down to one cluster and return a storagev1.VolumeAttachmentInterface. type VolumeAttachmentClusterInterface interface { - Cluster(logicalcluster.Path) storagev1client.VolumeAttachmentInterface - List(ctx context.Context, opts metav1.ListOptions) (*storagev1.VolumeAttachmentList, error) + Cluster(logicalcluster.Path) storagev1.VolumeAttachmentInterface + List(ctx context.Context, opts metav1.ListOptions) (*apistoragev1.VolumeAttachmentList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + VolumeAttachmentClusterExpansion } type volumeAttachmentsClusterInterface struct { - clientCache kcpclient.Cache[*storagev1client.StorageV1Client] + clientCache kcpclient.Cache[*storagev1.StorageV1Client] } // Cluster scopes the client down to a particular cluster. -func (c *volumeAttachmentsClusterInterface) Cluster(clusterPath logicalcluster.Path) storagev1client.VolumeAttachmentInterface { +func (c *volumeAttachmentsClusterInterface) Cluster(clusterPath logicalcluster.Path) storagev1.VolumeAttachmentInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,7 +59,7 @@ func (c *volumeAttachmentsClusterInterface) Cluster(clusterPath logicalcluster.P } // List returns the entire collection of all VolumeAttachments across all clusters. -func (c *volumeAttachmentsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*storagev1.VolumeAttachmentList, error) { +func (c *volumeAttachmentsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*apistoragev1.VolumeAttachmentList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).VolumeAttachments().List(ctx, opts) } diff --git a/kubernetes/typed/storage/v1alpha1/csistoragecapacity.go b/kubernetes/typed/storage/v1alpha1/csistoragecapacity.go index 668ddf339..2fc843af3 100644 --- a/kubernetes/typed/storage/v1alpha1/csistoragecapacity.go +++ b/kubernetes/typed/storage/v1alpha1/csistoragecapacity.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" storagev1alpha1 "k8s.io/api/storage/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - storagev1alpha1client "k8s.io/client-go/kubernetes/typed/storage/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedstoragev1alpha1 "k8s.io/client-go/kubernetes/typed/storage/v1alpha1" ) // CSIStorageCapacitiesClusterGetter has a method to return a CSIStorageCapacityClusterInterface. @@ -40,12 +40,13 @@ type CSIStorageCapacitiesClusterGetter interface { // or scope down to one cluster and return a CSIStorageCapacitiesNamespacer. type CSIStorageCapacityClusterInterface interface { Cluster(logicalcluster.Path) CSIStorageCapacitiesNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*storagev1alpha1.CSIStorageCapacityList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*storagev1alpha1.CSIStorageCapacityList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + CSIStorageCapacityClusterExpansion } type cSIStorageCapacitiesClusterInterface struct { - clientCache kcpclient.Cache[*storagev1alpha1client.StorageV1alpha1Client] + clientCache kcpclient.Cache[*typedstoragev1alpha1.StorageV1alpha1Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *cSIStorageCapacitiesClusterInterface) Cluster(clusterPath logicalcluste } // List returns the entire collection of all CSIStorageCapacities across all clusters. -func (c *cSIStorageCapacitiesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*storagev1alpha1.CSIStorageCapacityList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).CSIStorageCapacities(metav1.NamespaceAll).List(ctx, opts) +func (c *cSIStorageCapacitiesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*storagev1alpha1.CSIStorageCapacityList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).CSIStorageCapacities(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all CSIStorageCapacities across all clusters. -func (c *cSIStorageCapacitiesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).CSIStorageCapacities(metav1.NamespaceAll).Watch(ctx, opts) +func (c *cSIStorageCapacitiesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).CSIStorageCapacities(v1.NamespaceAll).Watch(ctx, opts) } -// CSIStorageCapacitiesNamespacer can scope to objects within a namespace, returning a storagev1alpha1client.CSIStorageCapacityInterface. +// CSIStorageCapacitiesNamespacer can scope to objects within a namespace, returning a typedstoragev1alpha1.CSIStorageCapacityInterface. type CSIStorageCapacitiesNamespacer interface { - Namespace(string) storagev1alpha1client.CSIStorageCapacityInterface + Namespace(string) typedstoragev1alpha1.CSIStorageCapacityInterface } type cSIStorageCapacitiesNamespacer struct { - clientCache kcpclient.Cache[*storagev1alpha1client.StorageV1alpha1Client] + clientCache kcpclient.Cache[*typedstoragev1alpha1.StorageV1alpha1Client] clusterPath logicalcluster.Path } -func (n *cSIStorageCapacitiesNamespacer) Namespace(namespace string) storagev1alpha1client.CSIStorageCapacityInterface { +func (n *cSIStorageCapacitiesNamespacer) Namespace(namespace string) typedstoragev1alpha1.CSIStorageCapacityInterface { return n.clientCache.ClusterOrDie(n.clusterPath).CSIStorageCapacities(namespace) } diff --git a/kubernetes/typed/storage/v1alpha1/doc.go b/kubernetes/typed/storage/v1alpha1/doc.go new file mode 100644 index 000000000..08b80237c --- /dev/null +++ b/kubernetes/typed/storage/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/kubernetes/typed/storage/v1alpha1/fake/csistoragecapacity.go b/kubernetes/typed/storage/v1alpha1/fake/csistoragecapacity.go index 569c9b3a2..514d427f7 100644 --- a/kubernetes/typed/storage/v1alpha1/fake/csistoragecapacity.go +++ b/kubernetes/typed/storage/v1alpha1/fake/csistoragecapacity.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" storagev1alpha1 "k8s.io/api/storage/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsstoragev1alpha1 "k8s.io/client-go/applyconfigurations/storage/v1alpha1" - storagev1alpha1client "k8s.io/client-go/kubernetes/typed/storage/v1alpha1" - "k8s.io/client-go/testing" + v1alpha1 "k8s.io/client-go/applyconfigurations/storage/v1alpha1" + typedstoragev1alpha1 "k8s.io/client-go/kubernetes/typed/storage/v1alpha1" - kcpstoragev1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/storage/v1alpha1" + typedkcpstoragev1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/storage/v1alpha1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var cSIStorageCapacitiesResource = schema.GroupVersionResource{Group: "storage.k8s.io", Version: "v1alpha1", Resource: "csistoragecapacities"} -var cSIStorageCapacitiesKind = schema.GroupVersionKind{Group: "storage.k8s.io", Version: "v1alpha1", Kind: "CSIStorageCapacity"} - -type cSIStorageCapacitiesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *cSIStorageCapacitiesClusterClient) Cluster(clusterPath logicalcluster.Path) kcpstoragev1alpha1.CSIStorageCapacitiesNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &cSIStorageCapacitiesNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// cSIStorageCapacityClusterClient implements CSIStorageCapacityClusterInterface +type cSIStorageCapacityClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*storagev1alpha1.CSIStorageCapacity, *storagev1alpha1.CSIStorageCapacityList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of CSIStorageCapacities that match those selectors across all clusters. -func (c *cSIStorageCapacitiesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*storagev1alpha1.CSIStorageCapacityList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(cSIStorageCapacitiesResource, cSIStorageCapacitiesKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &storagev1alpha1.CSIStorageCapacityList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeCSIStorageCapacityClusterClient(fake *StorageV1alpha1ClusterClient) typedkcpstoragev1alpha1.CSIStorageCapacityClusterInterface { + return &cSIStorageCapacityClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*storagev1alpha1.CSIStorageCapacity, *storagev1alpha1.CSIStorageCapacityList]( + fake.Fake, + storagev1alpha1.SchemeGroupVersion.WithResource("csistoragecapacities"), + storagev1alpha1.SchemeGroupVersion.WithKind("CSIStorageCapacity"), + func() *storagev1alpha1.CSIStorageCapacity { return &storagev1alpha1.CSIStorageCapacity{} }, + func() *storagev1alpha1.CSIStorageCapacityList { return &storagev1alpha1.CSIStorageCapacityList{} }, + func(dst, src *storagev1alpha1.CSIStorageCapacityList) { dst.ListMeta = src.ListMeta }, + func(list *storagev1alpha1.CSIStorageCapacityList) []*storagev1alpha1.CSIStorageCapacity { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *storagev1alpha1.CSIStorageCapacityList, items []*storagev1alpha1.CSIStorageCapacity) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &storagev1alpha1.CSIStorageCapacityList{ListMeta: obj.(*storagev1alpha1.CSIStorageCapacityList).ListMeta} - for _, item := range obj.(*storagev1alpha1.CSIStorageCapacityList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested CSIStorageCapacities across all clusters. -func (c *cSIStorageCapacitiesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(cSIStorageCapacitiesResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *cSIStorageCapacityClusterClient) Cluster(cluster logicalcluster.Path) typedkcpstoragev1alpha1.CSIStorageCapacitiesNamespacer { + return &cSIStorageCapacityNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type cSIStorageCapacitiesNamespacer struct { +type cSIStorageCapacityNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *cSIStorageCapacitiesNamespacer) Namespace(namespace string) storagev1alpha1client.CSIStorageCapacityInterface { - return &cSIStorageCapacitiesClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *cSIStorageCapacityNamespacer) Namespace(namespace string) typedstoragev1alpha1.CSIStorageCapacityInterface { + return newFakeCSIStorageCapacityClient(n.Fake, namespace, n.ClusterPath) } -type cSIStorageCapacitiesClient struct { - *kcptesting.Fake +// cSIStorageCapacityScopedClient implements CSIStorageCapacityInterface +type cSIStorageCapacityScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*storagev1alpha1.CSIStorageCapacity, *storagev1alpha1.CSIStorageCapacityList, *v1alpha1.CSIStorageCapacityApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *cSIStorageCapacitiesClient) Create(ctx context.Context, cSIStorageCapacity *storagev1alpha1.CSIStorageCapacity, opts metav1.CreateOptions) (*storagev1alpha1.CSIStorageCapacity, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(cSIStorageCapacitiesResource, c.ClusterPath, c.Namespace, cSIStorageCapacity), &storagev1alpha1.CSIStorageCapacity{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1alpha1.CSIStorageCapacity), err -} - -func (c *cSIStorageCapacitiesClient) Update(ctx context.Context, cSIStorageCapacity *storagev1alpha1.CSIStorageCapacity, opts metav1.UpdateOptions) (*storagev1alpha1.CSIStorageCapacity, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(cSIStorageCapacitiesResource, c.ClusterPath, c.Namespace, cSIStorageCapacity), &storagev1alpha1.CSIStorageCapacity{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1alpha1.CSIStorageCapacity), err -} - -func (c *cSIStorageCapacitiesClient) UpdateStatus(ctx context.Context, cSIStorageCapacity *storagev1alpha1.CSIStorageCapacity, opts metav1.UpdateOptions) (*storagev1alpha1.CSIStorageCapacity, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(cSIStorageCapacitiesResource, c.ClusterPath, "status", c.Namespace, cSIStorageCapacity), &storagev1alpha1.CSIStorageCapacity{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1alpha1.CSIStorageCapacity), err -} - -func (c *cSIStorageCapacitiesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(cSIStorageCapacitiesResource, c.ClusterPath, c.Namespace, name, opts), &storagev1alpha1.CSIStorageCapacity{}) - return err -} - -func (c *cSIStorageCapacitiesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(cSIStorageCapacitiesResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &storagev1alpha1.CSIStorageCapacityList{}) - return err -} - -func (c *cSIStorageCapacitiesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*storagev1alpha1.CSIStorageCapacity, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(cSIStorageCapacitiesResource, c.ClusterPath, c.Namespace, name), &storagev1alpha1.CSIStorageCapacity{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1alpha1.CSIStorageCapacity), err -} - -// List takes label and field selectors, and returns the list of CSIStorageCapacities that match those selectors. -func (c *cSIStorageCapacitiesClient) List(ctx context.Context, opts metav1.ListOptions) (*storagev1alpha1.CSIStorageCapacityList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(cSIStorageCapacitiesResource, cSIStorageCapacitiesKind, c.ClusterPath, c.Namespace, opts), &storagev1alpha1.CSIStorageCapacityList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &storagev1alpha1.CSIStorageCapacityList{ListMeta: obj.(*storagev1alpha1.CSIStorageCapacityList).ListMeta} - for _, item := range obj.(*storagev1alpha1.CSIStorageCapacityList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *cSIStorageCapacitiesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(cSIStorageCapacitiesResource, c.ClusterPath, c.Namespace, opts)) } -func (c *cSIStorageCapacitiesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*storagev1alpha1.CSIStorageCapacity, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(cSIStorageCapacitiesResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &storagev1alpha1.CSIStorageCapacity{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1alpha1.CSIStorageCapacity), err -} - -func (c *cSIStorageCapacitiesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsstoragev1alpha1.CSIStorageCapacityApplyConfiguration, opts metav1.ApplyOptions) (*storagev1alpha1.CSIStorageCapacity, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(cSIStorageCapacitiesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &storagev1alpha1.CSIStorageCapacity{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1alpha1.CSIStorageCapacity), err -} - -func (c *cSIStorageCapacitiesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsstoragev1alpha1.CSIStorageCapacityApplyConfiguration, opts metav1.ApplyOptions) (*storagev1alpha1.CSIStorageCapacity, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(cSIStorageCapacitiesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &storagev1alpha1.CSIStorageCapacity{}) - if obj == nil { - return nil, err +func newFakeCSIStorageCapacityClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedstoragev1alpha1.CSIStorageCapacityInterface { + return &cSIStorageCapacityScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*storagev1alpha1.CSIStorageCapacity, *storagev1alpha1.CSIStorageCapacityList, *v1alpha1.CSIStorageCapacityApplyConfiguration]( + fake, + clusterPath, + namespace, + storagev1alpha1.SchemeGroupVersion.WithResource("csistoragecapacities"), + storagev1alpha1.SchemeGroupVersion.WithKind("CSIStorageCapacity"), + func() *storagev1alpha1.CSIStorageCapacity { return &storagev1alpha1.CSIStorageCapacity{} }, + func() *storagev1alpha1.CSIStorageCapacityList { return &storagev1alpha1.CSIStorageCapacityList{} }, + func(dst, src *storagev1alpha1.CSIStorageCapacityList) { dst.ListMeta = src.ListMeta }, + func(list *storagev1alpha1.CSIStorageCapacityList) []*storagev1alpha1.CSIStorageCapacity { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *storagev1alpha1.CSIStorageCapacityList, items []*storagev1alpha1.CSIStorageCapacity) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*storagev1alpha1.CSIStorageCapacity), err } diff --git a/kubernetes/typed/storage/v1alpha1/fake/doc.go b/kubernetes/typed/storage/v1alpha1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/storage/v1alpha1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/storage/v1alpha1/fake/storage_client.go b/kubernetes/typed/storage/v1alpha1/fake/storage_client.go index 2b4e64e67..d8da33c6a 100644 --- a/kubernetes/typed/storage/v1alpha1/fake/storage_client.go +++ b/kubernetes/typed/storage/v1alpha1/fake/storage_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" storagev1alpha1 "k8s.io/client-go/kubernetes/typed/storage/v1alpha1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpstoragev1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/storage/v1alpha1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -41,38 +41,38 @@ func (c *StorageV1alpha1ClusterClient) Cluster(clusterPath logicalcluster.Path) return &StorageV1alpha1Client{Fake: c.Fake, ClusterPath: clusterPath} } -func (c *StorageV1alpha1ClusterClient) VolumeAttachments() kcpstoragev1alpha1.VolumeAttachmentClusterInterface { - return &volumeAttachmentsClusterClient{Fake: c.Fake} +func (c *StorageV1alpha1ClusterClient) CSIStorageCapacities() kcpstoragev1alpha1.CSIStorageCapacityClusterInterface { + return newFakeCSIStorageCapacityClusterClient(c) } -func (c *StorageV1alpha1ClusterClient) CSIStorageCapacities() kcpstoragev1alpha1.CSIStorageCapacityClusterInterface { - return &cSIStorageCapacitiesClusterClient{Fake: c.Fake} +func (c *StorageV1alpha1ClusterClient) VolumeAttachments() kcpstoragev1alpha1.VolumeAttachmentClusterInterface { + return newFakeVolumeAttachmentClusterClient(c) } func (c *StorageV1alpha1ClusterClient) VolumeAttributesClasses() kcpstoragev1alpha1.VolumeAttributesClassClusterInterface { - return &volumeAttributesClassesClusterClient{Fake: c.Fake} + return newFakeVolumeAttributesClassClusterClient(c) } -var _ storagev1alpha1.StorageV1alpha1Interface = (*StorageV1alpha1Client)(nil) - type StorageV1alpha1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *StorageV1alpha1Client) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret +func (c *StorageV1alpha1Client) CSIStorageCapacities(namespace string) storagev1alpha1.CSIStorageCapacityInterface { + return newFakeCSIStorageCapacityClient(c.Fake, namespace, c.ClusterPath) } func (c *StorageV1alpha1Client) VolumeAttachments() storagev1alpha1.VolumeAttachmentInterface { - return &volumeAttachmentsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} + return newFakeVolumeAttachmentClient(c.Fake, c.ClusterPath) } -func (c *StorageV1alpha1Client) CSIStorageCapacities(namespace string) storagev1alpha1.CSIStorageCapacityInterface { - return &cSIStorageCapacitiesClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *StorageV1alpha1Client) VolumeAttributesClasses() storagev1alpha1.VolumeAttributesClassInterface { + return newFakeVolumeAttributesClassClient(c.Fake, c.ClusterPath) } -func (c *StorageV1alpha1Client) VolumeAttributesClasses() storagev1alpha1.VolumeAttributesClassInterface { - return &volumeAttributesClassesClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *StorageV1alpha1Client) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret } diff --git a/kubernetes/typed/storage/v1alpha1/fake/volumeattachment.go b/kubernetes/typed/storage/v1alpha1/fake/volumeattachment.go index baff932ae..1b7ba8985 100644 --- a/kubernetes/typed/storage/v1alpha1/fake/volumeattachment.go +++ b/kubernetes/typed/storage/v1alpha1/fake/volumeattachment.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" storagev1alpha1 "k8s.io/api/storage/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsstoragev1alpha1 "k8s.io/client-go/applyconfigurations/storage/v1alpha1" - storagev1alpha1client "k8s.io/client-go/kubernetes/typed/storage/v1alpha1" - "k8s.io/client-go/testing" + v1alpha1 "k8s.io/client-go/applyconfigurations/storage/v1alpha1" + typedstoragev1alpha1 "k8s.io/client-go/kubernetes/typed/storage/v1alpha1" + typedkcpstoragev1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/storage/v1alpha1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var volumeAttachmentsResource = schema.GroupVersionResource{Group: "storage.k8s.io", Version: "v1alpha1", Resource: "volumeattachments"} -var volumeAttachmentsKind = schema.GroupVersionKind{Group: "storage.k8s.io", Version: "v1alpha1", Kind: "VolumeAttachment"} - -type volumeAttachmentsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *volumeAttachmentsClusterClient) Cluster(clusterPath logicalcluster.Path) storagev1alpha1client.VolumeAttachmentInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &volumeAttachmentsClient{Fake: c.Fake, ClusterPath: clusterPath} +// volumeAttachmentClusterClient implements VolumeAttachmentClusterInterface +type volumeAttachmentClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*storagev1alpha1.VolumeAttachment, *storagev1alpha1.VolumeAttachmentList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of VolumeAttachments that match those selectors across all clusters. -func (c *volumeAttachmentsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*storagev1alpha1.VolumeAttachmentList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(volumeAttachmentsResource, volumeAttachmentsKind, logicalcluster.Wildcard, opts), &storagev1alpha1.VolumeAttachmentList{}) - if obj == nil { - return nil, err +func newFakeVolumeAttachmentClusterClient(fake *StorageV1alpha1ClusterClient) typedkcpstoragev1alpha1.VolumeAttachmentClusterInterface { + return &volumeAttachmentClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*storagev1alpha1.VolumeAttachment, *storagev1alpha1.VolumeAttachmentList]( + fake.Fake, + storagev1alpha1.SchemeGroupVersion.WithResource("volumeattachments"), + storagev1alpha1.SchemeGroupVersion.WithKind("VolumeAttachment"), + func() *storagev1alpha1.VolumeAttachment { return &storagev1alpha1.VolumeAttachment{} }, + func() *storagev1alpha1.VolumeAttachmentList { return &storagev1alpha1.VolumeAttachmentList{} }, + func(dst, src *storagev1alpha1.VolumeAttachmentList) { dst.ListMeta = src.ListMeta }, + func(list *storagev1alpha1.VolumeAttachmentList) []*storagev1alpha1.VolumeAttachment { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *storagev1alpha1.VolumeAttachmentList, items []*storagev1alpha1.VolumeAttachment) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &storagev1alpha1.VolumeAttachmentList{ListMeta: obj.(*storagev1alpha1.VolumeAttachmentList).ListMeta} - for _, item := range obj.(*storagev1alpha1.VolumeAttachmentList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested VolumeAttachments across all clusters. -func (c *volumeAttachmentsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(volumeAttachmentsResource, logicalcluster.Wildcard, opts)) +func (c *volumeAttachmentClusterClient) Cluster(cluster logicalcluster.Path) typedstoragev1alpha1.VolumeAttachmentInterface { + return newFakeVolumeAttachmentClient(c.Fake, cluster) } -type volumeAttachmentsClient struct { - *kcptesting.Fake +// volumeAttachmentScopedClient implements VolumeAttachmentInterface +type volumeAttachmentScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*storagev1alpha1.VolumeAttachment, *storagev1alpha1.VolumeAttachmentList, *v1alpha1.VolumeAttachmentApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *volumeAttachmentsClient) Create(ctx context.Context, volumeAttachment *storagev1alpha1.VolumeAttachment, opts metav1.CreateOptions) (*storagev1alpha1.VolumeAttachment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(volumeAttachmentsResource, c.ClusterPath, volumeAttachment), &storagev1alpha1.VolumeAttachment{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1alpha1.VolumeAttachment), err -} - -func (c *volumeAttachmentsClient) Update(ctx context.Context, volumeAttachment *storagev1alpha1.VolumeAttachment, opts metav1.UpdateOptions) (*storagev1alpha1.VolumeAttachment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(volumeAttachmentsResource, c.ClusterPath, volumeAttachment), &storagev1alpha1.VolumeAttachment{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1alpha1.VolumeAttachment), err -} - -func (c *volumeAttachmentsClient) UpdateStatus(ctx context.Context, volumeAttachment *storagev1alpha1.VolumeAttachment, opts metav1.UpdateOptions) (*storagev1alpha1.VolumeAttachment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(volumeAttachmentsResource, c.ClusterPath, "status", volumeAttachment), &storagev1alpha1.VolumeAttachment{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1alpha1.VolumeAttachment), err -} - -func (c *volumeAttachmentsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(volumeAttachmentsResource, c.ClusterPath, name, opts), &storagev1alpha1.VolumeAttachment{}) - return err -} - -func (c *volumeAttachmentsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(volumeAttachmentsResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &storagev1alpha1.VolumeAttachmentList{}) - return err -} - -func (c *volumeAttachmentsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*storagev1alpha1.VolumeAttachment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(volumeAttachmentsResource, c.ClusterPath, name), &storagev1alpha1.VolumeAttachment{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1alpha1.VolumeAttachment), err -} - -// List takes label and field selectors, and returns the list of VolumeAttachments that match those selectors. -func (c *volumeAttachmentsClient) List(ctx context.Context, opts metav1.ListOptions) (*storagev1alpha1.VolumeAttachmentList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(volumeAttachmentsResource, volumeAttachmentsKind, c.ClusterPath, opts), &storagev1alpha1.VolumeAttachmentList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &storagev1alpha1.VolumeAttachmentList{ListMeta: obj.(*storagev1alpha1.VolumeAttachmentList).ListMeta} - for _, item := range obj.(*storagev1alpha1.VolumeAttachmentList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *volumeAttachmentsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(volumeAttachmentsResource, c.ClusterPath, opts)) -} - -func (c *volumeAttachmentsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*storagev1alpha1.VolumeAttachment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(volumeAttachmentsResource, c.ClusterPath, name, pt, data, subresources...), &storagev1alpha1.VolumeAttachment{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1alpha1.VolumeAttachment), err -} - -func (c *volumeAttachmentsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsstoragev1alpha1.VolumeAttachmentApplyConfiguration, opts metav1.ApplyOptions) (*storagev1alpha1.VolumeAttachment, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(volumeAttachmentsResource, c.ClusterPath, *name, types.ApplyPatchType, data), &storagev1alpha1.VolumeAttachment{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1alpha1.VolumeAttachment), err -} - -func (c *volumeAttachmentsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsstoragev1alpha1.VolumeAttachmentApplyConfiguration, opts metav1.ApplyOptions) (*storagev1alpha1.VolumeAttachment, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(volumeAttachmentsResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &storagev1alpha1.VolumeAttachment{}) - if obj == nil { - return nil, err +func newFakeVolumeAttachmentClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedstoragev1alpha1.VolumeAttachmentInterface { + return &volumeAttachmentScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*storagev1alpha1.VolumeAttachment, *storagev1alpha1.VolumeAttachmentList, *v1alpha1.VolumeAttachmentApplyConfiguration]( + fake, + clusterPath, + "", + storagev1alpha1.SchemeGroupVersion.WithResource("volumeattachments"), + storagev1alpha1.SchemeGroupVersion.WithKind("VolumeAttachment"), + func() *storagev1alpha1.VolumeAttachment { return &storagev1alpha1.VolumeAttachment{} }, + func() *storagev1alpha1.VolumeAttachmentList { return &storagev1alpha1.VolumeAttachmentList{} }, + func(dst, src *storagev1alpha1.VolumeAttachmentList) { dst.ListMeta = src.ListMeta }, + func(list *storagev1alpha1.VolumeAttachmentList) []*storagev1alpha1.VolumeAttachment { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *storagev1alpha1.VolumeAttachmentList, items []*storagev1alpha1.VolumeAttachment) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*storagev1alpha1.VolumeAttachment), err } diff --git a/kubernetes/typed/storage/v1alpha1/fake/volumeattributesclass.go b/kubernetes/typed/storage/v1alpha1/fake/volumeattributesclass.go index d8f4b7932..86c3a2c88 100644 --- a/kubernetes/typed/storage/v1alpha1/fake/volumeattributesclass.go +++ b/kubernetes/typed/storage/v1alpha1/fake/volumeattributesclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" storagev1alpha1 "k8s.io/api/storage/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsstoragev1alpha1 "k8s.io/client-go/applyconfigurations/storage/v1alpha1" - storagev1alpha1client "k8s.io/client-go/kubernetes/typed/storage/v1alpha1" - "k8s.io/client-go/testing" + v1alpha1 "k8s.io/client-go/applyconfigurations/storage/v1alpha1" + typedstoragev1alpha1 "k8s.io/client-go/kubernetes/typed/storage/v1alpha1" + typedkcpstoragev1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/storage/v1alpha1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var volumeAttributesClassesResource = schema.GroupVersionResource{Group: "storage.k8s.io", Version: "v1alpha1", Resource: "volumeattributesclasses"} -var volumeAttributesClassesKind = schema.GroupVersionKind{Group: "storage.k8s.io", Version: "v1alpha1", Kind: "VolumeAttributesClass"} - -type volumeAttributesClassesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *volumeAttributesClassesClusterClient) Cluster(clusterPath logicalcluster.Path) storagev1alpha1client.VolumeAttributesClassInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &volumeAttributesClassesClient{Fake: c.Fake, ClusterPath: clusterPath} +// volumeAttributesClassClusterClient implements VolumeAttributesClassClusterInterface +type volumeAttributesClassClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*storagev1alpha1.VolumeAttributesClass, *storagev1alpha1.VolumeAttributesClassList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of VolumeAttributesClasses that match those selectors across all clusters. -func (c *volumeAttributesClassesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*storagev1alpha1.VolumeAttributesClassList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(volumeAttributesClassesResource, volumeAttributesClassesKind, logicalcluster.Wildcard, opts), &storagev1alpha1.VolumeAttributesClassList{}) - if obj == nil { - return nil, err +func newFakeVolumeAttributesClassClusterClient(fake *StorageV1alpha1ClusterClient) typedkcpstoragev1alpha1.VolumeAttributesClassClusterInterface { + return &volumeAttributesClassClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*storagev1alpha1.VolumeAttributesClass, *storagev1alpha1.VolumeAttributesClassList]( + fake.Fake, + storagev1alpha1.SchemeGroupVersion.WithResource("volumeattributesclasses"), + storagev1alpha1.SchemeGroupVersion.WithKind("VolumeAttributesClass"), + func() *storagev1alpha1.VolumeAttributesClass { return &storagev1alpha1.VolumeAttributesClass{} }, + func() *storagev1alpha1.VolumeAttributesClassList { return &storagev1alpha1.VolumeAttributesClassList{} }, + func(dst, src *storagev1alpha1.VolumeAttributesClassList) { dst.ListMeta = src.ListMeta }, + func(list *storagev1alpha1.VolumeAttributesClassList) []*storagev1alpha1.VolumeAttributesClass { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *storagev1alpha1.VolumeAttributesClassList, items []*storagev1alpha1.VolumeAttributesClass) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &storagev1alpha1.VolumeAttributesClassList{ListMeta: obj.(*storagev1alpha1.VolumeAttributesClassList).ListMeta} - for _, item := range obj.(*storagev1alpha1.VolumeAttributesClassList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested VolumeAttributesClasses across all clusters. -func (c *volumeAttributesClassesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(volumeAttributesClassesResource, logicalcluster.Wildcard, opts)) +func (c *volumeAttributesClassClusterClient) Cluster(cluster logicalcluster.Path) typedstoragev1alpha1.VolumeAttributesClassInterface { + return newFakeVolumeAttributesClassClient(c.Fake, cluster) } -type volumeAttributesClassesClient struct { - *kcptesting.Fake +// volumeAttributesClassScopedClient implements VolumeAttributesClassInterface +type volumeAttributesClassScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*storagev1alpha1.VolumeAttributesClass, *storagev1alpha1.VolumeAttributesClassList, *v1alpha1.VolumeAttributesClassApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *volumeAttributesClassesClient) Create(ctx context.Context, volumeAttributesClass *storagev1alpha1.VolumeAttributesClass, opts metav1.CreateOptions) (*storagev1alpha1.VolumeAttributesClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(volumeAttributesClassesResource, c.ClusterPath, volumeAttributesClass), &storagev1alpha1.VolumeAttributesClass{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1alpha1.VolumeAttributesClass), err -} - -func (c *volumeAttributesClassesClient) Update(ctx context.Context, volumeAttributesClass *storagev1alpha1.VolumeAttributesClass, opts metav1.UpdateOptions) (*storagev1alpha1.VolumeAttributesClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(volumeAttributesClassesResource, c.ClusterPath, volumeAttributesClass), &storagev1alpha1.VolumeAttributesClass{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1alpha1.VolumeAttributesClass), err -} - -func (c *volumeAttributesClassesClient) UpdateStatus(ctx context.Context, volumeAttributesClass *storagev1alpha1.VolumeAttributesClass, opts metav1.UpdateOptions) (*storagev1alpha1.VolumeAttributesClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(volumeAttributesClassesResource, c.ClusterPath, "status", volumeAttributesClass), &storagev1alpha1.VolumeAttributesClass{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1alpha1.VolumeAttributesClass), err -} - -func (c *volumeAttributesClassesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(volumeAttributesClassesResource, c.ClusterPath, name, opts), &storagev1alpha1.VolumeAttributesClass{}) - return err -} - -func (c *volumeAttributesClassesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(volumeAttributesClassesResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &storagev1alpha1.VolumeAttributesClassList{}) - return err -} - -func (c *volumeAttributesClassesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*storagev1alpha1.VolumeAttributesClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(volumeAttributesClassesResource, c.ClusterPath, name), &storagev1alpha1.VolumeAttributesClass{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1alpha1.VolumeAttributesClass), err -} - -// List takes label and field selectors, and returns the list of VolumeAttributesClasses that match those selectors. -func (c *volumeAttributesClassesClient) List(ctx context.Context, opts metav1.ListOptions) (*storagev1alpha1.VolumeAttributesClassList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(volumeAttributesClassesResource, volumeAttributesClassesKind, c.ClusterPath, opts), &storagev1alpha1.VolumeAttributesClassList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &storagev1alpha1.VolumeAttributesClassList{ListMeta: obj.(*storagev1alpha1.VolumeAttributesClassList).ListMeta} - for _, item := range obj.(*storagev1alpha1.VolumeAttributesClassList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *volumeAttributesClassesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(volumeAttributesClassesResource, c.ClusterPath, opts)) -} - -func (c *volumeAttributesClassesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*storagev1alpha1.VolumeAttributesClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(volumeAttributesClassesResource, c.ClusterPath, name, pt, data, subresources...), &storagev1alpha1.VolumeAttributesClass{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1alpha1.VolumeAttributesClass), err -} - -func (c *volumeAttributesClassesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsstoragev1alpha1.VolumeAttributesClassApplyConfiguration, opts metav1.ApplyOptions) (*storagev1alpha1.VolumeAttributesClass, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(volumeAttributesClassesResource, c.ClusterPath, *name, types.ApplyPatchType, data), &storagev1alpha1.VolumeAttributesClass{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1alpha1.VolumeAttributesClass), err -} - -func (c *volumeAttributesClassesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsstoragev1alpha1.VolumeAttributesClassApplyConfiguration, opts metav1.ApplyOptions) (*storagev1alpha1.VolumeAttributesClass, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(volumeAttributesClassesResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &storagev1alpha1.VolumeAttributesClass{}) - if obj == nil { - return nil, err +func newFakeVolumeAttributesClassClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedstoragev1alpha1.VolumeAttributesClassInterface { + return &volumeAttributesClassScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*storagev1alpha1.VolumeAttributesClass, *storagev1alpha1.VolumeAttributesClassList, *v1alpha1.VolumeAttributesClassApplyConfiguration]( + fake, + clusterPath, + "", + storagev1alpha1.SchemeGroupVersion.WithResource("volumeattributesclasses"), + storagev1alpha1.SchemeGroupVersion.WithKind("VolumeAttributesClass"), + func() *storagev1alpha1.VolumeAttributesClass { return &storagev1alpha1.VolumeAttributesClass{} }, + func() *storagev1alpha1.VolumeAttributesClassList { return &storagev1alpha1.VolumeAttributesClassList{} }, + func(dst, src *storagev1alpha1.VolumeAttributesClassList) { dst.ListMeta = src.ListMeta }, + func(list *storagev1alpha1.VolumeAttributesClassList) []*storagev1alpha1.VolumeAttributesClass { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *storagev1alpha1.VolumeAttributesClassList, items []*storagev1alpha1.VolumeAttributesClass) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*storagev1alpha1.VolumeAttributesClass), err } diff --git a/kubernetes/typed/storage/v1alpha1/generated_expansion.go b/kubernetes/typed/storage/v1alpha1/generated_expansion.go new file mode 100644 index 000000000..1573d1c17 --- /dev/null +++ b/kubernetes/typed/storage/v1alpha1/generated_expansion.go @@ -0,0 +1,25 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1alpha1 + +type CSIStorageCapacityClusterExpansion interface{} + +type VolumeAttachmentClusterExpansion interface{} + +type VolumeAttributesClassClusterExpansion interface{} diff --git a/kubernetes/typed/storage/v1alpha1/storage_client.go b/kubernetes/typed/storage/v1alpha1/storage_client.go index de6ff4600..b86a268eb 100644 --- a/kubernetes/typed/storage/v1alpha1/storage_client.go +++ b/kubernetes/typed/storage/v1alpha1/storage_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,24 +14,27 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apistoragev1alpha1 "k8s.io/api/storage/v1alpha1" storagev1alpha1 "k8s.io/client-go/kubernetes/typed/storage/v1alpha1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type StorageV1alpha1ClusterInterface interface { StorageV1alpha1ClusterScoper - VolumeAttachmentsClusterGetter CSIStorageCapacitiesClusterGetter + VolumeAttachmentsClusterGetter VolumeAttributesClassesClusterGetter } @@ -39,6 +42,7 @@ type StorageV1alpha1ClusterScoper interface { Cluster(logicalcluster.Path) storagev1alpha1.StorageV1alpha1Interface } +// StorageV1alpha1ClusterClient is used to interact with features provided by the storage.k8s.io group. type StorageV1alpha1ClusterClient struct { clientCache kcpclient.Cache[*storagev1alpha1.StorageV1alpha1Client] } @@ -50,14 +54,14 @@ func (c *StorageV1alpha1ClusterClient) Cluster(clusterPath logicalcluster.Path) return c.clientCache.ClusterOrDie(clusterPath) } -func (c *StorageV1alpha1ClusterClient) VolumeAttachments() VolumeAttachmentClusterInterface { - return &volumeAttachmentsClusterInterface{clientCache: c.clientCache} -} - func (c *StorageV1alpha1ClusterClient) CSIStorageCapacities() CSIStorageCapacityClusterInterface { return &cSIStorageCapacitiesClusterInterface{clientCache: c.clientCache} } +func (c *StorageV1alpha1ClusterClient) VolumeAttachments() VolumeAttachmentClusterInterface { + return &volumeAttachmentsClusterInterface{clientCache: c.clientCache} +} + func (c *StorageV1alpha1ClusterClient) VolumeAttributesClasses() VolumeAttributesClassClusterInterface { return &volumeAttributesClassesClusterInterface{clientCache: c.clientCache} } @@ -66,11 +70,13 @@ func (c *StorageV1alpha1ClusterClient) VolumeAttributesClasses() VolumeAttribute // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*StorageV1alpha1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new StorageV1alpha1ClusterClient for the given config and http client. @@ -82,6 +88,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*StorageV1alpha1Clus if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &StorageV1alpha1ClusterClient{clientCache: cache}, nil } @@ -94,3 +101,14 @@ func NewForConfigOrDie(c *rest.Config) *StorageV1alpha1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apistoragev1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/storage/v1alpha1/volumeattachment.go b/kubernetes/typed/storage/v1alpha1/volumeattachment.go index d42bfe6c1..47f0a248e 100644 --- a/kubernetes/typed/storage/v1alpha1/volumeattachment.go +++ b/kubernetes/typed/storage/v1alpha1/volumeattachment.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - storagev1alpha1 "k8s.io/api/storage/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - storagev1alpha1client "k8s.io/client-go/kubernetes/typed/storage/v1alpha1" + apistoragev1alpha1 "k8s.io/api/storage/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + storagev1alpha1 "k8s.io/client-go/kubernetes/typed/storage/v1alpha1" ) // VolumeAttachmentsClusterGetter has a method to return a VolumeAttachmentClusterInterface. @@ -37,19 +37,20 @@ type VolumeAttachmentsClusterGetter interface { } // VolumeAttachmentClusterInterface can operate on VolumeAttachments across all clusters, -// or scope down to one cluster and return a storagev1alpha1client.VolumeAttachmentInterface. +// or scope down to one cluster and return a storagev1alpha1.VolumeAttachmentInterface. type VolumeAttachmentClusterInterface interface { - Cluster(logicalcluster.Path) storagev1alpha1client.VolumeAttachmentInterface - List(ctx context.Context, opts metav1.ListOptions) (*storagev1alpha1.VolumeAttachmentList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) storagev1alpha1.VolumeAttachmentInterface + List(ctx context.Context, opts v1.ListOptions) (*apistoragev1alpha1.VolumeAttachmentList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + VolumeAttachmentClusterExpansion } type volumeAttachmentsClusterInterface struct { - clientCache kcpclient.Cache[*storagev1alpha1client.StorageV1alpha1Client] + clientCache kcpclient.Cache[*storagev1alpha1.StorageV1alpha1Client] } // Cluster scopes the client down to a particular cluster. -func (c *volumeAttachmentsClusterInterface) Cluster(clusterPath logicalcluster.Path) storagev1alpha1client.VolumeAttachmentInterface { +func (c *volumeAttachmentsClusterInterface) Cluster(clusterPath logicalcluster.Path) storagev1alpha1.VolumeAttachmentInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *volumeAttachmentsClusterInterface) Cluster(clusterPath logicalcluster.P } // List returns the entire collection of all VolumeAttachments across all clusters. -func (c *volumeAttachmentsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*storagev1alpha1.VolumeAttachmentList, error) { +func (c *volumeAttachmentsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apistoragev1alpha1.VolumeAttachmentList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).VolumeAttachments().List(ctx, opts) } // Watch begins to watch all VolumeAttachments across all clusters. -func (c *volumeAttachmentsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *volumeAttachmentsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).VolumeAttachments().Watch(ctx, opts) } diff --git a/kubernetes/typed/storage/v1alpha1/volumeattributesclass.go b/kubernetes/typed/storage/v1alpha1/volumeattributesclass.go index acecfc422..e5f7383d5 100644 --- a/kubernetes/typed/storage/v1alpha1/volumeattributesclass.go +++ b/kubernetes/typed/storage/v1alpha1/volumeattributesclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - storagev1alpha1 "k8s.io/api/storage/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - storagev1alpha1client "k8s.io/client-go/kubernetes/typed/storage/v1alpha1" + apistoragev1alpha1 "k8s.io/api/storage/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + storagev1alpha1 "k8s.io/client-go/kubernetes/typed/storage/v1alpha1" ) // VolumeAttributesClassesClusterGetter has a method to return a VolumeAttributesClassClusterInterface. @@ -37,19 +37,20 @@ type VolumeAttributesClassesClusterGetter interface { } // VolumeAttributesClassClusterInterface can operate on VolumeAttributesClasses across all clusters, -// or scope down to one cluster and return a storagev1alpha1client.VolumeAttributesClassInterface. +// or scope down to one cluster and return a storagev1alpha1.VolumeAttributesClassInterface. type VolumeAttributesClassClusterInterface interface { - Cluster(logicalcluster.Path) storagev1alpha1client.VolumeAttributesClassInterface - List(ctx context.Context, opts metav1.ListOptions) (*storagev1alpha1.VolumeAttributesClassList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) storagev1alpha1.VolumeAttributesClassInterface + List(ctx context.Context, opts v1.ListOptions) (*apistoragev1alpha1.VolumeAttributesClassList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + VolumeAttributesClassClusterExpansion } type volumeAttributesClassesClusterInterface struct { - clientCache kcpclient.Cache[*storagev1alpha1client.StorageV1alpha1Client] + clientCache kcpclient.Cache[*storagev1alpha1.StorageV1alpha1Client] } // Cluster scopes the client down to a particular cluster. -func (c *volumeAttributesClassesClusterInterface) Cluster(clusterPath logicalcluster.Path) storagev1alpha1client.VolumeAttributesClassInterface { +func (c *volumeAttributesClassesClusterInterface) Cluster(clusterPath logicalcluster.Path) storagev1alpha1.VolumeAttributesClassInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *volumeAttributesClassesClusterInterface) Cluster(clusterPath logicalclu } // List returns the entire collection of all VolumeAttributesClasses across all clusters. -func (c *volumeAttributesClassesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*storagev1alpha1.VolumeAttributesClassList, error) { +func (c *volumeAttributesClassesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apistoragev1alpha1.VolumeAttributesClassList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).VolumeAttributesClasses().List(ctx, opts) } // Watch begins to watch all VolumeAttributesClasses across all clusters. -func (c *volumeAttributesClassesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *volumeAttributesClassesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).VolumeAttributesClasses().Watch(ctx, opts) } diff --git a/kubernetes/typed/storage/v1beta1/csidriver.go b/kubernetes/typed/storage/v1beta1/csidriver.go index 3ed6116f8..bd864e96e 100644 --- a/kubernetes/typed/storage/v1beta1/csidriver.go +++ b/kubernetes/typed/storage/v1beta1/csidriver.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - storagev1beta1 "k8s.io/api/storage/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - storagev1beta1client "k8s.io/client-go/kubernetes/typed/storage/v1beta1" + apistoragev1beta1 "k8s.io/api/storage/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + storagev1beta1 "k8s.io/client-go/kubernetes/typed/storage/v1beta1" ) // CSIDriversClusterGetter has a method to return a CSIDriverClusterInterface. @@ -37,19 +37,20 @@ type CSIDriversClusterGetter interface { } // CSIDriverClusterInterface can operate on CSIDrivers across all clusters, -// or scope down to one cluster and return a storagev1beta1client.CSIDriverInterface. +// or scope down to one cluster and return a storagev1beta1.CSIDriverInterface. type CSIDriverClusterInterface interface { - Cluster(logicalcluster.Path) storagev1beta1client.CSIDriverInterface - List(ctx context.Context, opts metav1.ListOptions) (*storagev1beta1.CSIDriverList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) storagev1beta1.CSIDriverInterface + List(ctx context.Context, opts v1.ListOptions) (*apistoragev1beta1.CSIDriverList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + CSIDriverClusterExpansion } type cSIDriversClusterInterface struct { - clientCache kcpclient.Cache[*storagev1beta1client.StorageV1beta1Client] + clientCache kcpclient.Cache[*storagev1beta1.StorageV1beta1Client] } // Cluster scopes the client down to a particular cluster. -func (c *cSIDriversClusterInterface) Cluster(clusterPath logicalcluster.Path) storagev1beta1client.CSIDriverInterface { +func (c *cSIDriversClusterInterface) Cluster(clusterPath logicalcluster.Path) storagev1beta1.CSIDriverInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *cSIDriversClusterInterface) Cluster(clusterPath logicalcluster.Path) st } // List returns the entire collection of all CSIDrivers across all clusters. -func (c *cSIDriversClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*storagev1beta1.CSIDriverList, error) { +func (c *cSIDriversClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apistoragev1beta1.CSIDriverList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).CSIDrivers().List(ctx, opts) } // Watch begins to watch all CSIDrivers across all clusters. -func (c *cSIDriversClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *cSIDriversClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).CSIDrivers().Watch(ctx, opts) } diff --git a/kubernetes/typed/storage/v1beta1/csinode.go b/kubernetes/typed/storage/v1beta1/csinode.go index e0f186a5c..5e8280804 100644 --- a/kubernetes/typed/storage/v1beta1/csinode.go +++ b/kubernetes/typed/storage/v1beta1/csinode.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - storagev1beta1 "k8s.io/api/storage/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - storagev1beta1client "k8s.io/client-go/kubernetes/typed/storage/v1beta1" + apistoragev1beta1 "k8s.io/api/storage/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + storagev1beta1 "k8s.io/client-go/kubernetes/typed/storage/v1beta1" ) // CSINodesClusterGetter has a method to return a CSINodeClusterInterface. @@ -37,19 +37,20 @@ type CSINodesClusterGetter interface { } // CSINodeClusterInterface can operate on CSINodes across all clusters, -// or scope down to one cluster and return a storagev1beta1client.CSINodeInterface. +// or scope down to one cluster and return a storagev1beta1.CSINodeInterface. type CSINodeClusterInterface interface { - Cluster(logicalcluster.Path) storagev1beta1client.CSINodeInterface - List(ctx context.Context, opts metav1.ListOptions) (*storagev1beta1.CSINodeList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) storagev1beta1.CSINodeInterface + List(ctx context.Context, opts v1.ListOptions) (*apistoragev1beta1.CSINodeList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + CSINodeClusterExpansion } type cSINodesClusterInterface struct { - clientCache kcpclient.Cache[*storagev1beta1client.StorageV1beta1Client] + clientCache kcpclient.Cache[*storagev1beta1.StorageV1beta1Client] } // Cluster scopes the client down to a particular cluster. -func (c *cSINodesClusterInterface) Cluster(clusterPath logicalcluster.Path) storagev1beta1client.CSINodeInterface { +func (c *cSINodesClusterInterface) Cluster(clusterPath logicalcluster.Path) storagev1beta1.CSINodeInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *cSINodesClusterInterface) Cluster(clusterPath logicalcluster.Path) stor } // List returns the entire collection of all CSINodes across all clusters. -func (c *cSINodesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*storagev1beta1.CSINodeList, error) { +func (c *cSINodesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apistoragev1beta1.CSINodeList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).CSINodes().List(ctx, opts) } // Watch begins to watch all CSINodes across all clusters. -func (c *cSINodesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *cSINodesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).CSINodes().Watch(ctx, opts) } diff --git a/kubernetes/typed/storage/v1beta1/csistoragecapacity.go b/kubernetes/typed/storage/v1beta1/csistoragecapacity.go index d89629bfa..95b2bdb50 100644 --- a/kubernetes/typed/storage/v1beta1/csistoragecapacity.go +++ b/kubernetes/typed/storage/v1beta1/csistoragecapacity.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" storagev1beta1 "k8s.io/api/storage/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - storagev1beta1client "k8s.io/client-go/kubernetes/typed/storage/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + typedstoragev1beta1 "k8s.io/client-go/kubernetes/typed/storage/v1beta1" ) // CSIStorageCapacitiesClusterGetter has a method to return a CSIStorageCapacityClusterInterface. @@ -40,12 +40,13 @@ type CSIStorageCapacitiesClusterGetter interface { // or scope down to one cluster and return a CSIStorageCapacitiesNamespacer. type CSIStorageCapacityClusterInterface interface { Cluster(logicalcluster.Path) CSIStorageCapacitiesNamespacer - List(ctx context.Context, opts metav1.ListOptions) (*storagev1beta1.CSIStorageCapacityList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + List(ctx context.Context, opts v1.ListOptions) (*storagev1beta1.CSIStorageCapacityList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + CSIStorageCapacityClusterExpansion } type cSIStorageCapacitiesClusterInterface struct { - clientCache kcpclient.Cache[*storagev1beta1client.StorageV1beta1Client] + clientCache kcpclient.Cache[*typedstoragev1beta1.StorageV1beta1Client] } // Cluster scopes the client down to a particular cluster. @@ -58,25 +59,25 @@ func (c *cSIStorageCapacitiesClusterInterface) Cluster(clusterPath logicalcluste } // List returns the entire collection of all CSIStorageCapacities across all clusters. -func (c *cSIStorageCapacitiesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*storagev1beta1.CSIStorageCapacityList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).CSIStorageCapacities(metav1.NamespaceAll).List(ctx, opts) +func (c *cSIStorageCapacitiesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*storagev1beta1.CSIStorageCapacityList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).CSIStorageCapacities(v1.NamespaceAll).List(ctx, opts) } // Watch begins to watch all CSIStorageCapacities across all clusters. -func (c *cSIStorageCapacitiesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).CSIStorageCapacities(metav1.NamespaceAll).Watch(ctx, opts) +func (c *cSIStorageCapacitiesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).CSIStorageCapacities(v1.NamespaceAll).Watch(ctx, opts) } -// CSIStorageCapacitiesNamespacer can scope to objects within a namespace, returning a storagev1beta1client.CSIStorageCapacityInterface. +// CSIStorageCapacitiesNamespacer can scope to objects within a namespace, returning a typedstoragev1beta1.CSIStorageCapacityInterface. type CSIStorageCapacitiesNamespacer interface { - Namespace(string) storagev1beta1client.CSIStorageCapacityInterface + Namespace(string) typedstoragev1beta1.CSIStorageCapacityInterface } type cSIStorageCapacitiesNamespacer struct { - clientCache kcpclient.Cache[*storagev1beta1client.StorageV1beta1Client] + clientCache kcpclient.Cache[*typedstoragev1beta1.StorageV1beta1Client] clusterPath logicalcluster.Path } -func (n *cSIStorageCapacitiesNamespacer) Namespace(namespace string) storagev1beta1client.CSIStorageCapacityInterface { +func (n *cSIStorageCapacitiesNamespacer) Namespace(namespace string) typedstoragev1beta1.CSIStorageCapacityInterface { return n.clientCache.ClusterOrDie(n.clusterPath).CSIStorageCapacities(namespace) } diff --git a/kubernetes/typed/storage/v1beta1/doc.go b/kubernetes/typed/storage/v1beta1/doc.go new file mode 100644 index 000000000..541e9d258 --- /dev/null +++ b/kubernetes/typed/storage/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1beta1 diff --git a/kubernetes/typed/storage/v1beta1/fake/csidriver.go b/kubernetes/typed/storage/v1beta1/fake/csidriver.go index f7e0766ef..0f2bc2d09 100644 --- a/kubernetes/typed/storage/v1beta1/fake/csidriver.go +++ b/kubernetes/typed/storage/v1beta1/fake/csidriver.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" storagev1beta1 "k8s.io/api/storage/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsstoragev1beta1 "k8s.io/client-go/applyconfigurations/storage/v1beta1" - storagev1beta1client "k8s.io/client-go/kubernetes/typed/storage/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/storage/v1beta1" + typedstoragev1beta1 "k8s.io/client-go/kubernetes/typed/storage/v1beta1" + typedkcpstoragev1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/storage/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var cSIDriversResource = schema.GroupVersionResource{Group: "storage.k8s.io", Version: "v1beta1", Resource: "csidrivers"} -var cSIDriversKind = schema.GroupVersionKind{Group: "storage.k8s.io", Version: "v1beta1", Kind: "CSIDriver"} - -type cSIDriversClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *cSIDriversClusterClient) Cluster(clusterPath logicalcluster.Path) storagev1beta1client.CSIDriverInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &cSIDriversClient{Fake: c.Fake, ClusterPath: clusterPath} +// cSIDriverClusterClient implements CSIDriverClusterInterface +type cSIDriverClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*storagev1beta1.CSIDriver, *storagev1beta1.CSIDriverList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of CSIDrivers that match those selectors across all clusters. -func (c *cSIDriversClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*storagev1beta1.CSIDriverList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(cSIDriversResource, cSIDriversKind, logicalcluster.Wildcard, opts), &storagev1beta1.CSIDriverList{}) - if obj == nil { - return nil, err +func newFakeCSIDriverClusterClient(fake *StorageV1beta1ClusterClient) typedkcpstoragev1beta1.CSIDriverClusterInterface { + return &cSIDriverClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*storagev1beta1.CSIDriver, *storagev1beta1.CSIDriverList]( + fake.Fake, + storagev1beta1.SchemeGroupVersion.WithResource("csidrivers"), + storagev1beta1.SchemeGroupVersion.WithKind("CSIDriver"), + func() *storagev1beta1.CSIDriver { return &storagev1beta1.CSIDriver{} }, + func() *storagev1beta1.CSIDriverList { return &storagev1beta1.CSIDriverList{} }, + func(dst, src *storagev1beta1.CSIDriverList) { dst.ListMeta = src.ListMeta }, + func(list *storagev1beta1.CSIDriverList) []*storagev1beta1.CSIDriver { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *storagev1beta1.CSIDriverList, items []*storagev1beta1.CSIDriver) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &storagev1beta1.CSIDriverList{ListMeta: obj.(*storagev1beta1.CSIDriverList).ListMeta} - for _, item := range obj.(*storagev1beta1.CSIDriverList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested CSIDrivers across all clusters. -func (c *cSIDriversClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(cSIDriversResource, logicalcluster.Wildcard, opts)) +func (c *cSIDriverClusterClient) Cluster(cluster logicalcluster.Path) typedstoragev1beta1.CSIDriverInterface { + return newFakeCSIDriverClient(c.Fake, cluster) } -type cSIDriversClient struct { - *kcptesting.Fake +// cSIDriverScopedClient implements CSIDriverInterface +type cSIDriverScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*storagev1beta1.CSIDriver, *storagev1beta1.CSIDriverList, *v1beta1.CSIDriverApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *cSIDriversClient) Create(ctx context.Context, cSIDriver *storagev1beta1.CSIDriver, opts metav1.CreateOptions) (*storagev1beta1.CSIDriver, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(cSIDriversResource, c.ClusterPath, cSIDriver), &storagev1beta1.CSIDriver{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.CSIDriver), err -} - -func (c *cSIDriversClient) Update(ctx context.Context, cSIDriver *storagev1beta1.CSIDriver, opts metav1.UpdateOptions) (*storagev1beta1.CSIDriver, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(cSIDriversResource, c.ClusterPath, cSIDriver), &storagev1beta1.CSIDriver{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.CSIDriver), err -} - -func (c *cSIDriversClient) UpdateStatus(ctx context.Context, cSIDriver *storagev1beta1.CSIDriver, opts metav1.UpdateOptions) (*storagev1beta1.CSIDriver, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(cSIDriversResource, c.ClusterPath, "status", cSIDriver), &storagev1beta1.CSIDriver{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.CSIDriver), err -} - -func (c *cSIDriversClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(cSIDriversResource, c.ClusterPath, name, opts), &storagev1beta1.CSIDriver{}) - return err -} - -func (c *cSIDriversClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(cSIDriversResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &storagev1beta1.CSIDriverList{}) - return err -} - -func (c *cSIDriversClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*storagev1beta1.CSIDriver, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(cSIDriversResource, c.ClusterPath, name), &storagev1beta1.CSIDriver{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.CSIDriver), err -} - -// List takes label and field selectors, and returns the list of CSIDrivers that match those selectors. -func (c *cSIDriversClient) List(ctx context.Context, opts metav1.ListOptions) (*storagev1beta1.CSIDriverList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(cSIDriversResource, cSIDriversKind, c.ClusterPath, opts), &storagev1beta1.CSIDriverList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &storagev1beta1.CSIDriverList{ListMeta: obj.(*storagev1beta1.CSIDriverList).ListMeta} - for _, item := range obj.(*storagev1beta1.CSIDriverList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *cSIDriversClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(cSIDriversResource, c.ClusterPath, opts)) -} - -func (c *cSIDriversClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*storagev1beta1.CSIDriver, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(cSIDriversResource, c.ClusterPath, name, pt, data, subresources...), &storagev1beta1.CSIDriver{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.CSIDriver), err -} - -func (c *cSIDriversClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsstoragev1beta1.CSIDriverApplyConfiguration, opts metav1.ApplyOptions) (*storagev1beta1.CSIDriver, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(cSIDriversResource, c.ClusterPath, *name, types.ApplyPatchType, data), &storagev1beta1.CSIDriver{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.CSIDriver), err -} - -func (c *cSIDriversClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsstoragev1beta1.CSIDriverApplyConfiguration, opts metav1.ApplyOptions) (*storagev1beta1.CSIDriver, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(cSIDriversResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &storagev1beta1.CSIDriver{}) - if obj == nil { - return nil, err +func newFakeCSIDriverClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedstoragev1beta1.CSIDriverInterface { + return &cSIDriverScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*storagev1beta1.CSIDriver, *storagev1beta1.CSIDriverList, *v1beta1.CSIDriverApplyConfiguration]( + fake, + clusterPath, + "", + storagev1beta1.SchemeGroupVersion.WithResource("csidrivers"), + storagev1beta1.SchemeGroupVersion.WithKind("CSIDriver"), + func() *storagev1beta1.CSIDriver { return &storagev1beta1.CSIDriver{} }, + func() *storagev1beta1.CSIDriverList { return &storagev1beta1.CSIDriverList{} }, + func(dst, src *storagev1beta1.CSIDriverList) { dst.ListMeta = src.ListMeta }, + func(list *storagev1beta1.CSIDriverList) []*storagev1beta1.CSIDriver { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *storagev1beta1.CSIDriverList, items []*storagev1beta1.CSIDriver) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*storagev1beta1.CSIDriver), err } diff --git a/kubernetes/typed/storage/v1beta1/fake/csinode.go b/kubernetes/typed/storage/v1beta1/fake/csinode.go index 0cad78cef..0d289faec 100644 --- a/kubernetes/typed/storage/v1beta1/fake/csinode.go +++ b/kubernetes/typed/storage/v1beta1/fake/csinode.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" storagev1beta1 "k8s.io/api/storage/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsstoragev1beta1 "k8s.io/client-go/applyconfigurations/storage/v1beta1" - storagev1beta1client "k8s.io/client-go/kubernetes/typed/storage/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/storage/v1beta1" + typedstoragev1beta1 "k8s.io/client-go/kubernetes/typed/storage/v1beta1" + typedkcpstoragev1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/storage/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var cSINodesResource = schema.GroupVersionResource{Group: "storage.k8s.io", Version: "v1beta1", Resource: "csinodes"} -var cSINodesKind = schema.GroupVersionKind{Group: "storage.k8s.io", Version: "v1beta1", Kind: "CSINode"} - -type cSINodesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *cSINodesClusterClient) Cluster(clusterPath logicalcluster.Path) storagev1beta1client.CSINodeInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &cSINodesClient{Fake: c.Fake, ClusterPath: clusterPath} +// cSINodeClusterClient implements CSINodeClusterInterface +type cSINodeClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*storagev1beta1.CSINode, *storagev1beta1.CSINodeList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of CSINodes that match those selectors across all clusters. -func (c *cSINodesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*storagev1beta1.CSINodeList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(cSINodesResource, cSINodesKind, logicalcluster.Wildcard, opts), &storagev1beta1.CSINodeList{}) - if obj == nil { - return nil, err +func newFakeCSINodeClusterClient(fake *StorageV1beta1ClusterClient) typedkcpstoragev1beta1.CSINodeClusterInterface { + return &cSINodeClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*storagev1beta1.CSINode, *storagev1beta1.CSINodeList]( + fake.Fake, + storagev1beta1.SchemeGroupVersion.WithResource("csinodes"), + storagev1beta1.SchemeGroupVersion.WithKind("CSINode"), + func() *storagev1beta1.CSINode { return &storagev1beta1.CSINode{} }, + func() *storagev1beta1.CSINodeList { return &storagev1beta1.CSINodeList{} }, + func(dst, src *storagev1beta1.CSINodeList) { dst.ListMeta = src.ListMeta }, + func(list *storagev1beta1.CSINodeList) []*storagev1beta1.CSINode { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *storagev1beta1.CSINodeList, items []*storagev1beta1.CSINode) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &storagev1beta1.CSINodeList{ListMeta: obj.(*storagev1beta1.CSINodeList).ListMeta} - for _, item := range obj.(*storagev1beta1.CSINodeList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested CSINodes across all clusters. -func (c *cSINodesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(cSINodesResource, logicalcluster.Wildcard, opts)) +func (c *cSINodeClusterClient) Cluster(cluster logicalcluster.Path) typedstoragev1beta1.CSINodeInterface { + return newFakeCSINodeClient(c.Fake, cluster) } -type cSINodesClient struct { - *kcptesting.Fake +// cSINodeScopedClient implements CSINodeInterface +type cSINodeScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*storagev1beta1.CSINode, *storagev1beta1.CSINodeList, *v1beta1.CSINodeApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *cSINodesClient) Create(ctx context.Context, cSINode *storagev1beta1.CSINode, opts metav1.CreateOptions) (*storagev1beta1.CSINode, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(cSINodesResource, c.ClusterPath, cSINode), &storagev1beta1.CSINode{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.CSINode), err -} - -func (c *cSINodesClient) Update(ctx context.Context, cSINode *storagev1beta1.CSINode, opts metav1.UpdateOptions) (*storagev1beta1.CSINode, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(cSINodesResource, c.ClusterPath, cSINode), &storagev1beta1.CSINode{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.CSINode), err -} - -func (c *cSINodesClient) UpdateStatus(ctx context.Context, cSINode *storagev1beta1.CSINode, opts metav1.UpdateOptions) (*storagev1beta1.CSINode, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(cSINodesResource, c.ClusterPath, "status", cSINode), &storagev1beta1.CSINode{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.CSINode), err -} - -func (c *cSINodesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(cSINodesResource, c.ClusterPath, name, opts), &storagev1beta1.CSINode{}) - return err -} - -func (c *cSINodesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(cSINodesResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &storagev1beta1.CSINodeList{}) - return err -} - -func (c *cSINodesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*storagev1beta1.CSINode, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(cSINodesResource, c.ClusterPath, name), &storagev1beta1.CSINode{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.CSINode), err -} - -// List takes label and field selectors, and returns the list of CSINodes that match those selectors. -func (c *cSINodesClient) List(ctx context.Context, opts metav1.ListOptions) (*storagev1beta1.CSINodeList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(cSINodesResource, cSINodesKind, c.ClusterPath, opts), &storagev1beta1.CSINodeList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &storagev1beta1.CSINodeList{ListMeta: obj.(*storagev1beta1.CSINodeList).ListMeta} - for _, item := range obj.(*storagev1beta1.CSINodeList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *cSINodesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(cSINodesResource, c.ClusterPath, opts)) -} - -func (c *cSINodesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*storagev1beta1.CSINode, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(cSINodesResource, c.ClusterPath, name, pt, data, subresources...), &storagev1beta1.CSINode{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.CSINode), err -} - -func (c *cSINodesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsstoragev1beta1.CSINodeApplyConfiguration, opts metav1.ApplyOptions) (*storagev1beta1.CSINode, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(cSINodesResource, c.ClusterPath, *name, types.ApplyPatchType, data), &storagev1beta1.CSINode{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.CSINode), err -} - -func (c *cSINodesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsstoragev1beta1.CSINodeApplyConfiguration, opts metav1.ApplyOptions) (*storagev1beta1.CSINode, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(cSINodesResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &storagev1beta1.CSINode{}) - if obj == nil { - return nil, err +func newFakeCSINodeClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedstoragev1beta1.CSINodeInterface { + return &cSINodeScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*storagev1beta1.CSINode, *storagev1beta1.CSINodeList, *v1beta1.CSINodeApplyConfiguration]( + fake, + clusterPath, + "", + storagev1beta1.SchemeGroupVersion.WithResource("csinodes"), + storagev1beta1.SchemeGroupVersion.WithKind("CSINode"), + func() *storagev1beta1.CSINode { return &storagev1beta1.CSINode{} }, + func() *storagev1beta1.CSINodeList { return &storagev1beta1.CSINodeList{} }, + func(dst, src *storagev1beta1.CSINodeList) { dst.ListMeta = src.ListMeta }, + func(list *storagev1beta1.CSINodeList) []*storagev1beta1.CSINode { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *storagev1beta1.CSINodeList, items []*storagev1beta1.CSINode) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*storagev1beta1.CSINode), err } diff --git a/kubernetes/typed/storage/v1beta1/fake/csistoragecapacity.go b/kubernetes/typed/storage/v1beta1/fake/csistoragecapacity.go index dda2c925f..9bb3a59a3 100644 --- a/kubernetes/typed/storage/v1beta1/fake/csistoragecapacity.go +++ b/kubernetes/typed/storage/v1beta1/fake/csistoragecapacity.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,197 +14,87 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" storagev1beta1 "k8s.io/api/storage/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsstoragev1beta1 "k8s.io/client-go/applyconfigurations/storage/v1beta1" - storagev1beta1client "k8s.io/client-go/kubernetes/typed/storage/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/storage/v1beta1" + typedstoragev1beta1 "k8s.io/client-go/kubernetes/typed/storage/v1beta1" - kcpstoragev1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/storage/v1beta1" + typedkcpstoragev1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/storage/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var cSIStorageCapacitiesResource = schema.GroupVersionResource{Group: "storage.k8s.io", Version: "v1beta1", Resource: "csistoragecapacities"} -var cSIStorageCapacitiesKind = schema.GroupVersionKind{Group: "storage.k8s.io", Version: "v1beta1", Kind: "CSIStorageCapacity"} - -type cSIStorageCapacitiesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *cSIStorageCapacitiesClusterClient) Cluster(clusterPath logicalcluster.Path) kcpstoragev1beta1.CSIStorageCapacitiesNamespacer { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &cSIStorageCapacitiesNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +// cSIStorageCapacityClusterClient implements CSIStorageCapacityClusterInterface +type cSIStorageCapacityClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*storagev1beta1.CSIStorageCapacity, *storagev1beta1.CSIStorageCapacityList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of CSIStorageCapacities that match those selectors across all clusters. -func (c *cSIStorageCapacitiesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*storagev1beta1.CSIStorageCapacityList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(cSIStorageCapacitiesResource, cSIStorageCapacitiesKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &storagev1beta1.CSIStorageCapacityList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() +func newFakeCSIStorageCapacityClusterClient(fake *StorageV1beta1ClusterClient) typedkcpstoragev1beta1.CSIStorageCapacityClusterInterface { + return &cSIStorageCapacityClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*storagev1beta1.CSIStorageCapacity, *storagev1beta1.CSIStorageCapacityList]( + fake.Fake, + storagev1beta1.SchemeGroupVersion.WithResource("csistoragecapacities"), + storagev1beta1.SchemeGroupVersion.WithKind("CSIStorageCapacity"), + func() *storagev1beta1.CSIStorageCapacity { return &storagev1beta1.CSIStorageCapacity{} }, + func() *storagev1beta1.CSIStorageCapacityList { return &storagev1beta1.CSIStorageCapacityList{} }, + func(dst, src *storagev1beta1.CSIStorageCapacityList) { dst.ListMeta = src.ListMeta }, + func(list *storagev1beta1.CSIStorageCapacityList) []*storagev1beta1.CSIStorageCapacity { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *storagev1beta1.CSIStorageCapacityList, items []*storagev1beta1.CSIStorageCapacity) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - list := &storagev1beta1.CSIStorageCapacityList{ListMeta: obj.(*storagev1beta1.CSIStorageCapacityList).ListMeta} - for _, item := range obj.(*storagev1beta1.CSIStorageCapacityList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested CSIStorageCapacities across all clusters. -func (c *cSIStorageCapacitiesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(cSIStorageCapacitiesResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +func (c *cSIStorageCapacityClusterClient) Cluster(cluster logicalcluster.Path) typedkcpstoragev1beta1.CSIStorageCapacitiesNamespacer { + return &cSIStorageCapacityNamespacer{Fake: c.Fake, ClusterPath: cluster} } -type cSIStorageCapacitiesNamespacer struct { +type cSIStorageCapacityNamespacer struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (n *cSIStorageCapacitiesNamespacer) Namespace(namespace string) storagev1beta1client.CSIStorageCapacityInterface { - return &cSIStorageCapacitiesClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +func (n *cSIStorageCapacityNamespacer) Namespace(namespace string) typedstoragev1beta1.CSIStorageCapacityInterface { + return newFakeCSIStorageCapacityClient(n.Fake, namespace, n.ClusterPath) } -type cSIStorageCapacitiesClient struct { - *kcptesting.Fake +// cSIStorageCapacityScopedClient implements CSIStorageCapacityInterface +type cSIStorageCapacityScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*storagev1beta1.CSIStorageCapacity, *storagev1beta1.CSIStorageCapacityList, *v1beta1.CSIStorageCapacityApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string -} - -func (c *cSIStorageCapacitiesClient) Create(ctx context.Context, cSIStorageCapacity *storagev1beta1.CSIStorageCapacity, opts metav1.CreateOptions) (*storagev1beta1.CSIStorageCapacity, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(cSIStorageCapacitiesResource, c.ClusterPath, c.Namespace, cSIStorageCapacity), &storagev1beta1.CSIStorageCapacity{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.CSIStorageCapacity), err -} - -func (c *cSIStorageCapacitiesClient) Update(ctx context.Context, cSIStorageCapacity *storagev1beta1.CSIStorageCapacity, opts metav1.UpdateOptions) (*storagev1beta1.CSIStorageCapacity, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(cSIStorageCapacitiesResource, c.ClusterPath, c.Namespace, cSIStorageCapacity), &storagev1beta1.CSIStorageCapacity{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.CSIStorageCapacity), err -} - -func (c *cSIStorageCapacitiesClient) UpdateStatus(ctx context.Context, cSIStorageCapacity *storagev1beta1.CSIStorageCapacity, opts metav1.UpdateOptions) (*storagev1beta1.CSIStorageCapacity, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(cSIStorageCapacitiesResource, c.ClusterPath, "status", c.Namespace, cSIStorageCapacity), &storagev1beta1.CSIStorageCapacity{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.CSIStorageCapacity), err -} - -func (c *cSIStorageCapacitiesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(cSIStorageCapacitiesResource, c.ClusterPath, c.Namespace, name, opts), &storagev1beta1.CSIStorageCapacity{}) - return err -} - -func (c *cSIStorageCapacitiesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(cSIStorageCapacitiesResource, c.ClusterPath, c.Namespace, listOpts) - - _, err := c.Fake.Invokes(action, &storagev1beta1.CSIStorageCapacityList{}) - return err -} - -func (c *cSIStorageCapacitiesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*storagev1beta1.CSIStorageCapacity, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(cSIStorageCapacitiesResource, c.ClusterPath, c.Namespace, name), &storagev1beta1.CSIStorageCapacity{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.CSIStorageCapacity), err -} - -// List takes label and field selectors, and returns the list of CSIStorageCapacities that match those selectors. -func (c *cSIStorageCapacitiesClient) List(ctx context.Context, opts metav1.ListOptions) (*storagev1beta1.CSIStorageCapacityList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(cSIStorageCapacitiesResource, cSIStorageCapacitiesKind, c.ClusterPath, c.Namespace, opts), &storagev1beta1.CSIStorageCapacityList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &storagev1beta1.CSIStorageCapacityList{ListMeta: obj.(*storagev1beta1.CSIStorageCapacityList).ListMeta} - for _, item := range obj.(*storagev1beta1.CSIStorageCapacityList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *cSIStorageCapacitiesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(cSIStorageCapacitiesResource, c.ClusterPath, c.Namespace, opts)) } -func (c *cSIStorageCapacitiesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*storagev1beta1.CSIStorageCapacity, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(cSIStorageCapacitiesResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &storagev1beta1.CSIStorageCapacity{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.CSIStorageCapacity), err -} - -func (c *cSIStorageCapacitiesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsstoragev1beta1.CSIStorageCapacityApplyConfiguration, opts metav1.ApplyOptions) (*storagev1beta1.CSIStorageCapacity, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(cSIStorageCapacitiesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &storagev1beta1.CSIStorageCapacity{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.CSIStorageCapacity), err -} - -func (c *cSIStorageCapacitiesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsstoragev1beta1.CSIStorageCapacityApplyConfiguration, opts metav1.ApplyOptions) (*storagev1beta1.CSIStorageCapacity, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(cSIStorageCapacitiesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &storagev1beta1.CSIStorageCapacity{}) - if obj == nil { - return nil, err +func newFakeCSIStorageCapacityClient(fake *kcptesting.Fake, namespace string, clusterPath logicalcluster.Path) typedstoragev1beta1.CSIStorageCapacityInterface { + return &cSIStorageCapacityScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*storagev1beta1.CSIStorageCapacity, *storagev1beta1.CSIStorageCapacityList, *v1beta1.CSIStorageCapacityApplyConfiguration]( + fake, + clusterPath, + namespace, + storagev1beta1.SchemeGroupVersion.WithResource("csistoragecapacities"), + storagev1beta1.SchemeGroupVersion.WithKind("CSIStorageCapacity"), + func() *storagev1beta1.CSIStorageCapacity { return &storagev1beta1.CSIStorageCapacity{} }, + func() *storagev1beta1.CSIStorageCapacityList { return &storagev1beta1.CSIStorageCapacityList{} }, + func(dst, src *storagev1beta1.CSIStorageCapacityList) { dst.ListMeta = src.ListMeta }, + func(list *storagev1beta1.CSIStorageCapacityList) []*storagev1beta1.CSIStorageCapacity { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *storagev1beta1.CSIStorageCapacityList, items []*storagev1beta1.CSIStorageCapacity) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*storagev1beta1.CSIStorageCapacity), err } diff --git a/kubernetes/typed/storage/v1beta1/fake/doc.go b/kubernetes/typed/storage/v1beta1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/storage/v1beta1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/storage/v1beta1/fake/storage_client.go b/kubernetes/typed/storage/v1beta1/fake/storage_client.go index 605641758..66dda405b 100644 --- a/kubernetes/typed/storage/v1beta1/fake/storage_client.go +++ b/kubernetes/typed/storage/v1beta1/fake/storage_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" storagev1beta1 "k8s.io/client-go/kubernetes/typed/storage/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpstoragev1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/storage/v1beta1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -41,62 +41,62 @@ func (c *StorageV1beta1ClusterClient) Cluster(clusterPath logicalcluster.Path) s return &StorageV1beta1Client{Fake: c.Fake, ClusterPath: clusterPath} } -func (c *StorageV1beta1ClusterClient) StorageClasses() kcpstoragev1beta1.StorageClassClusterInterface { - return &storageClassesClusterClient{Fake: c.Fake} +func (c *StorageV1beta1ClusterClient) CSIDrivers() kcpstoragev1beta1.CSIDriverClusterInterface { + return newFakeCSIDriverClusterClient(c) } -func (c *StorageV1beta1ClusterClient) VolumeAttachments() kcpstoragev1beta1.VolumeAttachmentClusterInterface { - return &volumeAttachmentsClusterClient{Fake: c.Fake} +func (c *StorageV1beta1ClusterClient) CSINodes() kcpstoragev1beta1.CSINodeClusterInterface { + return newFakeCSINodeClusterClient(c) } -func (c *StorageV1beta1ClusterClient) CSIDrivers() kcpstoragev1beta1.CSIDriverClusterInterface { - return &cSIDriversClusterClient{Fake: c.Fake} +func (c *StorageV1beta1ClusterClient) CSIStorageCapacities() kcpstoragev1beta1.CSIStorageCapacityClusterInterface { + return newFakeCSIStorageCapacityClusterClient(c) } -func (c *StorageV1beta1ClusterClient) CSINodes() kcpstoragev1beta1.CSINodeClusterInterface { - return &cSINodesClusterClient{Fake: c.Fake} +func (c *StorageV1beta1ClusterClient) StorageClasses() kcpstoragev1beta1.StorageClassClusterInterface { + return newFakeStorageClassClusterClient(c) } -func (c *StorageV1beta1ClusterClient) CSIStorageCapacities() kcpstoragev1beta1.CSIStorageCapacityClusterInterface { - return &cSIStorageCapacitiesClusterClient{Fake: c.Fake} +func (c *StorageV1beta1ClusterClient) VolumeAttachments() kcpstoragev1beta1.VolumeAttachmentClusterInterface { + return newFakeVolumeAttachmentClusterClient(c) } func (c *StorageV1beta1ClusterClient) VolumeAttributesClasses() kcpstoragev1beta1.VolumeAttributesClassClusterInterface { - return &volumeAttributesClassesClusterClient{Fake: c.Fake} + return newFakeVolumeAttributesClassClusterClient(c) } -var _ storagev1beta1.StorageV1beta1Interface = (*StorageV1beta1Client)(nil) - type StorageV1beta1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *StorageV1beta1Client) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret +func (c *StorageV1beta1Client) CSIDrivers() storagev1beta1.CSIDriverInterface { + return newFakeCSIDriverClient(c.Fake, c.ClusterPath) } -func (c *StorageV1beta1Client) StorageClasses() storagev1beta1.StorageClassInterface { - return &storageClassesClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +func (c *StorageV1beta1Client) CSINodes() storagev1beta1.CSINodeInterface { + return newFakeCSINodeClient(c.Fake, c.ClusterPath) } -func (c *StorageV1beta1Client) VolumeAttachments() storagev1beta1.VolumeAttachmentInterface { - return &volumeAttachmentsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +func (c *StorageV1beta1Client) CSIStorageCapacities(namespace string) storagev1beta1.CSIStorageCapacityInterface { + return newFakeCSIStorageCapacityClient(c.Fake, namespace, c.ClusterPath) } -func (c *StorageV1beta1Client) CSIDrivers() storagev1beta1.CSIDriverInterface { - return &cSIDriversClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +func (c *StorageV1beta1Client) StorageClasses() storagev1beta1.StorageClassInterface { + return newFakeStorageClassClient(c.Fake, c.ClusterPath) } -func (c *StorageV1beta1Client) CSINodes() storagev1beta1.CSINodeInterface { - return &cSINodesClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +func (c *StorageV1beta1Client) VolumeAttachments() storagev1beta1.VolumeAttachmentInterface { + return newFakeVolumeAttachmentClient(c.Fake, c.ClusterPath) } -func (c *StorageV1beta1Client) CSIStorageCapacities(namespace string) storagev1beta1.CSIStorageCapacityInterface { - return &cSIStorageCapacitiesClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *StorageV1beta1Client) VolumeAttributesClasses() storagev1beta1.VolumeAttributesClassInterface { + return newFakeVolumeAttributesClassClient(c.Fake, c.ClusterPath) } -func (c *StorageV1beta1Client) VolumeAttributesClasses() storagev1beta1.VolumeAttributesClassInterface { - return &volumeAttributesClassesClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *StorageV1beta1Client) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret } diff --git a/kubernetes/typed/storage/v1beta1/fake/storageclass.go b/kubernetes/typed/storage/v1beta1/fake/storageclass.go index 67f98af09..a79d2c9a5 100644 --- a/kubernetes/typed/storage/v1beta1/fake/storageclass.go +++ b/kubernetes/typed/storage/v1beta1/fake/storageclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" storagev1beta1 "k8s.io/api/storage/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsstoragev1beta1 "k8s.io/client-go/applyconfigurations/storage/v1beta1" - storagev1beta1client "k8s.io/client-go/kubernetes/typed/storage/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/storage/v1beta1" + typedstoragev1beta1 "k8s.io/client-go/kubernetes/typed/storage/v1beta1" + typedkcpstoragev1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/storage/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var storageClassesResource = schema.GroupVersionResource{Group: "storage.k8s.io", Version: "v1beta1", Resource: "storageclasses"} -var storageClassesKind = schema.GroupVersionKind{Group: "storage.k8s.io", Version: "v1beta1", Kind: "StorageClass"} - -type storageClassesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *storageClassesClusterClient) Cluster(clusterPath logicalcluster.Path) storagev1beta1client.StorageClassInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &storageClassesClient{Fake: c.Fake, ClusterPath: clusterPath} +// storageClassClusterClient implements StorageClassClusterInterface +type storageClassClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*storagev1beta1.StorageClass, *storagev1beta1.StorageClassList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of StorageClasses that match those selectors across all clusters. -func (c *storageClassesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*storagev1beta1.StorageClassList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(storageClassesResource, storageClassesKind, logicalcluster.Wildcard, opts), &storagev1beta1.StorageClassList{}) - if obj == nil { - return nil, err +func newFakeStorageClassClusterClient(fake *StorageV1beta1ClusterClient) typedkcpstoragev1beta1.StorageClassClusterInterface { + return &storageClassClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*storagev1beta1.StorageClass, *storagev1beta1.StorageClassList]( + fake.Fake, + storagev1beta1.SchemeGroupVersion.WithResource("storageclasses"), + storagev1beta1.SchemeGroupVersion.WithKind("StorageClass"), + func() *storagev1beta1.StorageClass { return &storagev1beta1.StorageClass{} }, + func() *storagev1beta1.StorageClassList { return &storagev1beta1.StorageClassList{} }, + func(dst, src *storagev1beta1.StorageClassList) { dst.ListMeta = src.ListMeta }, + func(list *storagev1beta1.StorageClassList) []*storagev1beta1.StorageClass { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *storagev1beta1.StorageClassList, items []*storagev1beta1.StorageClass) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &storagev1beta1.StorageClassList{ListMeta: obj.(*storagev1beta1.StorageClassList).ListMeta} - for _, item := range obj.(*storagev1beta1.StorageClassList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested StorageClasses across all clusters. -func (c *storageClassesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(storageClassesResource, logicalcluster.Wildcard, opts)) +func (c *storageClassClusterClient) Cluster(cluster logicalcluster.Path) typedstoragev1beta1.StorageClassInterface { + return newFakeStorageClassClient(c.Fake, cluster) } -type storageClassesClient struct { - *kcptesting.Fake +// storageClassScopedClient implements StorageClassInterface +type storageClassScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*storagev1beta1.StorageClass, *storagev1beta1.StorageClassList, *v1beta1.StorageClassApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *storageClassesClient) Create(ctx context.Context, storageClass *storagev1beta1.StorageClass, opts metav1.CreateOptions) (*storagev1beta1.StorageClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(storageClassesResource, c.ClusterPath, storageClass), &storagev1beta1.StorageClass{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.StorageClass), err -} - -func (c *storageClassesClient) Update(ctx context.Context, storageClass *storagev1beta1.StorageClass, opts metav1.UpdateOptions) (*storagev1beta1.StorageClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(storageClassesResource, c.ClusterPath, storageClass), &storagev1beta1.StorageClass{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.StorageClass), err -} - -func (c *storageClassesClient) UpdateStatus(ctx context.Context, storageClass *storagev1beta1.StorageClass, opts metav1.UpdateOptions) (*storagev1beta1.StorageClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(storageClassesResource, c.ClusterPath, "status", storageClass), &storagev1beta1.StorageClass{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.StorageClass), err -} - -func (c *storageClassesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(storageClassesResource, c.ClusterPath, name, opts), &storagev1beta1.StorageClass{}) - return err -} - -func (c *storageClassesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(storageClassesResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &storagev1beta1.StorageClassList{}) - return err -} - -func (c *storageClassesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*storagev1beta1.StorageClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(storageClassesResource, c.ClusterPath, name), &storagev1beta1.StorageClass{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.StorageClass), err -} - -// List takes label and field selectors, and returns the list of StorageClasses that match those selectors. -func (c *storageClassesClient) List(ctx context.Context, opts metav1.ListOptions) (*storagev1beta1.StorageClassList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(storageClassesResource, storageClassesKind, c.ClusterPath, opts), &storagev1beta1.StorageClassList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &storagev1beta1.StorageClassList{ListMeta: obj.(*storagev1beta1.StorageClassList).ListMeta} - for _, item := range obj.(*storagev1beta1.StorageClassList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *storageClassesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(storageClassesResource, c.ClusterPath, opts)) -} - -func (c *storageClassesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*storagev1beta1.StorageClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(storageClassesResource, c.ClusterPath, name, pt, data, subresources...), &storagev1beta1.StorageClass{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.StorageClass), err -} - -func (c *storageClassesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsstoragev1beta1.StorageClassApplyConfiguration, opts metav1.ApplyOptions) (*storagev1beta1.StorageClass, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(storageClassesResource, c.ClusterPath, *name, types.ApplyPatchType, data), &storagev1beta1.StorageClass{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.StorageClass), err -} - -func (c *storageClassesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsstoragev1beta1.StorageClassApplyConfiguration, opts metav1.ApplyOptions) (*storagev1beta1.StorageClass, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(storageClassesResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &storagev1beta1.StorageClass{}) - if obj == nil { - return nil, err +func newFakeStorageClassClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedstoragev1beta1.StorageClassInterface { + return &storageClassScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*storagev1beta1.StorageClass, *storagev1beta1.StorageClassList, *v1beta1.StorageClassApplyConfiguration]( + fake, + clusterPath, + "", + storagev1beta1.SchemeGroupVersion.WithResource("storageclasses"), + storagev1beta1.SchemeGroupVersion.WithKind("StorageClass"), + func() *storagev1beta1.StorageClass { return &storagev1beta1.StorageClass{} }, + func() *storagev1beta1.StorageClassList { return &storagev1beta1.StorageClassList{} }, + func(dst, src *storagev1beta1.StorageClassList) { dst.ListMeta = src.ListMeta }, + func(list *storagev1beta1.StorageClassList) []*storagev1beta1.StorageClass { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *storagev1beta1.StorageClassList, items []*storagev1beta1.StorageClass) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*storagev1beta1.StorageClass), err } diff --git a/kubernetes/typed/storage/v1beta1/fake/volumeattachment.go b/kubernetes/typed/storage/v1beta1/fake/volumeattachment.go index d6574493b..9c8ffae96 100644 --- a/kubernetes/typed/storage/v1beta1/fake/volumeattachment.go +++ b/kubernetes/typed/storage/v1beta1/fake/volumeattachment.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" storagev1beta1 "k8s.io/api/storage/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsstoragev1beta1 "k8s.io/client-go/applyconfigurations/storage/v1beta1" - storagev1beta1client "k8s.io/client-go/kubernetes/typed/storage/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/storage/v1beta1" + typedstoragev1beta1 "k8s.io/client-go/kubernetes/typed/storage/v1beta1" + typedkcpstoragev1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/storage/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var volumeAttachmentsResource = schema.GroupVersionResource{Group: "storage.k8s.io", Version: "v1beta1", Resource: "volumeattachments"} -var volumeAttachmentsKind = schema.GroupVersionKind{Group: "storage.k8s.io", Version: "v1beta1", Kind: "VolumeAttachment"} - -type volumeAttachmentsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *volumeAttachmentsClusterClient) Cluster(clusterPath logicalcluster.Path) storagev1beta1client.VolumeAttachmentInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &volumeAttachmentsClient{Fake: c.Fake, ClusterPath: clusterPath} +// volumeAttachmentClusterClient implements VolumeAttachmentClusterInterface +type volumeAttachmentClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*storagev1beta1.VolumeAttachment, *storagev1beta1.VolumeAttachmentList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of VolumeAttachments that match those selectors across all clusters. -func (c *volumeAttachmentsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*storagev1beta1.VolumeAttachmentList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(volumeAttachmentsResource, volumeAttachmentsKind, logicalcluster.Wildcard, opts), &storagev1beta1.VolumeAttachmentList{}) - if obj == nil { - return nil, err +func newFakeVolumeAttachmentClusterClient(fake *StorageV1beta1ClusterClient) typedkcpstoragev1beta1.VolumeAttachmentClusterInterface { + return &volumeAttachmentClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*storagev1beta1.VolumeAttachment, *storagev1beta1.VolumeAttachmentList]( + fake.Fake, + storagev1beta1.SchemeGroupVersion.WithResource("volumeattachments"), + storagev1beta1.SchemeGroupVersion.WithKind("VolumeAttachment"), + func() *storagev1beta1.VolumeAttachment { return &storagev1beta1.VolumeAttachment{} }, + func() *storagev1beta1.VolumeAttachmentList { return &storagev1beta1.VolumeAttachmentList{} }, + func(dst, src *storagev1beta1.VolumeAttachmentList) { dst.ListMeta = src.ListMeta }, + func(list *storagev1beta1.VolumeAttachmentList) []*storagev1beta1.VolumeAttachment { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *storagev1beta1.VolumeAttachmentList, items []*storagev1beta1.VolumeAttachment) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &storagev1beta1.VolumeAttachmentList{ListMeta: obj.(*storagev1beta1.VolumeAttachmentList).ListMeta} - for _, item := range obj.(*storagev1beta1.VolumeAttachmentList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested VolumeAttachments across all clusters. -func (c *volumeAttachmentsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(volumeAttachmentsResource, logicalcluster.Wildcard, opts)) +func (c *volumeAttachmentClusterClient) Cluster(cluster logicalcluster.Path) typedstoragev1beta1.VolumeAttachmentInterface { + return newFakeVolumeAttachmentClient(c.Fake, cluster) } -type volumeAttachmentsClient struct { - *kcptesting.Fake +// volumeAttachmentScopedClient implements VolumeAttachmentInterface +type volumeAttachmentScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*storagev1beta1.VolumeAttachment, *storagev1beta1.VolumeAttachmentList, *v1beta1.VolumeAttachmentApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *volumeAttachmentsClient) Create(ctx context.Context, volumeAttachment *storagev1beta1.VolumeAttachment, opts metav1.CreateOptions) (*storagev1beta1.VolumeAttachment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(volumeAttachmentsResource, c.ClusterPath, volumeAttachment), &storagev1beta1.VolumeAttachment{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.VolumeAttachment), err -} - -func (c *volumeAttachmentsClient) Update(ctx context.Context, volumeAttachment *storagev1beta1.VolumeAttachment, opts metav1.UpdateOptions) (*storagev1beta1.VolumeAttachment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(volumeAttachmentsResource, c.ClusterPath, volumeAttachment), &storagev1beta1.VolumeAttachment{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.VolumeAttachment), err -} - -func (c *volumeAttachmentsClient) UpdateStatus(ctx context.Context, volumeAttachment *storagev1beta1.VolumeAttachment, opts metav1.UpdateOptions) (*storagev1beta1.VolumeAttachment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(volumeAttachmentsResource, c.ClusterPath, "status", volumeAttachment), &storagev1beta1.VolumeAttachment{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.VolumeAttachment), err -} - -func (c *volumeAttachmentsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(volumeAttachmentsResource, c.ClusterPath, name, opts), &storagev1beta1.VolumeAttachment{}) - return err -} - -func (c *volumeAttachmentsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(volumeAttachmentsResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &storagev1beta1.VolumeAttachmentList{}) - return err -} - -func (c *volumeAttachmentsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*storagev1beta1.VolumeAttachment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(volumeAttachmentsResource, c.ClusterPath, name), &storagev1beta1.VolumeAttachment{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.VolumeAttachment), err -} - -// List takes label and field selectors, and returns the list of VolumeAttachments that match those selectors. -func (c *volumeAttachmentsClient) List(ctx context.Context, opts metav1.ListOptions) (*storagev1beta1.VolumeAttachmentList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(volumeAttachmentsResource, volumeAttachmentsKind, c.ClusterPath, opts), &storagev1beta1.VolumeAttachmentList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &storagev1beta1.VolumeAttachmentList{ListMeta: obj.(*storagev1beta1.VolumeAttachmentList).ListMeta} - for _, item := range obj.(*storagev1beta1.VolumeAttachmentList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *volumeAttachmentsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(volumeAttachmentsResource, c.ClusterPath, opts)) -} - -func (c *volumeAttachmentsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*storagev1beta1.VolumeAttachment, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(volumeAttachmentsResource, c.ClusterPath, name, pt, data, subresources...), &storagev1beta1.VolumeAttachment{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.VolumeAttachment), err -} - -func (c *volumeAttachmentsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsstoragev1beta1.VolumeAttachmentApplyConfiguration, opts metav1.ApplyOptions) (*storagev1beta1.VolumeAttachment, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(volumeAttachmentsResource, c.ClusterPath, *name, types.ApplyPatchType, data), &storagev1beta1.VolumeAttachment{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.VolumeAttachment), err -} - -func (c *volumeAttachmentsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsstoragev1beta1.VolumeAttachmentApplyConfiguration, opts metav1.ApplyOptions) (*storagev1beta1.VolumeAttachment, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(volumeAttachmentsResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &storagev1beta1.VolumeAttachment{}) - if obj == nil { - return nil, err +func newFakeVolumeAttachmentClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedstoragev1beta1.VolumeAttachmentInterface { + return &volumeAttachmentScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*storagev1beta1.VolumeAttachment, *storagev1beta1.VolumeAttachmentList, *v1beta1.VolumeAttachmentApplyConfiguration]( + fake, + clusterPath, + "", + storagev1beta1.SchemeGroupVersion.WithResource("volumeattachments"), + storagev1beta1.SchemeGroupVersion.WithKind("VolumeAttachment"), + func() *storagev1beta1.VolumeAttachment { return &storagev1beta1.VolumeAttachment{} }, + func() *storagev1beta1.VolumeAttachmentList { return &storagev1beta1.VolumeAttachmentList{} }, + func(dst, src *storagev1beta1.VolumeAttachmentList) { dst.ListMeta = src.ListMeta }, + func(list *storagev1beta1.VolumeAttachmentList) []*storagev1beta1.VolumeAttachment { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *storagev1beta1.VolumeAttachmentList, items []*storagev1beta1.VolumeAttachment) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*storagev1beta1.VolumeAttachment), err } diff --git a/kubernetes/typed/storage/v1beta1/fake/volumeattributesclass.go b/kubernetes/typed/storage/v1beta1/fake/volumeattributesclass.go index 5d30d2494..a0030417f 100644 --- a/kubernetes/typed/storage/v1beta1/fake/volumeattributesclass.go +++ b/kubernetes/typed/storage/v1beta1/fake/volumeattributesclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" storagev1beta1 "k8s.io/api/storage/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsstoragev1beta1 "k8s.io/client-go/applyconfigurations/storage/v1beta1" - storagev1beta1client "k8s.io/client-go/kubernetes/typed/storage/v1beta1" - "k8s.io/client-go/testing" + v1beta1 "k8s.io/client-go/applyconfigurations/storage/v1beta1" + typedstoragev1beta1 "k8s.io/client-go/kubernetes/typed/storage/v1beta1" + typedkcpstoragev1beta1 "github.com/kcp-dev/client-go/kubernetes/typed/storage/v1beta1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var volumeAttributesClassesResource = schema.GroupVersionResource{Group: "storage.k8s.io", Version: "v1beta1", Resource: "volumeattributesclasses"} -var volumeAttributesClassesKind = schema.GroupVersionKind{Group: "storage.k8s.io", Version: "v1beta1", Kind: "VolumeAttributesClass"} - -type volumeAttributesClassesClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *volumeAttributesClassesClusterClient) Cluster(clusterPath logicalcluster.Path) storagev1beta1client.VolumeAttributesClassInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &volumeAttributesClassesClient{Fake: c.Fake, ClusterPath: clusterPath} +// volumeAttributesClassClusterClient implements VolumeAttributesClassClusterInterface +type volumeAttributesClassClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*storagev1beta1.VolumeAttributesClass, *storagev1beta1.VolumeAttributesClassList] + Fake *kcptesting.Fake } -// List takes label and field selectors, and returns the list of VolumeAttributesClasses that match those selectors across all clusters. -func (c *volumeAttributesClassesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*storagev1beta1.VolumeAttributesClassList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(volumeAttributesClassesResource, volumeAttributesClassesKind, logicalcluster.Wildcard, opts), &storagev1beta1.VolumeAttributesClassList{}) - if obj == nil { - return nil, err +func newFakeVolumeAttributesClassClusterClient(fake *StorageV1beta1ClusterClient) typedkcpstoragev1beta1.VolumeAttributesClassClusterInterface { + return &volumeAttributesClassClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*storagev1beta1.VolumeAttributesClass, *storagev1beta1.VolumeAttributesClassList]( + fake.Fake, + storagev1beta1.SchemeGroupVersion.WithResource("volumeattributesclasses"), + storagev1beta1.SchemeGroupVersion.WithKind("VolumeAttributesClass"), + func() *storagev1beta1.VolumeAttributesClass { return &storagev1beta1.VolumeAttributesClass{} }, + func() *storagev1beta1.VolumeAttributesClassList { return &storagev1beta1.VolumeAttributesClassList{} }, + func(dst, src *storagev1beta1.VolumeAttributesClassList) { dst.ListMeta = src.ListMeta }, + func(list *storagev1beta1.VolumeAttributesClassList) []*storagev1beta1.VolumeAttributesClass { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *storagev1beta1.VolumeAttributesClassList, items []*storagev1beta1.VolumeAttributesClass) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &storagev1beta1.VolumeAttributesClassList{ListMeta: obj.(*storagev1beta1.VolumeAttributesClassList).ListMeta} - for _, item := range obj.(*storagev1beta1.VolumeAttributesClassList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err } -// Watch returns a watch.Interface that watches the requested VolumeAttributesClasses across all clusters. -func (c *volumeAttributesClassesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(volumeAttributesClassesResource, logicalcluster.Wildcard, opts)) +func (c *volumeAttributesClassClusterClient) Cluster(cluster logicalcluster.Path) typedstoragev1beta1.VolumeAttributesClassInterface { + return newFakeVolumeAttributesClassClient(c.Fake, cluster) } -type volumeAttributesClassesClient struct { - *kcptesting.Fake +// volumeAttributesClassScopedClient implements VolumeAttributesClassInterface +type volumeAttributesClassScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*storagev1beta1.VolumeAttributesClass, *storagev1beta1.VolumeAttributesClassList, *v1beta1.VolumeAttributesClassApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *volumeAttributesClassesClient) Create(ctx context.Context, volumeAttributesClass *storagev1beta1.VolumeAttributesClass, opts metav1.CreateOptions) (*storagev1beta1.VolumeAttributesClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(volumeAttributesClassesResource, c.ClusterPath, volumeAttributesClass), &storagev1beta1.VolumeAttributesClass{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.VolumeAttributesClass), err -} - -func (c *volumeAttributesClassesClient) Update(ctx context.Context, volumeAttributesClass *storagev1beta1.VolumeAttributesClass, opts metav1.UpdateOptions) (*storagev1beta1.VolumeAttributesClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(volumeAttributesClassesResource, c.ClusterPath, volumeAttributesClass), &storagev1beta1.VolumeAttributesClass{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.VolumeAttributesClass), err -} - -func (c *volumeAttributesClassesClient) UpdateStatus(ctx context.Context, volumeAttributesClass *storagev1beta1.VolumeAttributesClass, opts metav1.UpdateOptions) (*storagev1beta1.VolumeAttributesClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(volumeAttributesClassesResource, c.ClusterPath, "status", volumeAttributesClass), &storagev1beta1.VolumeAttributesClass{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.VolumeAttributesClass), err -} - -func (c *volumeAttributesClassesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(volumeAttributesClassesResource, c.ClusterPath, name, opts), &storagev1beta1.VolumeAttributesClass{}) - return err -} - -func (c *volumeAttributesClassesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(volumeAttributesClassesResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &storagev1beta1.VolumeAttributesClassList{}) - return err -} - -func (c *volumeAttributesClassesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*storagev1beta1.VolumeAttributesClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(volumeAttributesClassesResource, c.ClusterPath, name), &storagev1beta1.VolumeAttributesClass{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.VolumeAttributesClass), err -} - -// List takes label and field selectors, and returns the list of VolumeAttributesClasses that match those selectors. -func (c *volumeAttributesClassesClient) List(ctx context.Context, opts metav1.ListOptions) (*storagev1beta1.VolumeAttributesClassList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(volumeAttributesClassesResource, volumeAttributesClassesKind, c.ClusterPath, opts), &storagev1beta1.VolumeAttributesClassList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &storagev1beta1.VolumeAttributesClassList{ListMeta: obj.(*storagev1beta1.VolumeAttributesClassList).ListMeta} - for _, item := range obj.(*storagev1beta1.VolumeAttributesClassList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *volumeAttributesClassesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(volumeAttributesClassesResource, c.ClusterPath, opts)) -} - -func (c *volumeAttributesClassesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*storagev1beta1.VolumeAttributesClass, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(volumeAttributesClassesResource, c.ClusterPath, name, pt, data, subresources...), &storagev1beta1.VolumeAttributesClass{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.VolumeAttributesClass), err -} - -func (c *volumeAttributesClassesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsstoragev1beta1.VolumeAttributesClassApplyConfiguration, opts metav1.ApplyOptions) (*storagev1beta1.VolumeAttributesClass, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(volumeAttributesClassesResource, c.ClusterPath, *name, types.ApplyPatchType, data), &storagev1beta1.VolumeAttributesClass{}) - if obj == nil { - return nil, err - } - return obj.(*storagev1beta1.VolumeAttributesClass), err -} - -func (c *volumeAttributesClassesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsstoragev1beta1.VolumeAttributesClassApplyConfiguration, opts metav1.ApplyOptions) (*storagev1beta1.VolumeAttributesClass, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(volumeAttributesClassesResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &storagev1beta1.VolumeAttributesClass{}) - if obj == nil { - return nil, err +func newFakeVolumeAttributesClassClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedstoragev1beta1.VolumeAttributesClassInterface { + return &volumeAttributesClassScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*storagev1beta1.VolumeAttributesClass, *storagev1beta1.VolumeAttributesClassList, *v1beta1.VolumeAttributesClassApplyConfiguration]( + fake, + clusterPath, + "", + storagev1beta1.SchemeGroupVersion.WithResource("volumeattributesclasses"), + storagev1beta1.SchemeGroupVersion.WithKind("VolumeAttributesClass"), + func() *storagev1beta1.VolumeAttributesClass { return &storagev1beta1.VolumeAttributesClass{} }, + func() *storagev1beta1.VolumeAttributesClassList { return &storagev1beta1.VolumeAttributesClassList{} }, + func(dst, src *storagev1beta1.VolumeAttributesClassList) { dst.ListMeta = src.ListMeta }, + func(list *storagev1beta1.VolumeAttributesClassList) []*storagev1beta1.VolumeAttributesClass { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *storagev1beta1.VolumeAttributesClassList, items []*storagev1beta1.VolumeAttributesClass) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*storagev1beta1.VolumeAttributesClass), err } diff --git a/kubernetes/typed/storage/v1beta1/generated_expansion.go b/kubernetes/typed/storage/v1beta1/generated_expansion.go new file mode 100644 index 000000000..77a632cfd --- /dev/null +++ b/kubernetes/typed/storage/v1beta1/generated_expansion.go @@ -0,0 +1,31 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1beta1 + +type CSIDriverClusterExpansion interface{} + +type CSINodeClusterExpansion interface{} + +type CSIStorageCapacityClusterExpansion interface{} + +type StorageClassClusterExpansion interface{} + +type VolumeAttachmentClusterExpansion interface{} + +type VolumeAttributesClassClusterExpansion interface{} diff --git a/kubernetes/typed/storage/v1beta1/storage_client.go b/kubernetes/typed/storage/v1beta1/storage_client.go index 765d6160e..5b833f118 100644 --- a/kubernetes/typed/storage/v1beta1/storage_client.go +++ b/kubernetes/typed/storage/v1beta1/storage_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,27 +14,30 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apistoragev1beta1 "k8s.io/api/storage/v1beta1" storagev1beta1 "k8s.io/client-go/kubernetes/typed/storage/v1beta1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type StorageV1beta1ClusterInterface interface { StorageV1beta1ClusterScoper - StorageClassesClusterGetter - VolumeAttachmentsClusterGetter CSIDriversClusterGetter CSINodesClusterGetter CSIStorageCapacitiesClusterGetter + StorageClassesClusterGetter + VolumeAttachmentsClusterGetter VolumeAttributesClassesClusterGetter } @@ -42,6 +45,7 @@ type StorageV1beta1ClusterScoper interface { Cluster(logicalcluster.Path) storagev1beta1.StorageV1beta1Interface } +// StorageV1beta1ClusterClient is used to interact with features provided by the storage.k8s.io group. type StorageV1beta1ClusterClient struct { clientCache kcpclient.Cache[*storagev1beta1.StorageV1beta1Client] } @@ -53,14 +57,6 @@ func (c *StorageV1beta1ClusterClient) Cluster(clusterPath logicalcluster.Path) s return c.clientCache.ClusterOrDie(clusterPath) } -func (c *StorageV1beta1ClusterClient) StorageClasses() StorageClassClusterInterface { - return &storageClassesClusterInterface{clientCache: c.clientCache} -} - -func (c *StorageV1beta1ClusterClient) VolumeAttachments() VolumeAttachmentClusterInterface { - return &volumeAttachmentsClusterInterface{clientCache: c.clientCache} -} - func (c *StorageV1beta1ClusterClient) CSIDrivers() CSIDriverClusterInterface { return &cSIDriversClusterInterface{clientCache: c.clientCache} } @@ -73,6 +69,14 @@ func (c *StorageV1beta1ClusterClient) CSIStorageCapacities() CSIStorageCapacityC return &cSIStorageCapacitiesClusterInterface{clientCache: c.clientCache} } +func (c *StorageV1beta1ClusterClient) StorageClasses() StorageClassClusterInterface { + return &storageClassesClusterInterface{clientCache: c.clientCache} +} + +func (c *StorageV1beta1ClusterClient) VolumeAttachments() VolumeAttachmentClusterInterface { + return &volumeAttachmentsClusterInterface{clientCache: c.clientCache} +} + func (c *StorageV1beta1ClusterClient) VolumeAttributesClasses() VolumeAttributesClassClusterInterface { return &volumeAttributesClassesClusterInterface{clientCache: c.clientCache} } @@ -81,11 +85,13 @@ func (c *StorageV1beta1ClusterClient) VolumeAttributesClasses() VolumeAttributes // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*StorageV1beta1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new StorageV1beta1ClusterClient for the given config and http client. @@ -97,6 +103,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*StorageV1beta1Clust if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &StorageV1beta1ClusterClient{clientCache: cache}, nil } @@ -109,3 +116,14 @@ func NewForConfigOrDie(c *rest.Config) *StorageV1beta1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apistoragev1beta1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/storage/v1beta1/storageclass.go b/kubernetes/typed/storage/v1beta1/storageclass.go index 4c8e5cf71..5ac0104ef 100644 --- a/kubernetes/typed/storage/v1beta1/storageclass.go +++ b/kubernetes/typed/storage/v1beta1/storageclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - storagev1beta1 "k8s.io/api/storage/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - storagev1beta1client "k8s.io/client-go/kubernetes/typed/storage/v1beta1" + apistoragev1beta1 "k8s.io/api/storage/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + storagev1beta1 "k8s.io/client-go/kubernetes/typed/storage/v1beta1" ) // StorageClassesClusterGetter has a method to return a StorageClassClusterInterface. @@ -37,19 +37,20 @@ type StorageClassesClusterGetter interface { } // StorageClassClusterInterface can operate on StorageClasses across all clusters, -// or scope down to one cluster and return a storagev1beta1client.StorageClassInterface. +// or scope down to one cluster and return a storagev1beta1.StorageClassInterface. type StorageClassClusterInterface interface { - Cluster(logicalcluster.Path) storagev1beta1client.StorageClassInterface - List(ctx context.Context, opts metav1.ListOptions) (*storagev1beta1.StorageClassList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) storagev1beta1.StorageClassInterface + List(ctx context.Context, opts v1.ListOptions) (*apistoragev1beta1.StorageClassList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + StorageClassClusterExpansion } type storageClassesClusterInterface struct { - clientCache kcpclient.Cache[*storagev1beta1client.StorageV1beta1Client] + clientCache kcpclient.Cache[*storagev1beta1.StorageV1beta1Client] } // Cluster scopes the client down to a particular cluster. -func (c *storageClassesClusterInterface) Cluster(clusterPath logicalcluster.Path) storagev1beta1client.StorageClassInterface { +func (c *storageClassesClusterInterface) Cluster(clusterPath logicalcluster.Path) storagev1beta1.StorageClassInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *storageClassesClusterInterface) Cluster(clusterPath logicalcluster.Path } // List returns the entire collection of all StorageClasses across all clusters. -func (c *storageClassesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*storagev1beta1.StorageClassList, error) { +func (c *storageClassesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apistoragev1beta1.StorageClassList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).StorageClasses().List(ctx, opts) } // Watch begins to watch all StorageClasses across all clusters. -func (c *storageClassesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *storageClassesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).StorageClasses().Watch(ctx, opts) } diff --git a/kubernetes/typed/storage/v1beta1/volumeattachment.go b/kubernetes/typed/storage/v1beta1/volumeattachment.go index 9a2fd1023..ed7dac54c 100644 --- a/kubernetes/typed/storage/v1beta1/volumeattachment.go +++ b/kubernetes/typed/storage/v1beta1/volumeattachment.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - storagev1beta1 "k8s.io/api/storage/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - storagev1beta1client "k8s.io/client-go/kubernetes/typed/storage/v1beta1" + apistoragev1beta1 "k8s.io/api/storage/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + storagev1beta1 "k8s.io/client-go/kubernetes/typed/storage/v1beta1" ) // VolumeAttachmentsClusterGetter has a method to return a VolumeAttachmentClusterInterface. @@ -37,19 +37,20 @@ type VolumeAttachmentsClusterGetter interface { } // VolumeAttachmentClusterInterface can operate on VolumeAttachments across all clusters, -// or scope down to one cluster and return a storagev1beta1client.VolumeAttachmentInterface. +// or scope down to one cluster and return a storagev1beta1.VolumeAttachmentInterface. type VolumeAttachmentClusterInterface interface { - Cluster(logicalcluster.Path) storagev1beta1client.VolumeAttachmentInterface - List(ctx context.Context, opts metav1.ListOptions) (*storagev1beta1.VolumeAttachmentList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) storagev1beta1.VolumeAttachmentInterface + List(ctx context.Context, opts v1.ListOptions) (*apistoragev1beta1.VolumeAttachmentList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + VolumeAttachmentClusterExpansion } type volumeAttachmentsClusterInterface struct { - clientCache kcpclient.Cache[*storagev1beta1client.StorageV1beta1Client] + clientCache kcpclient.Cache[*storagev1beta1.StorageV1beta1Client] } // Cluster scopes the client down to a particular cluster. -func (c *volumeAttachmentsClusterInterface) Cluster(clusterPath logicalcluster.Path) storagev1beta1client.VolumeAttachmentInterface { +func (c *volumeAttachmentsClusterInterface) Cluster(clusterPath logicalcluster.Path) storagev1beta1.VolumeAttachmentInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *volumeAttachmentsClusterInterface) Cluster(clusterPath logicalcluster.P } // List returns the entire collection of all VolumeAttachments across all clusters. -func (c *volumeAttachmentsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*storagev1beta1.VolumeAttachmentList, error) { +func (c *volumeAttachmentsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apistoragev1beta1.VolumeAttachmentList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).VolumeAttachments().List(ctx, opts) } // Watch begins to watch all VolumeAttachments across all clusters. -func (c *volumeAttachmentsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *volumeAttachmentsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).VolumeAttachments().Watch(ctx, opts) } diff --git a/kubernetes/typed/storage/v1beta1/volumeattributesclass.go b/kubernetes/typed/storage/v1beta1/volumeattributesclass.go index a1b5c575e..521ae434c 100644 --- a/kubernetes/typed/storage/v1beta1/volumeattributesclass.go +++ b/kubernetes/typed/storage/v1beta1/volumeattributesclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1beta1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - storagev1beta1 "k8s.io/api/storage/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - storagev1beta1client "k8s.io/client-go/kubernetes/typed/storage/v1beta1" + apistoragev1beta1 "k8s.io/api/storage/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + storagev1beta1 "k8s.io/client-go/kubernetes/typed/storage/v1beta1" ) // VolumeAttributesClassesClusterGetter has a method to return a VolumeAttributesClassClusterInterface. @@ -37,19 +37,20 @@ type VolumeAttributesClassesClusterGetter interface { } // VolumeAttributesClassClusterInterface can operate on VolumeAttributesClasses across all clusters, -// or scope down to one cluster and return a storagev1beta1client.VolumeAttributesClassInterface. +// or scope down to one cluster and return a storagev1beta1.VolumeAttributesClassInterface. type VolumeAttributesClassClusterInterface interface { - Cluster(logicalcluster.Path) storagev1beta1client.VolumeAttributesClassInterface - List(ctx context.Context, opts metav1.ListOptions) (*storagev1beta1.VolumeAttributesClassList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) storagev1beta1.VolumeAttributesClassInterface + List(ctx context.Context, opts v1.ListOptions) (*apistoragev1beta1.VolumeAttributesClassList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + VolumeAttributesClassClusterExpansion } type volumeAttributesClassesClusterInterface struct { - clientCache kcpclient.Cache[*storagev1beta1client.StorageV1beta1Client] + clientCache kcpclient.Cache[*storagev1beta1.StorageV1beta1Client] } // Cluster scopes the client down to a particular cluster. -func (c *volumeAttributesClassesClusterInterface) Cluster(clusterPath logicalcluster.Path) storagev1beta1client.VolumeAttributesClassInterface { +func (c *volumeAttributesClassesClusterInterface) Cluster(clusterPath logicalcluster.Path) storagev1beta1.VolumeAttributesClassInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *volumeAttributesClassesClusterInterface) Cluster(clusterPath logicalclu } // List returns the entire collection of all VolumeAttributesClasses across all clusters. -func (c *volumeAttributesClassesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*storagev1beta1.VolumeAttributesClassList, error) { +func (c *volumeAttributesClassesClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apistoragev1beta1.VolumeAttributesClassList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).VolumeAttributesClasses().List(ctx, opts) } // Watch begins to watch all VolumeAttributesClasses across all clusters. -func (c *volumeAttributesClassesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *volumeAttributesClassesClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).VolumeAttributesClasses().Watch(ctx, opts) } diff --git a/kubernetes/typed/storagemigration/v1alpha1/doc.go b/kubernetes/typed/storagemigration/v1alpha1/doc.go new file mode 100644 index 000000000..08b80237c --- /dev/null +++ b/kubernetes/typed/storagemigration/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/kubernetes/typed/storagemigration/v1alpha1/fake/doc.go b/kubernetes/typed/storagemigration/v1alpha1/fake/doc.go new file mode 100644 index 000000000..b4777acfa --- /dev/null +++ b/kubernetes/typed/storagemigration/v1alpha1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +// Package fake has the automatically generated cluster clients. +package fake diff --git a/kubernetes/typed/storagemigration/v1alpha1/fake/storagemigration_client.go b/kubernetes/typed/storagemigration/v1alpha1/fake/storagemigration_client.go index 12a87132e..988e27fa0 100644 --- a/kubernetes/typed/storagemigration/v1alpha1/fake/storagemigration_client.go +++ b/kubernetes/typed/storagemigration/v1alpha1/fake/storagemigration_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake @@ -22,7 +22,7 @@ import ( "github.com/kcp-dev/logicalcluster/v3" storagemigrationv1alpha1 "k8s.io/client-go/kubernetes/typed/storagemigration/v1alpha1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" kcpstoragemigrationv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/storagemigration/v1alpha1" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" @@ -42,21 +42,21 @@ func (c *StoragemigrationV1alpha1ClusterClient) Cluster(clusterPath logicalclust } func (c *StoragemigrationV1alpha1ClusterClient) StorageVersionMigrations() kcpstoragemigrationv1alpha1.StorageVersionMigrationClusterInterface { - return &storageVersionMigrationsClusterClient{Fake: c.Fake} + return newFakeStorageVersionMigrationClusterClient(c) } -var _ storagemigrationv1alpha1.StoragemigrationV1alpha1Interface = (*StoragemigrationV1alpha1Client)(nil) - type StoragemigrationV1alpha1Client struct { *kcptesting.Fake ClusterPath logicalcluster.Path } +func (c *StoragemigrationV1alpha1Client) StorageVersionMigrations() storagemigrationv1alpha1.StorageVersionMigrationInterface { + return newFakeStorageVersionMigrationClient(c.Fake, c.ClusterPath) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. func (c *StoragemigrationV1alpha1Client) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } - -func (c *StoragemigrationV1alpha1Client) StorageVersionMigrations() storagemigrationv1alpha1.StorageVersionMigrationInterface { - return &storageVersionMigrationsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} -} diff --git a/kubernetes/typed/storagemigration/v1alpha1/fake/storageversionmigration.go b/kubernetes/typed/storagemigration/v1alpha1/fake/storageversionmigration.go index 55aa61563..d9395a98e 100644 --- a/kubernetes/typed/storagemigration/v1alpha1/fake/storageversionmigration.go +++ b/kubernetes/typed/storagemigration/v1alpha1/fake/storageversionmigration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,186 +14,86 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package fake import ( - "context" - "encoding/json" - "fmt" - "github.com/kcp-dev/logicalcluster/v3" storagemigrationv1alpha1 "k8s.io/api/storagemigration/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" - applyconfigurationsstoragemigrationv1alpha1 "k8s.io/client-go/applyconfigurations/storagemigration/v1alpha1" - storagemigrationv1alpha1client "k8s.io/client-go/kubernetes/typed/storagemigration/v1alpha1" - "k8s.io/client-go/testing" + v1alpha1 "k8s.io/client-go/applyconfigurations/storagemigration/v1alpha1" + typedstoragemigrationv1alpha1 "k8s.io/client-go/kubernetes/typed/storagemigration/v1alpha1" + typedkcpstoragemigrationv1alpha1 "github.com/kcp-dev/client-go/kubernetes/typed/storagemigration/v1alpha1" + kcpgentype "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/gentype" kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" ) -var storageVersionMigrationsResource = schema.GroupVersionResource{Group: "storagemigration.k8s.io", Version: "v1alpha1", Resource: "storageversionmigrations"} -var storageVersionMigrationsKind = schema.GroupVersionKind{Group: "storagemigration.k8s.io", Version: "v1alpha1", Kind: "StorageVersionMigration"} - -type storageVersionMigrationsClusterClient struct { - *kcptesting.Fake -} - -// Cluster scopes the client down to a particular cluster. -func (c *storageVersionMigrationsClusterClient) Cluster(clusterPath logicalcluster.Path) storagemigrationv1alpha1client.StorageVersionMigrationInterface { - if clusterPath == logicalcluster.Wildcard { - panic("A specific cluster must be provided when scoping, not the wildcard.") - } - - return &storageVersionMigrationsClient{Fake: c.Fake, ClusterPath: clusterPath} -} - -// List takes label and field selectors, and returns the list of StorageVersionMigrations that match those selectors across all clusters. -func (c *storageVersionMigrationsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*storagemigrationv1alpha1.StorageVersionMigrationList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(storageVersionMigrationsResource, storageVersionMigrationsKind, logicalcluster.Wildcard, opts), &storagemigrationv1alpha1.StorageVersionMigrationList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &storagemigrationv1alpha1.StorageVersionMigrationList{ListMeta: obj.(*storagemigrationv1alpha1.StorageVersionMigrationList).ListMeta} - for _, item := range obj.(*storagemigrationv1alpha1.StorageVersionMigrationList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested StorageVersionMigrations across all clusters. -func (c *storageVersionMigrationsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(storageVersionMigrationsResource, logicalcluster.Wildcard, opts)) -} - -type storageVersionMigrationsClient struct { - *kcptesting.Fake +// storageVersionMigrationClusterClient implements StorageVersionMigrationClusterInterface +type storageVersionMigrationClusterClient struct { + *kcpgentype.FakeClusterClientWithList[*storagemigrationv1alpha1.StorageVersionMigration, *storagemigrationv1alpha1.StorageVersionMigrationList] + Fake *kcptesting.Fake +} + +func newFakeStorageVersionMigrationClusterClient(fake *StoragemigrationV1alpha1ClusterClient) typedkcpstoragemigrationv1alpha1.StorageVersionMigrationClusterInterface { + return &storageVersionMigrationClusterClient{ + kcpgentype.NewFakeClusterClientWithList[*storagemigrationv1alpha1.StorageVersionMigration, *storagemigrationv1alpha1.StorageVersionMigrationList]( + fake.Fake, + storagemigrationv1alpha1.SchemeGroupVersion.WithResource("storageversionmigrations"), + storagemigrationv1alpha1.SchemeGroupVersion.WithKind("StorageVersionMigration"), + func() *storagemigrationv1alpha1.StorageVersionMigration { + return &storagemigrationv1alpha1.StorageVersionMigration{} + }, + func() *storagemigrationv1alpha1.StorageVersionMigrationList { + return &storagemigrationv1alpha1.StorageVersionMigrationList{} + }, + func(dst, src *storagemigrationv1alpha1.StorageVersionMigrationList) { dst.ListMeta = src.ListMeta }, + func(list *storagemigrationv1alpha1.StorageVersionMigrationList) []*storagemigrationv1alpha1.StorageVersionMigration { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *storagemigrationv1alpha1.StorageVersionMigrationList, items []*storagemigrationv1alpha1.StorageVersionMigration) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake.Fake, + } +} + +func (c *storageVersionMigrationClusterClient) Cluster(cluster logicalcluster.Path) typedstoragemigrationv1alpha1.StorageVersionMigrationInterface { + return newFakeStorageVersionMigrationClient(c.Fake, cluster) +} + +// storageVersionMigrationScopedClient implements StorageVersionMigrationInterface +type storageVersionMigrationScopedClient struct { + *kcpgentype.FakeClientWithListAndApply[*storagemigrationv1alpha1.StorageVersionMigration, *storagemigrationv1alpha1.StorageVersionMigrationList, *v1alpha1.StorageVersionMigrationApplyConfiguration] + Fake *kcptesting.Fake ClusterPath logicalcluster.Path } -func (c *storageVersionMigrationsClient) Create(ctx context.Context, storageVersionMigration *storagemigrationv1alpha1.StorageVersionMigration, opts metav1.CreateOptions) (*storagemigrationv1alpha1.StorageVersionMigration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(storageVersionMigrationsResource, c.ClusterPath, storageVersionMigration), &storagemigrationv1alpha1.StorageVersionMigration{}) - if obj == nil { - return nil, err - } - return obj.(*storagemigrationv1alpha1.StorageVersionMigration), err -} - -func (c *storageVersionMigrationsClient) Update(ctx context.Context, storageVersionMigration *storagemigrationv1alpha1.StorageVersionMigration, opts metav1.UpdateOptions) (*storagemigrationv1alpha1.StorageVersionMigration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(storageVersionMigrationsResource, c.ClusterPath, storageVersionMigration), &storagemigrationv1alpha1.StorageVersionMigration{}) - if obj == nil { - return nil, err - } - return obj.(*storagemigrationv1alpha1.StorageVersionMigration), err -} - -func (c *storageVersionMigrationsClient) UpdateStatus(ctx context.Context, storageVersionMigration *storagemigrationv1alpha1.StorageVersionMigration, opts metav1.UpdateOptions) (*storagemigrationv1alpha1.StorageVersionMigration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(storageVersionMigrationsResource, c.ClusterPath, "status", storageVersionMigration), &storagemigrationv1alpha1.StorageVersionMigration{}) - if obj == nil { - return nil, err - } - return obj.(*storagemigrationv1alpha1.StorageVersionMigration), err -} - -func (c *storageVersionMigrationsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(storageVersionMigrationsResource, c.ClusterPath, name, opts), &storagemigrationv1alpha1.StorageVersionMigration{}) - return err -} - -func (c *storageVersionMigrationsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewRootDeleteCollectionAction(storageVersionMigrationsResource, c.ClusterPath, listOpts) - - _, err := c.Fake.Invokes(action, &storagemigrationv1alpha1.StorageVersionMigrationList{}) - return err -} - -func (c *storageVersionMigrationsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*storagemigrationv1alpha1.StorageVersionMigration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(storageVersionMigrationsResource, c.ClusterPath, name), &storagemigrationv1alpha1.StorageVersionMigration{}) - if obj == nil { - return nil, err - } - return obj.(*storagemigrationv1alpha1.StorageVersionMigration), err -} - -// List takes label and field selectors, and returns the list of StorageVersionMigrations that match those selectors. -func (c *storageVersionMigrationsClient) List(ctx context.Context, opts metav1.ListOptions) (*storagemigrationv1alpha1.StorageVersionMigrationList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(storageVersionMigrationsResource, storageVersionMigrationsKind, c.ClusterPath, opts), &storagemigrationv1alpha1.StorageVersionMigrationList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &storagemigrationv1alpha1.StorageVersionMigrationList{ListMeta: obj.(*storagemigrationv1alpha1.StorageVersionMigrationList).ListMeta} - for _, item := range obj.(*storagemigrationv1alpha1.StorageVersionMigrationList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -func (c *storageVersionMigrationsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(storageVersionMigrationsResource, c.ClusterPath, opts)) -} - -func (c *storageVersionMigrationsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*storagemigrationv1alpha1.StorageVersionMigration, error) { - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(storageVersionMigrationsResource, c.ClusterPath, name, pt, data, subresources...), &storagemigrationv1alpha1.StorageVersionMigration{}) - if obj == nil { - return nil, err - } - return obj.(*storagemigrationv1alpha1.StorageVersionMigration), err -} - -func (c *storageVersionMigrationsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsstoragemigrationv1alpha1.StorageVersionMigrationApplyConfiguration, opts metav1.ApplyOptions) (*storagemigrationv1alpha1.StorageVersionMigration, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(storageVersionMigrationsResource, c.ClusterPath, *name, types.ApplyPatchType, data), &storagemigrationv1alpha1.StorageVersionMigration{}) - if obj == nil { - return nil, err - } - return obj.(*storagemigrationv1alpha1.StorageVersionMigration), err -} - -func (c *storageVersionMigrationsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsstoragemigrationv1alpha1.StorageVersionMigrationApplyConfiguration, opts metav1.ApplyOptions) (*storagemigrationv1alpha1.StorageVersionMigration, error) { - if applyConfiguration == nil { - return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") - } - data, err := json.Marshal(applyConfiguration) - if err != nil { - return nil, err - } - name := applyConfiguration.Name - if name == nil { - return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") - } - obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(storageVersionMigrationsResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &storagemigrationv1alpha1.StorageVersionMigration{}) - if obj == nil { - return nil, err +func newFakeStorageVersionMigrationClient(fake *kcptesting.Fake, clusterPath logicalcluster.Path) typedstoragemigrationv1alpha1.StorageVersionMigrationInterface { + return &storageVersionMigrationScopedClient{ + kcpgentype.NewFakeClientWithListAndApply[*storagemigrationv1alpha1.StorageVersionMigration, *storagemigrationv1alpha1.StorageVersionMigrationList, *v1alpha1.StorageVersionMigrationApplyConfiguration]( + fake, + clusterPath, + "", + storagemigrationv1alpha1.SchemeGroupVersion.WithResource("storageversionmigrations"), + storagemigrationv1alpha1.SchemeGroupVersion.WithKind("StorageVersionMigration"), + func() *storagemigrationv1alpha1.StorageVersionMigration { + return &storagemigrationv1alpha1.StorageVersionMigration{} + }, + func() *storagemigrationv1alpha1.StorageVersionMigrationList { + return &storagemigrationv1alpha1.StorageVersionMigrationList{} + }, + func(dst, src *storagemigrationv1alpha1.StorageVersionMigrationList) { dst.ListMeta = src.ListMeta }, + func(list *storagemigrationv1alpha1.StorageVersionMigrationList) []*storagemigrationv1alpha1.StorageVersionMigration { + return kcpgentype.ToPointerSlice(list.Items) + }, + func(list *storagemigrationv1alpha1.StorageVersionMigrationList, items []*storagemigrationv1alpha1.StorageVersionMigration) { + list.Items = kcpgentype.FromPointerSlice(items) + }, + ), + fake, + clusterPath, } - return obj.(*storagemigrationv1alpha1.StorageVersionMigration), err } diff --git a/kubernetes/typed/storagemigration/v1alpha1/generated_expansion.go b/kubernetes/typed/storagemigration/v1alpha1/generated_expansion.go new file mode 100644 index 000000000..1e6dc0d32 --- /dev/null +++ b/kubernetes/typed/storagemigration/v1alpha1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-client-gen. DO NOT EDIT. + +package v1alpha1 + +type StorageVersionMigrationClusterExpansion interface{} diff --git a/kubernetes/typed/storagemigration/v1alpha1/storagemigration_client.go b/kubernetes/typed/storagemigration/v1alpha1/storagemigration_client.go index 33bd0b75e..174b02c95 100644 --- a/kubernetes/typed/storagemigration/v1alpha1/storagemigration_client.go +++ b/kubernetes/typed/storagemigration/v1alpha1/storagemigration_client.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha1 import ( - "net/http" + http "net/http" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" + apistoragemigrationv1alpha1 "k8s.io/api/storagemigration/v1alpha1" storagemigrationv1alpha1 "k8s.io/client-go/kubernetes/typed/storagemigration/v1alpha1" - "k8s.io/client-go/rest" + rest "k8s.io/client-go/rest" + + kcpscheme "github.com/kcp-dev/client-go/kubernetes/scheme" ) type StoragemigrationV1alpha1ClusterInterface interface { @@ -37,6 +40,7 @@ type StoragemigrationV1alpha1ClusterScoper interface { Cluster(logicalcluster.Path) storagemigrationv1alpha1.StoragemigrationV1alpha1Interface } +// StoragemigrationV1alpha1ClusterClient is used to interact with features provided by the storagemigration.k8s.io group. type StoragemigrationV1alpha1ClusterClient struct { clientCache kcpclient.Cache[*storagemigrationv1alpha1.StoragemigrationV1alpha1Client] } @@ -56,11 +60,13 @@ func (c *StoragemigrationV1alpha1ClusterClient) StorageVersionMigrations() Stora // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*StoragemigrationV1alpha1ClusterClient, error) { - client, err := rest.HTTPClientFor(c) + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) if err != nil { return nil, err } - return NewForConfigAndClient(c, client) + return NewForConfigAndClient(&config, httpClient) } // NewForConfigAndClient creates a new StoragemigrationV1alpha1ClusterClient for the given config and http client. @@ -72,6 +78,7 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*StoragemigrationV1a if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil { return nil, err } + return &StoragemigrationV1alpha1ClusterClient{clientCache: cache}, nil } @@ -84,3 +91,14 @@ func NewForConfigOrDie(c *rest.Config) *StoragemigrationV1alpha1ClusterClient { } return client } + +func setConfigDefaults(config *rest.Config) { + gv := apistoragemigrationv1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(kcpscheme.Scheme, kcpscheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} diff --git a/kubernetes/typed/storagemigration/v1alpha1/storageversionmigration.go b/kubernetes/typed/storagemigration/v1alpha1/storageversionmigration.go index 852894612..e3dac37fe 100644 --- a/kubernetes/typed/storagemigration/v1alpha1/storageversionmigration.go +++ b/kubernetes/typed/storagemigration/v1alpha1/storageversionmigration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-client-gen. DO NOT EDIT. package v1alpha1 import ( - "context" + context "context" kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" "github.com/kcp-dev/logicalcluster/v3" - storagemigrationv1alpha1 "k8s.io/api/storagemigration/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" - storagemigrationv1alpha1client "k8s.io/client-go/kubernetes/typed/storagemigration/v1alpha1" + apistoragemigrationv1alpha1 "k8s.io/api/storagemigration/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + storagemigrationv1alpha1 "k8s.io/client-go/kubernetes/typed/storagemigration/v1alpha1" ) // StorageVersionMigrationsClusterGetter has a method to return a StorageVersionMigrationClusterInterface. @@ -37,19 +37,20 @@ type StorageVersionMigrationsClusterGetter interface { } // StorageVersionMigrationClusterInterface can operate on StorageVersionMigrations across all clusters, -// or scope down to one cluster and return a storagemigrationv1alpha1client.StorageVersionMigrationInterface. +// or scope down to one cluster and return a storagemigrationv1alpha1.StorageVersionMigrationInterface. type StorageVersionMigrationClusterInterface interface { - Cluster(logicalcluster.Path) storagemigrationv1alpha1client.StorageVersionMigrationInterface - List(ctx context.Context, opts metav1.ListOptions) (*storagemigrationv1alpha1.StorageVersionMigrationList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Cluster(logicalcluster.Path) storagemigrationv1alpha1.StorageVersionMigrationInterface + List(ctx context.Context, opts v1.ListOptions) (*apistoragemigrationv1alpha1.StorageVersionMigrationList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + StorageVersionMigrationClusterExpansion } type storageVersionMigrationsClusterInterface struct { - clientCache kcpclient.Cache[*storagemigrationv1alpha1client.StoragemigrationV1alpha1Client] + clientCache kcpclient.Cache[*storagemigrationv1alpha1.StoragemigrationV1alpha1Client] } // Cluster scopes the client down to a particular cluster. -func (c *storageVersionMigrationsClusterInterface) Cluster(clusterPath logicalcluster.Path) storagemigrationv1alpha1client.StorageVersionMigrationInterface { +func (c *storageVersionMigrationsClusterInterface) Cluster(clusterPath logicalcluster.Path) storagemigrationv1alpha1.StorageVersionMigrationInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } @@ -58,11 +59,11 @@ func (c *storageVersionMigrationsClusterInterface) Cluster(clusterPath logicalcl } // List returns the entire collection of all StorageVersionMigrations across all clusters. -func (c *storageVersionMigrationsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*storagemigrationv1alpha1.StorageVersionMigrationList, error) { +func (c *storageVersionMigrationsClusterInterface) List(ctx context.Context, opts v1.ListOptions) (*apistoragemigrationv1alpha1.StorageVersionMigrationList, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).StorageVersionMigrations().List(ctx, opts) } // Watch begins to watch all StorageVersionMigrations across all clusters. -func (c *storageVersionMigrationsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { +func (c *storageVersionMigrationsClusterInterface) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).StorageVersionMigrations().Watch(ctx, opts) } diff --git a/listers/admissionregistration/v1/expansion_generated.go b/listers/admissionregistration/v1/expansion_generated.go new file mode 100644 index 000000000..b6a0c6377 --- /dev/null +++ b/listers/admissionregistration/v1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1 diff --git a/listers/admissionregistration/v1/mutatingwebhookconfiguration.go b/listers/admissionregistration/v1/mutatingwebhookconfiguration.go index da261e741..b43b13285 100644 --- a/listers/admissionregistration/v1/mutatingwebhookconfiguration.go +++ b/listers/admissionregistration/v1/mutatingwebhookconfiguration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" admissionregistrationv1 "k8s.io/api/admissionregistration/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - admissionregistrationv1listers "k8s.io/client-go/listers/admissionregistration/v1" + listersadmissionregistrationv1 "k8s.io/client-go/listers/admissionregistration/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// MutatingWebhookConfigurationClusterLister can list MutatingWebhookConfigurations across all workspaces, or scope down to a MutatingWebhookConfigurationLister for one workspace. +// MutatingWebhookConfigurationClusterLister helps list MutatingWebhookConfigurations across all workspaces, +// or scope down to a MutatingWebhookConfigurationLister for one workspace. // All objects returned here must be treated as read-only. type MutatingWebhookConfigurationClusterLister interface { // List lists all MutatingWebhookConfigurations in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*admissionregistrationv1.MutatingWebhookConfiguration, err error) // Cluster returns a lister that can list and get MutatingWebhookConfigurations in one workspace. - Cluster(clusterName logicalcluster.Name) admissionregistrationv1listers.MutatingWebhookConfigurationLister + Cluster(clusterName logicalcluster.Name) listersadmissionregistrationv1.MutatingWebhookConfigurationLister MutatingWebhookConfigurationClusterListerExpansion } +// mutatingWebhookConfigurationClusterLister implements the MutatingWebhookConfigurationClusterLister interface. type mutatingWebhookConfigurationClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*admissionregistrationv1.MutatingWebhookConfiguration] } +var _ MutatingWebhookConfigurationClusterLister = new(mutatingWebhookConfigurationClusterLister) + // NewMutatingWebhookConfigurationClusterLister returns a new MutatingWebhookConfigurationClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewMutatingWebhookConfigurationClusterLister(indexer cache.Indexer) *mutatingWebhookConfigurationClusterLister { - return &mutatingWebhookConfigurationClusterLister{indexer: indexer} -} - -// List lists all MutatingWebhookConfigurations in the indexer across all workspaces. -func (s *mutatingWebhookConfigurationClusterLister) List(selector labels.Selector) (ret []*admissionregistrationv1.MutatingWebhookConfiguration, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*admissionregistrationv1.MutatingWebhookConfiguration)) - }) - return ret, err +func NewMutatingWebhookConfigurationClusterLister(indexer cache.Indexer) MutatingWebhookConfigurationClusterLister { + return &mutatingWebhookConfigurationClusterLister{ + kcplisters.NewCluster[*admissionregistrationv1.MutatingWebhookConfiguration](indexer, admissionregistrationv1.Resource("mutatingwebhookconfiguration")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get MutatingWebhookConfigurations. -func (s *mutatingWebhookConfigurationClusterLister) Cluster(clusterName logicalcluster.Name) admissionregistrationv1listers.MutatingWebhookConfigurationLister { - return &mutatingWebhookConfigurationLister{indexer: s.indexer, clusterName: clusterName} +func (l *mutatingWebhookConfigurationClusterLister) Cluster(clusterName logicalcluster.Name) listersadmissionregistrationv1.MutatingWebhookConfigurationLister { + return &mutatingWebhookConfigurationLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// mutatingWebhookConfigurationLister implements the admissionregistrationv1listers.MutatingWebhookConfigurationLister interface. +// mutatingWebhookConfigurationLister can list all MutatingWebhookConfigurations inside a workspace +// or scope down to a listersadmissionregistrationv1.MutatingWebhookConfigurationNamespaceLister for one namespace. type mutatingWebhookConfigurationLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*admissionregistrationv1.MutatingWebhookConfiguration] } -// List lists all MutatingWebhookConfigurations in the indexer for a workspace. -func (s *mutatingWebhookConfigurationLister) List(selector labels.Selector) (ret []*admissionregistrationv1.MutatingWebhookConfiguration, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*admissionregistrationv1.MutatingWebhookConfiguration)) - }) - return ret, err -} +var _ listersadmissionregistrationv1.MutatingWebhookConfigurationLister = new(mutatingWebhookConfigurationLister) -// Get retrieves the MutatingWebhookConfiguration from the indexer for a given workspace and name. -func (s *mutatingWebhookConfigurationLister) Get(name string) (*admissionregistrationv1.MutatingWebhookConfiguration, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(admissionregistrationv1.Resource("mutatingwebhookconfigurations"), name) +// NewMutatingWebhookConfigurationLister returns a new MutatingWebhookConfigurationLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewMutatingWebhookConfigurationLister(indexer cache.Indexer) listersadmissionregistrationv1.MutatingWebhookConfigurationLister { + return &mutatingWebhookConfigurationLister{ + kcplisters.New[*admissionregistrationv1.MutatingWebhookConfiguration](indexer, admissionregistrationv1.Resource("mutatingwebhookconfiguration")), } - return obj.(*admissionregistrationv1.MutatingWebhookConfiguration), nil +} + +// mutatingWebhookConfigurationScopedLister can list all MutatingWebhookConfigurations inside a workspace +// or scope down to a listersadmissionregistrationv1.MutatingWebhookConfigurationNamespaceLister. +type mutatingWebhookConfigurationScopedLister struct { + kcplisters.ResourceIndexer[*admissionregistrationv1.MutatingWebhookConfiguration] } diff --git a/listers/admissionregistration/v1/validatingadmissionpolicy.go b/listers/admissionregistration/v1/validatingadmissionpolicy.go index 92fd8c3c6..7b939f27b 100644 --- a/listers/admissionregistration/v1/validatingadmissionpolicy.go +++ b/listers/admissionregistration/v1/validatingadmissionpolicy.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" admissionregistrationv1 "k8s.io/api/admissionregistration/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - admissionregistrationv1listers "k8s.io/client-go/listers/admissionregistration/v1" + listersadmissionregistrationv1 "k8s.io/client-go/listers/admissionregistration/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ValidatingAdmissionPolicyClusterLister can list ValidatingAdmissionPolicies across all workspaces, or scope down to a ValidatingAdmissionPolicyLister for one workspace. +// ValidatingAdmissionPolicyClusterLister helps list ValidatingAdmissionPolicies across all workspaces, +// or scope down to a ValidatingAdmissionPolicyLister for one workspace. // All objects returned here must be treated as read-only. type ValidatingAdmissionPolicyClusterLister interface { // List lists all ValidatingAdmissionPolicies in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*admissionregistrationv1.ValidatingAdmissionPolicy, err error) // Cluster returns a lister that can list and get ValidatingAdmissionPolicies in one workspace. - Cluster(clusterName logicalcluster.Name) admissionregistrationv1listers.ValidatingAdmissionPolicyLister + Cluster(clusterName logicalcluster.Name) listersadmissionregistrationv1.ValidatingAdmissionPolicyLister ValidatingAdmissionPolicyClusterListerExpansion } +// validatingAdmissionPolicyClusterLister implements the ValidatingAdmissionPolicyClusterLister interface. type validatingAdmissionPolicyClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*admissionregistrationv1.ValidatingAdmissionPolicy] } +var _ ValidatingAdmissionPolicyClusterLister = new(validatingAdmissionPolicyClusterLister) + // NewValidatingAdmissionPolicyClusterLister returns a new ValidatingAdmissionPolicyClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewValidatingAdmissionPolicyClusterLister(indexer cache.Indexer) *validatingAdmissionPolicyClusterLister { - return &validatingAdmissionPolicyClusterLister{indexer: indexer} -} - -// List lists all ValidatingAdmissionPolicies in the indexer across all workspaces. -func (s *validatingAdmissionPolicyClusterLister) List(selector labels.Selector) (ret []*admissionregistrationv1.ValidatingAdmissionPolicy, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*admissionregistrationv1.ValidatingAdmissionPolicy)) - }) - return ret, err +func NewValidatingAdmissionPolicyClusterLister(indexer cache.Indexer) ValidatingAdmissionPolicyClusterLister { + return &validatingAdmissionPolicyClusterLister{ + kcplisters.NewCluster[*admissionregistrationv1.ValidatingAdmissionPolicy](indexer, admissionregistrationv1.Resource("validatingadmissionpolicy")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ValidatingAdmissionPolicies. -func (s *validatingAdmissionPolicyClusterLister) Cluster(clusterName logicalcluster.Name) admissionregistrationv1listers.ValidatingAdmissionPolicyLister { - return &validatingAdmissionPolicyLister{indexer: s.indexer, clusterName: clusterName} +func (l *validatingAdmissionPolicyClusterLister) Cluster(clusterName logicalcluster.Name) listersadmissionregistrationv1.ValidatingAdmissionPolicyLister { + return &validatingAdmissionPolicyLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// validatingAdmissionPolicyLister implements the admissionregistrationv1listers.ValidatingAdmissionPolicyLister interface. +// validatingAdmissionPolicyLister can list all ValidatingAdmissionPolicies inside a workspace +// or scope down to a listersadmissionregistrationv1.ValidatingAdmissionPolicyNamespaceLister for one namespace. type validatingAdmissionPolicyLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*admissionregistrationv1.ValidatingAdmissionPolicy] } -// List lists all ValidatingAdmissionPolicies in the indexer for a workspace. -func (s *validatingAdmissionPolicyLister) List(selector labels.Selector) (ret []*admissionregistrationv1.ValidatingAdmissionPolicy, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*admissionregistrationv1.ValidatingAdmissionPolicy)) - }) - return ret, err -} +var _ listersadmissionregistrationv1.ValidatingAdmissionPolicyLister = new(validatingAdmissionPolicyLister) -// Get retrieves the ValidatingAdmissionPolicy from the indexer for a given workspace and name. -func (s *validatingAdmissionPolicyLister) Get(name string) (*admissionregistrationv1.ValidatingAdmissionPolicy, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(admissionregistrationv1.Resource("validatingadmissionpolicies"), name) +// NewValidatingAdmissionPolicyLister returns a new ValidatingAdmissionPolicyLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewValidatingAdmissionPolicyLister(indexer cache.Indexer) listersadmissionregistrationv1.ValidatingAdmissionPolicyLister { + return &validatingAdmissionPolicyLister{ + kcplisters.New[*admissionregistrationv1.ValidatingAdmissionPolicy](indexer, admissionregistrationv1.Resource("validatingadmissionpolicy")), } - return obj.(*admissionregistrationv1.ValidatingAdmissionPolicy), nil +} + +// validatingAdmissionPolicyScopedLister can list all ValidatingAdmissionPolicies inside a workspace +// or scope down to a listersadmissionregistrationv1.ValidatingAdmissionPolicyNamespaceLister. +type validatingAdmissionPolicyScopedLister struct { + kcplisters.ResourceIndexer[*admissionregistrationv1.ValidatingAdmissionPolicy] } diff --git a/listers/admissionregistration/v1/validatingadmissionpolicybinding.go b/listers/admissionregistration/v1/validatingadmissionpolicybinding.go index 5d36690c7..a0de45eeb 100644 --- a/listers/admissionregistration/v1/validatingadmissionpolicybinding.go +++ b/listers/admissionregistration/v1/validatingadmissionpolicybinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" admissionregistrationv1 "k8s.io/api/admissionregistration/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - admissionregistrationv1listers "k8s.io/client-go/listers/admissionregistration/v1" + listersadmissionregistrationv1 "k8s.io/client-go/listers/admissionregistration/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ValidatingAdmissionPolicyBindingClusterLister can list ValidatingAdmissionPolicyBindings across all workspaces, or scope down to a ValidatingAdmissionPolicyBindingLister for one workspace. +// ValidatingAdmissionPolicyBindingClusterLister helps list ValidatingAdmissionPolicyBindings across all workspaces, +// or scope down to a ValidatingAdmissionPolicyBindingLister for one workspace. // All objects returned here must be treated as read-only. type ValidatingAdmissionPolicyBindingClusterLister interface { // List lists all ValidatingAdmissionPolicyBindings in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*admissionregistrationv1.ValidatingAdmissionPolicyBinding, err error) // Cluster returns a lister that can list and get ValidatingAdmissionPolicyBindings in one workspace. - Cluster(clusterName logicalcluster.Name) admissionregistrationv1listers.ValidatingAdmissionPolicyBindingLister + Cluster(clusterName logicalcluster.Name) listersadmissionregistrationv1.ValidatingAdmissionPolicyBindingLister ValidatingAdmissionPolicyBindingClusterListerExpansion } +// validatingAdmissionPolicyBindingClusterLister implements the ValidatingAdmissionPolicyBindingClusterLister interface. type validatingAdmissionPolicyBindingClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*admissionregistrationv1.ValidatingAdmissionPolicyBinding] } +var _ ValidatingAdmissionPolicyBindingClusterLister = new(validatingAdmissionPolicyBindingClusterLister) + // NewValidatingAdmissionPolicyBindingClusterLister returns a new ValidatingAdmissionPolicyBindingClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewValidatingAdmissionPolicyBindingClusterLister(indexer cache.Indexer) *validatingAdmissionPolicyBindingClusterLister { - return &validatingAdmissionPolicyBindingClusterLister{indexer: indexer} -} - -// List lists all ValidatingAdmissionPolicyBindings in the indexer across all workspaces. -func (s *validatingAdmissionPolicyBindingClusterLister) List(selector labels.Selector) (ret []*admissionregistrationv1.ValidatingAdmissionPolicyBinding, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*admissionregistrationv1.ValidatingAdmissionPolicyBinding)) - }) - return ret, err +func NewValidatingAdmissionPolicyBindingClusterLister(indexer cache.Indexer) ValidatingAdmissionPolicyBindingClusterLister { + return &validatingAdmissionPolicyBindingClusterLister{ + kcplisters.NewCluster[*admissionregistrationv1.ValidatingAdmissionPolicyBinding](indexer, admissionregistrationv1.Resource("validatingadmissionpolicybinding")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ValidatingAdmissionPolicyBindings. -func (s *validatingAdmissionPolicyBindingClusterLister) Cluster(clusterName logicalcluster.Name) admissionregistrationv1listers.ValidatingAdmissionPolicyBindingLister { - return &validatingAdmissionPolicyBindingLister{indexer: s.indexer, clusterName: clusterName} +func (l *validatingAdmissionPolicyBindingClusterLister) Cluster(clusterName logicalcluster.Name) listersadmissionregistrationv1.ValidatingAdmissionPolicyBindingLister { + return &validatingAdmissionPolicyBindingLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// validatingAdmissionPolicyBindingLister implements the admissionregistrationv1listers.ValidatingAdmissionPolicyBindingLister interface. +// validatingAdmissionPolicyBindingLister can list all ValidatingAdmissionPolicyBindings inside a workspace +// or scope down to a listersadmissionregistrationv1.ValidatingAdmissionPolicyBindingNamespaceLister for one namespace. type validatingAdmissionPolicyBindingLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*admissionregistrationv1.ValidatingAdmissionPolicyBinding] } -// List lists all ValidatingAdmissionPolicyBindings in the indexer for a workspace. -func (s *validatingAdmissionPolicyBindingLister) List(selector labels.Selector) (ret []*admissionregistrationv1.ValidatingAdmissionPolicyBinding, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*admissionregistrationv1.ValidatingAdmissionPolicyBinding)) - }) - return ret, err -} +var _ listersadmissionregistrationv1.ValidatingAdmissionPolicyBindingLister = new(validatingAdmissionPolicyBindingLister) -// Get retrieves the ValidatingAdmissionPolicyBinding from the indexer for a given workspace and name. -func (s *validatingAdmissionPolicyBindingLister) Get(name string) (*admissionregistrationv1.ValidatingAdmissionPolicyBinding, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(admissionregistrationv1.Resource("validatingadmissionpolicybindings"), name) +// NewValidatingAdmissionPolicyBindingLister returns a new ValidatingAdmissionPolicyBindingLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewValidatingAdmissionPolicyBindingLister(indexer cache.Indexer) listersadmissionregistrationv1.ValidatingAdmissionPolicyBindingLister { + return &validatingAdmissionPolicyBindingLister{ + kcplisters.New[*admissionregistrationv1.ValidatingAdmissionPolicyBinding](indexer, admissionregistrationv1.Resource("validatingadmissionpolicybinding")), } - return obj.(*admissionregistrationv1.ValidatingAdmissionPolicyBinding), nil +} + +// validatingAdmissionPolicyBindingScopedLister can list all ValidatingAdmissionPolicyBindings inside a workspace +// or scope down to a listersadmissionregistrationv1.ValidatingAdmissionPolicyBindingNamespaceLister. +type validatingAdmissionPolicyBindingScopedLister struct { + kcplisters.ResourceIndexer[*admissionregistrationv1.ValidatingAdmissionPolicyBinding] } diff --git a/listers/admissionregistration/v1/validatingwebhookconfiguration.go b/listers/admissionregistration/v1/validatingwebhookconfiguration.go index fe8329cbd..63d43b1e5 100644 --- a/listers/admissionregistration/v1/validatingwebhookconfiguration.go +++ b/listers/admissionregistration/v1/validatingwebhookconfiguration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" admissionregistrationv1 "k8s.io/api/admissionregistration/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - admissionregistrationv1listers "k8s.io/client-go/listers/admissionregistration/v1" + listersadmissionregistrationv1 "k8s.io/client-go/listers/admissionregistration/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ValidatingWebhookConfigurationClusterLister can list ValidatingWebhookConfigurations across all workspaces, or scope down to a ValidatingWebhookConfigurationLister for one workspace. +// ValidatingWebhookConfigurationClusterLister helps list ValidatingWebhookConfigurations across all workspaces, +// or scope down to a ValidatingWebhookConfigurationLister for one workspace. // All objects returned here must be treated as read-only. type ValidatingWebhookConfigurationClusterLister interface { // List lists all ValidatingWebhookConfigurations in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*admissionregistrationv1.ValidatingWebhookConfiguration, err error) // Cluster returns a lister that can list and get ValidatingWebhookConfigurations in one workspace. - Cluster(clusterName logicalcluster.Name) admissionregistrationv1listers.ValidatingWebhookConfigurationLister + Cluster(clusterName logicalcluster.Name) listersadmissionregistrationv1.ValidatingWebhookConfigurationLister ValidatingWebhookConfigurationClusterListerExpansion } +// validatingWebhookConfigurationClusterLister implements the ValidatingWebhookConfigurationClusterLister interface. type validatingWebhookConfigurationClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*admissionregistrationv1.ValidatingWebhookConfiguration] } +var _ ValidatingWebhookConfigurationClusterLister = new(validatingWebhookConfigurationClusterLister) + // NewValidatingWebhookConfigurationClusterLister returns a new ValidatingWebhookConfigurationClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewValidatingWebhookConfigurationClusterLister(indexer cache.Indexer) *validatingWebhookConfigurationClusterLister { - return &validatingWebhookConfigurationClusterLister{indexer: indexer} -} - -// List lists all ValidatingWebhookConfigurations in the indexer across all workspaces. -func (s *validatingWebhookConfigurationClusterLister) List(selector labels.Selector) (ret []*admissionregistrationv1.ValidatingWebhookConfiguration, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*admissionregistrationv1.ValidatingWebhookConfiguration)) - }) - return ret, err +func NewValidatingWebhookConfigurationClusterLister(indexer cache.Indexer) ValidatingWebhookConfigurationClusterLister { + return &validatingWebhookConfigurationClusterLister{ + kcplisters.NewCluster[*admissionregistrationv1.ValidatingWebhookConfiguration](indexer, admissionregistrationv1.Resource("validatingwebhookconfiguration")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ValidatingWebhookConfigurations. -func (s *validatingWebhookConfigurationClusterLister) Cluster(clusterName logicalcluster.Name) admissionregistrationv1listers.ValidatingWebhookConfigurationLister { - return &validatingWebhookConfigurationLister{indexer: s.indexer, clusterName: clusterName} +func (l *validatingWebhookConfigurationClusterLister) Cluster(clusterName logicalcluster.Name) listersadmissionregistrationv1.ValidatingWebhookConfigurationLister { + return &validatingWebhookConfigurationLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// validatingWebhookConfigurationLister implements the admissionregistrationv1listers.ValidatingWebhookConfigurationLister interface. +// validatingWebhookConfigurationLister can list all ValidatingWebhookConfigurations inside a workspace +// or scope down to a listersadmissionregistrationv1.ValidatingWebhookConfigurationNamespaceLister for one namespace. type validatingWebhookConfigurationLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*admissionregistrationv1.ValidatingWebhookConfiguration] } -// List lists all ValidatingWebhookConfigurations in the indexer for a workspace. -func (s *validatingWebhookConfigurationLister) List(selector labels.Selector) (ret []*admissionregistrationv1.ValidatingWebhookConfiguration, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*admissionregistrationv1.ValidatingWebhookConfiguration)) - }) - return ret, err -} +var _ listersadmissionregistrationv1.ValidatingWebhookConfigurationLister = new(validatingWebhookConfigurationLister) -// Get retrieves the ValidatingWebhookConfiguration from the indexer for a given workspace and name. -func (s *validatingWebhookConfigurationLister) Get(name string) (*admissionregistrationv1.ValidatingWebhookConfiguration, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(admissionregistrationv1.Resource("validatingwebhookconfigurations"), name) +// NewValidatingWebhookConfigurationLister returns a new ValidatingWebhookConfigurationLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewValidatingWebhookConfigurationLister(indexer cache.Indexer) listersadmissionregistrationv1.ValidatingWebhookConfigurationLister { + return &validatingWebhookConfigurationLister{ + kcplisters.New[*admissionregistrationv1.ValidatingWebhookConfiguration](indexer, admissionregistrationv1.Resource("validatingwebhookconfiguration")), } - return obj.(*admissionregistrationv1.ValidatingWebhookConfiguration), nil +} + +// validatingWebhookConfigurationScopedLister can list all ValidatingWebhookConfigurations inside a workspace +// or scope down to a listersadmissionregistrationv1.ValidatingWebhookConfigurationNamespaceLister. +type validatingWebhookConfigurationScopedLister struct { + kcplisters.ResourceIndexer[*admissionregistrationv1.ValidatingWebhookConfiguration] } diff --git a/listers/admissionregistration/v1alpha1/expansion_generated.go b/listers/admissionregistration/v1alpha1/expansion_generated.go new file mode 100644 index 000000000..3b8521c00 --- /dev/null +++ b/listers/admissionregistration/v1alpha1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1alpha1 diff --git a/listers/admissionregistration/v1alpha1/mutatingadmissionpolicy.go b/listers/admissionregistration/v1alpha1/mutatingadmissionpolicy.go index 6c9cfc205..bd3a68510 100644 --- a/listers/admissionregistration/v1alpha1/mutatingadmissionpolicy.go +++ b/listers/admissionregistration/v1alpha1/mutatingadmissionpolicy.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1alpha1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" admissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - admissionregistrationv1alpha1listers "k8s.io/client-go/listers/admissionregistration/v1alpha1" + listersadmissionregistrationv1alpha1 "k8s.io/client-go/listers/admissionregistration/v1alpha1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// MutatingAdmissionPolicyClusterLister can list MutatingAdmissionPolicies across all workspaces, or scope down to a MutatingAdmissionPolicyLister for one workspace. +// MutatingAdmissionPolicyClusterLister helps list MutatingAdmissionPolicies across all workspaces, +// or scope down to a MutatingAdmissionPolicyLister for one workspace. // All objects returned here must be treated as read-only. type MutatingAdmissionPolicyClusterLister interface { // List lists all MutatingAdmissionPolicies in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*admissionregistrationv1alpha1.MutatingAdmissionPolicy, err error) // Cluster returns a lister that can list and get MutatingAdmissionPolicies in one workspace. - Cluster(clusterName logicalcluster.Name) admissionregistrationv1alpha1listers.MutatingAdmissionPolicyLister + Cluster(clusterName logicalcluster.Name) listersadmissionregistrationv1alpha1.MutatingAdmissionPolicyLister MutatingAdmissionPolicyClusterListerExpansion } +// mutatingAdmissionPolicyClusterLister implements the MutatingAdmissionPolicyClusterLister interface. type mutatingAdmissionPolicyClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*admissionregistrationv1alpha1.MutatingAdmissionPolicy] } +var _ MutatingAdmissionPolicyClusterLister = new(mutatingAdmissionPolicyClusterLister) + // NewMutatingAdmissionPolicyClusterLister returns a new MutatingAdmissionPolicyClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewMutatingAdmissionPolicyClusterLister(indexer cache.Indexer) *mutatingAdmissionPolicyClusterLister { - return &mutatingAdmissionPolicyClusterLister{indexer: indexer} -} - -// List lists all MutatingAdmissionPolicies in the indexer across all workspaces. -func (s *mutatingAdmissionPolicyClusterLister) List(selector labels.Selector) (ret []*admissionregistrationv1alpha1.MutatingAdmissionPolicy, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*admissionregistrationv1alpha1.MutatingAdmissionPolicy)) - }) - return ret, err +func NewMutatingAdmissionPolicyClusterLister(indexer cache.Indexer) MutatingAdmissionPolicyClusterLister { + return &mutatingAdmissionPolicyClusterLister{ + kcplisters.NewCluster[*admissionregistrationv1alpha1.MutatingAdmissionPolicy](indexer, admissionregistrationv1alpha1.Resource("mutatingadmissionpolicy")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get MutatingAdmissionPolicies. -func (s *mutatingAdmissionPolicyClusterLister) Cluster(clusterName logicalcluster.Name) admissionregistrationv1alpha1listers.MutatingAdmissionPolicyLister { - return &mutatingAdmissionPolicyLister{indexer: s.indexer, clusterName: clusterName} +func (l *mutatingAdmissionPolicyClusterLister) Cluster(clusterName logicalcluster.Name) listersadmissionregistrationv1alpha1.MutatingAdmissionPolicyLister { + return &mutatingAdmissionPolicyLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// mutatingAdmissionPolicyLister implements the admissionregistrationv1alpha1listers.MutatingAdmissionPolicyLister interface. +// mutatingAdmissionPolicyLister can list all MutatingAdmissionPolicies inside a workspace +// or scope down to a listersadmissionregistrationv1alpha1.MutatingAdmissionPolicyNamespaceLister for one namespace. type mutatingAdmissionPolicyLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*admissionregistrationv1alpha1.MutatingAdmissionPolicy] } -// List lists all MutatingAdmissionPolicies in the indexer for a workspace. -func (s *mutatingAdmissionPolicyLister) List(selector labels.Selector) (ret []*admissionregistrationv1alpha1.MutatingAdmissionPolicy, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*admissionregistrationv1alpha1.MutatingAdmissionPolicy)) - }) - return ret, err -} +var _ listersadmissionregistrationv1alpha1.MutatingAdmissionPolicyLister = new(mutatingAdmissionPolicyLister) -// Get retrieves the MutatingAdmissionPolicy from the indexer for a given workspace and name. -func (s *mutatingAdmissionPolicyLister) Get(name string) (*admissionregistrationv1alpha1.MutatingAdmissionPolicy, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(admissionregistrationv1alpha1.Resource("mutatingadmissionpolicies"), name) +// NewMutatingAdmissionPolicyLister returns a new MutatingAdmissionPolicyLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewMutatingAdmissionPolicyLister(indexer cache.Indexer) listersadmissionregistrationv1alpha1.MutatingAdmissionPolicyLister { + return &mutatingAdmissionPolicyLister{ + kcplisters.New[*admissionregistrationv1alpha1.MutatingAdmissionPolicy](indexer, admissionregistrationv1alpha1.Resource("mutatingadmissionpolicy")), } - return obj.(*admissionregistrationv1alpha1.MutatingAdmissionPolicy), nil +} + +// mutatingAdmissionPolicyScopedLister can list all MutatingAdmissionPolicies inside a workspace +// or scope down to a listersadmissionregistrationv1alpha1.MutatingAdmissionPolicyNamespaceLister. +type mutatingAdmissionPolicyScopedLister struct { + kcplisters.ResourceIndexer[*admissionregistrationv1alpha1.MutatingAdmissionPolicy] } diff --git a/listers/admissionregistration/v1alpha1/mutatingadmissionpolicybinding.go b/listers/admissionregistration/v1alpha1/mutatingadmissionpolicybinding.go index 34b6ce417..0881b9306 100644 --- a/listers/admissionregistration/v1alpha1/mutatingadmissionpolicybinding.go +++ b/listers/admissionregistration/v1alpha1/mutatingadmissionpolicybinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1alpha1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" admissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - admissionregistrationv1alpha1listers "k8s.io/client-go/listers/admissionregistration/v1alpha1" + listersadmissionregistrationv1alpha1 "k8s.io/client-go/listers/admissionregistration/v1alpha1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// MutatingAdmissionPolicyBindingClusterLister can list MutatingAdmissionPolicyBindings across all workspaces, or scope down to a MutatingAdmissionPolicyBindingLister for one workspace. +// MutatingAdmissionPolicyBindingClusterLister helps list MutatingAdmissionPolicyBindings across all workspaces, +// or scope down to a MutatingAdmissionPolicyBindingLister for one workspace. // All objects returned here must be treated as read-only. type MutatingAdmissionPolicyBindingClusterLister interface { // List lists all MutatingAdmissionPolicyBindings in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding, err error) // Cluster returns a lister that can list and get MutatingAdmissionPolicyBindings in one workspace. - Cluster(clusterName logicalcluster.Name) admissionregistrationv1alpha1listers.MutatingAdmissionPolicyBindingLister + Cluster(clusterName logicalcluster.Name) listersadmissionregistrationv1alpha1.MutatingAdmissionPolicyBindingLister MutatingAdmissionPolicyBindingClusterListerExpansion } +// mutatingAdmissionPolicyBindingClusterLister implements the MutatingAdmissionPolicyBindingClusterLister interface. type mutatingAdmissionPolicyBindingClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding] } +var _ MutatingAdmissionPolicyBindingClusterLister = new(mutatingAdmissionPolicyBindingClusterLister) + // NewMutatingAdmissionPolicyBindingClusterLister returns a new MutatingAdmissionPolicyBindingClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewMutatingAdmissionPolicyBindingClusterLister(indexer cache.Indexer) *mutatingAdmissionPolicyBindingClusterLister { - return &mutatingAdmissionPolicyBindingClusterLister{indexer: indexer} -} - -// List lists all MutatingAdmissionPolicyBindings in the indexer across all workspaces. -func (s *mutatingAdmissionPolicyBindingClusterLister) List(selector labels.Selector) (ret []*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding)) - }) - return ret, err +func NewMutatingAdmissionPolicyBindingClusterLister(indexer cache.Indexer) MutatingAdmissionPolicyBindingClusterLister { + return &mutatingAdmissionPolicyBindingClusterLister{ + kcplisters.NewCluster[*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding](indexer, admissionregistrationv1alpha1.Resource("mutatingadmissionpolicybinding")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get MutatingAdmissionPolicyBindings. -func (s *mutatingAdmissionPolicyBindingClusterLister) Cluster(clusterName logicalcluster.Name) admissionregistrationv1alpha1listers.MutatingAdmissionPolicyBindingLister { - return &mutatingAdmissionPolicyBindingLister{indexer: s.indexer, clusterName: clusterName} +func (l *mutatingAdmissionPolicyBindingClusterLister) Cluster(clusterName logicalcluster.Name) listersadmissionregistrationv1alpha1.MutatingAdmissionPolicyBindingLister { + return &mutatingAdmissionPolicyBindingLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// mutatingAdmissionPolicyBindingLister implements the admissionregistrationv1alpha1listers.MutatingAdmissionPolicyBindingLister interface. +// mutatingAdmissionPolicyBindingLister can list all MutatingAdmissionPolicyBindings inside a workspace +// or scope down to a listersadmissionregistrationv1alpha1.MutatingAdmissionPolicyBindingNamespaceLister for one namespace. type mutatingAdmissionPolicyBindingLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding] } -// List lists all MutatingAdmissionPolicyBindings in the indexer for a workspace. -func (s *mutatingAdmissionPolicyBindingLister) List(selector labels.Selector) (ret []*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding)) - }) - return ret, err -} +var _ listersadmissionregistrationv1alpha1.MutatingAdmissionPolicyBindingLister = new(mutatingAdmissionPolicyBindingLister) -// Get retrieves the MutatingAdmissionPolicyBinding from the indexer for a given workspace and name. -func (s *mutatingAdmissionPolicyBindingLister) Get(name string) (*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(admissionregistrationv1alpha1.Resource("mutatingadmissionpolicybindings"), name) +// NewMutatingAdmissionPolicyBindingLister returns a new MutatingAdmissionPolicyBindingLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewMutatingAdmissionPolicyBindingLister(indexer cache.Indexer) listersadmissionregistrationv1alpha1.MutatingAdmissionPolicyBindingLister { + return &mutatingAdmissionPolicyBindingLister{ + kcplisters.New[*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding](indexer, admissionregistrationv1alpha1.Resource("mutatingadmissionpolicybinding")), } - return obj.(*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding), nil +} + +// mutatingAdmissionPolicyBindingScopedLister can list all MutatingAdmissionPolicyBindings inside a workspace +// or scope down to a listersadmissionregistrationv1alpha1.MutatingAdmissionPolicyBindingNamespaceLister. +type mutatingAdmissionPolicyBindingScopedLister struct { + kcplisters.ResourceIndexer[*admissionregistrationv1alpha1.MutatingAdmissionPolicyBinding] } diff --git a/listers/admissionregistration/v1alpha1/validatingadmissionpolicy.go b/listers/admissionregistration/v1alpha1/validatingadmissionpolicy.go index f33d5b5d5..140f0763a 100644 --- a/listers/admissionregistration/v1alpha1/validatingadmissionpolicy.go +++ b/listers/admissionregistration/v1alpha1/validatingadmissionpolicy.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1alpha1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" admissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - admissionregistrationv1alpha1listers "k8s.io/client-go/listers/admissionregistration/v1alpha1" + listersadmissionregistrationv1alpha1 "k8s.io/client-go/listers/admissionregistration/v1alpha1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ValidatingAdmissionPolicyClusterLister can list ValidatingAdmissionPolicies across all workspaces, or scope down to a ValidatingAdmissionPolicyLister for one workspace. +// ValidatingAdmissionPolicyClusterLister helps list ValidatingAdmissionPolicies across all workspaces, +// or scope down to a ValidatingAdmissionPolicyLister for one workspace. // All objects returned here must be treated as read-only. type ValidatingAdmissionPolicyClusterLister interface { // List lists all ValidatingAdmissionPolicies in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*admissionregistrationv1alpha1.ValidatingAdmissionPolicy, err error) // Cluster returns a lister that can list and get ValidatingAdmissionPolicies in one workspace. - Cluster(clusterName logicalcluster.Name) admissionregistrationv1alpha1listers.ValidatingAdmissionPolicyLister + Cluster(clusterName logicalcluster.Name) listersadmissionregistrationv1alpha1.ValidatingAdmissionPolicyLister ValidatingAdmissionPolicyClusterListerExpansion } +// validatingAdmissionPolicyClusterLister implements the ValidatingAdmissionPolicyClusterLister interface. type validatingAdmissionPolicyClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*admissionregistrationv1alpha1.ValidatingAdmissionPolicy] } +var _ ValidatingAdmissionPolicyClusterLister = new(validatingAdmissionPolicyClusterLister) + // NewValidatingAdmissionPolicyClusterLister returns a new ValidatingAdmissionPolicyClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewValidatingAdmissionPolicyClusterLister(indexer cache.Indexer) *validatingAdmissionPolicyClusterLister { - return &validatingAdmissionPolicyClusterLister{indexer: indexer} -} - -// List lists all ValidatingAdmissionPolicies in the indexer across all workspaces. -func (s *validatingAdmissionPolicyClusterLister) List(selector labels.Selector) (ret []*admissionregistrationv1alpha1.ValidatingAdmissionPolicy, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*admissionregistrationv1alpha1.ValidatingAdmissionPolicy)) - }) - return ret, err +func NewValidatingAdmissionPolicyClusterLister(indexer cache.Indexer) ValidatingAdmissionPolicyClusterLister { + return &validatingAdmissionPolicyClusterLister{ + kcplisters.NewCluster[*admissionregistrationv1alpha1.ValidatingAdmissionPolicy](indexer, admissionregistrationv1alpha1.Resource("validatingadmissionpolicy")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ValidatingAdmissionPolicies. -func (s *validatingAdmissionPolicyClusterLister) Cluster(clusterName logicalcluster.Name) admissionregistrationv1alpha1listers.ValidatingAdmissionPolicyLister { - return &validatingAdmissionPolicyLister{indexer: s.indexer, clusterName: clusterName} +func (l *validatingAdmissionPolicyClusterLister) Cluster(clusterName logicalcluster.Name) listersadmissionregistrationv1alpha1.ValidatingAdmissionPolicyLister { + return &validatingAdmissionPolicyLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// validatingAdmissionPolicyLister implements the admissionregistrationv1alpha1listers.ValidatingAdmissionPolicyLister interface. +// validatingAdmissionPolicyLister can list all ValidatingAdmissionPolicies inside a workspace +// or scope down to a listersadmissionregistrationv1alpha1.ValidatingAdmissionPolicyNamespaceLister for one namespace. type validatingAdmissionPolicyLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*admissionregistrationv1alpha1.ValidatingAdmissionPolicy] } -// List lists all ValidatingAdmissionPolicies in the indexer for a workspace. -func (s *validatingAdmissionPolicyLister) List(selector labels.Selector) (ret []*admissionregistrationv1alpha1.ValidatingAdmissionPolicy, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*admissionregistrationv1alpha1.ValidatingAdmissionPolicy)) - }) - return ret, err -} +var _ listersadmissionregistrationv1alpha1.ValidatingAdmissionPolicyLister = new(validatingAdmissionPolicyLister) -// Get retrieves the ValidatingAdmissionPolicy from the indexer for a given workspace and name. -func (s *validatingAdmissionPolicyLister) Get(name string) (*admissionregistrationv1alpha1.ValidatingAdmissionPolicy, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(admissionregistrationv1alpha1.Resource("validatingadmissionpolicies"), name) +// NewValidatingAdmissionPolicyLister returns a new ValidatingAdmissionPolicyLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewValidatingAdmissionPolicyLister(indexer cache.Indexer) listersadmissionregistrationv1alpha1.ValidatingAdmissionPolicyLister { + return &validatingAdmissionPolicyLister{ + kcplisters.New[*admissionregistrationv1alpha1.ValidatingAdmissionPolicy](indexer, admissionregistrationv1alpha1.Resource("validatingadmissionpolicy")), } - return obj.(*admissionregistrationv1alpha1.ValidatingAdmissionPolicy), nil +} + +// validatingAdmissionPolicyScopedLister can list all ValidatingAdmissionPolicies inside a workspace +// or scope down to a listersadmissionregistrationv1alpha1.ValidatingAdmissionPolicyNamespaceLister. +type validatingAdmissionPolicyScopedLister struct { + kcplisters.ResourceIndexer[*admissionregistrationv1alpha1.ValidatingAdmissionPolicy] } diff --git a/listers/admissionregistration/v1alpha1/validatingadmissionpolicybinding.go b/listers/admissionregistration/v1alpha1/validatingadmissionpolicybinding.go index d2e703758..1aa861b8b 100644 --- a/listers/admissionregistration/v1alpha1/validatingadmissionpolicybinding.go +++ b/listers/admissionregistration/v1alpha1/validatingadmissionpolicybinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1alpha1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" admissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - admissionregistrationv1alpha1listers "k8s.io/client-go/listers/admissionregistration/v1alpha1" + listersadmissionregistrationv1alpha1 "k8s.io/client-go/listers/admissionregistration/v1alpha1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ValidatingAdmissionPolicyBindingClusterLister can list ValidatingAdmissionPolicyBindings across all workspaces, or scope down to a ValidatingAdmissionPolicyBindingLister for one workspace. +// ValidatingAdmissionPolicyBindingClusterLister helps list ValidatingAdmissionPolicyBindings across all workspaces, +// or scope down to a ValidatingAdmissionPolicyBindingLister for one workspace. // All objects returned here must be treated as read-only. type ValidatingAdmissionPolicyBindingClusterLister interface { // List lists all ValidatingAdmissionPolicyBindings in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding, err error) // Cluster returns a lister that can list and get ValidatingAdmissionPolicyBindings in one workspace. - Cluster(clusterName logicalcluster.Name) admissionregistrationv1alpha1listers.ValidatingAdmissionPolicyBindingLister + Cluster(clusterName logicalcluster.Name) listersadmissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingLister ValidatingAdmissionPolicyBindingClusterListerExpansion } +// validatingAdmissionPolicyBindingClusterLister implements the ValidatingAdmissionPolicyBindingClusterLister interface. type validatingAdmissionPolicyBindingClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding] } +var _ ValidatingAdmissionPolicyBindingClusterLister = new(validatingAdmissionPolicyBindingClusterLister) + // NewValidatingAdmissionPolicyBindingClusterLister returns a new ValidatingAdmissionPolicyBindingClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewValidatingAdmissionPolicyBindingClusterLister(indexer cache.Indexer) *validatingAdmissionPolicyBindingClusterLister { - return &validatingAdmissionPolicyBindingClusterLister{indexer: indexer} -} - -// List lists all ValidatingAdmissionPolicyBindings in the indexer across all workspaces. -func (s *validatingAdmissionPolicyBindingClusterLister) List(selector labels.Selector) (ret []*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding)) - }) - return ret, err +func NewValidatingAdmissionPolicyBindingClusterLister(indexer cache.Indexer) ValidatingAdmissionPolicyBindingClusterLister { + return &validatingAdmissionPolicyBindingClusterLister{ + kcplisters.NewCluster[*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding](indexer, admissionregistrationv1alpha1.Resource("validatingadmissionpolicybinding")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ValidatingAdmissionPolicyBindings. -func (s *validatingAdmissionPolicyBindingClusterLister) Cluster(clusterName logicalcluster.Name) admissionregistrationv1alpha1listers.ValidatingAdmissionPolicyBindingLister { - return &validatingAdmissionPolicyBindingLister{indexer: s.indexer, clusterName: clusterName} +func (l *validatingAdmissionPolicyBindingClusterLister) Cluster(clusterName logicalcluster.Name) listersadmissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingLister { + return &validatingAdmissionPolicyBindingLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// validatingAdmissionPolicyBindingLister implements the admissionregistrationv1alpha1listers.ValidatingAdmissionPolicyBindingLister interface. +// validatingAdmissionPolicyBindingLister can list all ValidatingAdmissionPolicyBindings inside a workspace +// or scope down to a listersadmissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingNamespaceLister for one namespace. type validatingAdmissionPolicyBindingLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding] } -// List lists all ValidatingAdmissionPolicyBindings in the indexer for a workspace. -func (s *validatingAdmissionPolicyBindingLister) List(selector labels.Selector) (ret []*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding)) - }) - return ret, err -} +var _ listersadmissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingLister = new(validatingAdmissionPolicyBindingLister) -// Get retrieves the ValidatingAdmissionPolicyBinding from the indexer for a given workspace and name. -func (s *validatingAdmissionPolicyBindingLister) Get(name string) (*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(admissionregistrationv1alpha1.Resource("validatingadmissionpolicybindings"), name) +// NewValidatingAdmissionPolicyBindingLister returns a new ValidatingAdmissionPolicyBindingLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewValidatingAdmissionPolicyBindingLister(indexer cache.Indexer) listersadmissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingLister { + return &validatingAdmissionPolicyBindingLister{ + kcplisters.New[*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding](indexer, admissionregistrationv1alpha1.Resource("validatingadmissionpolicybinding")), } - return obj.(*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding), nil +} + +// validatingAdmissionPolicyBindingScopedLister can list all ValidatingAdmissionPolicyBindings inside a workspace +// or scope down to a listersadmissionregistrationv1alpha1.ValidatingAdmissionPolicyBindingNamespaceLister. +type validatingAdmissionPolicyBindingScopedLister struct { + kcplisters.ResourceIndexer[*admissionregistrationv1alpha1.ValidatingAdmissionPolicyBinding] } diff --git a/listers/admissionregistration/v1beta1/expansion_generated.go b/listers/admissionregistration/v1beta1/expansion_generated.go new file mode 100644 index 000000000..23cac805b --- /dev/null +++ b/listers/admissionregistration/v1beta1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1beta1 diff --git a/listers/admissionregistration/v1beta1/mutatingwebhookconfiguration.go b/listers/admissionregistration/v1beta1/mutatingwebhookconfiguration.go index d7e018822..ee4adb1db 100644 --- a/listers/admissionregistration/v1beta1/mutatingwebhookconfiguration.go +++ b/listers/admissionregistration/v1beta1/mutatingwebhookconfiguration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - admissionregistrationv1beta1listers "k8s.io/client-go/listers/admissionregistration/v1beta1" + listersadmissionregistrationv1beta1 "k8s.io/client-go/listers/admissionregistration/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// MutatingWebhookConfigurationClusterLister can list MutatingWebhookConfigurations across all workspaces, or scope down to a MutatingWebhookConfigurationLister for one workspace. +// MutatingWebhookConfigurationClusterLister helps list MutatingWebhookConfigurations across all workspaces, +// or scope down to a MutatingWebhookConfigurationLister for one workspace. // All objects returned here must be treated as read-only. type MutatingWebhookConfigurationClusterLister interface { // List lists all MutatingWebhookConfigurations in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*admissionregistrationv1beta1.MutatingWebhookConfiguration, err error) // Cluster returns a lister that can list and get MutatingWebhookConfigurations in one workspace. - Cluster(clusterName logicalcluster.Name) admissionregistrationv1beta1listers.MutatingWebhookConfigurationLister + Cluster(clusterName logicalcluster.Name) listersadmissionregistrationv1beta1.MutatingWebhookConfigurationLister MutatingWebhookConfigurationClusterListerExpansion } +// mutatingWebhookConfigurationClusterLister implements the MutatingWebhookConfigurationClusterLister interface. type mutatingWebhookConfigurationClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*admissionregistrationv1beta1.MutatingWebhookConfiguration] } +var _ MutatingWebhookConfigurationClusterLister = new(mutatingWebhookConfigurationClusterLister) + // NewMutatingWebhookConfigurationClusterLister returns a new MutatingWebhookConfigurationClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewMutatingWebhookConfigurationClusterLister(indexer cache.Indexer) *mutatingWebhookConfigurationClusterLister { - return &mutatingWebhookConfigurationClusterLister{indexer: indexer} -} - -// List lists all MutatingWebhookConfigurations in the indexer across all workspaces. -func (s *mutatingWebhookConfigurationClusterLister) List(selector labels.Selector) (ret []*admissionregistrationv1beta1.MutatingWebhookConfiguration, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*admissionregistrationv1beta1.MutatingWebhookConfiguration)) - }) - return ret, err +func NewMutatingWebhookConfigurationClusterLister(indexer cache.Indexer) MutatingWebhookConfigurationClusterLister { + return &mutatingWebhookConfigurationClusterLister{ + kcplisters.NewCluster[*admissionregistrationv1beta1.MutatingWebhookConfiguration](indexer, admissionregistrationv1beta1.Resource("mutatingwebhookconfiguration")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get MutatingWebhookConfigurations. -func (s *mutatingWebhookConfigurationClusterLister) Cluster(clusterName logicalcluster.Name) admissionregistrationv1beta1listers.MutatingWebhookConfigurationLister { - return &mutatingWebhookConfigurationLister{indexer: s.indexer, clusterName: clusterName} +func (l *mutatingWebhookConfigurationClusterLister) Cluster(clusterName logicalcluster.Name) listersadmissionregistrationv1beta1.MutatingWebhookConfigurationLister { + return &mutatingWebhookConfigurationLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// mutatingWebhookConfigurationLister implements the admissionregistrationv1beta1listers.MutatingWebhookConfigurationLister interface. +// mutatingWebhookConfigurationLister can list all MutatingWebhookConfigurations inside a workspace +// or scope down to a listersadmissionregistrationv1beta1.MutatingWebhookConfigurationNamespaceLister for one namespace. type mutatingWebhookConfigurationLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*admissionregistrationv1beta1.MutatingWebhookConfiguration] } -// List lists all MutatingWebhookConfigurations in the indexer for a workspace. -func (s *mutatingWebhookConfigurationLister) List(selector labels.Selector) (ret []*admissionregistrationv1beta1.MutatingWebhookConfiguration, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*admissionregistrationv1beta1.MutatingWebhookConfiguration)) - }) - return ret, err -} +var _ listersadmissionregistrationv1beta1.MutatingWebhookConfigurationLister = new(mutatingWebhookConfigurationLister) -// Get retrieves the MutatingWebhookConfiguration from the indexer for a given workspace and name. -func (s *mutatingWebhookConfigurationLister) Get(name string) (*admissionregistrationv1beta1.MutatingWebhookConfiguration, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(admissionregistrationv1beta1.Resource("mutatingwebhookconfigurations"), name) +// NewMutatingWebhookConfigurationLister returns a new MutatingWebhookConfigurationLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewMutatingWebhookConfigurationLister(indexer cache.Indexer) listersadmissionregistrationv1beta1.MutatingWebhookConfigurationLister { + return &mutatingWebhookConfigurationLister{ + kcplisters.New[*admissionregistrationv1beta1.MutatingWebhookConfiguration](indexer, admissionregistrationv1beta1.Resource("mutatingwebhookconfiguration")), } - return obj.(*admissionregistrationv1beta1.MutatingWebhookConfiguration), nil +} + +// mutatingWebhookConfigurationScopedLister can list all MutatingWebhookConfigurations inside a workspace +// or scope down to a listersadmissionregistrationv1beta1.MutatingWebhookConfigurationNamespaceLister. +type mutatingWebhookConfigurationScopedLister struct { + kcplisters.ResourceIndexer[*admissionregistrationv1beta1.MutatingWebhookConfiguration] } diff --git a/listers/admissionregistration/v1beta1/validatingadmissionpolicy.go b/listers/admissionregistration/v1beta1/validatingadmissionpolicy.go index c56b896a1..5bda260b8 100644 --- a/listers/admissionregistration/v1beta1/validatingadmissionpolicy.go +++ b/listers/admissionregistration/v1beta1/validatingadmissionpolicy.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - admissionregistrationv1beta1listers "k8s.io/client-go/listers/admissionregistration/v1beta1" + listersadmissionregistrationv1beta1 "k8s.io/client-go/listers/admissionregistration/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ValidatingAdmissionPolicyClusterLister can list ValidatingAdmissionPolicies across all workspaces, or scope down to a ValidatingAdmissionPolicyLister for one workspace. +// ValidatingAdmissionPolicyClusterLister helps list ValidatingAdmissionPolicies across all workspaces, +// or scope down to a ValidatingAdmissionPolicyLister for one workspace. // All objects returned here must be treated as read-only. type ValidatingAdmissionPolicyClusterLister interface { // List lists all ValidatingAdmissionPolicies in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*admissionregistrationv1beta1.ValidatingAdmissionPolicy, err error) // Cluster returns a lister that can list and get ValidatingAdmissionPolicies in one workspace. - Cluster(clusterName logicalcluster.Name) admissionregistrationv1beta1listers.ValidatingAdmissionPolicyLister + Cluster(clusterName logicalcluster.Name) listersadmissionregistrationv1beta1.ValidatingAdmissionPolicyLister ValidatingAdmissionPolicyClusterListerExpansion } +// validatingAdmissionPolicyClusterLister implements the ValidatingAdmissionPolicyClusterLister interface. type validatingAdmissionPolicyClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*admissionregistrationv1beta1.ValidatingAdmissionPolicy] } +var _ ValidatingAdmissionPolicyClusterLister = new(validatingAdmissionPolicyClusterLister) + // NewValidatingAdmissionPolicyClusterLister returns a new ValidatingAdmissionPolicyClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewValidatingAdmissionPolicyClusterLister(indexer cache.Indexer) *validatingAdmissionPolicyClusterLister { - return &validatingAdmissionPolicyClusterLister{indexer: indexer} -} - -// List lists all ValidatingAdmissionPolicies in the indexer across all workspaces. -func (s *validatingAdmissionPolicyClusterLister) List(selector labels.Selector) (ret []*admissionregistrationv1beta1.ValidatingAdmissionPolicy, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*admissionregistrationv1beta1.ValidatingAdmissionPolicy)) - }) - return ret, err +func NewValidatingAdmissionPolicyClusterLister(indexer cache.Indexer) ValidatingAdmissionPolicyClusterLister { + return &validatingAdmissionPolicyClusterLister{ + kcplisters.NewCluster[*admissionregistrationv1beta1.ValidatingAdmissionPolicy](indexer, admissionregistrationv1beta1.Resource("validatingadmissionpolicy")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ValidatingAdmissionPolicies. -func (s *validatingAdmissionPolicyClusterLister) Cluster(clusterName logicalcluster.Name) admissionregistrationv1beta1listers.ValidatingAdmissionPolicyLister { - return &validatingAdmissionPolicyLister{indexer: s.indexer, clusterName: clusterName} +func (l *validatingAdmissionPolicyClusterLister) Cluster(clusterName logicalcluster.Name) listersadmissionregistrationv1beta1.ValidatingAdmissionPolicyLister { + return &validatingAdmissionPolicyLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// validatingAdmissionPolicyLister implements the admissionregistrationv1beta1listers.ValidatingAdmissionPolicyLister interface. +// validatingAdmissionPolicyLister can list all ValidatingAdmissionPolicies inside a workspace +// or scope down to a listersadmissionregistrationv1beta1.ValidatingAdmissionPolicyNamespaceLister for one namespace. type validatingAdmissionPolicyLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*admissionregistrationv1beta1.ValidatingAdmissionPolicy] } -// List lists all ValidatingAdmissionPolicies in the indexer for a workspace. -func (s *validatingAdmissionPolicyLister) List(selector labels.Selector) (ret []*admissionregistrationv1beta1.ValidatingAdmissionPolicy, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*admissionregistrationv1beta1.ValidatingAdmissionPolicy)) - }) - return ret, err -} +var _ listersadmissionregistrationv1beta1.ValidatingAdmissionPolicyLister = new(validatingAdmissionPolicyLister) -// Get retrieves the ValidatingAdmissionPolicy from the indexer for a given workspace and name. -func (s *validatingAdmissionPolicyLister) Get(name string) (*admissionregistrationv1beta1.ValidatingAdmissionPolicy, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(admissionregistrationv1beta1.Resource("validatingadmissionpolicies"), name) +// NewValidatingAdmissionPolicyLister returns a new ValidatingAdmissionPolicyLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewValidatingAdmissionPolicyLister(indexer cache.Indexer) listersadmissionregistrationv1beta1.ValidatingAdmissionPolicyLister { + return &validatingAdmissionPolicyLister{ + kcplisters.New[*admissionregistrationv1beta1.ValidatingAdmissionPolicy](indexer, admissionregistrationv1beta1.Resource("validatingadmissionpolicy")), } - return obj.(*admissionregistrationv1beta1.ValidatingAdmissionPolicy), nil +} + +// validatingAdmissionPolicyScopedLister can list all ValidatingAdmissionPolicies inside a workspace +// or scope down to a listersadmissionregistrationv1beta1.ValidatingAdmissionPolicyNamespaceLister. +type validatingAdmissionPolicyScopedLister struct { + kcplisters.ResourceIndexer[*admissionregistrationv1beta1.ValidatingAdmissionPolicy] } diff --git a/listers/admissionregistration/v1beta1/validatingadmissionpolicybinding.go b/listers/admissionregistration/v1beta1/validatingadmissionpolicybinding.go index 542ab921b..8457bf472 100644 --- a/listers/admissionregistration/v1beta1/validatingadmissionpolicybinding.go +++ b/listers/admissionregistration/v1beta1/validatingadmissionpolicybinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - admissionregistrationv1beta1listers "k8s.io/client-go/listers/admissionregistration/v1beta1" + listersadmissionregistrationv1beta1 "k8s.io/client-go/listers/admissionregistration/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ValidatingAdmissionPolicyBindingClusterLister can list ValidatingAdmissionPolicyBindings across all workspaces, or scope down to a ValidatingAdmissionPolicyBindingLister for one workspace. +// ValidatingAdmissionPolicyBindingClusterLister helps list ValidatingAdmissionPolicyBindings across all workspaces, +// or scope down to a ValidatingAdmissionPolicyBindingLister for one workspace. // All objects returned here must be treated as read-only. type ValidatingAdmissionPolicyBindingClusterLister interface { // List lists all ValidatingAdmissionPolicyBindings in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding, err error) // Cluster returns a lister that can list and get ValidatingAdmissionPolicyBindings in one workspace. - Cluster(clusterName logicalcluster.Name) admissionregistrationv1beta1listers.ValidatingAdmissionPolicyBindingLister + Cluster(clusterName logicalcluster.Name) listersadmissionregistrationv1beta1.ValidatingAdmissionPolicyBindingLister ValidatingAdmissionPolicyBindingClusterListerExpansion } +// validatingAdmissionPolicyBindingClusterLister implements the ValidatingAdmissionPolicyBindingClusterLister interface. type validatingAdmissionPolicyBindingClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding] } +var _ ValidatingAdmissionPolicyBindingClusterLister = new(validatingAdmissionPolicyBindingClusterLister) + // NewValidatingAdmissionPolicyBindingClusterLister returns a new ValidatingAdmissionPolicyBindingClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewValidatingAdmissionPolicyBindingClusterLister(indexer cache.Indexer) *validatingAdmissionPolicyBindingClusterLister { - return &validatingAdmissionPolicyBindingClusterLister{indexer: indexer} -} - -// List lists all ValidatingAdmissionPolicyBindings in the indexer across all workspaces. -func (s *validatingAdmissionPolicyBindingClusterLister) List(selector labels.Selector) (ret []*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding)) - }) - return ret, err +func NewValidatingAdmissionPolicyBindingClusterLister(indexer cache.Indexer) ValidatingAdmissionPolicyBindingClusterLister { + return &validatingAdmissionPolicyBindingClusterLister{ + kcplisters.NewCluster[*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding](indexer, admissionregistrationv1beta1.Resource("validatingadmissionpolicybinding")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ValidatingAdmissionPolicyBindings. -func (s *validatingAdmissionPolicyBindingClusterLister) Cluster(clusterName logicalcluster.Name) admissionregistrationv1beta1listers.ValidatingAdmissionPolicyBindingLister { - return &validatingAdmissionPolicyBindingLister{indexer: s.indexer, clusterName: clusterName} +func (l *validatingAdmissionPolicyBindingClusterLister) Cluster(clusterName logicalcluster.Name) listersadmissionregistrationv1beta1.ValidatingAdmissionPolicyBindingLister { + return &validatingAdmissionPolicyBindingLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// validatingAdmissionPolicyBindingLister implements the admissionregistrationv1beta1listers.ValidatingAdmissionPolicyBindingLister interface. +// validatingAdmissionPolicyBindingLister can list all ValidatingAdmissionPolicyBindings inside a workspace +// or scope down to a listersadmissionregistrationv1beta1.ValidatingAdmissionPolicyBindingNamespaceLister for one namespace. type validatingAdmissionPolicyBindingLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding] } -// List lists all ValidatingAdmissionPolicyBindings in the indexer for a workspace. -func (s *validatingAdmissionPolicyBindingLister) List(selector labels.Selector) (ret []*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding)) - }) - return ret, err -} +var _ listersadmissionregistrationv1beta1.ValidatingAdmissionPolicyBindingLister = new(validatingAdmissionPolicyBindingLister) -// Get retrieves the ValidatingAdmissionPolicyBinding from the indexer for a given workspace and name. -func (s *validatingAdmissionPolicyBindingLister) Get(name string) (*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(admissionregistrationv1beta1.Resource("validatingadmissionpolicybindings"), name) +// NewValidatingAdmissionPolicyBindingLister returns a new ValidatingAdmissionPolicyBindingLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewValidatingAdmissionPolicyBindingLister(indexer cache.Indexer) listersadmissionregistrationv1beta1.ValidatingAdmissionPolicyBindingLister { + return &validatingAdmissionPolicyBindingLister{ + kcplisters.New[*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding](indexer, admissionregistrationv1beta1.Resource("validatingadmissionpolicybinding")), } - return obj.(*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding), nil +} + +// validatingAdmissionPolicyBindingScopedLister can list all ValidatingAdmissionPolicyBindings inside a workspace +// or scope down to a listersadmissionregistrationv1beta1.ValidatingAdmissionPolicyBindingNamespaceLister. +type validatingAdmissionPolicyBindingScopedLister struct { + kcplisters.ResourceIndexer[*admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding] } diff --git a/listers/admissionregistration/v1beta1/validatingwebhookconfiguration.go b/listers/admissionregistration/v1beta1/validatingwebhookconfiguration.go index 0b407848d..f00a50839 100644 --- a/listers/admissionregistration/v1beta1/validatingwebhookconfiguration.go +++ b/listers/admissionregistration/v1beta1/validatingwebhookconfiguration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - admissionregistrationv1beta1listers "k8s.io/client-go/listers/admissionregistration/v1beta1" + listersadmissionregistrationv1beta1 "k8s.io/client-go/listers/admissionregistration/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ValidatingWebhookConfigurationClusterLister can list ValidatingWebhookConfigurations across all workspaces, or scope down to a ValidatingWebhookConfigurationLister for one workspace. +// ValidatingWebhookConfigurationClusterLister helps list ValidatingWebhookConfigurations across all workspaces, +// or scope down to a ValidatingWebhookConfigurationLister for one workspace. // All objects returned here must be treated as read-only. type ValidatingWebhookConfigurationClusterLister interface { // List lists all ValidatingWebhookConfigurations in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*admissionregistrationv1beta1.ValidatingWebhookConfiguration, err error) // Cluster returns a lister that can list and get ValidatingWebhookConfigurations in one workspace. - Cluster(clusterName logicalcluster.Name) admissionregistrationv1beta1listers.ValidatingWebhookConfigurationLister + Cluster(clusterName logicalcluster.Name) listersadmissionregistrationv1beta1.ValidatingWebhookConfigurationLister ValidatingWebhookConfigurationClusterListerExpansion } +// validatingWebhookConfigurationClusterLister implements the ValidatingWebhookConfigurationClusterLister interface. type validatingWebhookConfigurationClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*admissionregistrationv1beta1.ValidatingWebhookConfiguration] } +var _ ValidatingWebhookConfigurationClusterLister = new(validatingWebhookConfigurationClusterLister) + // NewValidatingWebhookConfigurationClusterLister returns a new ValidatingWebhookConfigurationClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewValidatingWebhookConfigurationClusterLister(indexer cache.Indexer) *validatingWebhookConfigurationClusterLister { - return &validatingWebhookConfigurationClusterLister{indexer: indexer} -} - -// List lists all ValidatingWebhookConfigurations in the indexer across all workspaces. -func (s *validatingWebhookConfigurationClusterLister) List(selector labels.Selector) (ret []*admissionregistrationv1beta1.ValidatingWebhookConfiguration, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*admissionregistrationv1beta1.ValidatingWebhookConfiguration)) - }) - return ret, err +func NewValidatingWebhookConfigurationClusterLister(indexer cache.Indexer) ValidatingWebhookConfigurationClusterLister { + return &validatingWebhookConfigurationClusterLister{ + kcplisters.NewCluster[*admissionregistrationv1beta1.ValidatingWebhookConfiguration](indexer, admissionregistrationv1beta1.Resource("validatingwebhookconfiguration")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ValidatingWebhookConfigurations. -func (s *validatingWebhookConfigurationClusterLister) Cluster(clusterName logicalcluster.Name) admissionregistrationv1beta1listers.ValidatingWebhookConfigurationLister { - return &validatingWebhookConfigurationLister{indexer: s.indexer, clusterName: clusterName} +func (l *validatingWebhookConfigurationClusterLister) Cluster(clusterName logicalcluster.Name) listersadmissionregistrationv1beta1.ValidatingWebhookConfigurationLister { + return &validatingWebhookConfigurationLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// validatingWebhookConfigurationLister implements the admissionregistrationv1beta1listers.ValidatingWebhookConfigurationLister interface. +// validatingWebhookConfigurationLister can list all ValidatingWebhookConfigurations inside a workspace +// or scope down to a listersadmissionregistrationv1beta1.ValidatingWebhookConfigurationNamespaceLister for one namespace. type validatingWebhookConfigurationLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*admissionregistrationv1beta1.ValidatingWebhookConfiguration] } -// List lists all ValidatingWebhookConfigurations in the indexer for a workspace. -func (s *validatingWebhookConfigurationLister) List(selector labels.Selector) (ret []*admissionregistrationv1beta1.ValidatingWebhookConfiguration, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*admissionregistrationv1beta1.ValidatingWebhookConfiguration)) - }) - return ret, err -} +var _ listersadmissionregistrationv1beta1.ValidatingWebhookConfigurationLister = new(validatingWebhookConfigurationLister) -// Get retrieves the ValidatingWebhookConfiguration from the indexer for a given workspace and name. -func (s *validatingWebhookConfigurationLister) Get(name string) (*admissionregistrationv1beta1.ValidatingWebhookConfiguration, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(admissionregistrationv1beta1.Resource("validatingwebhookconfigurations"), name) +// NewValidatingWebhookConfigurationLister returns a new ValidatingWebhookConfigurationLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewValidatingWebhookConfigurationLister(indexer cache.Indexer) listersadmissionregistrationv1beta1.ValidatingWebhookConfigurationLister { + return &validatingWebhookConfigurationLister{ + kcplisters.New[*admissionregistrationv1beta1.ValidatingWebhookConfiguration](indexer, admissionregistrationv1beta1.Resource("validatingwebhookconfiguration")), } - return obj.(*admissionregistrationv1beta1.ValidatingWebhookConfiguration), nil +} + +// validatingWebhookConfigurationScopedLister can list all ValidatingWebhookConfigurations inside a workspace +// or scope down to a listersadmissionregistrationv1beta1.ValidatingWebhookConfigurationNamespaceLister. +type validatingWebhookConfigurationScopedLister struct { + kcplisters.ResourceIndexer[*admissionregistrationv1beta1.ValidatingWebhookConfiguration] } diff --git a/listers/apiserverinternal/v1alpha1/expansion_generated.go b/listers/apiserverinternal/v1alpha1/expansion_generated.go new file mode 100644 index 000000000..3b8521c00 --- /dev/null +++ b/listers/apiserverinternal/v1alpha1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1alpha1 diff --git a/listers/apiserverinternal/v1alpha1/storageversion.go b/listers/apiserverinternal/v1alpha1/storageversion.go index 9da778a3b..cfaa232e5 100644 --- a/listers/apiserverinternal/v1alpha1/storageversion.go +++ b/listers/apiserverinternal/v1alpha1/storageversion.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1alpha1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" - internalv1alpha1 "k8s.io/api/apiserverinternal/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" + apiserverinternalv1alpha1 "k8s.io/api/apiserverinternal/v1alpha1" "k8s.io/apimachinery/pkg/labels" - internalv1alpha1listers "k8s.io/client-go/listers/apiserverinternal/v1alpha1" + listersapiserverinternalv1alpha1 "k8s.io/client-go/listers/apiserverinternal/v1alpha1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// StorageVersionClusterLister can list StorageVersions across all workspaces, or scope down to a StorageVersionLister for one workspace. +// StorageVersionClusterLister helps list StorageVersions across all workspaces, +// or scope down to a StorageVersionLister for one workspace. // All objects returned here must be treated as read-only. type StorageVersionClusterLister interface { // List lists all StorageVersions in the indexer. // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*internalv1alpha1.StorageVersion, err error) + List(selector labels.Selector) (ret []*apiserverinternalv1alpha1.StorageVersion, err error) // Cluster returns a lister that can list and get StorageVersions in one workspace. - Cluster(clusterName logicalcluster.Name) internalv1alpha1listers.StorageVersionLister + Cluster(clusterName logicalcluster.Name) listersapiserverinternalv1alpha1.StorageVersionLister StorageVersionClusterListerExpansion } +// storageVersionClusterLister implements the StorageVersionClusterLister interface. type storageVersionClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*apiserverinternalv1alpha1.StorageVersion] } +var _ StorageVersionClusterLister = new(storageVersionClusterLister) + // NewStorageVersionClusterLister returns a new StorageVersionClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewStorageVersionClusterLister(indexer cache.Indexer) *storageVersionClusterLister { - return &storageVersionClusterLister{indexer: indexer} -} - -// List lists all StorageVersions in the indexer across all workspaces. -func (s *storageVersionClusterLister) List(selector labels.Selector) (ret []*internalv1alpha1.StorageVersion, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*internalv1alpha1.StorageVersion)) - }) - return ret, err +func NewStorageVersionClusterLister(indexer cache.Indexer) StorageVersionClusterLister { + return &storageVersionClusterLister{ + kcplisters.NewCluster[*apiserverinternalv1alpha1.StorageVersion](indexer, apiserverinternalv1alpha1.Resource("storageversion")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get StorageVersions. -func (s *storageVersionClusterLister) Cluster(clusterName logicalcluster.Name) internalv1alpha1listers.StorageVersionLister { - return &storageVersionLister{indexer: s.indexer, clusterName: clusterName} +func (l *storageVersionClusterLister) Cluster(clusterName logicalcluster.Name) listersapiserverinternalv1alpha1.StorageVersionLister { + return &storageVersionLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// storageVersionLister implements the internalv1alpha1listers.StorageVersionLister interface. +// storageVersionLister can list all StorageVersions inside a workspace +// or scope down to a listersapiserverinternalv1alpha1.StorageVersionNamespaceLister for one namespace. type storageVersionLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*apiserverinternalv1alpha1.StorageVersion] } -// List lists all StorageVersions in the indexer for a workspace. -func (s *storageVersionLister) List(selector labels.Selector) (ret []*internalv1alpha1.StorageVersion, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*internalv1alpha1.StorageVersion)) - }) - return ret, err -} +var _ listersapiserverinternalv1alpha1.StorageVersionLister = new(storageVersionLister) -// Get retrieves the StorageVersion from the indexer for a given workspace and name. -func (s *storageVersionLister) Get(name string) (*internalv1alpha1.StorageVersion, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(internalv1alpha1.Resource("storageversions"), name) +// NewStorageVersionLister returns a new StorageVersionLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewStorageVersionLister(indexer cache.Indexer) listersapiserverinternalv1alpha1.StorageVersionLister { + return &storageVersionLister{ + kcplisters.New[*apiserverinternalv1alpha1.StorageVersion](indexer, apiserverinternalv1alpha1.Resource("storageversion")), } - return obj.(*internalv1alpha1.StorageVersion), nil +} + +// storageVersionScopedLister can list all StorageVersions inside a workspace +// or scope down to a listersapiserverinternalv1alpha1.StorageVersionNamespaceLister. +type storageVersionScopedLister struct { + kcplisters.ResourceIndexer[*apiserverinternalv1alpha1.StorageVersion] } diff --git a/listers/apps/v1/controllerrevision.go b/listers/apps/v1/controllerrevision.go index 50bf5271e..04edf96f2 100644 --- a/listers/apps/v1/controllerrevision.go +++ b/listers/apps/v1/controllerrevision.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" appsv1 "k8s.io/api/apps/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - appsv1listers "k8s.io/client-go/listers/apps/v1" + listersappsv1 "k8s.io/client-go/listers/apps/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ControllerRevisionClusterLister can list ControllerRevisions across all workspaces, or scope down to a ControllerRevisionLister for one workspace. +// ControllerRevisionClusterLister helps list ControllerRevisions across all workspaces, +// or scope down to a ControllerRevisionLister for one workspace. // All objects returned here must be treated as read-only. type ControllerRevisionClusterLister interface { // List lists all ControllerRevisions in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*appsv1.ControllerRevision, err error) // Cluster returns a lister that can list and get ControllerRevisions in one workspace. - Cluster(clusterName logicalcluster.Name) appsv1listers.ControllerRevisionLister + Cluster(clusterName logicalcluster.Name) listersappsv1.ControllerRevisionLister ControllerRevisionClusterListerExpansion } +// controllerRevisionClusterLister implements the ControllerRevisionClusterLister interface. type controllerRevisionClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*appsv1.ControllerRevision] } +var _ ControllerRevisionClusterLister = new(controllerRevisionClusterLister) + // NewControllerRevisionClusterLister returns a new ControllerRevisionClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewControllerRevisionClusterLister(indexer cache.Indexer) *controllerRevisionClusterLister { - return &controllerRevisionClusterLister{indexer: indexer} -} - -// List lists all ControllerRevisions in the indexer across all workspaces. -func (s *controllerRevisionClusterLister) List(selector labels.Selector) (ret []*appsv1.ControllerRevision, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*appsv1.ControllerRevision)) - }) - return ret, err +func NewControllerRevisionClusterLister(indexer cache.Indexer) ControllerRevisionClusterLister { + return &controllerRevisionClusterLister{ + kcplisters.NewCluster[*appsv1.ControllerRevision](indexer, appsv1.Resource("controllerrevision")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ControllerRevisions. -func (s *controllerRevisionClusterLister) Cluster(clusterName logicalcluster.Name) appsv1listers.ControllerRevisionLister { - return &controllerRevisionLister{indexer: s.indexer, clusterName: clusterName} +func (l *controllerRevisionClusterLister) Cluster(clusterName logicalcluster.Name) listersappsv1.ControllerRevisionLister { + return &controllerRevisionLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// controllerRevisionLister implements the appsv1listers.ControllerRevisionLister interface. +// controllerRevisionLister can list all ControllerRevisions inside a workspace +// or scope down to a listersappsv1.ControllerRevisionNamespaceLister for one namespace. type controllerRevisionLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*appsv1.ControllerRevision] } -// List lists all ControllerRevisions in the indexer for a workspace. -func (s *controllerRevisionLister) List(selector labels.Selector) (ret []*appsv1.ControllerRevision, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*appsv1.ControllerRevision)) - }) - return ret, err -} +var _ listersappsv1.ControllerRevisionLister = new(controllerRevisionLister) // ControllerRevisions returns an object that can list and get ControllerRevisions in one namespace. -func (s *controllerRevisionLister) ControllerRevisions(namespace string) appsv1listers.ControllerRevisionNamespaceLister { - return &controllerRevisionNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *controllerRevisionLister) ControllerRevisions(namespace string) listersappsv1.ControllerRevisionNamespaceLister { + return &controllerRevisionNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// controllerRevisionNamespaceLister implements the appsv1listers.ControllerRevisionNamespaceLister interface. +// controllerRevisionNamespaceLister implements the listersappsv1.ControllerRevisionNamespaceLister +// interface. type controllerRevisionNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*appsv1.ControllerRevision] } -// List lists all ControllerRevisions in the indexer for a given workspace and namespace. -func (s *controllerRevisionNamespaceLister) List(selector labels.Selector) (ret []*appsv1.ControllerRevision, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*appsv1.ControllerRevision)) - }) - return ret, err -} +var _ listersappsv1.ControllerRevisionNamespaceLister = new(controllerRevisionNamespaceLister) -// Get retrieves the ControllerRevision from the indexer for a given workspace, namespace and name. -func (s *controllerRevisionNamespaceLister) Get(name string) (*appsv1.ControllerRevision, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewControllerRevisionLister returns a new ControllerRevisionLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewControllerRevisionLister(indexer cache.Indexer) listersappsv1.ControllerRevisionLister { + return &controllerRevisionLister{ + kcplisters.New[*appsv1.ControllerRevision](indexer, appsv1.Resource("controllerrevision")), } - if !exists { - return nil, errors.NewNotFound(appsv1.Resource("controllerrevisions"), name) +} + +// controllerRevisionScopedLister can list all ControllerRevisions inside a workspace +// or scope down to a listersappsv1.ControllerRevisionNamespaceLister for one namespace. +type controllerRevisionScopedLister struct { + kcplisters.ResourceIndexer[*appsv1.ControllerRevision] +} + +// ControllerRevisions returns an object that can list and get ControllerRevisions in one namespace. +func (l *controllerRevisionScopedLister) ControllerRevisions(namespace string) listersappsv1.ControllerRevisionLister { + return &controllerRevisionLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*appsv1.ControllerRevision), nil } diff --git a/listers/apps/v1/daemonset.go b/listers/apps/v1/daemonset.go index f665e7317..d352371d9 100644 --- a/listers/apps/v1/daemonset.go +++ b/listers/apps/v1/daemonset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" appsv1 "k8s.io/api/apps/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - appsv1listers "k8s.io/client-go/listers/apps/v1" + listersappsv1 "k8s.io/client-go/listers/apps/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// DaemonSetClusterLister can list DaemonSets across all workspaces, or scope down to a DaemonSetLister for one workspace. +// DaemonSetClusterLister helps list DaemonSets across all workspaces, +// or scope down to a DaemonSetLister for one workspace. // All objects returned here must be treated as read-only. type DaemonSetClusterLister interface { // List lists all DaemonSets in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*appsv1.DaemonSet, err error) // Cluster returns a lister that can list and get DaemonSets in one workspace. - Cluster(clusterName logicalcluster.Name) appsv1listers.DaemonSetLister + Cluster(clusterName logicalcluster.Name) listersappsv1.DaemonSetLister DaemonSetClusterListerExpansion } +// daemonSetClusterLister implements the DaemonSetClusterLister interface. type daemonSetClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*appsv1.DaemonSet] } +var _ DaemonSetClusterLister = new(daemonSetClusterLister) + // NewDaemonSetClusterLister returns a new DaemonSetClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewDaemonSetClusterLister(indexer cache.Indexer) *daemonSetClusterLister { - return &daemonSetClusterLister{indexer: indexer} -} - -// List lists all DaemonSets in the indexer across all workspaces. -func (s *daemonSetClusterLister) List(selector labels.Selector) (ret []*appsv1.DaemonSet, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*appsv1.DaemonSet)) - }) - return ret, err +func NewDaemonSetClusterLister(indexer cache.Indexer) DaemonSetClusterLister { + return &daemonSetClusterLister{ + kcplisters.NewCluster[*appsv1.DaemonSet](indexer, appsv1.Resource("daemonset")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get DaemonSets. -func (s *daemonSetClusterLister) Cluster(clusterName logicalcluster.Name) appsv1listers.DaemonSetLister { - return &daemonSetLister{indexer: s.indexer, clusterName: clusterName} +func (l *daemonSetClusterLister) Cluster(clusterName logicalcluster.Name) listersappsv1.DaemonSetLister { + return &daemonSetLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// daemonSetLister implements the appsv1listers.DaemonSetLister interface. +// daemonSetLister can list all DaemonSets inside a workspace +// or scope down to a listersappsv1.DaemonSetNamespaceLister for one namespace. type daemonSetLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*appsv1.DaemonSet] } -// List lists all DaemonSets in the indexer for a workspace. -func (s *daemonSetLister) List(selector labels.Selector) (ret []*appsv1.DaemonSet, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*appsv1.DaemonSet)) - }) - return ret, err -} +var _ listersappsv1.DaemonSetLister = new(daemonSetLister) // DaemonSets returns an object that can list and get DaemonSets in one namespace. -func (s *daemonSetLister) DaemonSets(namespace string) appsv1listers.DaemonSetNamespaceLister { - return &daemonSetNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *daemonSetLister) DaemonSets(namespace string) listersappsv1.DaemonSetNamespaceLister { + return &daemonSetNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// daemonSetNamespaceLister implements the appsv1listers.DaemonSetNamespaceLister interface. +// daemonSetNamespaceLister implements the listersappsv1.DaemonSetNamespaceLister +// interface. type daemonSetNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*appsv1.DaemonSet] } -// List lists all DaemonSets in the indexer for a given workspace and namespace. -func (s *daemonSetNamespaceLister) List(selector labels.Selector) (ret []*appsv1.DaemonSet, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*appsv1.DaemonSet)) - }) - return ret, err -} +var _ listersappsv1.DaemonSetNamespaceLister = new(daemonSetNamespaceLister) -// Get retrieves the DaemonSet from the indexer for a given workspace, namespace and name. -func (s *daemonSetNamespaceLister) Get(name string) (*appsv1.DaemonSet, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewDaemonSetLister returns a new DaemonSetLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewDaemonSetLister(indexer cache.Indexer) listersappsv1.DaemonSetLister { + return &daemonSetLister{ + kcplisters.New[*appsv1.DaemonSet](indexer, appsv1.Resource("daemonset")), } - if !exists { - return nil, errors.NewNotFound(appsv1.Resource("daemonsets"), name) +} + +// daemonSetScopedLister can list all DaemonSets inside a workspace +// or scope down to a listersappsv1.DaemonSetNamespaceLister for one namespace. +type daemonSetScopedLister struct { + kcplisters.ResourceIndexer[*appsv1.DaemonSet] +} + +// DaemonSets returns an object that can list and get DaemonSets in one namespace. +func (l *daemonSetScopedLister) DaemonSets(namespace string) listersappsv1.DaemonSetLister { + return &daemonSetLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*appsv1.DaemonSet), nil } diff --git a/listers/apps/v1/daemonset_expansion.go b/listers/apps/v1/daemonset_expansion.go index 689c9ec81..e48e01438 100644 --- a/listers/apps/v1/daemonset_expansion.go +++ b/listers/apps/v1/daemonset_expansion.go @@ -20,7 +20,7 @@ import ( "fmt" apps "k8s.io/api/apps/v1" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" ) diff --git a/listers/apps/v1/deployment.go b/listers/apps/v1/deployment.go index eb2d4127a..5da6eb981 100644 --- a/listers/apps/v1/deployment.go +++ b/listers/apps/v1/deployment.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" appsv1 "k8s.io/api/apps/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - appsv1listers "k8s.io/client-go/listers/apps/v1" + listersappsv1 "k8s.io/client-go/listers/apps/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// DeploymentClusterLister can list Deployments across all workspaces, or scope down to a DeploymentLister for one workspace. +// DeploymentClusterLister helps list Deployments across all workspaces, +// or scope down to a DeploymentLister for one workspace. // All objects returned here must be treated as read-only. type DeploymentClusterLister interface { // List lists all Deployments in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*appsv1.Deployment, err error) // Cluster returns a lister that can list and get Deployments in one workspace. - Cluster(clusterName logicalcluster.Name) appsv1listers.DeploymentLister + Cluster(clusterName logicalcluster.Name) listersappsv1.DeploymentLister DeploymentClusterListerExpansion } +// deploymentClusterLister implements the DeploymentClusterLister interface. type deploymentClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*appsv1.Deployment] } +var _ DeploymentClusterLister = new(deploymentClusterLister) + // NewDeploymentClusterLister returns a new DeploymentClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewDeploymentClusterLister(indexer cache.Indexer) *deploymentClusterLister { - return &deploymentClusterLister{indexer: indexer} -} - -// List lists all Deployments in the indexer across all workspaces. -func (s *deploymentClusterLister) List(selector labels.Selector) (ret []*appsv1.Deployment, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*appsv1.Deployment)) - }) - return ret, err +func NewDeploymentClusterLister(indexer cache.Indexer) DeploymentClusterLister { + return &deploymentClusterLister{ + kcplisters.NewCluster[*appsv1.Deployment](indexer, appsv1.Resource("deployment")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get Deployments. -func (s *deploymentClusterLister) Cluster(clusterName logicalcluster.Name) appsv1listers.DeploymentLister { - return &deploymentLister{indexer: s.indexer, clusterName: clusterName} +func (l *deploymentClusterLister) Cluster(clusterName logicalcluster.Name) listersappsv1.DeploymentLister { + return &deploymentLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// deploymentLister implements the appsv1listers.DeploymentLister interface. +// deploymentLister can list all Deployments inside a workspace +// or scope down to a listersappsv1.DeploymentNamespaceLister for one namespace. type deploymentLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*appsv1.Deployment] } -// List lists all Deployments in the indexer for a workspace. -func (s *deploymentLister) List(selector labels.Selector) (ret []*appsv1.Deployment, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*appsv1.Deployment)) - }) - return ret, err -} +var _ listersappsv1.DeploymentLister = new(deploymentLister) // Deployments returns an object that can list and get Deployments in one namespace. -func (s *deploymentLister) Deployments(namespace string) appsv1listers.DeploymentNamespaceLister { - return &deploymentNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *deploymentLister) Deployments(namespace string) listersappsv1.DeploymentNamespaceLister { + return &deploymentNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// deploymentNamespaceLister implements the appsv1listers.DeploymentNamespaceLister interface. +// deploymentNamespaceLister implements the listersappsv1.DeploymentNamespaceLister +// interface. type deploymentNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*appsv1.Deployment] } -// List lists all Deployments in the indexer for a given workspace and namespace. -func (s *deploymentNamespaceLister) List(selector labels.Selector) (ret []*appsv1.Deployment, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*appsv1.Deployment)) - }) - return ret, err -} +var _ listersappsv1.DeploymentNamespaceLister = new(deploymentNamespaceLister) -// Get retrieves the Deployment from the indexer for a given workspace, namespace and name. -func (s *deploymentNamespaceLister) Get(name string) (*appsv1.Deployment, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewDeploymentLister returns a new DeploymentLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewDeploymentLister(indexer cache.Indexer) listersappsv1.DeploymentLister { + return &deploymentLister{ + kcplisters.New[*appsv1.Deployment](indexer, appsv1.Resource("deployment")), } - if !exists { - return nil, errors.NewNotFound(appsv1.Resource("deployments"), name) +} + +// deploymentScopedLister can list all Deployments inside a workspace +// or scope down to a listersappsv1.DeploymentNamespaceLister for one namespace. +type deploymentScopedLister struct { + kcplisters.ResourceIndexer[*appsv1.Deployment] +} + +// Deployments returns an object that can list and get Deployments in one namespace. +func (l *deploymentScopedLister) Deployments(namespace string) listersappsv1.DeploymentLister { + return &deploymentLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*appsv1.Deployment), nil } diff --git a/listers/apps/v1/expansion_generated.go b/listers/apps/v1/expansion_generated.go new file mode 100644 index 000000000..b6a0c6377 --- /dev/null +++ b/listers/apps/v1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1 diff --git a/listers/apps/v1/replicaset.go b/listers/apps/v1/replicaset.go index d16001630..da263167e 100644 --- a/listers/apps/v1/replicaset.go +++ b/listers/apps/v1/replicaset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" appsv1 "k8s.io/api/apps/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - appsv1listers "k8s.io/client-go/listers/apps/v1" + listersappsv1 "k8s.io/client-go/listers/apps/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ReplicaSetClusterLister can list ReplicaSets across all workspaces, or scope down to a ReplicaSetLister for one workspace. +// ReplicaSetClusterLister helps list ReplicaSets across all workspaces, +// or scope down to a ReplicaSetLister for one workspace. // All objects returned here must be treated as read-only. type ReplicaSetClusterLister interface { // List lists all ReplicaSets in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*appsv1.ReplicaSet, err error) // Cluster returns a lister that can list and get ReplicaSets in one workspace. - Cluster(clusterName logicalcluster.Name) appsv1listers.ReplicaSetLister + Cluster(clusterName logicalcluster.Name) listersappsv1.ReplicaSetLister ReplicaSetClusterListerExpansion } +// replicaSetClusterLister implements the ReplicaSetClusterLister interface. type replicaSetClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*appsv1.ReplicaSet] } +var _ ReplicaSetClusterLister = new(replicaSetClusterLister) + // NewReplicaSetClusterLister returns a new ReplicaSetClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewReplicaSetClusterLister(indexer cache.Indexer) *replicaSetClusterLister { - return &replicaSetClusterLister{indexer: indexer} -} - -// List lists all ReplicaSets in the indexer across all workspaces. -func (s *replicaSetClusterLister) List(selector labels.Selector) (ret []*appsv1.ReplicaSet, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*appsv1.ReplicaSet)) - }) - return ret, err +func NewReplicaSetClusterLister(indexer cache.Indexer) ReplicaSetClusterLister { + return &replicaSetClusterLister{ + kcplisters.NewCluster[*appsv1.ReplicaSet](indexer, appsv1.Resource("replicaset")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ReplicaSets. -func (s *replicaSetClusterLister) Cluster(clusterName logicalcluster.Name) appsv1listers.ReplicaSetLister { - return &replicaSetLister{indexer: s.indexer, clusterName: clusterName} +func (l *replicaSetClusterLister) Cluster(clusterName logicalcluster.Name) listersappsv1.ReplicaSetLister { + return &replicaSetLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// replicaSetLister implements the appsv1listers.ReplicaSetLister interface. +// replicaSetLister can list all ReplicaSets inside a workspace +// or scope down to a listersappsv1.ReplicaSetNamespaceLister for one namespace. type replicaSetLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*appsv1.ReplicaSet] } -// List lists all ReplicaSets in the indexer for a workspace. -func (s *replicaSetLister) List(selector labels.Selector) (ret []*appsv1.ReplicaSet, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*appsv1.ReplicaSet)) - }) - return ret, err -} +var _ listersappsv1.ReplicaSetLister = new(replicaSetLister) // ReplicaSets returns an object that can list and get ReplicaSets in one namespace. -func (s *replicaSetLister) ReplicaSets(namespace string) appsv1listers.ReplicaSetNamespaceLister { - return &replicaSetNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *replicaSetLister) ReplicaSets(namespace string) listersappsv1.ReplicaSetNamespaceLister { + return &replicaSetNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// replicaSetNamespaceLister implements the appsv1listers.ReplicaSetNamespaceLister interface. +// replicaSetNamespaceLister implements the listersappsv1.ReplicaSetNamespaceLister +// interface. type replicaSetNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*appsv1.ReplicaSet] } -// List lists all ReplicaSets in the indexer for a given workspace and namespace. -func (s *replicaSetNamespaceLister) List(selector labels.Selector) (ret []*appsv1.ReplicaSet, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*appsv1.ReplicaSet)) - }) - return ret, err -} +var _ listersappsv1.ReplicaSetNamespaceLister = new(replicaSetNamespaceLister) -// Get retrieves the ReplicaSet from the indexer for a given workspace, namespace and name. -func (s *replicaSetNamespaceLister) Get(name string) (*appsv1.ReplicaSet, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewReplicaSetLister returns a new ReplicaSetLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewReplicaSetLister(indexer cache.Indexer) listersappsv1.ReplicaSetLister { + return &replicaSetLister{ + kcplisters.New[*appsv1.ReplicaSet](indexer, appsv1.Resource("replicaset")), } - if !exists { - return nil, errors.NewNotFound(appsv1.Resource("replicasets"), name) +} + +// replicaSetScopedLister can list all ReplicaSets inside a workspace +// or scope down to a listersappsv1.ReplicaSetNamespaceLister for one namespace. +type replicaSetScopedLister struct { + kcplisters.ResourceIndexer[*appsv1.ReplicaSet] +} + +// ReplicaSets returns an object that can list and get ReplicaSets in one namespace. +func (l *replicaSetScopedLister) ReplicaSets(namespace string) listersappsv1.ReplicaSetLister { + return &replicaSetLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*appsv1.ReplicaSet), nil } diff --git a/listers/apps/v1/replicaset_expansion.go b/listers/apps/v1/replicaset_expansion.go index 02d077461..233a8dab4 100644 --- a/listers/apps/v1/replicaset_expansion.go +++ b/listers/apps/v1/replicaset_expansion.go @@ -20,7 +20,7 @@ import ( "fmt" apps "k8s.io/api/apps/v1" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" ) diff --git a/listers/apps/v1/statefulset.go b/listers/apps/v1/statefulset.go index e3d3ccc5d..ddc95ea54 100644 --- a/listers/apps/v1/statefulset.go +++ b/listers/apps/v1/statefulset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" appsv1 "k8s.io/api/apps/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - appsv1listers "k8s.io/client-go/listers/apps/v1" + listersappsv1 "k8s.io/client-go/listers/apps/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// StatefulSetClusterLister can list StatefulSets across all workspaces, or scope down to a StatefulSetLister for one workspace. +// StatefulSetClusterLister helps list StatefulSets across all workspaces, +// or scope down to a StatefulSetLister for one workspace. // All objects returned here must be treated as read-only. type StatefulSetClusterLister interface { // List lists all StatefulSets in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*appsv1.StatefulSet, err error) // Cluster returns a lister that can list and get StatefulSets in one workspace. - Cluster(clusterName logicalcluster.Name) appsv1listers.StatefulSetLister + Cluster(clusterName logicalcluster.Name) listersappsv1.StatefulSetLister StatefulSetClusterListerExpansion } +// statefulSetClusterLister implements the StatefulSetClusterLister interface. type statefulSetClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*appsv1.StatefulSet] } +var _ StatefulSetClusterLister = new(statefulSetClusterLister) + // NewStatefulSetClusterLister returns a new StatefulSetClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewStatefulSetClusterLister(indexer cache.Indexer) *statefulSetClusterLister { - return &statefulSetClusterLister{indexer: indexer} -} - -// List lists all StatefulSets in the indexer across all workspaces. -func (s *statefulSetClusterLister) List(selector labels.Selector) (ret []*appsv1.StatefulSet, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*appsv1.StatefulSet)) - }) - return ret, err +func NewStatefulSetClusterLister(indexer cache.Indexer) StatefulSetClusterLister { + return &statefulSetClusterLister{ + kcplisters.NewCluster[*appsv1.StatefulSet](indexer, appsv1.Resource("statefulset")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get StatefulSets. -func (s *statefulSetClusterLister) Cluster(clusterName logicalcluster.Name) appsv1listers.StatefulSetLister { - return &statefulSetLister{indexer: s.indexer, clusterName: clusterName} +func (l *statefulSetClusterLister) Cluster(clusterName logicalcluster.Name) listersappsv1.StatefulSetLister { + return &statefulSetLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// statefulSetLister implements the appsv1listers.StatefulSetLister interface. +// statefulSetLister can list all StatefulSets inside a workspace +// or scope down to a listersappsv1.StatefulSetNamespaceLister for one namespace. type statefulSetLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*appsv1.StatefulSet] } -// List lists all StatefulSets in the indexer for a workspace. -func (s *statefulSetLister) List(selector labels.Selector) (ret []*appsv1.StatefulSet, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*appsv1.StatefulSet)) - }) - return ret, err -} +var _ listersappsv1.StatefulSetLister = new(statefulSetLister) // StatefulSets returns an object that can list and get StatefulSets in one namespace. -func (s *statefulSetLister) StatefulSets(namespace string) appsv1listers.StatefulSetNamespaceLister { - return &statefulSetNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *statefulSetLister) StatefulSets(namespace string) listersappsv1.StatefulSetNamespaceLister { + return &statefulSetNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// statefulSetNamespaceLister implements the appsv1listers.StatefulSetNamespaceLister interface. +// statefulSetNamespaceLister implements the listersappsv1.StatefulSetNamespaceLister +// interface. type statefulSetNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*appsv1.StatefulSet] } -// List lists all StatefulSets in the indexer for a given workspace and namespace. -func (s *statefulSetNamespaceLister) List(selector labels.Selector) (ret []*appsv1.StatefulSet, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*appsv1.StatefulSet)) - }) - return ret, err -} +var _ listersappsv1.StatefulSetNamespaceLister = new(statefulSetNamespaceLister) -// Get retrieves the StatefulSet from the indexer for a given workspace, namespace and name. -func (s *statefulSetNamespaceLister) Get(name string) (*appsv1.StatefulSet, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewStatefulSetLister returns a new StatefulSetLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewStatefulSetLister(indexer cache.Indexer) listersappsv1.StatefulSetLister { + return &statefulSetLister{ + kcplisters.New[*appsv1.StatefulSet](indexer, appsv1.Resource("statefulset")), } - if !exists { - return nil, errors.NewNotFound(appsv1.Resource("statefulsets"), name) +} + +// statefulSetScopedLister can list all StatefulSets inside a workspace +// or scope down to a listersappsv1.StatefulSetNamespaceLister for one namespace. +type statefulSetScopedLister struct { + kcplisters.ResourceIndexer[*appsv1.StatefulSet] +} + +// StatefulSets returns an object that can list and get StatefulSets in one namespace. +func (l *statefulSetScopedLister) StatefulSets(namespace string) listersappsv1.StatefulSetLister { + return &statefulSetLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*appsv1.StatefulSet), nil } diff --git a/listers/apps/v1/statefulset_expansion.go b/listers/apps/v1/statefulset_expansion.go index b72ed2c32..205dcd673 100644 --- a/listers/apps/v1/statefulset_expansion.go +++ b/listers/apps/v1/statefulset_expansion.go @@ -20,7 +20,7 @@ import ( "fmt" apps "k8s.io/api/apps/v1" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" ) diff --git a/listers/apps/v1beta1/controllerrevision.go b/listers/apps/v1beta1/controllerrevision.go index b06f8ea91..fc2ba558d 100644 --- a/listers/apps/v1beta1/controllerrevision.go +++ b/listers/apps/v1beta1/controllerrevision.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" appsv1beta1 "k8s.io/api/apps/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - appsv1beta1listers "k8s.io/client-go/listers/apps/v1beta1" + listersappsv1beta1 "k8s.io/client-go/listers/apps/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ControllerRevisionClusterLister can list ControllerRevisions across all workspaces, or scope down to a ControllerRevisionLister for one workspace. +// ControllerRevisionClusterLister helps list ControllerRevisions across all workspaces, +// or scope down to a ControllerRevisionLister for one workspace. // All objects returned here must be treated as read-only. type ControllerRevisionClusterLister interface { // List lists all ControllerRevisions in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*appsv1beta1.ControllerRevision, err error) // Cluster returns a lister that can list and get ControllerRevisions in one workspace. - Cluster(clusterName logicalcluster.Name) appsv1beta1listers.ControllerRevisionLister + Cluster(clusterName logicalcluster.Name) listersappsv1beta1.ControllerRevisionLister ControllerRevisionClusterListerExpansion } +// controllerRevisionClusterLister implements the ControllerRevisionClusterLister interface. type controllerRevisionClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*appsv1beta1.ControllerRevision] } +var _ ControllerRevisionClusterLister = new(controllerRevisionClusterLister) + // NewControllerRevisionClusterLister returns a new ControllerRevisionClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewControllerRevisionClusterLister(indexer cache.Indexer) *controllerRevisionClusterLister { - return &controllerRevisionClusterLister{indexer: indexer} -} - -// List lists all ControllerRevisions in the indexer across all workspaces. -func (s *controllerRevisionClusterLister) List(selector labels.Selector) (ret []*appsv1beta1.ControllerRevision, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*appsv1beta1.ControllerRevision)) - }) - return ret, err +func NewControllerRevisionClusterLister(indexer cache.Indexer) ControllerRevisionClusterLister { + return &controllerRevisionClusterLister{ + kcplisters.NewCluster[*appsv1beta1.ControllerRevision](indexer, appsv1beta1.Resource("controllerrevision")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ControllerRevisions. -func (s *controllerRevisionClusterLister) Cluster(clusterName logicalcluster.Name) appsv1beta1listers.ControllerRevisionLister { - return &controllerRevisionLister{indexer: s.indexer, clusterName: clusterName} +func (l *controllerRevisionClusterLister) Cluster(clusterName logicalcluster.Name) listersappsv1beta1.ControllerRevisionLister { + return &controllerRevisionLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// controllerRevisionLister implements the appsv1beta1listers.ControllerRevisionLister interface. +// controllerRevisionLister can list all ControllerRevisions inside a workspace +// or scope down to a listersappsv1beta1.ControllerRevisionNamespaceLister for one namespace. type controllerRevisionLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*appsv1beta1.ControllerRevision] } -// List lists all ControllerRevisions in the indexer for a workspace. -func (s *controllerRevisionLister) List(selector labels.Selector) (ret []*appsv1beta1.ControllerRevision, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*appsv1beta1.ControllerRevision)) - }) - return ret, err -} +var _ listersappsv1beta1.ControllerRevisionLister = new(controllerRevisionLister) // ControllerRevisions returns an object that can list and get ControllerRevisions in one namespace. -func (s *controllerRevisionLister) ControllerRevisions(namespace string) appsv1beta1listers.ControllerRevisionNamespaceLister { - return &controllerRevisionNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *controllerRevisionLister) ControllerRevisions(namespace string) listersappsv1beta1.ControllerRevisionNamespaceLister { + return &controllerRevisionNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// controllerRevisionNamespaceLister implements the appsv1beta1listers.ControllerRevisionNamespaceLister interface. +// controllerRevisionNamespaceLister implements the listersappsv1beta1.ControllerRevisionNamespaceLister +// interface. type controllerRevisionNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*appsv1beta1.ControllerRevision] } -// List lists all ControllerRevisions in the indexer for a given workspace and namespace. -func (s *controllerRevisionNamespaceLister) List(selector labels.Selector) (ret []*appsv1beta1.ControllerRevision, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*appsv1beta1.ControllerRevision)) - }) - return ret, err -} +var _ listersappsv1beta1.ControllerRevisionNamespaceLister = new(controllerRevisionNamespaceLister) -// Get retrieves the ControllerRevision from the indexer for a given workspace, namespace and name. -func (s *controllerRevisionNamespaceLister) Get(name string) (*appsv1beta1.ControllerRevision, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewControllerRevisionLister returns a new ControllerRevisionLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewControllerRevisionLister(indexer cache.Indexer) listersappsv1beta1.ControllerRevisionLister { + return &controllerRevisionLister{ + kcplisters.New[*appsv1beta1.ControllerRevision](indexer, appsv1beta1.Resource("controllerrevision")), } - if !exists { - return nil, errors.NewNotFound(appsv1beta1.Resource("controllerrevisions"), name) +} + +// controllerRevisionScopedLister can list all ControllerRevisions inside a workspace +// or scope down to a listersappsv1beta1.ControllerRevisionNamespaceLister for one namespace. +type controllerRevisionScopedLister struct { + kcplisters.ResourceIndexer[*appsv1beta1.ControllerRevision] +} + +// ControllerRevisions returns an object that can list and get ControllerRevisions in one namespace. +func (l *controllerRevisionScopedLister) ControllerRevisions(namespace string) listersappsv1beta1.ControllerRevisionLister { + return &controllerRevisionLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*appsv1beta1.ControllerRevision), nil } diff --git a/listers/apps/v1beta1/deployment.go b/listers/apps/v1beta1/deployment.go index 11e6c5c5b..f52fc9097 100644 --- a/listers/apps/v1beta1/deployment.go +++ b/listers/apps/v1beta1/deployment.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" appsv1beta1 "k8s.io/api/apps/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - appsv1beta1listers "k8s.io/client-go/listers/apps/v1beta1" + listersappsv1beta1 "k8s.io/client-go/listers/apps/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// DeploymentClusterLister can list Deployments across all workspaces, or scope down to a DeploymentLister for one workspace. +// DeploymentClusterLister helps list Deployments across all workspaces, +// or scope down to a DeploymentLister for one workspace. // All objects returned here must be treated as read-only. type DeploymentClusterLister interface { // List lists all Deployments in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*appsv1beta1.Deployment, err error) // Cluster returns a lister that can list and get Deployments in one workspace. - Cluster(clusterName logicalcluster.Name) appsv1beta1listers.DeploymentLister + Cluster(clusterName logicalcluster.Name) listersappsv1beta1.DeploymentLister DeploymentClusterListerExpansion } +// deploymentClusterLister implements the DeploymentClusterLister interface. type deploymentClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*appsv1beta1.Deployment] } +var _ DeploymentClusterLister = new(deploymentClusterLister) + // NewDeploymentClusterLister returns a new DeploymentClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewDeploymentClusterLister(indexer cache.Indexer) *deploymentClusterLister { - return &deploymentClusterLister{indexer: indexer} -} - -// List lists all Deployments in the indexer across all workspaces. -func (s *deploymentClusterLister) List(selector labels.Selector) (ret []*appsv1beta1.Deployment, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*appsv1beta1.Deployment)) - }) - return ret, err +func NewDeploymentClusterLister(indexer cache.Indexer) DeploymentClusterLister { + return &deploymentClusterLister{ + kcplisters.NewCluster[*appsv1beta1.Deployment](indexer, appsv1beta1.Resource("deployment")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get Deployments. -func (s *deploymentClusterLister) Cluster(clusterName logicalcluster.Name) appsv1beta1listers.DeploymentLister { - return &deploymentLister{indexer: s.indexer, clusterName: clusterName} +func (l *deploymentClusterLister) Cluster(clusterName logicalcluster.Name) listersappsv1beta1.DeploymentLister { + return &deploymentLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// deploymentLister implements the appsv1beta1listers.DeploymentLister interface. +// deploymentLister can list all Deployments inside a workspace +// or scope down to a listersappsv1beta1.DeploymentNamespaceLister for one namespace. type deploymentLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*appsv1beta1.Deployment] } -// List lists all Deployments in the indexer for a workspace. -func (s *deploymentLister) List(selector labels.Selector) (ret []*appsv1beta1.Deployment, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*appsv1beta1.Deployment)) - }) - return ret, err -} +var _ listersappsv1beta1.DeploymentLister = new(deploymentLister) // Deployments returns an object that can list and get Deployments in one namespace. -func (s *deploymentLister) Deployments(namespace string) appsv1beta1listers.DeploymentNamespaceLister { - return &deploymentNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *deploymentLister) Deployments(namespace string) listersappsv1beta1.DeploymentNamespaceLister { + return &deploymentNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// deploymentNamespaceLister implements the appsv1beta1listers.DeploymentNamespaceLister interface. +// deploymentNamespaceLister implements the listersappsv1beta1.DeploymentNamespaceLister +// interface. type deploymentNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*appsv1beta1.Deployment] } -// List lists all Deployments in the indexer for a given workspace and namespace. -func (s *deploymentNamespaceLister) List(selector labels.Selector) (ret []*appsv1beta1.Deployment, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*appsv1beta1.Deployment)) - }) - return ret, err -} +var _ listersappsv1beta1.DeploymentNamespaceLister = new(deploymentNamespaceLister) -// Get retrieves the Deployment from the indexer for a given workspace, namespace and name. -func (s *deploymentNamespaceLister) Get(name string) (*appsv1beta1.Deployment, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewDeploymentLister returns a new DeploymentLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewDeploymentLister(indexer cache.Indexer) listersappsv1beta1.DeploymentLister { + return &deploymentLister{ + kcplisters.New[*appsv1beta1.Deployment](indexer, appsv1beta1.Resource("deployment")), } - if !exists { - return nil, errors.NewNotFound(appsv1beta1.Resource("deployments"), name) +} + +// deploymentScopedLister can list all Deployments inside a workspace +// or scope down to a listersappsv1beta1.DeploymentNamespaceLister for one namespace. +type deploymentScopedLister struct { + kcplisters.ResourceIndexer[*appsv1beta1.Deployment] +} + +// Deployments returns an object that can list and get Deployments in one namespace. +func (l *deploymentScopedLister) Deployments(namespace string) listersappsv1beta1.DeploymentLister { + return &deploymentLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*appsv1beta1.Deployment), nil } diff --git a/listers/apps/v1beta1/expansion_generated.go b/listers/apps/v1beta1/expansion_generated.go new file mode 100644 index 000000000..23cac805b --- /dev/null +++ b/listers/apps/v1beta1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1beta1 diff --git a/listers/apps/v1beta1/statefulset.go b/listers/apps/v1beta1/statefulset.go index 89ab19504..5d407c777 100644 --- a/listers/apps/v1beta1/statefulset.go +++ b/listers/apps/v1beta1/statefulset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" appsv1beta1 "k8s.io/api/apps/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - appsv1beta1listers "k8s.io/client-go/listers/apps/v1beta1" + listersappsv1beta1 "k8s.io/client-go/listers/apps/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// StatefulSetClusterLister can list StatefulSets across all workspaces, or scope down to a StatefulSetLister for one workspace. +// StatefulSetClusterLister helps list StatefulSets across all workspaces, +// or scope down to a StatefulSetLister for one workspace. // All objects returned here must be treated as read-only. type StatefulSetClusterLister interface { // List lists all StatefulSets in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*appsv1beta1.StatefulSet, err error) // Cluster returns a lister that can list and get StatefulSets in one workspace. - Cluster(clusterName logicalcluster.Name) appsv1beta1listers.StatefulSetLister + Cluster(clusterName logicalcluster.Name) listersappsv1beta1.StatefulSetLister StatefulSetClusterListerExpansion } +// statefulSetClusterLister implements the StatefulSetClusterLister interface. type statefulSetClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*appsv1beta1.StatefulSet] } +var _ StatefulSetClusterLister = new(statefulSetClusterLister) + // NewStatefulSetClusterLister returns a new StatefulSetClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewStatefulSetClusterLister(indexer cache.Indexer) *statefulSetClusterLister { - return &statefulSetClusterLister{indexer: indexer} -} - -// List lists all StatefulSets in the indexer across all workspaces. -func (s *statefulSetClusterLister) List(selector labels.Selector) (ret []*appsv1beta1.StatefulSet, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*appsv1beta1.StatefulSet)) - }) - return ret, err +func NewStatefulSetClusterLister(indexer cache.Indexer) StatefulSetClusterLister { + return &statefulSetClusterLister{ + kcplisters.NewCluster[*appsv1beta1.StatefulSet](indexer, appsv1beta1.Resource("statefulset")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get StatefulSets. -func (s *statefulSetClusterLister) Cluster(clusterName logicalcluster.Name) appsv1beta1listers.StatefulSetLister { - return &statefulSetLister{indexer: s.indexer, clusterName: clusterName} +func (l *statefulSetClusterLister) Cluster(clusterName logicalcluster.Name) listersappsv1beta1.StatefulSetLister { + return &statefulSetLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// statefulSetLister implements the appsv1beta1listers.StatefulSetLister interface. +// statefulSetLister can list all StatefulSets inside a workspace +// or scope down to a listersappsv1beta1.StatefulSetNamespaceLister for one namespace. type statefulSetLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*appsv1beta1.StatefulSet] } -// List lists all StatefulSets in the indexer for a workspace. -func (s *statefulSetLister) List(selector labels.Selector) (ret []*appsv1beta1.StatefulSet, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*appsv1beta1.StatefulSet)) - }) - return ret, err -} +var _ listersappsv1beta1.StatefulSetLister = new(statefulSetLister) // StatefulSets returns an object that can list and get StatefulSets in one namespace. -func (s *statefulSetLister) StatefulSets(namespace string) appsv1beta1listers.StatefulSetNamespaceLister { - return &statefulSetNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *statefulSetLister) StatefulSets(namespace string) listersappsv1beta1.StatefulSetNamespaceLister { + return &statefulSetNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// statefulSetNamespaceLister implements the appsv1beta1listers.StatefulSetNamespaceLister interface. +// statefulSetNamespaceLister implements the listersappsv1beta1.StatefulSetNamespaceLister +// interface. type statefulSetNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*appsv1beta1.StatefulSet] } -// List lists all StatefulSets in the indexer for a given workspace and namespace. -func (s *statefulSetNamespaceLister) List(selector labels.Selector) (ret []*appsv1beta1.StatefulSet, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*appsv1beta1.StatefulSet)) - }) - return ret, err -} +var _ listersappsv1beta1.StatefulSetNamespaceLister = new(statefulSetNamespaceLister) -// Get retrieves the StatefulSet from the indexer for a given workspace, namespace and name. -func (s *statefulSetNamespaceLister) Get(name string) (*appsv1beta1.StatefulSet, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewStatefulSetLister returns a new StatefulSetLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewStatefulSetLister(indexer cache.Indexer) listersappsv1beta1.StatefulSetLister { + return &statefulSetLister{ + kcplisters.New[*appsv1beta1.StatefulSet](indexer, appsv1beta1.Resource("statefulset")), } - if !exists { - return nil, errors.NewNotFound(appsv1beta1.Resource("statefulsets"), name) +} + +// statefulSetScopedLister can list all StatefulSets inside a workspace +// or scope down to a listersappsv1beta1.StatefulSetNamespaceLister for one namespace. +type statefulSetScopedLister struct { + kcplisters.ResourceIndexer[*appsv1beta1.StatefulSet] +} + +// StatefulSets returns an object that can list and get StatefulSets in one namespace. +func (l *statefulSetScopedLister) StatefulSets(namespace string) listersappsv1beta1.StatefulSetLister { + return &statefulSetLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*appsv1beta1.StatefulSet), nil } diff --git a/listers/apps/v1beta1/statefulset_expansion.go b/listers/apps/v1beta1/statefulset_expansion.go index 24ef8ccb6..506cca09b 100644 --- a/listers/apps/v1beta1/statefulset_expansion.go +++ b/listers/apps/v1beta1/statefulset_expansion.go @@ -20,7 +20,7 @@ import ( "fmt" apps "k8s.io/api/apps/v1beta1" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" ) diff --git a/listers/apps/v1beta2/controllerrevision.go b/listers/apps/v1beta2/controllerrevision.go index f15401e51..62ec012fa 100644 --- a/listers/apps/v1beta2/controllerrevision.go +++ b/listers/apps/v1beta2/controllerrevision.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta2 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" appsv1beta2 "k8s.io/api/apps/v1beta2" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - appsv1beta2listers "k8s.io/client-go/listers/apps/v1beta2" + listersappsv1beta2 "k8s.io/client-go/listers/apps/v1beta2" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ControllerRevisionClusterLister can list ControllerRevisions across all workspaces, or scope down to a ControllerRevisionLister for one workspace. +// ControllerRevisionClusterLister helps list ControllerRevisions across all workspaces, +// or scope down to a ControllerRevisionLister for one workspace. // All objects returned here must be treated as read-only. type ControllerRevisionClusterLister interface { // List lists all ControllerRevisions in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*appsv1beta2.ControllerRevision, err error) // Cluster returns a lister that can list and get ControllerRevisions in one workspace. - Cluster(clusterName logicalcluster.Name) appsv1beta2listers.ControllerRevisionLister + Cluster(clusterName logicalcluster.Name) listersappsv1beta2.ControllerRevisionLister ControllerRevisionClusterListerExpansion } +// controllerRevisionClusterLister implements the ControllerRevisionClusterLister interface. type controllerRevisionClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*appsv1beta2.ControllerRevision] } +var _ ControllerRevisionClusterLister = new(controllerRevisionClusterLister) + // NewControllerRevisionClusterLister returns a new ControllerRevisionClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewControllerRevisionClusterLister(indexer cache.Indexer) *controllerRevisionClusterLister { - return &controllerRevisionClusterLister{indexer: indexer} -} - -// List lists all ControllerRevisions in the indexer across all workspaces. -func (s *controllerRevisionClusterLister) List(selector labels.Selector) (ret []*appsv1beta2.ControllerRevision, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*appsv1beta2.ControllerRevision)) - }) - return ret, err +func NewControllerRevisionClusterLister(indexer cache.Indexer) ControllerRevisionClusterLister { + return &controllerRevisionClusterLister{ + kcplisters.NewCluster[*appsv1beta2.ControllerRevision](indexer, appsv1beta2.Resource("controllerrevision")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ControllerRevisions. -func (s *controllerRevisionClusterLister) Cluster(clusterName logicalcluster.Name) appsv1beta2listers.ControllerRevisionLister { - return &controllerRevisionLister{indexer: s.indexer, clusterName: clusterName} +func (l *controllerRevisionClusterLister) Cluster(clusterName logicalcluster.Name) listersappsv1beta2.ControllerRevisionLister { + return &controllerRevisionLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// controllerRevisionLister implements the appsv1beta2listers.ControllerRevisionLister interface. +// controllerRevisionLister can list all ControllerRevisions inside a workspace +// or scope down to a listersappsv1beta2.ControllerRevisionNamespaceLister for one namespace. type controllerRevisionLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*appsv1beta2.ControllerRevision] } -// List lists all ControllerRevisions in the indexer for a workspace. -func (s *controllerRevisionLister) List(selector labels.Selector) (ret []*appsv1beta2.ControllerRevision, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*appsv1beta2.ControllerRevision)) - }) - return ret, err -} +var _ listersappsv1beta2.ControllerRevisionLister = new(controllerRevisionLister) // ControllerRevisions returns an object that can list and get ControllerRevisions in one namespace. -func (s *controllerRevisionLister) ControllerRevisions(namespace string) appsv1beta2listers.ControllerRevisionNamespaceLister { - return &controllerRevisionNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *controllerRevisionLister) ControllerRevisions(namespace string) listersappsv1beta2.ControllerRevisionNamespaceLister { + return &controllerRevisionNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// controllerRevisionNamespaceLister implements the appsv1beta2listers.ControllerRevisionNamespaceLister interface. +// controllerRevisionNamespaceLister implements the listersappsv1beta2.ControllerRevisionNamespaceLister +// interface. type controllerRevisionNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*appsv1beta2.ControllerRevision] } -// List lists all ControllerRevisions in the indexer for a given workspace and namespace. -func (s *controllerRevisionNamespaceLister) List(selector labels.Selector) (ret []*appsv1beta2.ControllerRevision, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*appsv1beta2.ControllerRevision)) - }) - return ret, err -} +var _ listersappsv1beta2.ControllerRevisionNamespaceLister = new(controllerRevisionNamespaceLister) -// Get retrieves the ControllerRevision from the indexer for a given workspace, namespace and name. -func (s *controllerRevisionNamespaceLister) Get(name string) (*appsv1beta2.ControllerRevision, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewControllerRevisionLister returns a new ControllerRevisionLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewControllerRevisionLister(indexer cache.Indexer) listersappsv1beta2.ControllerRevisionLister { + return &controllerRevisionLister{ + kcplisters.New[*appsv1beta2.ControllerRevision](indexer, appsv1beta2.Resource("controllerrevision")), } - if !exists { - return nil, errors.NewNotFound(appsv1beta2.Resource("controllerrevisions"), name) +} + +// controllerRevisionScopedLister can list all ControllerRevisions inside a workspace +// or scope down to a listersappsv1beta2.ControllerRevisionNamespaceLister for one namespace. +type controllerRevisionScopedLister struct { + kcplisters.ResourceIndexer[*appsv1beta2.ControllerRevision] +} + +// ControllerRevisions returns an object that can list and get ControllerRevisions in one namespace. +func (l *controllerRevisionScopedLister) ControllerRevisions(namespace string) listersappsv1beta2.ControllerRevisionLister { + return &controllerRevisionLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*appsv1beta2.ControllerRevision), nil } diff --git a/listers/apps/v1beta2/daemonset.go b/listers/apps/v1beta2/daemonset.go index ae847aacb..4e72ca32b 100644 --- a/listers/apps/v1beta2/daemonset.go +++ b/listers/apps/v1beta2/daemonset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta2 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" appsv1beta2 "k8s.io/api/apps/v1beta2" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - appsv1beta2listers "k8s.io/client-go/listers/apps/v1beta2" + listersappsv1beta2 "k8s.io/client-go/listers/apps/v1beta2" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// DaemonSetClusterLister can list DaemonSets across all workspaces, or scope down to a DaemonSetLister for one workspace. +// DaemonSetClusterLister helps list DaemonSets across all workspaces, +// or scope down to a DaemonSetLister for one workspace. // All objects returned here must be treated as read-only. type DaemonSetClusterLister interface { // List lists all DaemonSets in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*appsv1beta2.DaemonSet, err error) // Cluster returns a lister that can list and get DaemonSets in one workspace. - Cluster(clusterName logicalcluster.Name) appsv1beta2listers.DaemonSetLister + Cluster(clusterName logicalcluster.Name) listersappsv1beta2.DaemonSetLister DaemonSetClusterListerExpansion } +// daemonSetClusterLister implements the DaemonSetClusterLister interface. type daemonSetClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*appsv1beta2.DaemonSet] } +var _ DaemonSetClusterLister = new(daemonSetClusterLister) + // NewDaemonSetClusterLister returns a new DaemonSetClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewDaemonSetClusterLister(indexer cache.Indexer) *daemonSetClusterLister { - return &daemonSetClusterLister{indexer: indexer} -} - -// List lists all DaemonSets in the indexer across all workspaces. -func (s *daemonSetClusterLister) List(selector labels.Selector) (ret []*appsv1beta2.DaemonSet, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*appsv1beta2.DaemonSet)) - }) - return ret, err +func NewDaemonSetClusterLister(indexer cache.Indexer) DaemonSetClusterLister { + return &daemonSetClusterLister{ + kcplisters.NewCluster[*appsv1beta2.DaemonSet](indexer, appsv1beta2.Resource("daemonset")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get DaemonSets. -func (s *daemonSetClusterLister) Cluster(clusterName logicalcluster.Name) appsv1beta2listers.DaemonSetLister { - return &daemonSetLister{indexer: s.indexer, clusterName: clusterName} +func (l *daemonSetClusterLister) Cluster(clusterName logicalcluster.Name) listersappsv1beta2.DaemonSetLister { + return &daemonSetLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// daemonSetLister implements the appsv1beta2listers.DaemonSetLister interface. +// daemonSetLister can list all DaemonSets inside a workspace +// or scope down to a listersappsv1beta2.DaemonSetNamespaceLister for one namespace. type daemonSetLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*appsv1beta2.DaemonSet] } -// List lists all DaemonSets in the indexer for a workspace. -func (s *daemonSetLister) List(selector labels.Selector) (ret []*appsv1beta2.DaemonSet, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*appsv1beta2.DaemonSet)) - }) - return ret, err -} +var _ listersappsv1beta2.DaemonSetLister = new(daemonSetLister) // DaemonSets returns an object that can list and get DaemonSets in one namespace. -func (s *daemonSetLister) DaemonSets(namespace string) appsv1beta2listers.DaemonSetNamespaceLister { - return &daemonSetNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *daemonSetLister) DaemonSets(namespace string) listersappsv1beta2.DaemonSetNamespaceLister { + return &daemonSetNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// daemonSetNamespaceLister implements the appsv1beta2listers.DaemonSetNamespaceLister interface. +// daemonSetNamespaceLister implements the listersappsv1beta2.DaemonSetNamespaceLister +// interface. type daemonSetNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*appsv1beta2.DaemonSet] } -// List lists all DaemonSets in the indexer for a given workspace and namespace. -func (s *daemonSetNamespaceLister) List(selector labels.Selector) (ret []*appsv1beta2.DaemonSet, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*appsv1beta2.DaemonSet)) - }) - return ret, err -} +var _ listersappsv1beta2.DaemonSetNamespaceLister = new(daemonSetNamespaceLister) -// Get retrieves the DaemonSet from the indexer for a given workspace, namespace and name. -func (s *daemonSetNamespaceLister) Get(name string) (*appsv1beta2.DaemonSet, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewDaemonSetLister returns a new DaemonSetLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewDaemonSetLister(indexer cache.Indexer) listersappsv1beta2.DaemonSetLister { + return &daemonSetLister{ + kcplisters.New[*appsv1beta2.DaemonSet](indexer, appsv1beta2.Resource("daemonset")), } - if !exists { - return nil, errors.NewNotFound(appsv1beta2.Resource("daemonsets"), name) +} + +// daemonSetScopedLister can list all DaemonSets inside a workspace +// or scope down to a listersappsv1beta2.DaemonSetNamespaceLister for one namespace. +type daemonSetScopedLister struct { + kcplisters.ResourceIndexer[*appsv1beta2.DaemonSet] +} + +// DaemonSets returns an object that can list and get DaemonSets in one namespace. +func (l *daemonSetScopedLister) DaemonSets(namespace string) listersappsv1beta2.DaemonSetLister { + return &daemonSetLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*appsv1beta2.DaemonSet), nil } diff --git a/listers/apps/v1beta2/daemonset_expansion.go b/listers/apps/v1beta2/daemonset_expansion.go index 169d7b667..eb17b02e2 100644 --- a/listers/apps/v1beta2/daemonset_expansion.go +++ b/listers/apps/v1beta2/daemonset_expansion.go @@ -20,7 +20,7 @@ import ( "fmt" apps "k8s.io/api/apps/v1beta2" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" ) diff --git a/listers/apps/v1beta2/deployment.go b/listers/apps/v1beta2/deployment.go index f2080cb78..a40d5fc75 100644 --- a/listers/apps/v1beta2/deployment.go +++ b/listers/apps/v1beta2/deployment.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta2 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" appsv1beta2 "k8s.io/api/apps/v1beta2" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - appsv1beta2listers "k8s.io/client-go/listers/apps/v1beta2" + listersappsv1beta2 "k8s.io/client-go/listers/apps/v1beta2" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// DeploymentClusterLister can list Deployments across all workspaces, or scope down to a DeploymentLister for one workspace. +// DeploymentClusterLister helps list Deployments across all workspaces, +// or scope down to a DeploymentLister for one workspace. // All objects returned here must be treated as read-only. type DeploymentClusterLister interface { // List lists all Deployments in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*appsv1beta2.Deployment, err error) // Cluster returns a lister that can list and get Deployments in one workspace. - Cluster(clusterName logicalcluster.Name) appsv1beta2listers.DeploymentLister + Cluster(clusterName logicalcluster.Name) listersappsv1beta2.DeploymentLister DeploymentClusterListerExpansion } +// deploymentClusterLister implements the DeploymentClusterLister interface. type deploymentClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*appsv1beta2.Deployment] } +var _ DeploymentClusterLister = new(deploymentClusterLister) + // NewDeploymentClusterLister returns a new DeploymentClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewDeploymentClusterLister(indexer cache.Indexer) *deploymentClusterLister { - return &deploymentClusterLister{indexer: indexer} -} - -// List lists all Deployments in the indexer across all workspaces. -func (s *deploymentClusterLister) List(selector labels.Selector) (ret []*appsv1beta2.Deployment, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*appsv1beta2.Deployment)) - }) - return ret, err +func NewDeploymentClusterLister(indexer cache.Indexer) DeploymentClusterLister { + return &deploymentClusterLister{ + kcplisters.NewCluster[*appsv1beta2.Deployment](indexer, appsv1beta2.Resource("deployment")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get Deployments. -func (s *deploymentClusterLister) Cluster(clusterName logicalcluster.Name) appsv1beta2listers.DeploymentLister { - return &deploymentLister{indexer: s.indexer, clusterName: clusterName} +func (l *deploymentClusterLister) Cluster(clusterName logicalcluster.Name) listersappsv1beta2.DeploymentLister { + return &deploymentLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// deploymentLister implements the appsv1beta2listers.DeploymentLister interface. +// deploymentLister can list all Deployments inside a workspace +// or scope down to a listersappsv1beta2.DeploymentNamespaceLister for one namespace. type deploymentLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*appsv1beta2.Deployment] } -// List lists all Deployments in the indexer for a workspace. -func (s *deploymentLister) List(selector labels.Selector) (ret []*appsv1beta2.Deployment, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*appsv1beta2.Deployment)) - }) - return ret, err -} +var _ listersappsv1beta2.DeploymentLister = new(deploymentLister) // Deployments returns an object that can list and get Deployments in one namespace. -func (s *deploymentLister) Deployments(namespace string) appsv1beta2listers.DeploymentNamespaceLister { - return &deploymentNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *deploymentLister) Deployments(namespace string) listersappsv1beta2.DeploymentNamespaceLister { + return &deploymentNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// deploymentNamespaceLister implements the appsv1beta2listers.DeploymentNamespaceLister interface. +// deploymentNamespaceLister implements the listersappsv1beta2.DeploymentNamespaceLister +// interface. type deploymentNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*appsv1beta2.Deployment] } -// List lists all Deployments in the indexer for a given workspace and namespace. -func (s *deploymentNamespaceLister) List(selector labels.Selector) (ret []*appsv1beta2.Deployment, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*appsv1beta2.Deployment)) - }) - return ret, err -} +var _ listersappsv1beta2.DeploymentNamespaceLister = new(deploymentNamespaceLister) -// Get retrieves the Deployment from the indexer for a given workspace, namespace and name. -func (s *deploymentNamespaceLister) Get(name string) (*appsv1beta2.Deployment, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewDeploymentLister returns a new DeploymentLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewDeploymentLister(indexer cache.Indexer) listersappsv1beta2.DeploymentLister { + return &deploymentLister{ + kcplisters.New[*appsv1beta2.Deployment](indexer, appsv1beta2.Resource("deployment")), } - if !exists { - return nil, errors.NewNotFound(appsv1beta2.Resource("deployments"), name) +} + +// deploymentScopedLister can list all Deployments inside a workspace +// or scope down to a listersappsv1beta2.DeploymentNamespaceLister for one namespace. +type deploymentScopedLister struct { + kcplisters.ResourceIndexer[*appsv1beta2.Deployment] +} + +// Deployments returns an object that can list and get Deployments in one namespace. +func (l *deploymentScopedLister) Deployments(namespace string) listersappsv1beta2.DeploymentLister { + return &deploymentLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*appsv1beta2.Deployment), nil } diff --git a/listers/apps/v1beta2/expansion_generated.go b/listers/apps/v1beta2/expansion_generated.go new file mode 100644 index 000000000..3e58e545a --- /dev/null +++ b/listers/apps/v1beta2/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1beta2 diff --git a/listers/apps/v1beta2/replicaset.go b/listers/apps/v1beta2/replicaset.go index 7f7ee2224..34c0e5049 100644 --- a/listers/apps/v1beta2/replicaset.go +++ b/listers/apps/v1beta2/replicaset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta2 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" appsv1beta2 "k8s.io/api/apps/v1beta2" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - appsv1beta2listers "k8s.io/client-go/listers/apps/v1beta2" + listersappsv1beta2 "k8s.io/client-go/listers/apps/v1beta2" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ReplicaSetClusterLister can list ReplicaSets across all workspaces, or scope down to a ReplicaSetLister for one workspace. +// ReplicaSetClusterLister helps list ReplicaSets across all workspaces, +// or scope down to a ReplicaSetLister for one workspace. // All objects returned here must be treated as read-only. type ReplicaSetClusterLister interface { // List lists all ReplicaSets in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*appsv1beta2.ReplicaSet, err error) // Cluster returns a lister that can list and get ReplicaSets in one workspace. - Cluster(clusterName logicalcluster.Name) appsv1beta2listers.ReplicaSetLister + Cluster(clusterName logicalcluster.Name) listersappsv1beta2.ReplicaSetLister ReplicaSetClusterListerExpansion } +// replicaSetClusterLister implements the ReplicaSetClusterLister interface. type replicaSetClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*appsv1beta2.ReplicaSet] } +var _ ReplicaSetClusterLister = new(replicaSetClusterLister) + // NewReplicaSetClusterLister returns a new ReplicaSetClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewReplicaSetClusterLister(indexer cache.Indexer) *replicaSetClusterLister { - return &replicaSetClusterLister{indexer: indexer} -} - -// List lists all ReplicaSets in the indexer across all workspaces. -func (s *replicaSetClusterLister) List(selector labels.Selector) (ret []*appsv1beta2.ReplicaSet, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*appsv1beta2.ReplicaSet)) - }) - return ret, err +func NewReplicaSetClusterLister(indexer cache.Indexer) ReplicaSetClusterLister { + return &replicaSetClusterLister{ + kcplisters.NewCluster[*appsv1beta2.ReplicaSet](indexer, appsv1beta2.Resource("replicaset")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ReplicaSets. -func (s *replicaSetClusterLister) Cluster(clusterName logicalcluster.Name) appsv1beta2listers.ReplicaSetLister { - return &replicaSetLister{indexer: s.indexer, clusterName: clusterName} +func (l *replicaSetClusterLister) Cluster(clusterName logicalcluster.Name) listersappsv1beta2.ReplicaSetLister { + return &replicaSetLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// replicaSetLister implements the appsv1beta2listers.ReplicaSetLister interface. +// replicaSetLister can list all ReplicaSets inside a workspace +// or scope down to a listersappsv1beta2.ReplicaSetNamespaceLister for one namespace. type replicaSetLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*appsv1beta2.ReplicaSet] } -// List lists all ReplicaSets in the indexer for a workspace. -func (s *replicaSetLister) List(selector labels.Selector) (ret []*appsv1beta2.ReplicaSet, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*appsv1beta2.ReplicaSet)) - }) - return ret, err -} +var _ listersappsv1beta2.ReplicaSetLister = new(replicaSetLister) // ReplicaSets returns an object that can list and get ReplicaSets in one namespace. -func (s *replicaSetLister) ReplicaSets(namespace string) appsv1beta2listers.ReplicaSetNamespaceLister { - return &replicaSetNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *replicaSetLister) ReplicaSets(namespace string) listersappsv1beta2.ReplicaSetNamespaceLister { + return &replicaSetNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// replicaSetNamespaceLister implements the appsv1beta2listers.ReplicaSetNamespaceLister interface. +// replicaSetNamespaceLister implements the listersappsv1beta2.ReplicaSetNamespaceLister +// interface. type replicaSetNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*appsv1beta2.ReplicaSet] } -// List lists all ReplicaSets in the indexer for a given workspace and namespace. -func (s *replicaSetNamespaceLister) List(selector labels.Selector) (ret []*appsv1beta2.ReplicaSet, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*appsv1beta2.ReplicaSet)) - }) - return ret, err -} +var _ listersappsv1beta2.ReplicaSetNamespaceLister = new(replicaSetNamespaceLister) -// Get retrieves the ReplicaSet from the indexer for a given workspace, namespace and name. -func (s *replicaSetNamespaceLister) Get(name string) (*appsv1beta2.ReplicaSet, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewReplicaSetLister returns a new ReplicaSetLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewReplicaSetLister(indexer cache.Indexer) listersappsv1beta2.ReplicaSetLister { + return &replicaSetLister{ + kcplisters.New[*appsv1beta2.ReplicaSet](indexer, appsv1beta2.Resource("replicaset")), } - if !exists { - return nil, errors.NewNotFound(appsv1beta2.Resource("replicasets"), name) +} + +// replicaSetScopedLister can list all ReplicaSets inside a workspace +// or scope down to a listersappsv1beta2.ReplicaSetNamespaceLister for one namespace. +type replicaSetScopedLister struct { + kcplisters.ResourceIndexer[*appsv1beta2.ReplicaSet] +} + +// ReplicaSets returns an object that can list and get ReplicaSets in one namespace. +func (l *replicaSetScopedLister) ReplicaSets(namespace string) listersappsv1beta2.ReplicaSetLister { + return &replicaSetLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*appsv1beta2.ReplicaSet), nil } diff --git a/listers/apps/v1beta2/replicaset_expansion.go b/listers/apps/v1beta2/replicaset_expansion.go index 484eb6324..e691efb0e 100644 --- a/listers/apps/v1beta2/replicaset_expansion.go +++ b/listers/apps/v1beta2/replicaset_expansion.go @@ -20,7 +20,7 @@ import ( "fmt" apps "k8s.io/api/apps/v1beta2" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" ) diff --git a/listers/apps/v1beta2/statefulset.go b/listers/apps/v1beta2/statefulset.go index fec7f0d8e..eb309fde4 100644 --- a/listers/apps/v1beta2/statefulset.go +++ b/listers/apps/v1beta2/statefulset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta2 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" appsv1beta2 "k8s.io/api/apps/v1beta2" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - appsv1beta2listers "k8s.io/client-go/listers/apps/v1beta2" + listersappsv1beta2 "k8s.io/client-go/listers/apps/v1beta2" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// StatefulSetClusterLister can list StatefulSets across all workspaces, or scope down to a StatefulSetLister for one workspace. +// StatefulSetClusterLister helps list StatefulSets across all workspaces, +// or scope down to a StatefulSetLister for one workspace. // All objects returned here must be treated as read-only. type StatefulSetClusterLister interface { // List lists all StatefulSets in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*appsv1beta2.StatefulSet, err error) // Cluster returns a lister that can list and get StatefulSets in one workspace. - Cluster(clusterName logicalcluster.Name) appsv1beta2listers.StatefulSetLister + Cluster(clusterName logicalcluster.Name) listersappsv1beta2.StatefulSetLister StatefulSetClusterListerExpansion } +// statefulSetClusterLister implements the StatefulSetClusterLister interface. type statefulSetClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*appsv1beta2.StatefulSet] } +var _ StatefulSetClusterLister = new(statefulSetClusterLister) + // NewStatefulSetClusterLister returns a new StatefulSetClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewStatefulSetClusterLister(indexer cache.Indexer) *statefulSetClusterLister { - return &statefulSetClusterLister{indexer: indexer} -} - -// List lists all StatefulSets in the indexer across all workspaces. -func (s *statefulSetClusterLister) List(selector labels.Selector) (ret []*appsv1beta2.StatefulSet, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*appsv1beta2.StatefulSet)) - }) - return ret, err +func NewStatefulSetClusterLister(indexer cache.Indexer) StatefulSetClusterLister { + return &statefulSetClusterLister{ + kcplisters.NewCluster[*appsv1beta2.StatefulSet](indexer, appsv1beta2.Resource("statefulset")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get StatefulSets. -func (s *statefulSetClusterLister) Cluster(clusterName logicalcluster.Name) appsv1beta2listers.StatefulSetLister { - return &statefulSetLister{indexer: s.indexer, clusterName: clusterName} +func (l *statefulSetClusterLister) Cluster(clusterName logicalcluster.Name) listersappsv1beta2.StatefulSetLister { + return &statefulSetLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// statefulSetLister implements the appsv1beta2listers.StatefulSetLister interface. +// statefulSetLister can list all StatefulSets inside a workspace +// or scope down to a listersappsv1beta2.StatefulSetNamespaceLister for one namespace. type statefulSetLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*appsv1beta2.StatefulSet] } -// List lists all StatefulSets in the indexer for a workspace. -func (s *statefulSetLister) List(selector labels.Selector) (ret []*appsv1beta2.StatefulSet, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*appsv1beta2.StatefulSet)) - }) - return ret, err -} +var _ listersappsv1beta2.StatefulSetLister = new(statefulSetLister) // StatefulSets returns an object that can list and get StatefulSets in one namespace. -func (s *statefulSetLister) StatefulSets(namespace string) appsv1beta2listers.StatefulSetNamespaceLister { - return &statefulSetNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *statefulSetLister) StatefulSets(namespace string) listersappsv1beta2.StatefulSetNamespaceLister { + return &statefulSetNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// statefulSetNamespaceLister implements the appsv1beta2listers.StatefulSetNamespaceLister interface. +// statefulSetNamespaceLister implements the listersappsv1beta2.StatefulSetNamespaceLister +// interface. type statefulSetNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*appsv1beta2.StatefulSet] } -// List lists all StatefulSets in the indexer for a given workspace and namespace. -func (s *statefulSetNamespaceLister) List(selector labels.Selector) (ret []*appsv1beta2.StatefulSet, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*appsv1beta2.StatefulSet)) - }) - return ret, err -} +var _ listersappsv1beta2.StatefulSetNamespaceLister = new(statefulSetNamespaceLister) -// Get retrieves the StatefulSet from the indexer for a given workspace, namespace and name. -func (s *statefulSetNamespaceLister) Get(name string) (*appsv1beta2.StatefulSet, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewStatefulSetLister returns a new StatefulSetLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewStatefulSetLister(indexer cache.Indexer) listersappsv1beta2.StatefulSetLister { + return &statefulSetLister{ + kcplisters.New[*appsv1beta2.StatefulSet](indexer, appsv1beta2.Resource("statefulset")), } - if !exists { - return nil, errors.NewNotFound(appsv1beta2.Resource("statefulsets"), name) +} + +// statefulSetScopedLister can list all StatefulSets inside a workspace +// or scope down to a listersappsv1beta2.StatefulSetNamespaceLister for one namespace. +type statefulSetScopedLister struct { + kcplisters.ResourceIndexer[*appsv1beta2.StatefulSet] +} + +// StatefulSets returns an object that can list and get StatefulSets in one namespace. +func (l *statefulSetScopedLister) StatefulSets(namespace string) listersappsv1beta2.StatefulSetLister { + return &statefulSetLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*appsv1beta2.StatefulSet), nil } diff --git a/listers/apps/v1beta2/statefulset_expansion.go b/listers/apps/v1beta2/statefulset_expansion.go index f9a3b38cb..a9a6b84d0 100644 --- a/listers/apps/v1beta2/statefulset_expansion.go +++ b/listers/apps/v1beta2/statefulset_expansion.go @@ -20,7 +20,7 @@ import ( "fmt" apps "k8s.io/api/apps/v1beta2" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" ) diff --git a/listers/autoscaling/v1/expansion_generated.go b/listers/autoscaling/v1/expansion_generated.go new file mode 100644 index 000000000..b6a0c6377 --- /dev/null +++ b/listers/autoscaling/v1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1 diff --git a/listers/autoscaling/v1/horizontalpodautoscaler.go b/listers/autoscaling/v1/horizontalpodautoscaler.go index 52fc6295f..5e5a6f955 100644 --- a/listers/autoscaling/v1/horizontalpodautoscaler.go +++ b/listers/autoscaling/v1/horizontalpodautoscaler.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" autoscalingv1 "k8s.io/api/autoscaling/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - autoscalingv1listers "k8s.io/client-go/listers/autoscaling/v1" + listersautoscalingv1 "k8s.io/client-go/listers/autoscaling/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// HorizontalPodAutoscalerClusterLister can list HorizontalPodAutoscalers across all workspaces, or scope down to a HorizontalPodAutoscalerLister for one workspace. +// HorizontalPodAutoscalerClusterLister helps list HorizontalPodAutoscalers across all workspaces, +// or scope down to a HorizontalPodAutoscalerLister for one workspace. // All objects returned here must be treated as read-only. type HorizontalPodAutoscalerClusterLister interface { // List lists all HorizontalPodAutoscalers in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*autoscalingv1.HorizontalPodAutoscaler, err error) // Cluster returns a lister that can list and get HorizontalPodAutoscalers in one workspace. - Cluster(clusterName logicalcluster.Name) autoscalingv1listers.HorizontalPodAutoscalerLister + Cluster(clusterName logicalcluster.Name) listersautoscalingv1.HorizontalPodAutoscalerLister HorizontalPodAutoscalerClusterListerExpansion } +// horizontalPodAutoscalerClusterLister implements the HorizontalPodAutoscalerClusterLister interface. type horizontalPodAutoscalerClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*autoscalingv1.HorizontalPodAutoscaler] } +var _ HorizontalPodAutoscalerClusterLister = new(horizontalPodAutoscalerClusterLister) + // NewHorizontalPodAutoscalerClusterLister returns a new HorizontalPodAutoscalerClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewHorizontalPodAutoscalerClusterLister(indexer cache.Indexer) *horizontalPodAutoscalerClusterLister { - return &horizontalPodAutoscalerClusterLister{indexer: indexer} -} - -// List lists all HorizontalPodAutoscalers in the indexer across all workspaces. -func (s *horizontalPodAutoscalerClusterLister) List(selector labels.Selector) (ret []*autoscalingv1.HorizontalPodAutoscaler, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*autoscalingv1.HorizontalPodAutoscaler)) - }) - return ret, err +func NewHorizontalPodAutoscalerClusterLister(indexer cache.Indexer) HorizontalPodAutoscalerClusterLister { + return &horizontalPodAutoscalerClusterLister{ + kcplisters.NewCluster[*autoscalingv1.HorizontalPodAutoscaler](indexer, autoscalingv1.Resource("horizontalpodautoscaler")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get HorizontalPodAutoscalers. -func (s *horizontalPodAutoscalerClusterLister) Cluster(clusterName logicalcluster.Name) autoscalingv1listers.HorizontalPodAutoscalerLister { - return &horizontalPodAutoscalerLister{indexer: s.indexer, clusterName: clusterName} +func (l *horizontalPodAutoscalerClusterLister) Cluster(clusterName logicalcluster.Name) listersautoscalingv1.HorizontalPodAutoscalerLister { + return &horizontalPodAutoscalerLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// horizontalPodAutoscalerLister implements the autoscalingv1listers.HorizontalPodAutoscalerLister interface. +// horizontalPodAutoscalerLister can list all HorizontalPodAutoscalers inside a workspace +// or scope down to a listersautoscalingv1.HorizontalPodAutoscalerNamespaceLister for one namespace. type horizontalPodAutoscalerLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*autoscalingv1.HorizontalPodAutoscaler] } -// List lists all HorizontalPodAutoscalers in the indexer for a workspace. -func (s *horizontalPodAutoscalerLister) List(selector labels.Selector) (ret []*autoscalingv1.HorizontalPodAutoscaler, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*autoscalingv1.HorizontalPodAutoscaler)) - }) - return ret, err -} +var _ listersautoscalingv1.HorizontalPodAutoscalerLister = new(horizontalPodAutoscalerLister) // HorizontalPodAutoscalers returns an object that can list and get HorizontalPodAutoscalers in one namespace. -func (s *horizontalPodAutoscalerLister) HorizontalPodAutoscalers(namespace string) autoscalingv1listers.HorizontalPodAutoscalerNamespaceLister { - return &horizontalPodAutoscalerNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *horizontalPodAutoscalerLister) HorizontalPodAutoscalers(namespace string) listersautoscalingv1.HorizontalPodAutoscalerNamespaceLister { + return &horizontalPodAutoscalerNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// horizontalPodAutoscalerNamespaceLister implements the autoscalingv1listers.HorizontalPodAutoscalerNamespaceLister interface. +// horizontalPodAutoscalerNamespaceLister implements the listersautoscalingv1.HorizontalPodAutoscalerNamespaceLister +// interface. type horizontalPodAutoscalerNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*autoscalingv1.HorizontalPodAutoscaler] } -// List lists all HorizontalPodAutoscalers in the indexer for a given workspace and namespace. -func (s *horizontalPodAutoscalerNamespaceLister) List(selector labels.Selector) (ret []*autoscalingv1.HorizontalPodAutoscaler, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*autoscalingv1.HorizontalPodAutoscaler)) - }) - return ret, err -} +var _ listersautoscalingv1.HorizontalPodAutoscalerNamespaceLister = new(horizontalPodAutoscalerNamespaceLister) -// Get retrieves the HorizontalPodAutoscaler from the indexer for a given workspace, namespace and name. -func (s *horizontalPodAutoscalerNamespaceLister) Get(name string) (*autoscalingv1.HorizontalPodAutoscaler, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewHorizontalPodAutoscalerLister returns a new HorizontalPodAutoscalerLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewHorizontalPodAutoscalerLister(indexer cache.Indexer) listersautoscalingv1.HorizontalPodAutoscalerLister { + return &horizontalPodAutoscalerLister{ + kcplisters.New[*autoscalingv1.HorizontalPodAutoscaler](indexer, autoscalingv1.Resource("horizontalpodautoscaler")), } - if !exists { - return nil, errors.NewNotFound(autoscalingv1.Resource("horizontalpodautoscalers"), name) +} + +// horizontalPodAutoscalerScopedLister can list all HorizontalPodAutoscalers inside a workspace +// or scope down to a listersautoscalingv1.HorizontalPodAutoscalerNamespaceLister for one namespace. +type horizontalPodAutoscalerScopedLister struct { + kcplisters.ResourceIndexer[*autoscalingv1.HorizontalPodAutoscaler] +} + +// HorizontalPodAutoscalers returns an object that can list and get HorizontalPodAutoscalers in one namespace. +func (l *horizontalPodAutoscalerScopedLister) HorizontalPodAutoscalers(namespace string) listersautoscalingv1.HorizontalPodAutoscalerLister { + return &horizontalPodAutoscalerLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*autoscalingv1.HorizontalPodAutoscaler), nil } diff --git a/listers/autoscaling/v2/expansion_generated.go b/listers/autoscaling/v2/expansion_generated.go new file mode 100644 index 000000000..5dc07a5a6 --- /dev/null +++ b/listers/autoscaling/v2/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v2 diff --git a/listers/autoscaling/v2/horizontalpodautoscaler.go b/listers/autoscaling/v2/horizontalpodautoscaler.go index 169dee953..98934646b 100644 --- a/listers/autoscaling/v2/horizontalpodautoscaler.go +++ b/listers/autoscaling/v2/horizontalpodautoscaler.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v2 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" autoscalingv2 "k8s.io/api/autoscaling/v2" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - autoscalingv2listers "k8s.io/client-go/listers/autoscaling/v2" + listersautoscalingv2 "k8s.io/client-go/listers/autoscaling/v2" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// HorizontalPodAutoscalerClusterLister can list HorizontalPodAutoscalers across all workspaces, or scope down to a HorizontalPodAutoscalerLister for one workspace. +// HorizontalPodAutoscalerClusterLister helps list HorizontalPodAutoscalers across all workspaces, +// or scope down to a HorizontalPodAutoscalerLister for one workspace. // All objects returned here must be treated as read-only. type HorizontalPodAutoscalerClusterLister interface { // List lists all HorizontalPodAutoscalers in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*autoscalingv2.HorizontalPodAutoscaler, err error) // Cluster returns a lister that can list and get HorizontalPodAutoscalers in one workspace. - Cluster(clusterName logicalcluster.Name) autoscalingv2listers.HorizontalPodAutoscalerLister + Cluster(clusterName logicalcluster.Name) listersautoscalingv2.HorizontalPodAutoscalerLister HorizontalPodAutoscalerClusterListerExpansion } +// horizontalPodAutoscalerClusterLister implements the HorizontalPodAutoscalerClusterLister interface. type horizontalPodAutoscalerClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*autoscalingv2.HorizontalPodAutoscaler] } +var _ HorizontalPodAutoscalerClusterLister = new(horizontalPodAutoscalerClusterLister) + // NewHorizontalPodAutoscalerClusterLister returns a new HorizontalPodAutoscalerClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewHorizontalPodAutoscalerClusterLister(indexer cache.Indexer) *horizontalPodAutoscalerClusterLister { - return &horizontalPodAutoscalerClusterLister{indexer: indexer} -} - -// List lists all HorizontalPodAutoscalers in the indexer across all workspaces. -func (s *horizontalPodAutoscalerClusterLister) List(selector labels.Selector) (ret []*autoscalingv2.HorizontalPodAutoscaler, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*autoscalingv2.HorizontalPodAutoscaler)) - }) - return ret, err +func NewHorizontalPodAutoscalerClusterLister(indexer cache.Indexer) HorizontalPodAutoscalerClusterLister { + return &horizontalPodAutoscalerClusterLister{ + kcplisters.NewCluster[*autoscalingv2.HorizontalPodAutoscaler](indexer, autoscalingv2.Resource("horizontalpodautoscaler")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get HorizontalPodAutoscalers. -func (s *horizontalPodAutoscalerClusterLister) Cluster(clusterName logicalcluster.Name) autoscalingv2listers.HorizontalPodAutoscalerLister { - return &horizontalPodAutoscalerLister{indexer: s.indexer, clusterName: clusterName} +func (l *horizontalPodAutoscalerClusterLister) Cluster(clusterName logicalcluster.Name) listersautoscalingv2.HorizontalPodAutoscalerLister { + return &horizontalPodAutoscalerLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// horizontalPodAutoscalerLister implements the autoscalingv2listers.HorizontalPodAutoscalerLister interface. +// horizontalPodAutoscalerLister can list all HorizontalPodAutoscalers inside a workspace +// or scope down to a listersautoscalingv2.HorizontalPodAutoscalerNamespaceLister for one namespace. type horizontalPodAutoscalerLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*autoscalingv2.HorizontalPodAutoscaler] } -// List lists all HorizontalPodAutoscalers in the indexer for a workspace. -func (s *horizontalPodAutoscalerLister) List(selector labels.Selector) (ret []*autoscalingv2.HorizontalPodAutoscaler, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*autoscalingv2.HorizontalPodAutoscaler)) - }) - return ret, err -} +var _ listersautoscalingv2.HorizontalPodAutoscalerLister = new(horizontalPodAutoscalerLister) // HorizontalPodAutoscalers returns an object that can list and get HorizontalPodAutoscalers in one namespace. -func (s *horizontalPodAutoscalerLister) HorizontalPodAutoscalers(namespace string) autoscalingv2listers.HorizontalPodAutoscalerNamespaceLister { - return &horizontalPodAutoscalerNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *horizontalPodAutoscalerLister) HorizontalPodAutoscalers(namespace string) listersautoscalingv2.HorizontalPodAutoscalerNamespaceLister { + return &horizontalPodAutoscalerNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// horizontalPodAutoscalerNamespaceLister implements the autoscalingv2listers.HorizontalPodAutoscalerNamespaceLister interface. +// horizontalPodAutoscalerNamespaceLister implements the listersautoscalingv2.HorizontalPodAutoscalerNamespaceLister +// interface. type horizontalPodAutoscalerNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*autoscalingv2.HorizontalPodAutoscaler] } -// List lists all HorizontalPodAutoscalers in the indexer for a given workspace and namespace. -func (s *horizontalPodAutoscalerNamespaceLister) List(selector labels.Selector) (ret []*autoscalingv2.HorizontalPodAutoscaler, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*autoscalingv2.HorizontalPodAutoscaler)) - }) - return ret, err -} +var _ listersautoscalingv2.HorizontalPodAutoscalerNamespaceLister = new(horizontalPodAutoscalerNamespaceLister) -// Get retrieves the HorizontalPodAutoscaler from the indexer for a given workspace, namespace and name. -func (s *horizontalPodAutoscalerNamespaceLister) Get(name string) (*autoscalingv2.HorizontalPodAutoscaler, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewHorizontalPodAutoscalerLister returns a new HorizontalPodAutoscalerLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewHorizontalPodAutoscalerLister(indexer cache.Indexer) listersautoscalingv2.HorizontalPodAutoscalerLister { + return &horizontalPodAutoscalerLister{ + kcplisters.New[*autoscalingv2.HorizontalPodAutoscaler](indexer, autoscalingv2.Resource("horizontalpodautoscaler")), } - if !exists { - return nil, errors.NewNotFound(autoscalingv2.Resource("horizontalpodautoscalers"), name) +} + +// horizontalPodAutoscalerScopedLister can list all HorizontalPodAutoscalers inside a workspace +// or scope down to a listersautoscalingv2.HorizontalPodAutoscalerNamespaceLister for one namespace. +type horizontalPodAutoscalerScopedLister struct { + kcplisters.ResourceIndexer[*autoscalingv2.HorizontalPodAutoscaler] +} + +// HorizontalPodAutoscalers returns an object that can list and get HorizontalPodAutoscalers in one namespace. +func (l *horizontalPodAutoscalerScopedLister) HorizontalPodAutoscalers(namespace string) listersautoscalingv2.HorizontalPodAutoscalerLister { + return &horizontalPodAutoscalerLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*autoscalingv2.HorizontalPodAutoscaler), nil } diff --git a/listers/autoscaling/v2beta1/expansion_generated.go b/listers/autoscaling/v2beta1/expansion_generated.go new file mode 100644 index 000000000..fb1dcf717 --- /dev/null +++ b/listers/autoscaling/v2beta1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v2beta1 diff --git a/listers/autoscaling/v2beta1/horizontalpodautoscaler.go b/listers/autoscaling/v2beta1/horizontalpodautoscaler.go index 8b778ec01..c9226ac01 100644 --- a/listers/autoscaling/v2beta1/horizontalpodautoscaler.go +++ b/listers/autoscaling/v2beta1/horizontalpodautoscaler.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v2beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" autoscalingv2beta1 "k8s.io/api/autoscaling/v2beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - autoscalingv2beta1listers "k8s.io/client-go/listers/autoscaling/v2beta1" + listersautoscalingv2beta1 "k8s.io/client-go/listers/autoscaling/v2beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// HorizontalPodAutoscalerClusterLister can list HorizontalPodAutoscalers across all workspaces, or scope down to a HorizontalPodAutoscalerLister for one workspace. +// HorizontalPodAutoscalerClusterLister helps list HorizontalPodAutoscalers across all workspaces, +// or scope down to a HorizontalPodAutoscalerLister for one workspace. // All objects returned here must be treated as read-only. type HorizontalPodAutoscalerClusterLister interface { // List lists all HorizontalPodAutoscalers in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*autoscalingv2beta1.HorizontalPodAutoscaler, err error) // Cluster returns a lister that can list and get HorizontalPodAutoscalers in one workspace. - Cluster(clusterName logicalcluster.Name) autoscalingv2beta1listers.HorizontalPodAutoscalerLister + Cluster(clusterName logicalcluster.Name) listersautoscalingv2beta1.HorizontalPodAutoscalerLister HorizontalPodAutoscalerClusterListerExpansion } +// horizontalPodAutoscalerClusterLister implements the HorizontalPodAutoscalerClusterLister interface. type horizontalPodAutoscalerClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*autoscalingv2beta1.HorizontalPodAutoscaler] } +var _ HorizontalPodAutoscalerClusterLister = new(horizontalPodAutoscalerClusterLister) + // NewHorizontalPodAutoscalerClusterLister returns a new HorizontalPodAutoscalerClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewHorizontalPodAutoscalerClusterLister(indexer cache.Indexer) *horizontalPodAutoscalerClusterLister { - return &horizontalPodAutoscalerClusterLister{indexer: indexer} -} - -// List lists all HorizontalPodAutoscalers in the indexer across all workspaces. -func (s *horizontalPodAutoscalerClusterLister) List(selector labels.Selector) (ret []*autoscalingv2beta1.HorizontalPodAutoscaler, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*autoscalingv2beta1.HorizontalPodAutoscaler)) - }) - return ret, err +func NewHorizontalPodAutoscalerClusterLister(indexer cache.Indexer) HorizontalPodAutoscalerClusterLister { + return &horizontalPodAutoscalerClusterLister{ + kcplisters.NewCluster[*autoscalingv2beta1.HorizontalPodAutoscaler](indexer, autoscalingv2beta1.Resource("horizontalpodautoscaler")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get HorizontalPodAutoscalers. -func (s *horizontalPodAutoscalerClusterLister) Cluster(clusterName logicalcluster.Name) autoscalingv2beta1listers.HorizontalPodAutoscalerLister { - return &horizontalPodAutoscalerLister{indexer: s.indexer, clusterName: clusterName} +func (l *horizontalPodAutoscalerClusterLister) Cluster(clusterName logicalcluster.Name) listersautoscalingv2beta1.HorizontalPodAutoscalerLister { + return &horizontalPodAutoscalerLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// horizontalPodAutoscalerLister implements the autoscalingv2beta1listers.HorizontalPodAutoscalerLister interface. +// horizontalPodAutoscalerLister can list all HorizontalPodAutoscalers inside a workspace +// or scope down to a listersautoscalingv2beta1.HorizontalPodAutoscalerNamespaceLister for one namespace. type horizontalPodAutoscalerLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*autoscalingv2beta1.HorizontalPodAutoscaler] } -// List lists all HorizontalPodAutoscalers in the indexer for a workspace. -func (s *horizontalPodAutoscalerLister) List(selector labels.Selector) (ret []*autoscalingv2beta1.HorizontalPodAutoscaler, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*autoscalingv2beta1.HorizontalPodAutoscaler)) - }) - return ret, err -} +var _ listersautoscalingv2beta1.HorizontalPodAutoscalerLister = new(horizontalPodAutoscalerLister) // HorizontalPodAutoscalers returns an object that can list and get HorizontalPodAutoscalers in one namespace. -func (s *horizontalPodAutoscalerLister) HorizontalPodAutoscalers(namespace string) autoscalingv2beta1listers.HorizontalPodAutoscalerNamespaceLister { - return &horizontalPodAutoscalerNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *horizontalPodAutoscalerLister) HorizontalPodAutoscalers(namespace string) listersautoscalingv2beta1.HorizontalPodAutoscalerNamespaceLister { + return &horizontalPodAutoscalerNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// horizontalPodAutoscalerNamespaceLister implements the autoscalingv2beta1listers.HorizontalPodAutoscalerNamespaceLister interface. +// horizontalPodAutoscalerNamespaceLister implements the listersautoscalingv2beta1.HorizontalPodAutoscalerNamespaceLister +// interface. type horizontalPodAutoscalerNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*autoscalingv2beta1.HorizontalPodAutoscaler] } -// List lists all HorizontalPodAutoscalers in the indexer for a given workspace and namespace. -func (s *horizontalPodAutoscalerNamespaceLister) List(selector labels.Selector) (ret []*autoscalingv2beta1.HorizontalPodAutoscaler, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*autoscalingv2beta1.HorizontalPodAutoscaler)) - }) - return ret, err -} +var _ listersautoscalingv2beta1.HorizontalPodAutoscalerNamespaceLister = new(horizontalPodAutoscalerNamespaceLister) -// Get retrieves the HorizontalPodAutoscaler from the indexer for a given workspace, namespace and name. -func (s *horizontalPodAutoscalerNamespaceLister) Get(name string) (*autoscalingv2beta1.HorizontalPodAutoscaler, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewHorizontalPodAutoscalerLister returns a new HorizontalPodAutoscalerLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewHorizontalPodAutoscalerLister(indexer cache.Indexer) listersautoscalingv2beta1.HorizontalPodAutoscalerLister { + return &horizontalPodAutoscalerLister{ + kcplisters.New[*autoscalingv2beta1.HorizontalPodAutoscaler](indexer, autoscalingv2beta1.Resource("horizontalpodautoscaler")), } - if !exists { - return nil, errors.NewNotFound(autoscalingv2beta1.Resource("horizontalpodautoscalers"), name) +} + +// horizontalPodAutoscalerScopedLister can list all HorizontalPodAutoscalers inside a workspace +// or scope down to a listersautoscalingv2beta1.HorizontalPodAutoscalerNamespaceLister for one namespace. +type horizontalPodAutoscalerScopedLister struct { + kcplisters.ResourceIndexer[*autoscalingv2beta1.HorizontalPodAutoscaler] +} + +// HorizontalPodAutoscalers returns an object that can list and get HorizontalPodAutoscalers in one namespace. +func (l *horizontalPodAutoscalerScopedLister) HorizontalPodAutoscalers(namespace string) listersautoscalingv2beta1.HorizontalPodAutoscalerLister { + return &horizontalPodAutoscalerLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*autoscalingv2beta1.HorizontalPodAutoscaler), nil } diff --git a/listers/autoscaling/v2beta2/expansion_generated.go b/listers/autoscaling/v2beta2/expansion_generated.go new file mode 100644 index 000000000..2b868fbf6 --- /dev/null +++ b/listers/autoscaling/v2beta2/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v2beta2 diff --git a/listers/autoscaling/v2beta2/horizontalpodautoscaler.go b/listers/autoscaling/v2beta2/horizontalpodautoscaler.go index 01452b690..bb739cf51 100644 --- a/listers/autoscaling/v2beta2/horizontalpodautoscaler.go +++ b/listers/autoscaling/v2beta2/horizontalpodautoscaler.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v2beta2 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" autoscalingv2beta2 "k8s.io/api/autoscaling/v2beta2" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - autoscalingv2beta2listers "k8s.io/client-go/listers/autoscaling/v2beta2" + listersautoscalingv2beta2 "k8s.io/client-go/listers/autoscaling/v2beta2" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// HorizontalPodAutoscalerClusterLister can list HorizontalPodAutoscalers across all workspaces, or scope down to a HorizontalPodAutoscalerLister for one workspace. +// HorizontalPodAutoscalerClusterLister helps list HorizontalPodAutoscalers across all workspaces, +// or scope down to a HorizontalPodAutoscalerLister for one workspace. // All objects returned here must be treated as read-only. type HorizontalPodAutoscalerClusterLister interface { // List lists all HorizontalPodAutoscalers in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*autoscalingv2beta2.HorizontalPodAutoscaler, err error) // Cluster returns a lister that can list and get HorizontalPodAutoscalers in one workspace. - Cluster(clusterName logicalcluster.Name) autoscalingv2beta2listers.HorizontalPodAutoscalerLister + Cluster(clusterName logicalcluster.Name) listersautoscalingv2beta2.HorizontalPodAutoscalerLister HorizontalPodAutoscalerClusterListerExpansion } +// horizontalPodAutoscalerClusterLister implements the HorizontalPodAutoscalerClusterLister interface. type horizontalPodAutoscalerClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*autoscalingv2beta2.HorizontalPodAutoscaler] } +var _ HorizontalPodAutoscalerClusterLister = new(horizontalPodAutoscalerClusterLister) + // NewHorizontalPodAutoscalerClusterLister returns a new HorizontalPodAutoscalerClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewHorizontalPodAutoscalerClusterLister(indexer cache.Indexer) *horizontalPodAutoscalerClusterLister { - return &horizontalPodAutoscalerClusterLister{indexer: indexer} -} - -// List lists all HorizontalPodAutoscalers in the indexer across all workspaces. -func (s *horizontalPodAutoscalerClusterLister) List(selector labels.Selector) (ret []*autoscalingv2beta2.HorizontalPodAutoscaler, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*autoscalingv2beta2.HorizontalPodAutoscaler)) - }) - return ret, err +func NewHorizontalPodAutoscalerClusterLister(indexer cache.Indexer) HorizontalPodAutoscalerClusterLister { + return &horizontalPodAutoscalerClusterLister{ + kcplisters.NewCluster[*autoscalingv2beta2.HorizontalPodAutoscaler](indexer, autoscalingv2beta2.Resource("horizontalpodautoscaler")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get HorizontalPodAutoscalers. -func (s *horizontalPodAutoscalerClusterLister) Cluster(clusterName logicalcluster.Name) autoscalingv2beta2listers.HorizontalPodAutoscalerLister { - return &horizontalPodAutoscalerLister{indexer: s.indexer, clusterName: clusterName} +func (l *horizontalPodAutoscalerClusterLister) Cluster(clusterName logicalcluster.Name) listersautoscalingv2beta2.HorizontalPodAutoscalerLister { + return &horizontalPodAutoscalerLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// horizontalPodAutoscalerLister implements the autoscalingv2beta2listers.HorizontalPodAutoscalerLister interface. +// horizontalPodAutoscalerLister can list all HorizontalPodAutoscalers inside a workspace +// or scope down to a listersautoscalingv2beta2.HorizontalPodAutoscalerNamespaceLister for one namespace. type horizontalPodAutoscalerLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*autoscalingv2beta2.HorizontalPodAutoscaler] } -// List lists all HorizontalPodAutoscalers in the indexer for a workspace. -func (s *horizontalPodAutoscalerLister) List(selector labels.Selector) (ret []*autoscalingv2beta2.HorizontalPodAutoscaler, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*autoscalingv2beta2.HorizontalPodAutoscaler)) - }) - return ret, err -} +var _ listersautoscalingv2beta2.HorizontalPodAutoscalerLister = new(horizontalPodAutoscalerLister) // HorizontalPodAutoscalers returns an object that can list and get HorizontalPodAutoscalers in one namespace. -func (s *horizontalPodAutoscalerLister) HorizontalPodAutoscalers(namespace string) autoscalingv2beta2listers.HorizontalPodAutoscalerNamespaceLister { - return &horizontalPodAutoscalerNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *horizontalPodAutoscalerLister) HorizontalPodAutoscalers(namespace string) listersautoscalingv2beta2.HorizontalPodAutoscalerNamespaceLister { + return &horizontalPodAutoscalerNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// horizontalPodAutoscalerNamespaceLister implements the autoscalingv2beta2listers.HorizontalPodAutoscalerNamespaceLister interface. +// horizontalPodAutoscalerNamespaceLister implements the listersautoscalingv2beta2.HorizontalPodAutoscalerNamespaceLister +// interface. type horizontalPodAutoscalerNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*autoscalingv2beta2.HorizontalPodAutoscaler] } -// List lists all HorizontalPodAutoscalers in the indexer for a given workspace and namespace. -func (s *horizontalPodAutoscalerNamespaceLister) List(selector labels.Selector) (ret []*autoscalingv2beta2.HorizontalPodAutoscaler, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*autoscalingv2beta2.HorizontalPodAutoscaler)) - }) - return ret, err -} +var _ listersautoscalingv2beta2.HorizontalPodAutoscalerNamespaceLister = new(horizontalPodAutoscalerNamespaceLister) -// Get retrieves the HorizontalPodAutoscaler from the indexer for a given workspace, namespace and name. -func (s *horizontalPodAutoscalerNamespaceLister) Get(name string) (*autoscalingv2beta2.HorizontalPodAutoscaler, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewHorizontalPodAutoscalerLister returns a new HorizontalPodAutoscalerLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewHorizontalPodAutoscalerLister(indexer cache.Indexer) listersautoscalingv2beta2.HorizontalPodAutoscalerLister { + return &horizontalPodAutoscalerLister{ + kcplisters.New[*autoscalingv2beta2.HorizontalPodAutoscaler](indexer, autoscalingv2beta2.Resource("horizontalpodautoscaler")), } - if !exists { - return nil, errors.NewNotFound(autoscalingv2beta2.Resource("horizontalpodautoscalers"), name) +} + +// horizontalPodAutoscalerScopedLister can list all HorizontalPodAutoscalers inside a workspace +// or scope down to a listersautoscalingv2beta2.HorizontalPodAutoscalerNamespaceLister for one namespace. +type horizontalPodAutoscalerScopedLister struct { + kcplisters.ResourceIndexer[*autoscalingv2beta2.HorizontalPodAutoscaler] +} + +// HorizontalPodAutoscalers returns an object that can list and get HorizontalPodAutoscalers in one namespace. +func (l *horizontalPodAutoscalerScopedLister) HorizontalPodAutoscalers(namespace string) listersautoscalingv2beta2.HorizontalPodAutoscalerLister { + return &horizontalPodAutoscalerLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*autoscalingv2beta2.HorizontalPodAutoscaler), nil } diff --git a/listers/batch/v1/cronjob.go b/listers/batch/v1/cronjob.go index f4ef24e54..5f3da2215 100644 --- a/listers/batch/v1/cronjob.go +++ b/listers/batch/v1/cronjob.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" batchv1 "k8s.io/api/batch/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - batchv1listers "k8s.io/client-go/listers/batch/v1" + listersbatchv1 "k8s.io/client-go/listers/batch/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// CronJobClusterLister can list CronJobs across all workspaces, or scope down to a CronJobLister for one workspace. +// CronJobClusterLister helps list CronJobs across all workspaces, +// or scope down to a CronJobLister for one workspace. // All objects returned here must be treated as read-only. type CronJobClusterLister interface { // List lists all CronJobs in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*batchv1.CronJob, err error) // Cluster returns a lister that can list and get CronJobs in one workspace. - Cluster(clusterName logicalcluster.Name) batchv1listers.CronJobLister + Cluster(clusterName logicalcluster.Name) listersbatchv1.CronJobLister CronJobClusterListerExpansion } +// cronJobClusterLister implements the CronJobClusterLister interface. type cronJobClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*batchv1.CronJob] } +var _ CronJobClusterLister = new(cronJobClusterLister) + // NewCronJobClusterLister returns a new CronJobClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewCronJobClusterLister(indexer cache.Indexer) *cronJobClusterLister { - return &cronJobClusterLister{indexer: indexer} -} - -// List lists all CronJobs in the indexer across all workspaces. -func (s *cronJobClusterLister) List(selector labels.Selector) (ret []*batchv1.CronJob, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*batchv1.CronJob)) - }) - return ret, err +func NewCronJobClusterLister(indexer cache.Indexer) CronJobClusterLister { + return &cronJobClusterLister{ + kcplisters.NewCluster[*batchv1.CronJob](indexer, batchv1.Resource("cronjob")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get CronJobs. -func (s *cronJobClusterLister) Cluster(clusterName logicalcluster.Name) batchv1listers.CronJobLister { - return &cronJobLister{indexer: s.indexer, clusterName: clusterName} +func (l *cronJobClusterLister) Cluster(clusterName logicalcluster.Name) listersbatchv1.CronJobLister { + return &cronJobLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// cronJobLister implements the batchv1listers.CronJobLister interface. +// cronJobLister can list all CronJobs inside a workspace +// or scope down to a listersbatchv1.CronJobNamespaceLister for one namespace. type cronJobLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*batchv1.CronJob] } -// List lists all CronJobs in the indexer for a workspace. -func (s *cronJobLister) List(selector labels.Selector) (ret []*batchv1.CronJob, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*batchv1.CronJob)) - }) - return ret, err -} +var _ listersbatchv1.CronJobLister = new(cronJobLister) // CronJobs returns an object that can list and get CronJobs in one namespace. -func (s *cronJobLister) CronJobs(namespace string) batchv1listers.CronJobNamespaceLister { - return &cronJobNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *cronJobLister) CronJobs(namespace string) listersbatchv1.CronJobNamespaceLister { + return &cronJobNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// cronJobNamespaceLister implements the batchv1listers.CronJobNamespaceLister interface. +// cronJobNamespaceLister implements the listersbatchv1.CronJobNamespaceLister +// interface. type cronJobNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*batchv1.CronJob] } -// List lists all CronJobs in the indexer for a given workspace and namespace. -func (s *cronJobNamespaceLister) List(selector labels.Selector) (ret []*batchv1.CronJob, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*batchv1.CronJob)) - }) - return ret, err -} +var _ listersbatchv1.CronJobNamespaceLister = new(cronJobNamespaceLister) -// Get retrieves the CronJob from the indexer for a given workspace, namespace and name. -func (s *cronJobNamespaceLister) Get(name string) (*batchv1.CronJob, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewCronJobLister returns a new CronJobLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewCronJobLister(indexer cache.Indexer) listersbatchv1.CronJobLister { + return &cronJobLister{ + kcplisters.New[*batchv1.CronJob](indexer, batchv1.Resource("cronjob")), } - if !exists { - return nil, errors.NewNotFound(batchv1.Resource("cronjobs"), name) +} + +// cronJobScopedLister can list all CronJobs inside a workspace +// or scope down to a listersbatchv1.CronJobNamespaceLister for one namespace. +type cronJobScopedLister struct { + kcplisters.ResourceIndexer[*batchv1.CronJob] +} + +// CronJobs returns an object that can list and get CronJobs in one namespace. +func (l *cronJobScopedLister) CronJobs(namespace string) listersbatchv1.CronJobLister { + return &cronJobLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*batchv1.CronJob), nil } diff --git a/listers/batch/v1/expansion_generated.go b/listers/batch/v1/expansion_generated.go new file mode 100644 index 000000000..b6a0c6377 --- /dev/null +++ b/listers/batch/v1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1 diff --git a/listers/batch/v1/job.go b/listers/batch/v1/job.go index 6af484261..1c3e7b852 100644 --- a/listers/batch/v1/job.go +++ b/listers/batch/v1/job.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" batchv1 "k8s.io/api/batch/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - batchv1listers "k8s.io/client-go/listers/batch/v1" + listersbatchv1 "k8s.io/client-go/listers/batch/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// JobClusterLister can list Jobs across all workspaces, or scope down to a JobLister for one workspace. +// JobClusterLister helps list Jobs across all workspaces, +// or scope down to a JobLister for one workspace. // All objects returned here must be treated as read-only. type JobClusterLister interface { // List lists all Jobs in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*batchv1.Job, err error) // Cluster returns a lister that can list and get Jobs in one workspace. - Cluster(clusterName logicalcluster.Name) batchv1listers.JobLister + Cluster(clusterName logicalcluster.Name) listersbatchv1.JobLister JobClusterListerExpansion } +// jobClusterLister implements the JobClusterLister interface. type jobClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*batchv1.Job] } +var _ JobClusterLister = new(jobClusterLister) + // NewJobClusterLister returns a new JobClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewJobClusterLister(indexer cache.Indexer) *jobClusterLister { - return &jobClusterLister{indexer: indexer} -} - -// List lists all Jobs in the indexer across all workspaces. -func (s *jobClusterLister) List(selector labels.Selector) (ret []*batchv1.Job, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*batchv1.Job)) - }) - return ret, err +func NewJobClusterLister(indexer cache.Indexer) JobClusterLister { + return &jobClusterLister{ + kcplisters.NewCluster[*batchv1.Job](indexer, batchv1.Resource("job")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get Jobs. -func (s *jobClusterLister) Cluster(clusterName logicalcluster.Name) batchv1listers.JobLister { - return &jobLister{indexer: s.indexer, clusterName: clusterName} +func (l *jobClusterLister) Cluster(clusterName logicalcluster.Name) listersbatchv1.JobLister { + return &jobLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// jobLister implements the batchv1listers.JobLister interface. +// jobLister can list all Jobs inside a workspace +// or scope down to a listersbatchv1.JobNamespaceLister for one namespace. type jobLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*batchv1.Job] } -// List lists all Jobs in the indexer for a workspace. -func (s *jobLister) List(selector labels.Selector) (ret []*batchv1.Job, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*batchv1.Job)) - }) - return ret, err -} +var _ listersbatchv1.JobLister = new(jobLister) // Jobs returns an object that can list and get Jobs in one namespace. -func (s *jobLister) Jobs(namespace string) batchv1listers.JobNamespaceLister { - return &jobNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *jobLister) Jobs(namespace string) listersbatchv1.JobNamespaceLister { + return &jobNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// jobNamespaceLister implements the batchv1listers.JobNamespaceLister interface. +// jobNamespaceLister implements the listersbatchv1.JobNamespaceLister +// interface. type jobNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*batchv1.Job] } -// List lists all Jobs in the indexer for a given workspace and namespace. -func (s *jobNamespaceLister) List(selector labels.Selector) (ret []*batchv1.Job, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*batchv1.Job)) - }) - return ret, err -} +var _ listersbatchv1.JobNamespaceLister = new(jobNamespaceLister) -// Get retrieves the Job from the indexer for a given workspace, namespace and name. -func (s *jobNamespaceLister) Get(name string) (*batchv1.Job, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewJobLister returns a new JobLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewJobLister(indexer cache.Indexer) listersbatchv1.JobLister { + return &jobLister{ + kcplisters.New[*batchv1.Job](indexer, batchv1.Resource("job")), } - if !exists { - return nil, errors.NewNotFound(batchv1.Resource("jobs"), name) +} + +// jobScopedLister can list all Jobs inside a workspace +// or scope down to a listersbatchv1.JobNamespaceLister for one namespace. +type jobScopedLister struct { + kcplisters.ResourceIndexer[*batchv1.Job] +} + +// Jobs returns an object that can list and get Jobs in one namespace. +func (l *jobScopedLister) Jobs(namespace string) listersbatchv1.JobLister { + return &jobLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*batchv1.Job), nil } diff --git a/listers/batch/v1/job_expansion.go b/listers/batch/v1/job_expansion.go index 5258f4353..2003595cd 100644 --- a/listers/batch/v1/job_expansion.go +++ b/listers/batch/v1/job_expansion.go @@ -20,7 +20,7 @@ import ( "fmt" batch "k8s.io/api/batch/v1" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" ) diff --git a/listers/batch/v1beta1/cronjob.go b/listers/batch/v1beta1/cronjob.go index a9005909b..2a221a15f 100644 --- a/listers/batch/v1beta1/cronjob.go +++ b/listers/batch/v1beta1/cronjob.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" batchv1beta1 "k8s.io/api/batch/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - batchv1beta1listers "k8s.io/client-go/listers/batch/v1beta1" + listersbatchv1beta1 "k8s.io/client-go/listers/batch/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// CronJobClusterLister can list CronJobs across all workspaces, or scope down to a CronJobLister for one workspace. +// CronJobClusterLister helps list CronJobs across all workspaces, +// or scope down to a CronJobLister for one workspace. // All objects returned here must be treated as read-only. type CronJobClusterLister interface { // List lists all CronJobs in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*batchv1beta1.CronJob, err error) // Cluster returns a lister that can list and get CronJobs in one workspace. - Cluster(clusterName logicalcluster.Name) batchv1beta1listers.CronJobLister + Cluster(clusterName logicalcluster.Name) listersbatchv1beta1.CronJobLister CronJobClusterListerExpansion } +// cronJobClusterLister implements the CronJobClusterLister interface. type cronJobClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*batchv1beta1.CronJob] } +var _ CronJobClusterLister = new(cronJobClusterLister) + // NewCronJobClusterLister returns a new CronJobClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewCronJobClusterLister(indexer cache.Indexer) *cronJobClusterLister { - return &cronJobClusterLister{indexer: indexer} -} - -// List lists all CronJobs in the indexer across all workspaces. -func (s *cronJobClusterLister) List(selector labels.Selector) (ret []*batchv1beta1.CronJob, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*batchv1beta1.CronJob)) - }) - return ret, err +func NewCronJobClusterLister(indexer cache.Indexer) CronJobClusterLister { + return &cronJobClusterLister{ + kcplisters.NewCluster[*batchv1beta1.CronJob](indexer, batchv1beta1.Resource("cronjob")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get CronJobs. -func (s *cronJobClusterLister) Cluster(clusterName logicalcluster.Name) batchv1beta1listers.CronJobLister { - return &cronJobLister{indexer: s.indexer, clusterName: clusterName} +func (l *cronJobClusterLister) Cluster(clusterName logicalcluster.Name) listersbatchv1beta1.CronJobLister { + return &cronJobLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// cronJobLister implements the batchv1beta1listers.CronJobLister interface. +// cronJobLister can list all CronJobs inside a workspace +// or scope down to a listersbatchv1beta1.CronJobNamespaceLister for one namespace. type cronJobLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*batchv1beta1.CronJob] } -// List lists all CronJobs in the indexer for a workspace. -func (s *cronJobLister) List(selector labels.Selector) (ret []*batchv1beta1.CronJob, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*batchv1beta1.CronJob)) - }) - return ret, err -} +var _ listersbatchv1beta1.CronJobLister = new(cronJobLister) // CronJobs returns an object that can list and get CronJobs in one namespace. -func (s *cronJobLister) CronJobs(namespace string) batchv1beta1listers.CronJobNamespaceLister { - return &cronJobNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *cronJobLister) CronJobs(namespace string) listersbatchv1beta1.CronJobNamespaceLister { + return &cronJobNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// cronJobNamespaceLister implements the batchv1beta1listers.CronJobNamespaceLister interface. +// cronJobNamespaceLister implements the listersbatchv1beta1.CronJobNamespaceLister +// interface. type cronJobNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*batchv1beta1.CronJob] } -// List lists all CronJobs in the indexer for a given workspace and namespace. -func (s *cronJobNamespaceLister) List(selector labels.Selector) (ret []*batchv1beta1.CronJob, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*batchv1beta1.CronJob)) - }) - return ret, err -} +var _ listersbatchv1beta1.CronJobNamespaceLister = new(cronJobNamespaceLister) -// Get retrieves the CronJob from the indexer for a given workspace, namespace and name. -func (s *cronJobNamespaceLister) Get(name string) (*batchv1beta1.CronJob, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewCronJobLister returns a new CronJobLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewCronJobLister(indexer cache.Indexer) listersbatchv1beta1.CronJobLister { + return &cronJobLister{ + kcplisters.New[*batchv1beta1.CronJob](indexer, batchv1beta1.Resource("cronjob")), } - if !exists { - return nil, errors.NewNotFound(batchv1beta1.Resource("cronjobs"), name) +} + +// cronJobScopedLister can list all CronJobs inside a workspace +// or scope down to a listersbatchv1beta1.CronJobNamespaceLister for one namespace. +type cronJobScopedLister struct { + kcplisters.ResourceIndexer[*batchv1beta1.CronJob] +} + +// CronJobs returns an object that can list and get CronJobs in one namespace. +func (l *cronJobScopedLister) CronJobs(namespace string) listersbatchv1beta1.CronJobLister { + return &cronJobLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*batchv1beta1.CronJob), nil } diff --git a/listers/batch/v1beta1/expansion_generated.go b/listers/batch/v1beta1/expansion_generated.go new file mode 100644 index 000000000..23cac805b --- /dev/null +++ b/listers/batch/v1beta1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1beta1 diff --git a/listers/certificates/v1/certificatesigningrequest.go b/listers/certificates/v1/certificatesigningrequest.go index 7ebd87e9d..fa83faf0a 100644 --- a/listers/certificates/v1/certificatesigningrequest.go +++ b/listers/certificates/v1/certificatesigningrequest.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" certificatesv1 "k8s.io/api/certificates/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - certificatesv1listers "k8s.io/client-go/listers/certificates/v1" + listerscertificatesv1 "k8s.io/client-go/listers/certificates/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// CertificateSigningRequestClusterLister can list CertificateSigningRequests across all workspaces, or scope down to a CertificateSigningRequestLister for one workspace. +// CertificateSigningRequestClusterLister helps list CertificateSigningRequests across all workspaces, +// or scope down to a CertificateSigningRequestLister for one workspace. // All objects returned here must be treated as read-only. type CertificateSigningRequestClusterLister interface { // List lists all CertificateSigningRequests in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*certificatesv1.CertificateSigningRequest, err error) // Cluster returns a lister that can list and get CertificateSigningRequests in one workspace. - Cluster(clusterName logicalcluster.Name) certificatesv1listers.CertificateSigningRequestLister + Cluster(clusterName logicalcluster.Name) listerscertificatesv1.CertificateSigningRequestLister CertificateSigningRequestClusterListerExpansion } +// certificateSigningRequestClusterLister implements the CertificateSigningRequestClusterLister interface. type certificateSigningRequestClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*certificatesv1.CertificateSigningRequest] } +var _ CertificateSigningRequestClusterLister = new(certificateSigningRequestClusterLister) + // NewCertificateSigningRequestClusterLister returns a new CertificateSigningRequestClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewCertificateSigningRequestClusterLister(indexer cache.Indexer) *certificateSigningRequestClusterLister { - return &certificateSigningRequestClusterLister{indexer: indexer} -} - -// List lists all CertificateSigningRequests in the indexer across all workspaces. -func (s *certificateSigningRequestClusterLister) List(selector labels.Selector) (ret []*certificatesv1.CertificateSigningRequest, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*certificatesv1.CertificateSigningRequest)) - }) - return ret, err +func NewCertificateSigningRequestClusterLister(indexer cache.Indexer) CertificateSigningRequestClusterLister { + return &certificateSigningRequestClusterLister{ + kcplisters.NewCluster[*certificatesv1.CertificateSigningRequest](indexer, certificatesv1.Resource("certificatesigningrequest")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get CertificateSigningRequests. -func (s *certificateSigningRequestClusterLister) Cluster(clusterName logicalcluster.Name) certificatesv1listers.CertificateSigningRequestLister { - return &certificateSigningRequestLister{indexer: s.indexer, clusterName: clusterName} +func (l *certificateSigningRequestClusterLister) Cluster(clusterName logicalcluster.Name) listerscertificatesv1.CertificateSigningRequestLister { + return &certificateSigningRequestLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// certificateSigningRequestLister implements the certificatesv1listers.CertificateSigningRequestLister interface. +// certificateSigningRequestLister can list all CertificateSigningRequests inside a workspace +// or scope down to a listerscertificatesv1.CertificateSigningRequestNamespaceLister for one namespace. type certificateSigningRequestLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*certificatesv1.CertificateSigningRequest] } -// List lists all CertificateSigningRequests in the indexer for a workspace. -func (s *certificateSigningRequestLister) List(selector labels.Selector) (ret []*certificatesv1.CertificateSigningRequest, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*certificatesv1.CertificateSigningRequest)) - }) - return ret, err -} +var _ listerscertificatesv1.CertificateSigningRequestLister = new(certificateSigningRequestLister) -// Get retrieves the CertificateSigningRequest from the indexer for a given workspace and name. -func (s *certificateSigningRequestLister) Get(name string) (*certificatesv1.CertificateSigningRequest, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(certificatesv1.Resource("certificatesigningrequests"), name) +// NewCertificateSigningRequestLister returns a new CertificateSigningRequestLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewCertificateSigningRequestLister(indexer cache.Indexer) listerscertificatesv1.CertificateSigningRequestLister { + return &certificateSigningRequestLister{ + kcplisters.New[*certificatesv1.CertificateSigningRequest](indexer, certificatesv1.Resource("certificatesigningrequest")), } - return obj.(*certificatesv1.CertificateSigningRequest), nil +} + +// certificateSigningRequestScopedLister can list all CertificateSigningRequests inside a workspace +// or scope down to a listerscertificatesv1.CertificateSigningRequestNamespaceLister. +type certificateSigningRequestScopedLister struct { + kcplisters.ResourceIndexer[*certificatesv1.CertificateSigningRequest] } diff --git a/listers/certificates/v1/expansion_generated.go b/listers/certificates/v1/expansion_generated.go new file mode 100644 index 000000000..b6a0c6377 --- /dev/null +++ b/listers/certificates/v1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1 diff --git a/listers/certificates/v1alpha1/clustertrustbundle.go b/listers/certificates/v1alpha1/clustertrustbundle.go index 2e7e54251..1ce676f11 100644 --- a/listers/certificates/v1alpha1/clustertrustbundle.go +++ b/listers/certificates/v1alpha1/clustertrustbundle.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1alpha1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" certificatesv1alpha1 "k8s.io/api/certificates/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - certificatesv1alpha1listers "k8s.io/client-go/listers/certificates/v1alpha1" + listerscertificatesv1alpha1 "k8s.io/client-go/listers/certificates/v1alpha1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ClusterTrustBundleClusterLister can list ClusterTrustBundles across all workspaces, or scope down to a ClusterTrustBundleLister for one workspace. +// ClusterTrustBundleClusterLister helps list ClusterTrustBundles across all workspaces, +// or scope down to a ClusterTrustBundleLister for one workspace. // All objects returned here must be treated as read-only. type ClusterTrustBundleClusterLister interface { // List lists all ClusterTrustBundles in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*certificatesv1alpha1.ClusterTrustBundle, err error) // Cluster returns a lister that can list and get ClusterTrustBundles in one workspace. - Cluster(clusterName logicalcluster.Name) certificatesv1alpha1listers.ClusterTrustBundleLister + Cluster(clusterName logicalcluster.Name) listerscertificatesv1alpha1.ClusterTrustBundleLister ClusterTrustBundleClusterListerExpansion } +// clusterTrustBundleClusterLister implements the ClusterTrustBundleClusterLister interface. type clusterTrustBundleClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*certificatesv1alpha1.ClusterTrustBundle] } +var _ ClusterTrustBundleClusterLister = new(clusterTrustBundleClusterLister) + // NewClusterTrustBundleClusterLister returns a new ClusterTrustBundleClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewClusterTrustBundleClusterLister(indexer cache.Indexer) *clusterTrustBundleClusterLister { - return &clusterTrustBundleClusterLister{indexer: indexer} -} - -// List lists all ClusterTrustBundles in the indexer across all workspaces. -func (s *clusterTrustBundleClusterLister) List(selector labels.Selector) (ret []*certificatesv1alpha1.ClusterTrustBundle, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*certificatesv1alpha1.ClusterTrustBundle)) - }) - return ret, err +func NewClusterTrustBundleClusterLister(indexer cache.Indexer) ClusterTrustBundleClusterLister { + return &clusterTrustBundleClusterLister{ + kcplisters.NewCluster[*certificatesv1alpha1.ClusterTrustBundle](indexer, certificatesv1alpha1.Resource("clustertrustbundle")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ClusterTrustBundles. -func (s *clusterTrustBundleClusterLister) Cluster(clusterName logicalcluster.Name) certificatesv1alpha1listers.ClusterTrustBundleLister { - return &clusterTrustBundleLister{indexer: s.indexer, clusterName: clusterName} +func (l *clusterTrustBundleClusterLister) Cluster(clusterName logicalcluster.Name) listerscertificatesv1alpha1.ClusterTrustBundleLister { + return &clusterTrustBundleLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// clusterTrustBundleLister implements the certificatesv1alpha1listers.ClusterTrustBundleLister interface. +// clusterTrustBundleLister can list all ClusterTrustBundles inside a workspace +// or scope down to a listerscertificatesv1alpha1.ClusterTrustBundleNamespaceLister for one namespace. type clusterTrustBundleLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*certificatesv1alpha1.ClusterTrustBundle] } -// List lists all ClusterTrustBundles in the indexer for a workspace. -func (s *clusterTrustBundleLister) List(selector labels.Selector) (ret []*certificatesv1alpha1.ClusterTrustBundle, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*certificatesv1alpha1.ClusterTrustBundle)) - }) - return ret, err -} +var _ listerscertificatesv1alpha1.ClusterTrustBundleLister = new(clusterTrustBundleLister) -// Get retrieves the ClusterTrustBundle from the indexer for a given workspace and name. -func (s *clusterTrustBundleLister) Get(name string) (*certificatesv1alpha1.ClusterTrustBundle, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(certificatesv1alpha1.Resource("clustertrustbundles"), name) +// NewClusterTrustBundleLister returns a new ClusterTrustBundleLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewClusterTrustBundleLister(indexer cache.Indexer) listerscertificatesv1alpha1.ClusterTrustBundleLister { + return &clusterTrustBundleLister{ + kcplisters.New[*certificatesv1alpha1.ClusterTrustBundle](indexer, certificatesv1alpha1.Resource("clustertrustbundle")), } - return obj.(*certificatesv1alpha1.ClusterTrustBundle), nil +} + +// clusterTrustBundleScopedLister can list all ClusterTrustBundles inside a workspace +// or scope down to a listerscertificatesv1alpha1.ClusterTrustBundleNamespaceLister. +type clusterTrustBundleScopedLister struct { + kcplisters.ResourceIndexer[*certificatesv1alpha1.ClusterTrustBundle] } diff --git a/listers/certificates/v1alpha1/expansion_generated.go b/listers/certificates/v1alpha1/expansion_generated.go new file mode 100644 index 000000000..3b8521c00 --- /dev/null +++ b/listers/certificates/v1alpha1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1alpha1 diff --git a/listers/certificates/v1beta1/certificatesigningrequest.go b/listers/certificates/v1beta1/certificatesigningrequest.go index f5c0519d8..a275ab5fb 100644 --- a/listers/certificates/v1beta1/certificatesigningrequest.go +++ b/listers/certificates/v1beta1/certificatesigningrequest.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" certificatesv1beta1 "k8s.io/api/certificates/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - certificatesv1beta1listers "k8s.io/client-go/listers/certificates/v1beta1" + listerscertificatesv1beta1 "k8s.io/client-go/listers/certificates/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// CertificateSigningRequestClusterLister can list CertificateSigningRequests across all workspaces, or scope down to a CertificateSigningRequestLister for one workspace. +// CertificateSigningRequestClusterLister helps list CertificateSigningRequests across all workspaces, +// or scope down to a CertificateSigningRequestLister for one workspace. // All objects returned here must be treated as read-only. type CertificateSigningRequestClusterLister interface { // List lists all CertificateSigningRequests in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*certificatesv1beta1.CertificateSigningRequest, err error) // Cluster returns a lister that can list and get CertificateSigningRequests in one workspace. - Cluster(clusterName logicalcluster.Name) certificatesv1beta1listers.CertificateSigningRequestLister + Cluster(clusterName logicalcluster.Name) listerscertificatesv1beta1.CertificateSigningRequestLister CertificateSigningRequestClusterListerExpansion } +// certificateSigningRequestClusterLister implements the CertificateSigningRequestClusterLister interface. type certificateSigningRequestClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*certificatesv1beta1.CertificateSigningRequest] } +var _ CertificateSigningRequestClusterLister = new(certificateSigningRequestClusterLister) + // NewCertificateSigningRequestClusterLister returns a new CertificateSigningRequestClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewCertificateSigningRequestClusterLister(indexer cache.Indexer) *certificateSigningRequestClusterLister { - return &certificateSigningRequestClusterLister{indexer: indexer} -} - -// List lists all CertificateSigningRequests in the indexer across all workspaces. -func (s *certificateSigningRequestClusterLister) List(selector labels.Selector) (ret []*certificatesv1beta1.CertificateSigningRequest, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*certificatesv1beta1.CertificateSigningRequest)) - }) - return ret, err +func NewCertificateSigningRequestClusterLister(indexer cache.Indexer) CertificateSigningRequestClusterLister { + return &certificateSigningRequestClusterLister{ + kcplisters.NewCluster[*certificatesv1beta1.CertificateSigningRequest](indexer, certificatesv1beta1.Resource("certificatesigningrequest")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get CertificateSigningRequests. -func (s *certificateSigningRequestClusterLister) Cluster(clusterName logicalcluster.Name) certificatesv1beta1listers.CertificateSigningRequestLister { - return &certificateSigningRequestLister{indexer: s.indexer, clusterName: clusterName} +func (l *certificateSigningRequestClusterLister) Cluster(clusterName logicalcluster.Name) listerscertificatesv1beta1.CertificateSigningRequestLister { + return &certificateSigningRequestLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// certificateSigningRequestLister implements the certificatesv1beta1listers.CertificateSigningRequestLister interface. +// certificateSigningRequestLister can list all CertificateSigningRequests inside a workspace +// or scope down to a listerscertificatesv1beta1.CertificateSigningRequestNamespaceLister for one namespace. type certificateSigningRequestLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*certificatesv1beta1.CertificateSigningRequest] } -// List lists all CertificateSigningRequests in the indexer for a workspace. -func (s *certificateSigningRequestLister) List(selector labels.Selector) (ret []*certificatesv1beta1.CertificateSigningRequest, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*certificatesv1beta1.CertificateSigningRequest)) - }) - return ret, err -} +var _ listerscertificatesv1beta1.CertificateSigningRequestLister = new(certificateSigningRequestLister) -// Get retrieves the CertificateSigningRequest from the indexer for a given workspace and name. -func (s *certificateSigningRequestLister) Get(name string) (*certificatesv1beta1.CertificateSigningRequest, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(certificatesv1beta1.Resource("certificatesigningrequests"), name) +// NewCertificateSigningRequestLister returns a new CertificateSigningRequestLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewCertificateSigningRequestLister(indexer cache.Indexer) listerscertificatesv1beta1.CertificateSigningRequestLister { + return &certificateSigningRequestLister{ + kcplisters.New[*certificatesv1beta1.CertificateSigningRequest](indexer, certificatesv1beta1.Resource("certificatesigningrequest")), } - return obj.(*certificatesv1beta1.CertificateSigningRequest), nil +} + +// certificateSigningRequestScopedLister can list all CertificateSigningRequests inside a workspace +// or scope down to a listerscertificatesv1beta1.CertificateSigningRequestNamespaceLister. +type certificateSigningRequestScopedLister struct { + kcplisters.ResourceIndexer[*certificatesv1beta1.CertificateSigningRequest] } diff --git a/listers/certificates/v1beta1/expansion_generated.go b/listers/certificates/v1beta1/expansion_generated.go new file mode 100644 index 000000000..23cac805b --- /dev/null +++ b/listers/certificates/v1beta1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1beta1 diff --git a/listers/coordination/v1/expansion_generated.go b/listers/coordination/v1/expansion_generated.go new file mode 100644 index 000000000..b6a0c6377 --- /dev/null +++ b/listers/coordination/v1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1 diff --git a/listers/coordination/v1/lease.go b/listers/coordination/v1/lease.go index 975fd701f..ec57225b1 100644 --- a/listers/coordination/v1/lease.go +++ b/listers/coordination/v1/lease.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" coordinationv1 "k8s.io/api/coordination/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - coordinationv1listers "k8s.io/client-go/listers/coordination/v1" + listerscoordinationv1 "k8s.io/client-go/listers/coordination/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// LeaseClusterLister can list Leases across all workspaces, or scope down to a LeaseLister for one workspace. +// LeaseClusterLister helps list Leases across all workspaces, +// or scope down to a LeaseLister for one workspace. // All objects returned here must be treated as read-only. type LeaseClusterLister interface { // List lists all Leases in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*coordinationv1.Lease, err error) // Cluster returns a lister that can list and get Leases in one workspace. - Cluster(clusterName logicalcluster.Name) coordinationv1listers.LeaseLister + Cluster(clusterName logicalcluster.Name) listerscoordinationv1.LeaseLister LeaseClusterListerExpansion } +// leaseClusterLister implements the LeaseClusterLister interface. type leaseClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*coordinationv1.Lease] } +var _ LeaseClusterLister = new(leaseClusterLister) + // NewLeaseClusterLister returns a new LeaseClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewLeaseClusterLister(indexer cache.Indexer) *leaseClusterLister { - return &leaseClusterLister{indexer: indexer} -} - -// List lists all Leases in the indexer across all workspaces. -func (s *leaseClusterLister) List(selector labels.Selector) (ret []*coordinationv1.Lease, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*coordinationv1.Lease)) - }) - return ret, err +func NewLeaseClusterLister(indexer cache.Indexer) LeaseClusterLister { + return &leaseClusterLister{ + kcplisters.NewCluster[*coordinationv1.Lease](indexer, coordinationv1.Resource("lease")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get Leases. -func (s *leaseClusterLister) Cluster(clusterName logicalcluster.Name) coordinationv1listers.LeaseLister { - return &leaseLister{indexer: s.indexer, clusterName: clusterName} +func (l *leaseClusterLister) Cluster(clusterName logicalcluster.Name) listerscoordinationv1.LeaseLister { + return &leaseLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// leaseLister implements the coordinationv1listers.LeaseLister interface. +// leaseLister can list all Leases inside a workspace +// or scope down to a listerscoordinationv1.LeaseNamespaceLister for one namespace. type leaseLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*coordinationv1.Lease] } -// List lists all Leases in the indexer for a workspace. -func (s *leaseLister) List(selector labels.Selector) (ret []*coordinationv1.Lease, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*coordinationv1.Lease)) - }) - return ret, err -} +var _ listerscoordinationv1.LeaseLister = new(leaseLister) // Leases returns an object that can list and get Leases in one namespace. -func (s *leaseLister) Leases(namespace string) coordinationv1listers.LeaseNamespaceLister { - return &leaseNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *leaseLister) Leases(namespace string) listerscoordinationv1.LeaseNamespaceLister { + return &leaseNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// leaseNamespaceLister implements the coordinationv1listers.LeaseNamespaceLister interface. +// leaseNamespaceLister implements the listerscoordinationv1.LeaseNamespaceLister +// interface. type leaseNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*coordinationv1.Lease] } -// List lists all Leases in the indexer for a given workspace and namespace. -func (s *leaseNamespaceLister) List(selector labels.Selector) (ret []*coordinationv1.Lease, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*coordinationv1.Lease)) - }) - return ret, err -} +var _ listerscoordinationv1.LeaseNamespaceLister = new(leaseNamespaceLister) -// Get retrieves the Lease from the indexer for a given workspace, namespace and name. -func (s *leaseNamespaceLister) Get(name string) (*coordinationv1.Lease, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewLeaseLister returns a new LeaseLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewLeaseLister(indexer cache.Indexer) listerscoordinationv1.LeaseLister { + return &leaseLister{ + kcplisters.New[*coordinationv1.Lease](indexer, coordinationv1.Resource("lease")), } - if !exists { - return nil, errors.NewNotFound(coordinationv1.Resource("leases"), name) +} + +// leaseScopedLister can list all Leases inside a workspace +// or scope down to a listerscoordinationv1.LeaseNamespaceLister for one namespace. +type leaseScopedLister struct { + kcplisters.ResourceIndexer[*coordinationv1.Lease] +} + +// Leases returns an object that can list and get Leases in one namespace. +func (l *leaseScopedLister) Leases(namespace string) listerscoordinationv1.LeaseLister { + return &leaseLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*coordinationv1.Lease), nil } diff --git a/listers/coordination/v1alpha2/expansion_generated.go b/listers/coordination/v1alpha2/expansion_generated.go new file mode 100644 index 000000000..458098c97 --- /dev/null +++ b/listers/coordination/v1alpha2/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1alpha2 diff --git a/listers/coordination/v1alpha2/leasecandidate.go b/listers/coordination/v1alpha2/leasecandidate.go index 0beb46398..661d4ee91 100644 --- a/listers/coordination/v1alpha2/leasecandidate.go +++ b/listers/coordination/v1alpha2/leasecandidate.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1alpha2 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" coordinationv1alpha2 "k8s.io/api/coordination/v1alpha2" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - coordinationv1alpha2listers "k8s.io/client-go/listers/coordination/v1alpha2" + listerscoordinationv1alpha2 "k8s.io/client-go/listers/coordination/v1alpha2" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// LeaseCandidateClusterLister can list LeaseCandidates across all workspaces, or scope down to a LeaseCandidateLister for one workspace. +// LeaseCandidateClusterLister helps list LeaseCandidates across all workspaces, +// or scope down to a LeaseCandidateLister for one workspace. // All objects returned here must be treated as read-only. type LeaseCandidateClusterLister interface { // List lists all LeaseCandidates in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*coordinationv1alpha2.LeaseCandidate, err error) // Cluster returns a lister that can list and get LeaseCandidates in one workspace. - Cluster(clusterName logicalcluster.Name) coordinationv1alpha2listers.LeaseCandidateLister + Cluster(clusterName logicalcluster.Name) listerscoordinationv1alpha2.LeaseCandidateLister LeaseCandidateClusterListerExpansion } +// leaseCandidateClusterLister implements the LeaseCandidateClusterLister interface. type leaseCandidateClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*coordinationv1alpha2.LeaseCandidate] } +var _ LeaseCandidateClusterLister = new(leaseCandidateClusterLister) + // NewLeaseCandidateClusterLister returns a new LeaseCandidateClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewLeaseCandidateClusterLister(indexer cache.Indexer) *leaseCandidateClusterLister { - return &leaseCandidateClusterLister{indexer: indexer} -} - -// List lists all LeaseCandidates in the indexer across all workspaces. -func (s *leaseCandidateClusterLister) List(selector labels.Selector) (ret []*coordinationv1alpha2.LeaseCandidate, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*coordinationv1alpha2.LeaseCandidate)) - }) - return ret, err +func NewLeaseCandidateClusterLister(indexer cache.Indexer) LeaseCandidateClusterLister { + return &leaseCandidateClusterLister{ + kcplisters.NewCluster[*coordinationv1alpha2.LeaseCandidate](indexer, coordinationv1alpha2.Resource("leasecandidate")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get LeaseCandidates. -func (s *leaseCandidateClusterLister) Cluster(clusterName logicalcluster.Name) coordinationv1alpha2listers.LeaseCandidateLister { - return &leaseCandidateLister{indexer: s.indexer, clusterName: clusterName} +func (l *leaseCandidateClusterLister) Cluster(clusterName logicalcluster.Name) listerscoordinationv1alpha2.LeaseCandidateLister { + return &leaseCandidateLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// leaseCandidateLister implements the coordinationv1alpha2listers.LeaseCandidateLister interface. +// leaseCandidateLister can list all LeaseCandidates inside a workspace +// or scope down to a listerscoordinationv1alpha2.LeaseCandidateNamespaceLister for one namespace. type leaseCandidateLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*coordinationv1alpha2.LeaseCandidate] } -// List lists all LeaseCandidates in the indexer for a workspace. -func (s *leaseCandidateLister) List(selector labels.Selector) (ret []*coordinationv1alpha2.LeaseCandidate, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*coordinationv1alpha2.LeaseCandidate)) - }) - return ret, err -} +var _ listerscoordinationv1alpha2.LeaseCandidateLister = new(leaseCandidateLister) // LeaseCandidates returns an object that can list and get LeaseCandidates in one namespace. -func (s *leaseCandidateLister) LeaseCandidates(namespace string) coordinationv1alpha2listers.LeaseCandidateNamespaceLister { - return &leaseCandidateNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *leaseCandidateLister) LeaseCandidates(namespace string) listerscoordinationv1alpha2.LeaseCandidateNamespaceLister { + return &leaseCandidateNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// leaseCandidateNamespaceLister implements the coordinationv1alpha2listers.LeaseCandidateNamespaceLister interface. +// leaseCandidateNamespaceLister implements the listerscoordinationv1alpha2.LeaseCandidateNamespaceLister +// interface. type leaseCandidateNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*coordinationv1alpha2.LeaseCandidate] } -// List lists all LeaseCandidates in the indexer for a given workspace and namespace. -func (s *leaseCandidateNamespaceLister) List(selector labels.Selector) (ret []*coordinationv1alpha2.LeaseCandidate, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*coordinationv1alpha2.LeaseCandidate)) - }) - return ret, err -} +var _ listerscoordinationv1alpha2.LeaseCandidateNamespaceLister = new(leaseCandidateNamespaceLister) -// Get retrieves the LeaseCandidate from the indexer for a given workspace, namespace and name. -func (s *leaseCandidateNamespaceLister) Get(name string) (*coordinationv1alpha2.LeaseCandidate, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewLeaseCandidateLister returns a new LeaseCandidateLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewLeaseCandidateLister(indexer cache.Indexer) listerscoordinationv1alpha2.LeaseCandidateLister { + return &leaseCandidateLister{ + kcplisters.New[*coordinationv1alpha2.LeaseCandidate](indexer, coordinationv1alpha2.Resource("leasecandidate")), } - if !exists { - return nil, errors.NewNotFound(coordinationv1alpha2.Resource("leasecandidates"), name) +} + +// leaseCandidateScopedLister can list all LeaseCandidates inside a workspace +// or scope down to a listerscoordinationv1alpha2.LeaseCandidateNamespaceLister for one namespace. +type leaseCandidateScopedLister struct { + kcplisters.ResourceIndexer[*coordinationv1alpha2.LeaseCandidate] +} + +// LeaseCandidates returns an object that can list and get LeaseCandidates in one namespace. +func (l *leaseCandidateScopedLister) LeaseCandidates(namespace string) listerscoordinationv1alpha2.LeaseCandidateLister { + return &leaseCandidateLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*coordinationv1alpha2.LeaseCandidate), nil } diff --git a/listers/coordination/v1beta1/expansion_generated.go b/listers/coordination/v1beta1/expansion_generated.go new file mode 100644 index 000000000..23cac805b --- /dev/null +++ b/listers/coordination/v1beta1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1beta1 diff --git a/listers/coordination/v1beta1/lease.go b/listers/coordination/v1beta1/lease.go index f700edad8..0bb6a1773 100644 --- a/listers/coordination/v1beta1/lease.go +++ b/listers/coordination/v1beta1/lease.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" coordinationv1beta1 "k8s.io/api/coordination/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - coordinationv1beta1listers "k8s.io/client-go/listers/coordination/v1beta1" + listerscoordinationv1beta1 "k8s.io/client-go/listers/coordination/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// LeaseClusterLister can list Leases across all workspaces, or scope down to a LeaseLister for one workspace. +// LeaseClusterLister helps list Leases across all workspaces, +// or scope down to a LeaseLister for one workspace. // All objects returned here must be treated as read-only. type LeaseClusterLister interface { // List lists all Leases in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*coordinationv1beta1.Lease, err error) // Cluster returns a lister that can list and get Leases in one workspace. - Cluster(clusterName logicalcluster.Name) coordinationv1beta1listers.LeaseLister + Cluster(clusterName logicalcluster.Name) listerscoordinationv1beta1.LeaseLister LeaseClusterListerExpansion } +// leaseClusterLister implements the LeaseClusterLister interface. type leaseClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*coordinationv1beta1.Lease] } +var _ LeaseClusterLister = new(leaseClusterLister) + // NewLeaseClusterLister returns a new LeaseClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewLeaseClusterLister(indexer cache.Indexer) *leaseClusterLister { - return &leaseClusterLister{indexer: indexer} -} - -// List lists all Leases in the indexer across all workspaces. -func (s *leaseClusterLister) List(selector labels.Selector) (ret []*coordinationv1beta1.Lease, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*coordinationv1beta1.Lease)) - }) - return ret, err +func NewLeaseClusterLister(indexer cache.Indexer) LeaseClusterLister { + return &leaseClusterLister{ + kcplisters.NewCluster[*coordinationv1beta1.Lease](indexer, coordinationv1beta1.Resource("lease")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get Leases. -func (s *leaseClusterLister) Cluster(clusterName logicalcluster.Name) coordinationv1beta1listers.LeaseLister { - return &leaseLister{indexer: s.indexer, clusterName: clusterName} +func (l *leaseClusterLister) Cluster(clusterName logicalcluster.Name) listerscoordinationv1beta1.LeaseLister { + return &leaseLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// leaseLister implements the coordinationv1beta1listers.LeaseLister interface. +// leaseLister can list all Leases inside a workspace +// or scope down to a listerscoordinationv1beta1.LeaseNamespaceLister for one namespace. type leaseLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*coordinationv1beta1.Lease] } -// List lists all Leases in the indexer for a workspace. -func (s *leaseLister) List(selector labels.Selector) (ret []*coordinationv1beta1.Lease, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*coordinationv1beta1.Lease)) - }) - return ret, err -} +var _ listerscoordinationv1beta1.LeaseLister = new(leaseLister) // Leases returns an object that can list and get Leases in one namespace. -func (s *leaseLister) Leases(namespace string) coordinationv1beta1listers.LeaseNamespaceLister { - return &leaseNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *leaseLister) Leases(namespace string) listerscoordinationv1beta1.LeaseNamespaceLister { + return &leaseNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// leaseNamespaceLister implements the coordinationv1beta1listers.LeaseNamespaceLister interface. +// leaseNamespaceLister implements the listerscoordinationv1beta1.LeaseNamespaceLister +// interface. type leaseNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*coordinationv1beta1.Lease] } -// List lists all Leases in the indexer for a given workspace and namespace. -func (s *leaseNamespaceLister) List(selector labels.Selector) (ret []*coordinationv1beta1.Lease, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*coordinationv1beta1.Lease)) - }) - return ret, err -} +var _ listerscoordinationv1beta1.LeaseNamespaceLister = new(leaseNamespaceLister) -// Get retrieves the Lease from the indexer for a given workspace, namespace and name. -func (s *leaseNamespaceLister) Get(name string) (*coordinationv1beta1.Lease, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewLeaseLister returns a new LeaseLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewLeaseLister(indexer cache.Indexer) listerscoordinationv1beta1.LeaseLister { + return &leaseLister{ + kcplisters.New[*coordinationv1beta1.Lease](indexer, coordinationv1beta1.Resource("lease")), } - if !exists { - return nil, errors.NewNotFound(coordinationv1beta1.Resource("leases"), name) +} + +// leaseScopedLister can list all Leases inside a workspace +// or scope down to a listerscoordinationv1beta1.LeaseNamespaceLister for one namespace. +type leaseScopedLister struct { + kcplisters.ResourceIndexer[*coordinationv1beta1.Lease] +} + +// Leases returns an object that can list and get Leases in one namespace. +func (l *leaseScopedLister) Leases(namespace string) listerscoordinationv1beta1.LeaseLister { + return &leaseLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*coordinationv1beta1.Lease), nil } diff --git a/listers/core/v1/componentstatus.go b/listers/core/v1/componentstatus.go index 2720cc5b0..99263c066 100644 --- a/listers/core/v1/componentstatus.go +++ b/listers/core/v1/componentstatus.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - corev1listers "k8s.io/client-go/listers/core/v1" + listerscorev1 "k8s.io/client-go/listers/core/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ComponentStatusClusterLister can list ComponentStatuses across all workspaces, or scope down to a ComponentStatusLister for one workspace. +// ComponentStatusClusterLister helps list ComponentStatuses across all workspaces, +// or scope down to a ComponentStatusLister for one workspace. // All objects returned here must be treated as read-only. type ComponentStatusClusterLister interface { // List lists all ComponentStatuses in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*corev1.ComponentStatus, err error) // Cluster returns a lister that can list and get ComponentStatuses in one workspace. - Cluster(clusterName logicalcluster.Name) corev1listers.ComponentStatusLister + Cluster(clusterName logicalcluster.Name) listerscorev1.ComponentStatusLister ComponentStatusClusterListerExpansion } +// componentStatusClusterLister implements the ComponentStatusClusterLister interface. type componentStatusClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*corev1.ComponentStatus] } +var _ ComponentStatusClusterLister = new(componentStatusClusterLister) + // NewComponentStatusClusterLister returns a new ComponentStatusClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewComponentStatusClusterLister(indexer cache.Indexer) *componentStatusClusterLister { - return &componentStatusClusterLister{indexer: indexer} -} - -// List lists all ComponentStatuses in the indexer across all workspaces. -func (s *componentStatusClusterLister) List(selector labels.Selector) (ret []*corev1.ComponentStatus, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*corev1.ComponentStatus)) - }) - return ret, err +func NewComponentStatusClusterLister(indexer cache.Indexer) ComponentStatusClusterLister { + return &componentStatusClusterLister{ + kcplisters.NewCluster[*corev1.ComponentStatus](indexer, corev1.Resource("componentstatus")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ComponentStatuses. -func (s *componentStatusClusterLister) Cluster(clusterName logicalcluster.Name) corev1listers.ComponentStatusLister { - return &componentStatusLister{indexer: s.indexer, clusterName: clusterName} +func (l *componentStatusClusterLister) Cluster(clusterName logicalcluster.Name) listerscorev1.ComponentStatusLister { + return &componentStatusLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// componentStatusLister implements the corev1listers.ComponentStatusLister interface. +// componentStatusLister can list all ComponentStatuses inside a workspace +// or scope down to a listerscorev1.ComponentStatusNamespaceLister for one namespace. type componentStatusLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*corev1.ComponentStatus] } -// List lists all ComponentStatuses in the indexer for a workspace. -func (s *componentStatusLister) List(selector labels.Selector) (ret []*corev1.ComponentStatus, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*corev1.ComponentStatus)) - }) - return ret, err -} +var _ listerscorev1.ComponentStatusLister = new(componentStatusLister) -// Get retrieves the ComponentStatus from the indexer for a given workspace and name. -func (s *componentStatusLister) Get(name string) (*corev1.ComponentStatus, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(corev1.Resource("componentstatuses"), name) +// NewComponentStatusLister returns a new ComponentStatusLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewComponentStatusLister(indexer cache.Indexer) listerscorev1.ComponentStatusLister { + return &componentStatusLister{ + kcplisters.New[*corev1.ComponentStatus](indexer, corev1.Resource("componentstatus")), } - return obj.(*corev1.ComponentStatus), nil +} + +// componentStatusScopedLister can list all ComponentStatuses inside a workspace +// or scope down to a listerscorev1.ComponentStatusNamespaceLister. +type componentStatusScopedLister struct { + kcplisters.ResourceIndexer[*corev1.ComponentStatus] } diff --git a/listers/core/v1/configmap.go b/listers/core/v1/configmap.go index cadd91782..6adc5b529 100644 --- a/listers/core/v1/configmap.go +++ b/listers/core/v1/configmap.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - corev1listers "k8s.io/client-go/listers/core/v1" + listerscorev1 "k8s.io/client-go/listers/core/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ConfigMapClusterLister can list ConfigMaps across all workspaces, or scope down to a ConfigMapLister for one workspace. +// ConfigMapClusterLister helps list ConfigMaps across all workspaces, +// or scope down to a ConfigMapLister for one workspace. // All objects returned here must be treated as read-only. type ConfigMapClusterLister interface { // List lists all ConfigMaps in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*corev1.ConfigMap, err error) // Cluster returns a lister that can list and get ConfigMaps in one workspace. - Cluster(clusterName logicalcluster.Name) corev1listers.ConfigMapLister + Cluster(clusterName logicalcluster.Name) listerscorev1.ConfigMapLister ConfigMapClusterListerExpansion } +// configMapClusterLister implements the ConfigMapClusterLister interface. type configMapClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*corev1.ConfigMap] } +var _ ConfigMapClusterLister = new(configMapClusterLister) + // NewConfigMapClusterLister returns a new ConfigMapClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewConfigMapClusterLister(indexer cache.Indexer) *configMapClusterLister { - return &configMapClusterLister{indexer: indexer} -} - -// List lists all ConfigMaps in the indexer across all workspaces. -func (s *configMapClusterLister) List(selector labels.Selector) (ret []*corev1.ConfigMap, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*corev1.ConfigMap)) - }) - return ret, err +func NewConfigMapClusterLister(indexer cache.Indexer) ConfigMapClusterLister { + return &configMapClusterLister{ + kcplisters.NewCluster[*corev1.ConfigMap](indexer, corev1.Resource("configmap")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ConfigMaps. -func (s *configMapClusterLister) Cluster(clusterName logicalcluster.Name) corev1listers.ConfigMapLister { - return &configMapLister{indexer: s.indexer, clusterName: clusterName} +func (l *configMapClusterLister) Cluster(clusterName logicalcluster.Name) listerscorev1.ConfigMapLister { + return &configMapLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// configMapLister implements the corev1listers.ConfigMapLister interface. +// configMapLister can list all ConfigMaps inside a workspace +// or scope down to a listerscorev1.ConfigMapNamespaceLister for one namespace. type configMapLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*corev1.ConfigMap] } -// List lists all ConfigMaps in the indexer for a workspace. -func (s *configMapLister) List(selector labels.Selector) (ret []*corev1.ConfigMap, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*corev1.ConfigMap)) - }) - return ret, err -} +var _ listerscorev1.ConfigMapLister = new(configMapLister) // ConfigMaps returns an object that can list and get ConfigMaps in one namespace. -func (s *configMapLister) ConfigMaps(namespace string) corev1listers.ConfigMapNamespaceLister { - return &configMapNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *configMapLister) ConfigMaps(namespace string) listerscorev1.ConfigMapNamespaceLister { + return &configMapNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// configMapNamespaceLister implements the corev1listers.ConfigMapNamespaceLister interface. +// configMapNamespaceLister implements the listerscorev1.ConfigMapNamespaceLister +// interface. type configMapNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*corev1.ConfigMap] } -// List lists all ConfigMaps in the indexer for a given workspace and namespace. -func (s *configMapNamespaceLister) List(selector labels.Selector) (ret []*corev1.ConfigMap, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*corev1.ConfigMap)) - }) - return ret, err -} +var _ listerscorev1.ConfigMapNamespaceLister = new(configMapNamespaceLister) -// Get retrieves the ConfigMap from the indexer for a given workspace, namespace and name. -func (s *configMapNamespaceLister) Get(name string) (*corev1.ConfigMap, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewConfigMapLister returns a new ConfigMapLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewConfigMapLister(indexer cache.Indexer) listerscorev1.ConfigMapLister { + return &configMapLister{ + kcplisters.New[*corev1.ConfigMap](indexer, corev1.Resource("configmap")), } - if !exists { - return nil, errors.NewNotFound(corev1.Resource("configmaps"), name) +} + +// configMapScopedLister can list all ConfigMaps inside a workspace +// or scope down to a listerscorev1.ConfigMapNamespaceLister for one namespace. +type configMapScopedLister struct { + kcplisters.ResourceIndexer[*corev1.ConfigMap] +} + +// ConfigMaps returns an object that can list and get ConfigMaps in one namespace. +func (l *configMapScopedLister) ConfigMaps(namespace string) listerscorev1.ConfigMapLister { + return &configMapLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*corev1.ConfigMap), nil } diff --git a/listers/core/v1/endpoints.go b/listers/core/v1/endpoints.go index c7b8dda59..a27dd7fcf 100644 --- a/listers/core/v1/endpoints.go +++ b/listers/core/v1/endpoints.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - corev1listers "k8s.io/client-go/listers/core/v1" + listerscorev1 "k8s.io/client-go/listers/core/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// EndpointsClusterLister can list Endpoints across all workspaces, or scope down to a EndpointsLister for one workspace. +// EndpointsClusterLister helps list Endpoints across all workspaces, +// or scope down to a EndpointsLister for one workspace. // All objects returned here must be treated as read-only. type EndpointsClusterLister interface { // List lists all Endpoints in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*corev1.Endpoints, err error) // Cluster returns a lister that can list and get Endpoints in one workspace. - Cluster(clusterName logicalcluster.Name) corev1listers.EndpointsLister + Cluster(clusterName logicalcluster.Name) listerscorev1.EndpointsLister EndpointsClusterListerExpansion } +// endpointsClusterLister implements the EndpointsClusterLister interface. type endpointsClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*corev1.Endpoints] } +var _ EndpointsClusterLister = new(endpointsClusterLister) + // NewEndpointsClusterLister returns a new EndpointsClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewEndpointsClusterLister(indexer cache.Indexer) *endpointsClusterLister { - return &endpointsClusterLister{indexer: indexer} -} - -// List lists all Endpoints in the indexer across all workspaces. -func (s *endpointsClusterLister) List(selector labels.Selector) (ret []*corev1.Endpoints, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*corev1.Endpoints)) - }) - return ret, err +func NewEndpointsClusterLister(indexer cache.Indexer) EndpointsClusterLister { + return &endpointsClusterLister{ + kcplisters.NewCluster[*corev1.Endpoints](indexer, corev1.Resource("endpoints")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get Endpoints. -func (s *endpointsClusterLister) Cluster(clusterName logicalcluster.Name) corev1listers.EndpointsLister { - return &endpointsLister{indexer: s.indexer, clusterName: clusterName} +func (l *endpointsClusterLister) Cluster(clusterName logicalcluster.Name) listerscorev1.EndpointsLister { + return &endpointsLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// endpointsLister implements the corev1listers.EndpointsLister interface. +// endpointsLister can list all Endpoints inside a workspace +// or scope down to a listerscorev1.EndpointsNamespaceLister for one namespace. type endpointsLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*corev1.Endpoints] } -// List lists all Endpoints in the indexer for a workspace. -func (s *endpointsLister) List(selector labels.Selector) (ret []*corev1.Endpoints, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*corev1.Endpoints)) - }) - return ret, err -} +var _ listerscorev1.EndpointsLister = new(endpointsLister) // Endpoints returns an object that can list and get Endpoints in one namespace. -func (s *endpointsLister) Endpoints(namespace string) corev1listers.EndpointsNamespaceLister { - return &endpointsNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *endpointsLister) Endpoints(namespace string) listerscorev1.EndpointsNamespaceLister { + return &endpointsNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// endpointsNamespaceLister implements the corev1listers.EndpointsNamespaceLister interface. +// endpointsNamespaceLister implements the listerscorev1.EndpointsNamespaceLister +// interface. type endpointsNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*corev1.Endpoints] } -// List lists all Endpoints in the indexer for a given workspace and namespace. -func (s *endpointsNamespaceLister) List(selector labels.Selector) (ret []*corev1.Endpoints, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*corev1.Endpoints)) - }) - return ret, err -} +var _ listerscorev1.EndpointsNamespaceLister = new(endpointsNamespaceLister) -// Get retrieves the Endpoints from the indexer for a given workspace, namespace and name. -func (s *endpointsNamespaceLister) Get(name string) (*corev1.Endpoints, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewEndpointsLister returns a new EndpointsLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewEndpointsLister(indexer cache.Indexer) listerscorev1.EndpointsLister { + return &endpointsLister{ + kcplisters.New[*corev1.Endpoints](indexer, corev1.Resource("endpoints")), } - if !exists { - return nil, errors.NewNotFound(corev1.Resource("endpoints"), name) +} + +// endpointsScopedLister can list all Endpoints inside a workspace +// or scope down to a listerscorev1.EndpointsNamespaceLister for one namespace. +type endpointsScopedLister struct { + kcplisters.ResourceIndexer[*corev1.Endpoints] +} + +// Endpoints returns an object that can list and get Endpoints in one namespace. +func (l *endpointsScopedLister) Endpoints(namespace string) listerscorev1.EndpointsLister { + return &endpointsLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*corev1.Endpoints), nil } diff --git a/listers/core/v1/event.go b/listers/core/v1/event.go index 1c998cec3..c2c4e1e4e 100644 --- a/listers/core/v1/event.go +++ b/listers/core/v1/event.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - corev1listers "k8s.io/client-go/listers/core/v1" + listerscorev1 "k8s.io/client-go/listers/core/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// EventClusterLister can list Events across all workspaces, or scope down to a EventLister for one workspace. +// EventClusterLister helps list Events across all workspaces, +// or scope down to a EventLister for one workspace. // All objects returned here must be treated as read-only. type EventClusterLister interface { // List lists all Events in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*corev1.Event, err error) // Cluster returns a lister that can list and get Events in one workspace. - Cluster(clusterName logicalcluster.Name) corev1listers.EventLister + Cluster(clusterName logicalcluster.Name) listerscorev1.EventLister EventClusterListerExpansion } +// eventClusterLister implements the EventClusterLister interface. type eventClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*corev1.Event] } +var _ EventClusterLister = new(eventClusterLister) + // NewEventClusterLister returns a new EventClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewEventClusterLister(indexer cache.Indexer) *eventClusterLister { - return &eventClusterLister{indexer: indexer} -} - -// List lists all Events in the indexer across all workspaces. -func (s *eventClusterLister) List(selector labels.Selector) (ret []*corev1.Event, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*corev1.Event)) - }) - return ret, err +func NewEventClusterLister(indexer cache.Indexer) EventClusterLister { + return &eventClusterLister{ + kcplisters.NewCluster[*corev1.Event](indexer, corev1.Resource("event")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get Events. -func (s *eventClusterLister) Cluster(clusterName logicalcluster.Name) corev1listers.EventLister { - return &eventLister{indexer: s.indexer, clusterName: clusterName} +func (l *eventClusterLister) Cluster(clusterName logicalcluster.Name) listerscorev1.EventLister { + return &eventLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// eventLister implements the corev1listers.EventLister interface. +// eventLister can list all Events inside a workspace +// or scope down to a listerscorev1.EventNamespaceLister for one namespace. type eventLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*corev1.Event] } -// List lists all Events in the indexer for a workspace. -func (s *eventLister) List(selector labels.Selector) (ret []*corev1.Event, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*corev1.Event)) - }) - return ret, err -} +var _ listerscorev1.EventLister = new(eventLister) // Events returns an object that can list and get Events in one namespace. -func (s *eventLister) Events(namespace string) corev1listers.EventNamespaceLister { - return &eventNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *eventLister) Events(namespace string) listerscorev1.EventNamespaceLister { + return &eventNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// eventNamespaceLister implements the corev1listers.EventNamespaceLister interface. +// eventNamespaceLister implements the listerscorev1.EventNamespaceLister +// interface. type eventNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*corev1.Event] } -// List lists all Events in the indexer for a given workspace and namespace. -func (s *eventNamespaceLister) List(selector labels.Selector) (ret []*corev1.Event, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*corev1.Event)) - }) - return ret, err -} +var _ listerscorev1.EventNamespaceLister = new(eventNamespaceLister) -// Get retrieves the Event from the indexer for a given workspace, namespace and name. -func (s *eventNamespaceLister) Get(name string) (*corev1.Event, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewEventLister returns a new EventLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewEventLister(indexer cache.Indexer) listerscorev1.EventLister { + return &eventLister{ + kcplisters.New[*corev1.Event](indexer, corev1.Resource("event")), } - if !exists { - return nil, errors.NewNotFound(corev1.Resource("events"), name) +} + +// eventScopedLister can list all Events inside a workspace +// or scope down to a listerscorev1.EventNamespaceLister for one namespace. +type eventScopedLister struct { + kcplisters.ResourceIndexer[*corev1.Event] +} + +// Events returns an object that can list and get Events in one namespace. +func (l *eventScopedLister) Events(namespace string) listerscorev1.EventLister { + return &eventLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*corev1.Event), nil } diff --git a/listers/core/v1/expansion_generated.go b/listers/core/v1/expansion_generated.go new file mode 100644 index 000000000..b6a0c6377 --- /dev/null +++ b/listers/core/v1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1 diff --git a/listers/core/v1/limitrange.go b/listers/core/v1/limitrange.go index 7af072dd1..c73173a53 100644 --- a/listers/core/v1/limitrange.go +++ b/listers/core/v1/limitrange.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - corev1listers "k8s.io/client-go/listers/core/v1" + listerscorev1 "k8s.io/client-go/listers/core/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// LimitRangeClusterLister can list LimitRanges across all workspaces, or scope down to a LimitRangeLister for one workspace. +// LimitRangeClusterLister helps list LimitRanges across all workspaces, +// or scope down to a LimitRangeLister for one workspace. // All objects returned here must be treated as read-only. type LimitRangeClusterLister interface { // List lists all LimitRanges in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*corev1.LimitRange, err error) // Cluster returns a lister that can list and get LimitRanges in one workspace. - Cluster(clusterName logicalcluster.Name) corev1listers.LimitRangeLister + Cluster(clusterName logicalcluster.Name) listerscorev1.LimitRangeLister LimitRangeClusterListerExpansion } +// limitRangeClusterLister implements the LimitRangeClusterLister interface. type limitRangeClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*corev1.LimitRange] } +var _ LimitRangeClusterLister = new(limitRangeClusterLister) + // NewLimitRangeClusterLister returns a new LimitRangeClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewLimitRangeClusterLister(indexer cache.Indexer) *limitRangeClusterLister { - return &limitRangeClusterLister{indexer: indexer} -} - -// List lists all LimitRanges in the indexer across all workspaces. -func (s *limitRangeClusterLister) List(selector labels.Selector) (ret []*corev1.LimitRange, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*corev1.LimitRange)) - }) - return ret, err +func NewLimitRangeClusterLister(indexer cache.Indexer) LimitRangeClusterLister { + return &limitRangeClusterLister{ + kcplisters.NewCluster[*corev1.LimitRange](indexer, corev1.Resource("limitrange")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get LimitRanges. -func (s *limitRangeClusterLister) Cluster(clusterName logicalcluster.Name) corev1listers.LimitRangeLister { - return &limitRangeLister{indexer: s.indexer, clusterName: clusterName} +func (l *limitRangeClusterLister) Cluster(clusterName logicalcluster.Name) listerscorev1.LimitRangeLister { + return &limitRangeLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// limitRangeLister implements the corev1listers.LimitRangeLister interface. +// limitRangeLister can list all LimitRanges inside a workspace +// or scope down to a listerscorev1.LimitRangeNamespaceLister for one namespace. type limitRangeLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*corev1.LimitRange] } -// List lists all LimitRanges in the indexer for a workspace. -func (s *limitRangeLister) List(selector labels.Selector) (ret []*corev1.LimitRange, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*corev1.LimitRange)) - }) - return ret, err -} +var _ listerscorev1.LimitRangeLister = new(limitRangeLister) // LimitRanges returns an object that can list and get LimitRanges in one namespace. -func (s *limitRangeLister) LimitRanges(namespace string) corev1listers.LimitRangeNamespaceLister { - return &limitRangeNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *limitRangeLister) LimitRanges(namespace string) listerscorev1.LimitRangeNamespaceLister { + return &limitRangeNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// limitRangeNamespaceLister implements the corev1listers.LimitRangeNamespaceLister interface. +// limitRangeNamespaceLister implements the listerscorev1.LimitRangeNamespaceLister +// interface. type limitRangeNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*corev1.LimitRange] } -// List lists all LimitRanges in the indexer for a given workspace and namespace. -func (s *limitRangeNamespaceLister) List(selector labels.Selector) (ret []*corev1.LimitRange, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*corev1.LimitRange)) - }) - return ret, err -} +var _ listerscorev1.LimitRangeNamespaceLister = new(limitRangeNamespaceLister) -// Get retrieves the LimitRange from the indexer for a given workspace, namespace and name. -func (s *limitRangeNamespaceLister) Get(name string) (*corev1.LimitRange, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewLimitRangeLister returns a new LimitRangeLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewLimitRangeLister(indexer cache.Indexer) listerscorev1.LimitRangeLister { + return &limitRangeLister{ + kcplisters.New[*corev1.LimitRange](indexer, corev1.Resource("limitrange")), } - if !exists { - return nil, errors.NewNotFound(corev1.Resource("limitranges"), name) +} + +// limitRangeScopedLister can list all LimitRanges inside a workspace +// or scope down to a listerscorev1.LimitRangeNamespaceLister for one namespace. +type limitRangeScopedLister struct { + kcplisters.ResourceIndexer[*corev1.LimitRange] +} + +// LimitRanges returns an object that can list and get LimitRanges in one namespace. +func (l *limitRangeScopedLister) LimitRanges(namespace string) listerscorev1.LimitRangeLister { + return &limitRangeLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*corev1.LimitRange), nil } diff --git a/listers/core/v1/namespace.go b/listers/core/v1/namespace.go index 438fa5c33..67d6806c2 100644 --- a/listers/core/v1/namespace.go +++ b/listers/core/v1/namespace.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - corev1listers "k8s.io/client-go/listers/core/v1" + listerscorev1 "k8s.io/client-go/listers/core/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// NamespaceClusterLister can list Namespaces across all workspaces, or scope down to a NamespaceLister for one workspace. +// NamespaceClusterLister helps list Namespaces across all workspaces, +// or scope down to a NamespaceLister for one workspace. // All objects returned here must be treated as read-only. type NamespaceClusterLister interface { // List lists all Namespaces in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*corev1.Namespace, err error) // Cluster returns a lister that can list and get Namespaces in one workspace. - Cluster(clusterName logicalcluster.Name) corev1listers.NamespaceLister + Cluster(clusterName logicalcluster.Name) listerscorev1.NamespaceLister NamespaceClusterListerExpansion } +// namespaceClusterLister implements the NamespaceClusterLister interface. type namespaceClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*corev1.Namespace] } +var _ NamespaceClusterLister = new(namespaceClusterLister) + // NewNamespaceClusterLister returns a new NamespaceClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewNamespaceClusterLister(indexer cache.Indexer) *namespaceClusterLister { - return &namespaceClusterLister{indexer: indexer} -} - -// List lists all Namespaces in the indexer across all workspaces. -func (s *namespaceClusterLister) List(selector labels.Selector) (ret []*corev1.Namespace, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*corev1.Namespace)) - }) - return ret, err +func NewNamespaceClusterLister(indexer cache.Indexer) NamespaceClusterLister { + return &namespaceClusterLister{ + kcplisters.NewCluster[*corev1.Namespace](indexer, corev1.Resource("namespace")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get Namespaces. -func (s *namespaceClusterLister) Cluster(clusterName logicalcluster.Name) corev1listers.NamespaceLister { - return &namespaceLister{indexer: s.indexer, clusterName: clusterName} +func (l *namespaceClusterLister) Cluster(clusterName logicalcluster.Name) listerscorev1.NamespaceLister { + return &namespaceLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// namespaceLister implements the corev1listers.NamespaceLister interface. +// namespaceLister can list all Namespaces inside a workspace +// or scope down to a listerscorev1.NamespaceNamespaceLister for one namespace. type namespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*corev1.Namespace] } -// List lists all Namespaces in the indexer for a workspace. -func (s *namespaceLister) List(selector labels.Selector) (ret []*corev1.Namespace, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*corev1.Namespace)) - }) - return ret, err -} +var _ listerscorev1.NamespaceLister = new(namespaceLister) -// Get retrieves the Namespace from the indexer for a given workspace and name. -func (s *namespaceLister) Get(name string) (*corev1.Namespace, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(corev1.Resource("namespaces"), name) +// NewNamespaceLister returns a new NamespaceLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewNamespaceLister(indexer cache.Indexer) listerscorev1.NamespaceLister { + return &namespaceLister{ + kcplisters.New[*corev1.Namespace](indexer, corev1.Resource("namespace")), } - return obj.(*corev1.Namespace), nil +} + +// namespaceScopedLister can list all Namespaces inside a workspace +// or scope down to a listerscorev1.NamespaceNamespaceLister. +type namespaceScopedLister struct { + kcplisters.ResourceIndexer[*corev1.Namespace] } diff --git a/listers/core/v1/node.go b/listers/core/v1/node.go index c6251cdbe..476c36418 100644 --- a/listers/core/v1/node.go +++ b/listers/core/v1/node.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - corev1listers "k8s.io/client-go/listers/core/v1" + listerscorev1 "k8s.io/client-go/listers/core/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// NodeClusterLister can list Nodes across all workspaces, or scope down to a NodeLister for one workspace. +// NodeClusterLister helps list Nodes across all workspaces, +// or scope down to a NodeLister for one workspace. // All objects returned here must be treated as read-only. type NodeClusterLister interface { // List lists all Nodes in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*corev1.Node, err error) // Cluster returns a lister that can list and get Nodes in one workspace. - Cluster(clusterName logicalcluster.Name) corev1listers.NodeLister + Cluster(clusterName logicalcluster.Name) listerscorev1.NodeLister NodeClusterListerExpansion } +// nodeClusterLister implements the NodeClusterLister interface. type nodeClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*corev1.Node] } +var _ NodeClusterLister = new(nodeClusterLister) + // NewNodeClusterLister returns a new NodeClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewNodeClusterLister(indexer cache.Indexer) *nodeClusterLister { - return &nodeClusterLister{indexer: indexer} -} - -// List lists all Nodes in the indexer across all workspaces. -func (s *nodeClusterLister) List(selector labels.Selector) (ret []*corev1.Node, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*corev1.Node)) - }) - return ret, err +func NewNodeClusterLister(indexer cache.Indexer) NodeClusterLister { + return &nodeClusterLister{ + kcplisters.NewCluster[*corev1.Node](indexer, corev1.Resource("node")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get Nodes. -func (s *nodeClusterLister) Cluster(clusterName logicalcluster.Name) corev1listers.NodeLister { - return &nodeLister{indexer: s.indexer, clusterName: clusterName} +func (l *nodeClusterLister) Cluster(clusterName logicalcluster.Name) listerscorev1.NodeLister { + return &nodeLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// nodeLister implements the corev1listers.NodeLister interface. +// nodeLister can list all Nodes inside a workspace +// or scope down to a listerscorev1.NodeNamespaceLister for one namespace. type nodeLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*corev1.Node] } -// List lists all Nodes in the indexer for a workspace. -func (s *nodeLister) List(selector labels.Selector) (ret []*corev1.Node, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*corev1.Node)) - }) - return ret, err -} +var _ listerscorev1.NodeLister = new(nodeLister) -// Get retrieves the Node from the indexer for a given workspace and name. -func (s *nodeLister) Get(name string) (*corev1.Node, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(corev1.Resource("nodes"), name) +// NewNodeLister returns a new NodeLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewNodeLister(indexer cache.Indexer) listerscorev1.NodeLister { + return &nodeLister{ + kcplisters.New[*corev1.Node](indexer, corev1.Resource("node")), } - return obj.(*corev1.Node), nil +} + +// nodeScopedLister can list all Nodes inside a workspace +// or scope down to a listerscorev1.NodeNamespaceLister. +type nodeScopedLister struct { + kcplisters.ResourceIndexer[*corev1.Node] } diff --git a/listers/core/v1/persistentvolume.go b/listers/core/v1/persistentvolume.go index cfbe1dfc1..e43cf5d47 100644 --- a/listers/core/v1/persistentvolume.go +++ b/listers/core/v1/persistentvolume.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - corev1listers "k8s.io/client-go/listers/core/v1" + listerscorev1 "k8s.io/client-go/listers/core/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// PersistentVolumeClusterLister can list PersistentVolumes across all workspaces, or scope down to a PersistentVolumeLister for one workspace. +// PersistentVolumeClusterLister helps list PersistentVolumes across all workspaces, +// or scope down to a PersistentVolumeLister for one workspace. // All objects returned here must be treated as read-only. type PersistentVolumeClusterLister interface { // List lists all PersistentVolumes in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*corev1.PersistentVolume, err error) // Cluster returns a lister that can list and get PersistentVolumes in one workspace. - Cluster(clusterName logicalcluster.Name) corev1listers.PersistentVolumeLister + Cluster(clusterName logicalcluster.Name) listerscorev1.PersistentVolumeLister PersistentVolumeClusterListerExpansion } +// persistentVolumeClusterLister implements the PersistentVolumeClusterLister interface. type persistentVolumeClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*corev1.PersistentVolume] } +var _ PersistentVolumeClusterLister = new(persistentVolumeClusterLister) + // NewPersistentVolumeClusterLister returns a new PersistentVolumeClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewPersistentVolumeClusterLister(indexer cache.Indexer) *persistentVolumeClusterLister { - return &persistentVolumeClusterLister{indexer: indexer} -} - -// List lists all PersistentVolumes in the indexer across all workspaces. -func (s *persistentVolumeClusterLister) List(selector labels.Selector) (ret []*corev1.PersistentVolume, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*corev1.PersistentVolume)) - }) - return ret, err +func NewPersistentVolumeClusterLister(indexer cache.Indexer) PersistentVolumeClusterLister { + return &persistentVolumeClusterLister{ + kcplisters.NewCluster[*corev1.PersistentVolume](indexer, corev1.Resource("persistentvolume")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get PersistentVolumes. -func (s *persistentVolumeClusterLister) Cluster(clusterName logicalcluster.Name) corev1listers.PersistentVolumeLister { - return &persistentVolumeLister{indexer: s.indexer, clusterName: clusterName} +func (l *persistentVolumeClusterLister) Cluster(clusterName logicalcluster.Name) listerscorev1.PersistentVolumeLister { + return &persistentVolumeLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// persistentVolumeLister implements the corev1listers.PersistentVolumeLister interface. +// persistentVolumeLister can list all PersistentVolumes inside a workspace +// or scope down to a listerscorev1.PersistentVolumeNamespaceLister for one namespace. type persistentVolumeLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*corev1.PersistentVolume] } -// List lists all PersistentVolumes in the indexer for a workspace. -func (s *persistentVolumeLister) List(selector labels.Selector) (ret []*corev1.PersistentVolume, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*corev1.PersistentVolume)) - }) - return ret, err -} +var _ listerscorev1.PersistentVolumeLister = new(persistentVolumeLister) -// Get retrieves the PersistentVolume from the indexer for a given workspace and name. -func (s *persistentVolumeLister) Get(name string) (*corev1.PersistentVolume, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(corev1.Resource("persistentvolumes"), name) +// NewPersistentVolumeLister returns a new PersistentVolumeLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewPersistentVolumeLister(indexer cache.Indexer) listerscorev1.PersistentVolumeLister { + return &persistentVolumeLister{ + kcplisters.New[*corev1.PersistentVolume](indexer, corev1.Resource("persistentvolume")), } - return obj.(*corev1.PersistentVolume), nil +} + +// persistentVolumeScopedLister can list all PersistentVolumes inside a workspace +// or scope down to a listerscorev1.PersistentVolumeNamespaceLister. +type persistentVolumeScopedLister struct { + kcplisters.ResourceIndexer[*corev1.PersistentVolume] } diff --git a/listers/core/v1/persistentvolumeclaim.go b/listers/core/v1/persistentvolumeclaim.go index 39e87b6bc..7b1e61f1a 100644 --- a/listers/core/v1/persistentvolumeclaim.go +++ b/listers/core/v1/persistentvolumeclaim.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - corev1listers "k8s.io/client-go/listers/core/v1" + listerscorev1 "k8s.io/client-go/listers/core/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// PersistentVolumeClaimClusterLister can list PersistentVolumeClaims across all workspaces, or scope down to a PersistentVolumeClaimLister for one workspace. +// PersistentVolumeClaimClusterLister helps list PersistentVolumeClaims across all workspaces, +// or scope down to a PersistentVolumeClaimLister for one workspace. // All objects returned here must be treated as read-only. type PersistentVolumeClaimClusterLister interface { // List lists all PersistentVolumeClaims in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*corev1.PersistentVolumeClaim, err error) // Cluster returns a lister that can list and get PersistentVolumeClaims in one workspace. - Cluster(clusterName logicalcluster.Name) corev1listers.PersistentVolumeClaimLister + Cluster(clusterName logicalcluster.Name) listerscorev1.PersistentVolumeClaimLister PersistentVolumeClaimClusterListerExpansion } +// persistentVolumeClaimClusterLister implements the PersistentVolumeClaimClusterLister interface. type persistentVolumeClaimClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*corev1.PersistentVolumeClaim] } +var _ PersistentVolumeClaimClusterLister = new(persistentVolumeClaimClusterLister) + // NewPersistentVolumeClaimClusterLister returns a new PersistentVolumeClaimClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewPersistentVolumeClaimClusterLister(indexer cache.Indexer) *persistentVolumeClaimClusterLister { - return &persistentVolumeClaimClusterLister{indexer: indexer} -} - -// List lists all PersistentVolumeClaims in the indexer across all workspaces. -func (s *persistentVolumeClaimClusterLister) List(selector labels.Selector) (ret []*corev1.PersistentVolumeClaim, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*corev1.PersistentVolumeClaim)) - }) - return ret, err +func NewPersistentVolumeClaimClusterLister(indexer cache.Indexer) PersistentVolumeClaimClusterLister { + return &persistentVolumeClaimClusterLister{ + kcplisters.NewCluster[*corev1.PersistentVolumeClaim](indexer, corev1.Resource("persistentvolumeclaim")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get PersistentVolumeClaims. -func (s *persistentVolumeClaimClusterLister) Cluster(clusterName logicalcluster.Name) corev1listers.PersistentVolumeClaimLister { - return &persistentVolumeClaimLister{indexer: s.indexer, clusterName: clusterName} +func (l *persistentVolumeClaimClusterLister) Cluster(clusterName logicalcluster.Name) listerscorev1.PersistentVolumeClaimLister { + return &persistentVolumeClaimLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// persistentVolumeClaimLister implements the corev1listers.PersistentVolumeClaimLister interface. +// persistentVolumeClaimLister can list all PersistentVolumeClaims inside a workspace +// or scope down to a listerscorev1.PersistentVolumeClaimNamespaceLister for one namespace. type persistentVolumeClaimLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*corev1.PersistentVolumeClaim] } -// List lists all PersistentVolumeClaims in the indexer for a workspace. -func (s *persistentVolumeClaimLister) List(selector labels.Selector) (ret []*corev1.PersistentVolumeClaim, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*corev1.PersistentVolumeClaim)) - }) - return ret, err -} +var _ listerscorev1.PersistentVolumeClaimLister = new(persistentVolumeClaimLister) // PersistentVolumeClaims returns an object that can list and get PersistentVolumeClaims in one namespace. -func (s *persistentVolumeClaimLister) PersistentVolumeClaims(namespace string) corev1listers.PersistentVolumeClaimNamespaceLister { - return &persistentVolumeClaimNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *persistentVolumeClaimLister) PersistentVolumeClaims(namespace string) listerscorev1.PersistentVolumeClaimNamespaceLister { + return &persistentVolumeClaimNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// persistentVolumeClaimNamespaceLister implements the corev1listers.PersistentVolumeClaimNamespaceLister interface. +// persistentVolumeClaimNamespaceLister implements the listerscorev1.PersistentVolumeClaimNamespaceLister +// interface. type persistentVolumeClaimNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*corev1.PersistentVolumeClaim] } -// List lists all PersistentVolumeClaims in the indexer for a given workspace and namespace. -func (s *persistentVolumeClaimNamespaceLister) List(selector labels.Selector) (ret []*corev1.PersistentVolumeClaim, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*corev1.PersistentVolumeClaim)) - }) - return ret, err -} +var _ listerscorev1.PersistentVolumeClaimNamespaceLister = new(persistentVolumeClaimNamespaceLister) -// Get retrieves the PersistentVolumeClaim from the indexer for a given workspace, namespace and name. -func (s *persistentVolumeClaimNamespaceLister) Get(name string) (*corev1.PersistentVolumeClaim, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewPersistentVolumeClaimLister returns a new PersistentVolumeClaimLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewPersistentVolumeClaimLister(indexer cache.Indexer) listerscorev1.PersistentVolumeClaimLister { + return &persistentVolumeClaimLister{ + kcplisters.New[*corev1.PersistentVolumeClaim](indexer, corev1.Resource("persistentvolumeclaim")), } - if !exists { - return nil, errors.NewNotFound(corev1.Resource("persistentvolumeclaims"), name) +} + +// persistentVolumeClaimScopedLister can list all PersistentVolumeClaims inside a workspace +// or scope down to a listerscorev1.PersistentVolumeClaimNamespaceLister for one namespace. +type persistentVolumeClaimScopedLister struct { + kcplisters.ResourceIndexer[*corev1.PersistentVolumeClaim] +} + +// PersistentVolumeClaims returns an object that can list and get PersistentVolumeClaims in one namespace. +func (l *persistentVolumeClaimScopedLister) PersistentVolumeClaims(namespace string) listerscorev1.PersistentVolumeClaimLister { + return &persistentVolumeClaimLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*corev1.PersistentVolumeClaim), nil } diff --git a/listers/core/v1/pod.go b/listers/core/v1/pod.go index 9aa53b443..723faf328 100644 --- a/listers/core/v1/pod.go +++ b/listers/core/v1/pod.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - corev1listers "k8s.io/client-go/listers/core/v1" + listerscorev1 "k8s.io/client-go/listers/core/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// PodClusterLister can list Pods across all workspaces, or scope down to a PodLister for one workspace. +// PodClusterLister helps list Pods across all workspaces, +// or scope down to a PodLister for one workspace. // All objects returned here must be treated as read-only. type PodClusterLister interface { // List lists all Pods in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*corev1.Pod, err error) // Cluster returns a lister that can list and get Pods in one workspace. - Cluster(clusterName logicalcluster.Name) corev1listers.PodLister + Cluster(clusterName logicalcluster.Name) listerscorev1.PodLister PodClusterListerExpansion } +// podClusterLister implements the PodClusterLister interface. type podClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*corev1.Pod] } +var _ PodClusterLister = new(podClusterLister) + // NewPodClusterLister returns a new PodClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewPodClusterLister(indexer cache.Indexer) *podClusterLister { - return &podClusterLister{indexer: indexer} -} - -// List lists all Pods in the indexer across all workspaces. -func (s *podClusterLister) List(selector labels.Selector) (ret []*corev1.Pod, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*corev1.Pod)) - }) - return ret, err +func NewPodClusterLister(indexer cache.Indexer) PodClusterLister { + return &podClusterLister{ + kcplisters.NewCluster[*corev1.Pod](indexer, corev1.Resource("pod")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get Pods. -func (s *podClusterLister) Cluster(clusterName logicalcluster.Name) corev1listers.PodLister { - return &podLister{indexer: s.indexer, clusterName: clusterName} +func (l *podClusterLister) Cluster(clusterName logicalcluster.Name) listerscorev1.PodLister { + return &podLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// podLister implements the corev1listers.PodLister interface. +// podLister can list all Pods inside a workspace +// or scope down to a listerscorev1.PodNamespaceLister for one namespace. type podLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*corev1.Pod] } -// List lists all Pods in the indexer for a workspace. -func (s *podLister) List(selector labels.Selector) (ret []*corev1.Pod, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*corev1.Pod)) - }) - return ret, err -} +var _ listerscorev1.PodLister = new(podLister) // Pods returns an object that can list and get Pods in one namespace. -func (s *podLister) Pods(namespace string) corev1listers.PodNamespaceLister { - return &podNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *podLister) Pods(namespace string) listerscorev1.PodNamespaceLister { + return &podNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// podNamespaceLister implements the corev1listers.PodNamespaceLister interface. +// podNamespaceLister implements the listerscorev1.PodNamespaceLister +// interface. type podNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*corev1.Pod] } -// List lists all Pods in the indexer for a given workspace and namespace. -func (s *podNamespaceLister) List(selector labels.Selector) (ret []*corev1.Pod, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*corev1.Pod)) - }) - return ret, err -} +var _ listerscorev1.PodNamespaceLister = new(podNamespaceLister) -// Get retrieves the Pod from the indexer for a given workspace, namespace and name. -func (s *podNamespaceLister) Get(name string) (*corev1.Pod, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewPodLister returns a new PodLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewPodLister(indexer cache.Indexer) listerscorev1.PodLister { + return &podLister{ + kcplisters.New[*corev1.Pod](indexer, corev1.Resource("pod")), } - if !exists { - return nil, errors.NewNotFound(corev1.Resource("pods"), name) +} + +// podScopedLister can list all Pods inside a workspace +// or scope down to a listerscorev1.PodNamespaceLister for one namespace. +type podScopedLister struct { + kcplisters.ResourceIndexer[*corev1.Pod] +} + +// Pods returns an object that can list and get Pods in one namespace. +func (l *podScopedLister) Pods(namespace string) listerscorev1.PodLister { + return &podLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*corev1.Pod), nil } diff --git a/listers/core/v1/podtemplate.go b/listers/core/v1/podtemplate.go index eea7dfb3a..46f8a3ca5 100644 --- a/listers/core/v1/podtemplate.go +++ b/listers/core/v1/podtemplate.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - corev1listers "k8s.io/client-go/listers/core/v1" + listerscorev1 "k8s.io/client-go/listers/core/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// PodTemplateClusterLister can list PodTemplates across all workspaces, or scope down to a PodTemplateLister for one workspace. +// PodTemplateClusterLister helps list PodTemplates across all workspaces, +// or scope down to a PodTemplateLister for one workspace. // All objects returned here must be treated as read-only. type PodTemplateClusterLister interface { // List lists all PodTemplates in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*corev1.PodTemplate, err error) // Cluster returns a lister that can list and get PodTemplates in one workspace. - Cluster(clusterName logicalcluster.Name) corev1listers.PodTemplateLister + Cluster(clusterName logicalcluster.Name) listerscorev1.PodTemplateLister PodTemplateClusterListerExpansion } +// podTemplateClusterLister implements the PodTemplateClusterLister interface. type podTemplateClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*corev1.PodTemplate] } +var _ PodTemplateClusterLister = new(podTemplateClusterLister) + // NewPodTemplateClusterLister returns a new PodTemplateClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewPodTemplateClusterLister(indexer cache.Indexer) *podTemplateClusterLister { - return &podTemplateClusterLister{indexer: indexer} -} - -// List lists all PodTemplates in the indexer across all workspaces. -func (s *podTemplateClusterLister) List(selector labels.Selector) (ret []*corev1.PodTemplate, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*corev1.PodTemplate)) - }) - return ret, err +func NewPodTemplateClusterLister(indexer cache.Indexer) PodTemplateClusterLister { + return &podTemplateClusterLister{ + kcplisters.NewCluster[*corev1.PodTemplate](indexer, corev1.Resource("podtemplate")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get PodTemplates. -func (s *podTemplateClusterLister) Cluster(clusterName logicalcluster.Name) corev1listers.PodTemplateLister { - return &podTemplateLister{indexer: s.indexer, clusterName: clusterName} +func (l *podTemplateClusterLister) Cluster(clusterName logicalcluster.Name) listerscorev1.PodTemplateLister { + return &podTemplateLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// podTemplateLister implements the corev1listers.PodTemplateLister interface. +// podTemplateLister can list all PodTemplates inside a workspace +// or scope down to a listerscorev1.PodTemplateNamespaceLister for one namespace. type podTemplateLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*corev1.PodTemplate] } -// List lists all PodTemplates in the indexer for a workspace. -func (s *podTemplateLister) List(selector labels.Selector) (ret []*corev1.PodTemplate, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*corev1.PodTemplate)) - }) - return ret, err -} +var _ listerscorev1.PodTemplateLister = new(podTemplateLister) // PodTemplates returns an object that can list and get PodTemplates in one namespace. -func (s *podTemplateLister) PodTemplates(namespace string) corev1listers.PodTemplateNamespaceLister { - return &podTemplateNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *podTemplateLister) PodTemplates(namespace string) listerscorev1.PodTemplateNamespaceLister { + return &podTemplateNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// podTemplateNamespaceLister implements the corev1listers.PodTemplateNamespaceLister interface. +// podTemplateNamespaceLister implements the listerscorev1.PodTemplateNamespaceLister +// interface. type podTemplateNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*corev1.PodTemplate] } -// List lists all PodTemplates in the indexer for a given workspace and namespace. -func (s *podTemplateNamespaceLister) List(selector labels.Selector) (ret []*corev1.PodTemplate, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*corev1.PodTemplate)) - }) - return ret, err -} +var _ listerscorev1.PodTemplateNamespaceLister = new(podTemplateNamespaceLister) -// Get retrieves the PodTemplate from the indexer for a given workspace, namespace and name. -func (s *podTemplateNamespaceLister) Get(name string) (*corev1.PodTemplate, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewPodTemplateLister returns a new PodTemplateLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewPodTemplateLister(indexer cache.Indexer) listerscorev1.PodTemplateLister { + return &podTemplateLister{ + kcplisters.New[*corev1.PodTemplate](indexer, corev1.Resource("podtemplate")), } - if !exists { - return nil, errors.NewNotFound(corev1.Resource("podtemplates"), name) +} + +// podTemplateScopedLister can list all PodTemplates inside a workspace +// or scope down to a listerscorev1.PodTemplateNamespaceLister for one namespace. +type podTemplateScopedLister struct { + kcplisters.ResourceIndexer[*corev1.PodTemplate] +} + +// PodTemplates returns an object that can list and get PodTemplates in one namespace. +func (l *podTemplateScopedLister) PodTemplates(namespace string) listerscorev1.PodTemplateLister { + return &podTemplateLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*corev1.PodTemplate), nil } diff --git a/listers/core/v1/replicationcontroller.go b/listers/core/v1/replicationcontroller.go index 7be8b7613..b5f22dce3 100644 --- a/listers/core/v1/replicationcontroller.go +++ b/listers/core/v1/replicationcontroller.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - corev1listers "k8s.io/client-go/listers/core/v1" + listerscorev1 "k8s.io/client-go/listers/core/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ReplicationControllerClusterLister can list ReplicationControllers across all workspaces, or scope down to a ReplicationControllerLister for one workspace. +// ReplicationControllerClusterLister helps list ReplicationControllers across all workspaces, +// or scope down to a ReplicationControllerLister for one workspace. // All objects returned here must be treated as read-only. type ReplicationControllerClusterLister interface { // List lists all ReplicationControllers in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*corev1.ReplicationController, err error) // Cluster returns a lister that can list and get ReplicationControllers in one workspace. - Cluster(clusterName logicalcluster.Name) corev1listers.ReplicationControllerLister + Cluster(clusterName logicalcluster.Name) listerscorev1.ReplicationControllerLister ReplicationControllerClusterListerExpansion } +// replicationControllerClusterLister implements the ReplicationControllerClusterLister interface. type replicationControllerClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*corev1.ReplicationController] } +var _ ReplicationControllerClusterLister = new(replicationControllerClusterLister) + // NewReplicationControllerClusterLister returns a new ReplicationControllerClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewReplicationControllerClusterLister(indexer cache.Indexer) *replicationControllerClusterLister { - return &replicationControllerClusterLister{indexer: indexer} -} - -// List lists all ReplicationControllers in the indexer across all workspaces. -func (s *replicationControllerClusterLister) List(selector labels.Selector) (ret []*corev1.ReplicationController, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*corev1.ReplicationController)) - }) - return ret, err +func NewReplicationControllerClusterLister(indexer cache.Indexer) ReplicationControllerClusterLister { + return &replicationControllerClusterLister{ + kcplisters.NewCluster[*corev1.ReplicationController](indexer, corev1.Resource("replicationcontroller")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ReplicationControllers. -func (s *replicationControllerClusterLister) Cluster(clusterName logicalcluster.Name) corev1listers.ReplicationControllerLister { - return &replicationControllerLister{indexer: s.indexer, clusterName: clusterName} +func (l *replicationControllerClusterLister) Cluster(clusterName logicalcluster.Name) listerscorev1.ReplicationControllerLister { + return &replicationControllerLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// replicationControllerLister implements the corev1listers.ReplicationControllerLister interface. +// replicationControllerLister can list all ReplicationControllers inside a workspace +// or scope down to a listerscorev1.ReplicationControllerNamespaceLister for one namespace. type replicationControllerLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*corev1.ReplicationController] } -// List lists all ReplicationControllers in the indexer for a workspace. -func (s *replicationControllerLister) List(selector labels.Selector) (ret []*corev1.ReplicationController, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*corev1.ReplicationController)) - }) - return ret, err -} +var _ listerscorev1.ReplicationControllerLister = new(replicationControllerLister) // ReplicationControllers returns an object that can list and get ReplicationControllers in one namespace. -func (s *replicationControllerLister) ReplicationControllers(namespace string) corev1listers.ReplicationControllerNamespaceLister { - return &replicationControllerNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *replicationControllerLister) ReplicationControllers(namespace string) listerscorev1.ReplicationControllerNamespaceLister { + return &replicationControllerNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// replicationControllerNamespaceLister implements the corev1listers.ReplicationControllerNamespaceLister interface. +// replicationControllerNamespaceLister implements the listerscorev1.ReplicationControllerNamespaceLister +// interface. type replicationControllerNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*corev1.ReplicationController] } -// List lists all ReplicationControllers in the indexer for a given workspace and namespace. -func (s *replicationControllerNamespaceLister) List(selector labels.Selector) (ret []*corev1.ReplicationController, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*corev1.ReplicationController)) - }) - return ret, err -} +var _ listerscorev1.ReplicationControllerNamespaceLister = new(replicationControllerNamespaceLister) -// Get retrieves the ReplicationController from the indexer for a given workspace, namespace and name. -func (s *replicationControllerNamespaceLister) Get(name string) (*corev1.ReplicationController, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewReplicationControllerLister returns a new ReplicationControllerLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewReplicationControllerLister(indexer cache.Indexer) listerscorev1.ReplicationControllerLister { + return &replicationControllerLister{ + kcplisters.New[*corev1.ReplicationController](indexer, corev1.Resource("replicationcontroller")), } - if !exists { - return nil, errors.NewNotFound(corev1.Resource("replicationcontrollers"), name) +} + +// replicationControllerScopedLister can list all ReplicationControllers inside a workspace +// or scope down to a listerscorev1.ReplicationControllerNamespaceLister for one namespace. +type replicationControllerScopedLister struct { + kcplisters.ResourceIndexer[*corev1.ReplicationController] +} + +// ReplicationControllers returns an object that can list and get ReplicationControllers in one namespace. +func (l *replicationControllerScopedLister) ReplicationControllers(namespace string) listerscorev1.ReplicationControllerLister { + return &replicationControllerLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*corev1.ReplicationController), nil } diff --git a/listers/core/v1/replicationcontroller_expansion.go b/listers/core/v1/replicationcontroller_expansion.go index 31a116a09..46d2e1309 100644 --- a/listers/core/v1/replicationcontroller_expansion.go +++ b/listers/core/v1/replicationcontroller_expansion.go @@ -19,7 +19,7 @@ package v1 import ( "fmt" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/labels" ) diff --git a/listers/core/v1/resourcequota.go b/listers/core/v1/resourcequota.go index 279440eb0..540e78540 100644 --- a/listers/core/v1/resourcequota.go +++ b/listers/core/v1/resourcequota.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - corev1listers "k8s.io/client-go/listers/core/v1" + listerscorev1 "k8s.io/client-go/listers/core/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ResourceQuotaClusterLister can list ResourceQuotas across all workspaces, or scope down to a ResourceQuotaLister for one workspace. +// ResourceQuotaClusterLister helps list ResourceQuotas across all workspaces, +// or scope down to a ResourceQuotaLister for one workspace. // All objects returned here must be treated as read-only. type ResourceQuotaClusterLister interface { // List lists all ResourceQuotas in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*corev1.ResourceQuota, err error) // Cluster returns a lister that can list and get ResourceQuotas in one workspace. - Cluster(clusterName logicalcluster.Name) corev1listers.ResourceQuotaLister + Cluster(clusterName logicalcluster.Name) listerscorev1.ResourceQuotaLister ResourceQuotaClusterListerExpansion } +// resourceQuotaClusterLister implements the ResourceQuotaClusterLister interface. type resourceQuotaClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*corev1.ResourceQuota] } +var _ ResourceQuotaClusterLister = new(resourceQuotaClusterLister) + // NewResourceQuotaClusterLister returns a new ResourceQuotaClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewResourceQuotaClusterLister(indexer cache.Indexer) *resourceQuotaClusterLister { - return &resourceQuotaClusterLister{indexer: indexer} -} - -// List lists all ResourceQuotas in the indexer across all workspaces. -func (s *resourceQuotaClusterLister) List(selector labels.Selector) (ret []*corev1.ResourceQuota, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*corev1.ResourceQuota)) - }) - return ret, err +func NewResourceQuotaClusterLister(indexer cache.Indexer) ResourceQuotaClusterLister { + return &resourceQuotaClusterLister{ + kcplisters.NewCluster[*corev1.ResourceQuota](indexer, corev1.Resource("resourcequota")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ResourceQuotas. -func (s *resourceQuotaClusterLister) Cluster(clusterName logicalcluster.Name) corev1listers.ResourceQuotaLister { - return &resourceQuotaLister{indexer: s.indexer, clusterName: clusterName} +func (l *resourceQuotaClusterLister) Cluster(clusterName logicalcluster.Name) listerscorev1.ResourceQuotaLister { + return &resourceQuotaLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// resourceQuotaLister implements the corev1listers.ResourceQuotaLister interface. +// resourceQuotaLister can list all ResourceQuotas inside a workspace +// or scope down to a listerscorev1.ResourceQuotaNamespaceLister for one namespace. type resourceQuotaLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*corev1.ResourceQuota] } -// List lists all ResourceQuotas in the indexer for a workspace. -func (s *resourceQuotaLister) List(selector labels.Selector) (ret []*corev1.ResourceQuota, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*corev1.ResourceQuota)) - }) - return ret, err -} +var _ listerscorev1.ResourceQuotaLister = new(resourceQuotaLister) // ResourceQuotas returns an object that can list and get ResourceQuotas in one namespace. -func (s *resourceQuotaLister) ResourceQuotas(namespace string) corev1listers.ResourceQuotaNamespaceLister { - return &resourceQuotaNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *resourceQuotaLister) ResourceQuotas(namespace string) listerscorev1.ResourceQuotaNamespaceLister { + return &resourceQuotaNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// resourceQuotaNamespaceLister implements the corev1listers.ResourceQuotaNamespaceLister interface. +// resourceQuotaNamespaceLister implements the listerscorev1.ResourceQuotaNamespaceLister +// interface. type resourceQuotaNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*corev1.ResourceQuota] } -// List lists all ResourceQuotas in the indexer for a given workspace and namespace. -func (s *resourceQuotaNamespaceLister) List(selector labels.Selector) (ret []*corev1.ResourceQuota, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*corev1.ResourceQuota)) - }) - return ret, err -} +var _ listerscorev1.ResourceQuotaNamespaceLister = new(resourceQuotaNamespaceLister) -// Get retrieves the ResourceQuota from the indexer for a given workspace, namespace and name. -func (s *resourceQuotaNamespaceLister) Get(name string) (*corev1.ResourceQuota, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewResourceQuotaLister returns a new ResourceQuotaLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewResourceQuotaLister(indexer cache.Indexer) listerscorev1.ResourceQuotaLister { + return &resourceQuotaLister{ + kcplisters.New[*corev1.ResourceQuota](indexer, corev1.Resource("resourcequota")), } - if !exists { - return nil, errors.NewNotFound(corev1.Resource("resourcequotas"), name) +} + +// resourceQuotaScopedLister can list all ResourceQuotas inside a workspace +// or scope down to a listerscorev1.ResourceQuotaNamespaceLister for one namespace. +type resourceQuotaScopedLister struct { + kcplisters.ResourceIndexer[*corev1.ResourceQuota] +} + +// ResourceQuotas returns an object that can list and get ResourceQuotas in one namespace. +func (l *resourceQuotaScopedLister) ResourceQuotas(namespace string) listerscorev1.ResourceQuotaLister { + return &resourceQuotaLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*corev1.ResourceQuota), nil } diff --git a/listers/core/v1/secret.go b/listers/core/v1/secret.go index 1e2ed2e21..8f7f8630f 100644 --- a/listers/core/v1/secret.go +++ b/listers/core/v1/secret.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - corev1listers "k8s.io/client-go/listers/core/v1" + listerscorev1 "k8s.io/client-go/listers/core/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// SecretClusterLister can list Secrets across all workspaces, or scope down to a SecretLister for one workspace. +// SecretClusterLister helps list Secrets across all workspaces, +// or scope down to a SecretLister for one workspace. // All objects returned here must be treated as read-only. type SecretClusterLister interface { // List lists all Secrets in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*corev1.Secret, err error) // Cluster returns a lister that can list and get Secrets in one workspace. - Cluster(clusterName logicalcluster.Name) corev1listers.SecretLister + Cluster(clusterName logicalcluster.Name) listerscorev1.SecretLister SecretClusterListerExpansion } +// secretClusterLister implements the SecretClusterLister interface. type secretClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*corev1.Secret] } +var _ SecretClusterLister = new(secretClusterLister) + // NewSecretClusterLister returns a new SecretClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewSecretClusterLister(indexer cache.Indexer) *secretClusterLister { - return &secretClusterLister{indexer: indexer} -} - -// List lists all Secrets in the indexer across all workspaces. -func (s *secretClusterLister) List(selector labels.Selector) (ret []*corev1.Secret, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*corev1.Secret)) - }) - return ret, err +func NewSecretClusterLister(indexer cache.Indexer) SecretClusterLister { + return &secretClusterLister{ + kcplisters.NewCluster[*corev1.Secret](indexer, corev1.Resource("secret")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get Secrets. -func (s *secretClusterLister) Cluster(clusterName logicalcluster.Name) corev1listers.SecretLister { - return &secretLister{indexer: s.indexer, clusterName: clusterName} +func (l *secretClusterLister) Cluster(clusterName logicalcluster.Name) listerscorev1.SecretLister { + return &secretLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// secretLister implements the corev1listers.SecretLister interface. +// secretLister can list all Secrets inside a workspace +// or scope down to a listerscorev1.SecretNamespaceLister for one namespace. type secretLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*corev1.Secret] } -// List lists all Secrets in the indexer for a workspace. -func (s *secretLister) List(selector labels.Selector) (ret []*corev1.Secret, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*corev1.Secret)) - }) - return ret, err -} +var _ listerscorev1.SecretLister = new(secretLister) // Secrets returns an object that can list and get Secrets in one namespace. -func (s *secretLister) Secrets(namespace string) corev1listers.SecretNamespaceLister { - return &secretNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *secretLister) Secrets(namespace string) listerscorev1.SecretNamespaceLister { + return &secretNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// secretNamespaceLister implements the corev1listers.SecretNamespaceLister interface. +// secretNamespaceLister implements the listerscorev1.SecretNamespaceLister +// interface. type secretNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*corev1.Secret] } -// List lists all Secrets in the indexer for a given workspace and namespace. -func (s *secretNamespaceLister) List(selector labels.Selector) (ret []*corev1.Secret, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*corev1.Secret)) - }) - return ret, err -} +var _ listerscorev1.SecretNamespaceLister = new(secretNamespaceLister) -// Get retrieves the Secret from the indexer for a given workspace, namespace and name. -func (s *secretNamespaceLister) Get(name string) (*corev1.Secret, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewSecretLister returns a new SecretLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewSecretLister(indexer cache.Indexer) listerscorev1.SecretLister { + return &secretLister{ + kcplisters.New[*corev1.Secret](indexer, corev1.Resource("secret")), } - if !exists { - return nil, errors.NewNotFound(corev1.Resource("secrets"), name) +} + +// secretScopedLister can list all Secrets inside a workspace +// or scope down to a listerscorev1.SecretNamespaceLister for one namespace. +type secretScopedLister struct { + kcplisters.ResourceIndexer[*corev1.Secret] +} + +// Secrets returns an object that can list and get Secrets in one namespace. +func (l *secretScopedLister) Secrets(namespace string) listerscorev1.SecretLister { + return &secretLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*corev1.Secret), nil } diff --git a/listers/core/v1/service.go b/listers/core/v1/service.go index 754e1de1c..17fb08a4d 100644 --- a/listers/core/v1/service.go +++ b/listers/core/v1/service.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - corev1listers "k8s.io/client-go/listers/core/v1" + listerscorev1 "k8s.io/client-go/listers/core/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ServiceClusterLister can list Services across all workspaces, or scope down to a ServiceLister for one workspace. +// ServiceClusterLister helps list Services across all workspaces, +// or scope down to a ServiceLister for one workspace. // All objects returned here must be treated as read-only. type ServiceClusterLister interface { // List lists all Services in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*corev1.Service, err error) // Cluster returns a lister that can list and get Services in one workspace. - Cluster(clusterName logicalcluster.Name) corev1listers.ServiceLister + Cluster(clusterName logicalcluster.Name) listerscorev1.ServiceLister ServiceClusterListerExpansion } +// serviceClusterLister implements the ServiceClusterLister interface. type serviceClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*corev1.Service] } +var _ ServiceClusterLister = new(serviceClusterLister) + // NewServiceClusterLister returns a new ServiceClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewServiceClusterLister(indexer cache.Indexer) *serviceClusterLister { - return &serviceClusterLister{indexer: indexer} -} - -// List lists all Services in the indexer across all workspaces. -func (s *serviceClusterLister) List(selector labels.Selector) (ret []*corev1.Service, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*corev1.Service)) - }) - return ret, err +func NewServiceClusterLister(indexer cache.Indexer) ServiceClusterLister { + return &serviceClusterLister{ + kcplisters.NewCluster[*corev1.Service](indexer, corev1.Resource("service")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get Services. -func (s *serviceClusterLister) Cluster(clusterName logicalcluster.Name) corev1listers.ServiceLister { - return &serviceLister{indexer: s.indexer, clusterName: clusterName} +func (l *serviceClusterLister) Cluster(clusterName logicalcluster.Name) listerscorev1.ServiceLister { + return &serviceLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// serviceLister implements the corev1listers.ServiceLister interface. +// serviceLister can list all Services inside a workspace +// or scope down to a listerscorev1.ServiceNamespaceLister for one namespace. type serviceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*corev1.Service] } -// List lists all Services in the indexer for a workspace. -func (s *serviceLister) List(selector labels.Selector) (ret []*corev1.Service, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*corev1.Service)) - }) - return ret, err -} +var _ listerscorev1.ServiceLister = new(serviceLister) // Services returns an object that can list and get Services in one namespace. -func (s *serviceLister) Services(namespace string) corev1listers.ServiceNamespaceLister { - return &serviceNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *serviceLister) Services(namespace string) listerscorev1.ServiceNamespaceLister { + return &serviceNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// serviceNamespaceLister implements the corev1listers.ServiceNamespaceLister interface. +// serviceNamespaceLister implements the listerscorev1.ServiceNamespaceLister +// interface. type serviceNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*corev1.Service] } -// List lists all Services in the indexer for a given workspace and namespace. -func (s *serviceNamespaceLister) List(selector labels.Selector) (ret []*corev1.Service, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*corev1.Service)) - }) - return ret, err -} +var _ listerscorev1.ServiceNamespaceLister = new(serviceNamespaceLister) -// Get retrieves the Service from the indexer for a given workspace, namespace and name. -func (s *serviceNamespaceLister) Get(name string) (*corev1.Service, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewServiceLister returns a new ServiceLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewServiceLister(indexer cache.Indexer) listerscorev1.ServiceLister { + return &serviceLister{ + kcplisters.New[*corev1.Service](indexer, corev1.Resource("service")), } - if !exists { - return nil, errors.NewNotFound(corev1.Resource("services"), name) +} + +// serviceScopedLister can list all Services inside a workspace +// or scope down to a listerscorev1.ServiceNamespaceLister for one namespace. +type serviceScopedLister struct { + kcplisters.ResourceIndexer[*corev1.Service] +} + +// Services returns an object that can list and get Services in one namespace. +func (l *serviceScopedLister) Services(namespace string) listerscorev1.ServiceLister { + return &serviceLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*corev1.Service), nil } diff --git a/listers/core/v1/serviceaccount.go b/listers/core/v1/serviceaccount.go index 661c4d097..08eeb1fb2 100644 --- a/listers/core/v1/serviceaccount.go +++ b/listers/core/v1/serviceaccount.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - corev1listers "k8s.io/client-go/listers/core/v1" + listerscorev1 "k8s.io/client-go/listers/core/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ServiceAccountClusterLister can list ServiceAccounts across all workspaces, or scope down to a ServiceAccountLister for one workspace. +// ServiceAccountClusterLister helps list ServiceAccounts across all workspaces, +// or scope down to a ServiceAccountLister for one workspace. // All objects returned here must be treated as read-only. type ServiceAccountClusterLister interface { // List lists all ServiceAccounts in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*corev1.ServiceAccount, err error) // Cluster returns a lister that can list and get ServiceAccounts in one workspace. - Cluster(clusterName logicalcluster.Name) corev1listers.ServiceAccountLister + Cluster(clusterName logicalcluster.Name) listerscorev1.ServiceAccountLister ServiceAccountClusterListerExpansion } +// serviceAccountClusterLister implements the ServiceAccountClusterLister interface. type serviceAccountClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*corev1.ServiceAccount] } +var _ ServiceAccountClusterLister = new(serviceAccountClusterLister) + // NewServiceAccountClusterLister returns a new ServiceAccountClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewServiceAccountClusterLister(indexer cache.Indexer) *serviceAccountClusterLister { - return &serviceAccountClusterLister{indexer: indexer} -} - -// List lists all ServiceAccounts in the indexer across all workspaces. -func (s *serviceAccountClusterLister) List(selector labels.Selector) (ret []*corev1.ServiceAccount, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*corev1.ServiceAccount)) - }) - return ret, err +func NewServiceAccountClusterLister(indexer cache.Indexer) ServiceAccountClusterLister { + return &serviceAccountClusterLister{ + kcplisters.NewCluster[*corev1.ServiceAccount](indexer, corev1.Resource("serviceaccount")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ServiceAccounts. -func (s *serviceAccountClusterLister) Cluster(clusterName logicalcluster.Name) corev1listers.ServiceAccountLister { - return &serviceAccountLister{indexer: s.indexer, clusterName: clusterName} +func (l *serviceAccountClusterLister) Cluster(clusterName logicalcluster.Name) listerscorev1.ServiceAccountLister { + return &serviceAccountLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// serviceAccountLister implements the corev1listers.ServiceAccountLister interface. +// serviceAccountLister can list all ServiceAccounts inside a workspace +// or scope down to a listerscorev1.ServiceAccountNamespaceLister for one namespace. type serviceAccountLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*corev1.ServiceAccount] } -// List lists all ServiceAccounts in the indexer for a workspace. -func (s *serviceAccountLister) List(selector labels.Selector) (ret []*corev1.ServiceAccount, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*corev1.ServiceAccount)) - }) - return ret, err -} +var _ listerscorev1.ServiceAccountLister = new(serviceAccountLister) // ServiceAccounts returns an object that can list and get ServiceAccounts in one namespace. -func (s *serviceAccountLister) ServiceAccounts(namespace string) corev1listers.ServiceAccountNamespaceLister { - return &serviceAccountNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *serviceAccountLister) ServiceAccounts(namespace string) listerscorev1.ServiceAccountNamespaceLister { + return &serviceAccountNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// serviceAccountNamespaceLister implements the corev1listers.ServiceAccountNamespaceLister interface. +// serviceAccountNamespaceLister implements the listerscorev1.ServiceAccountNamespaceLister +// interface. type serviceAccountNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*corev1.ServiceAccount] } -// List lists all ServiceAccounts in the indexer for a given workspace and namespace. -func (s *serviceAccountNamespaceLister) List(selector labels.Selector) (ret []*corev1.ServiceAccount, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*corev1.ServiceAccount)) - }) - return ret, err -} +var _ listerscorev1.ServiceAccountNamespaceLister = new(serviceAccountNamespaceLister) -// Get retrieves the ServiceAccount from the indexer for a given workspace, namespace and name. -func (s *serviceAccountNamespaceLister) Get(name string) (*corev1.ServiceAccount, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewServiceAccountLister returns a new ServiceAccountLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewServiceAccountLister(indexer cache.Indexer) listerscorev1.ServiceAccountLister { + return &serviceAccountLister{ + kcplisters.New[*corev1.ServiceAccount](indexer, corev1.Resource("serviceaccount")), } - if !exists { - return nil, errors.NewNotFound(corev1.Resource("serviceaccounts"), name) +} + +// serviceAccountScopedLister can list all ServiceAccounts inside a workspace +// or scope down to a listerscorev1.ServiceAccountNamespaceLister for one namespace. +type serviceAccountScopedLister struct { + kcplisters.ResourceIndexer[*corev1.ServiceAccount] +} + +// ServiceAccounts returns an object that can list and get ServiceAccounts in one namespace. +func (l *serviceAccountScopedLister) ServiceAccounts(namespace string) listerscorev1.ServiceAccountLister { + return &serviceAccountLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*corev1.ServiceAccount), nil } diff --git a/listers/discovery/v1/endpointslice.go b/listers/discovery/v1/endpointslice.go index da0c4ab71..8a183be70 100644 --- a/listers/discovery/v1/endpointslice.go +++ b/listers/discovery/v1/endpointslice.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" discoveryv1 "k8s.io/api/discovery/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - discoveryv1listers "k8s.io/client-go/listers/discovery/v1" + listersdiscoveryv1 "k8s.io/client-go/listers/discovery/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// EndpointSliceClusterLister can list EndpointSlices across all workspaces, or scope down to a EndpointSliceLister for one workspace. +// EndpointSliceClusterLister helps list EndpointSlices across all workspaces, +// or scope down to a EndpointSliceLister for one workspace. // All objects returned here must be treated as read-only. type EndpointSliceClusterLister interface { // List lists all EndpointSlices in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*discoveryv1.EndpointSlice, err error) // Cluster returns a lister that can list and get EndpointSlices in one workspace. - Cluster(clusterName logicalcluster.Name) discoveryv1listers.EndpointSliceLister + Cluster(clusterName logicalcluster.Name) listersdiscoveryv1.EndpointSliceLister EndpointSliceClusterListerExpansion } +// endpointSliceClusterLister implements the EndpointSliceClusterLister interface. type endpointSliceClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*discoveryv1.EndpointSlice] } +var _ EndpointSliceClusterLister = new(endpointSliceClusterLister) + // NewEndpointSliceClusterLister returns a new EndpointSliceClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewEndpointSliceClusterLister(indexer cache.Indexer) *endpointSliceClusterLister { - return &endpointSliceClusterLister{indexer: indexer} -} - -// List lists all EndpointSlices in the indexer across all workspaces. -func (s *endpointSliceClusterLister) List(selector labels.Selector) (ret []*discoveryv1.EndpointSlice, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*discoveryv1.EndpointSlice)) - }) - return ret, err +func NewEndpointSliceClusterLister(indexer cache.Indexer) EndpointSliceClusterLister { + return &endpointSliceClusterLister{ + kcplisters.NewCluster[*discoveryv1.EndpointSlice](indexer, discoveryv1.Resource("endpointslice")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get EndpointSlices. -func (s *endpointSliceClusterLister) Cluster(clusterName logicalcluster.Name) discoveryv1listers.EndpointSliceLister { - return &endpointSliceLister{indexer: s.indexer, clusterName: clusterName} +func (l *endpointSliceClusterLister) Cluster(clusterName logicalcluster.Name) listersdiscoveryv1.EndpointSliceLister { + return &endpointSliceLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// endpointSliceLister implements the discoveryv1listers.EndpointSliceLister interface. +// endpointSliceLister can list all EndpointSlices inside a workspace +// or scope down to a listersdiscoveryv1.EndpointSliceNamespaceLister for one namespace. type endpointSliceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*discoveryv1.EndpointSlice] } -// List lists all EndpointSlices in the indexer for a workspace. -func (s *endpointSliceLister) List(selector labels.Selector) (ret []*discoveryv1.EndpointSlice, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*discoveryv1.EndpointSlice)) - }) - return ret, err -} +var _ listersdiscoveryv1.EndpointSliceLister = new(endpointSliceLister) // EndpointSlices returns an object that can list and get EndpointSlices in one namespace. -func (s *endpointSliceLister) EndpointSlices(namespace string) discoveryv1listers.EndpointSliceNamespaceLister { - return &endpointSliceNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *endpointSliceLister) EndpointSlices(namespace string) listersdiscoveryv1.EndpointSliceNamespaceLister { + return &endpointSliceNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// endpointSliceNamespaceLister implements the discoveryv1listers.EndpointSliceNamespaceLister interface. +// endpointSliceNamespaceLister implements the listersdiscoveryv1.EndpointSliceNamespaceLister +// interface. type endpointSliceNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*discoveryv1.EndpointSlice] } -// List lists all EndpointSlices in the indexer for a given workspace and namespace. -func (s *endpointSliceNamespaceLister) List(selector labels.Selector) (ret []*discoveryv1.EndpointSlice, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*discoveryv1.EndpointSlice)) - }) - return ret, err -} +var _ listersdiscoveryv1.EndpointSliceNamespaceLister = new(endpointSliceNamespaceLister) -// Get retrieves the EndpointSlice from the indexer for a given workspace, namespace and name. -func (s *endpointSliceNamespaceLister) Get(name string) (*discoveryv1.EndpointSlice, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewEndpointSliceLister returns a new EndpointSliceLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewEndpointSliceLister(indexer cache.Indexer) listersdiscoveryv1.EndpointSliceLister { + return &endpointSliceLister{ + kcplisters.New[*discoveryv1.EndpointSlice](indexer, discoveryv1.Resource("endpointslice")), } - if !exists { - return nil, errors.NewNotFound(discoveryv1.Resource("endpointslices"), name) +} + +// endpointSliceScopedLister can list all EndpointSlices inside a workspace +// or scope down to a listersdiscoveryv1.EndpointSliceNamespaceLister for one namespace. +type endpointSliceScopedLister struct { + kcplisters.ResourceIndexer[*discoveryv1.EndpointSlice] +} + +// EndpointSlices returns an object that can list and get EndpointSlices in one namespace. +func (l *endpointSliceScopedLister) EndpointSlices(namespace string) listersdiscoveryv1.EndpointSliceLister { + return &endpointSliceLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*discoveryv1.EndpointSlice), nil } diff --git a/listers/discovery/v1/expansion_generated.go b/listers/discovery/v1/expansion_generated.go new file mode 100644 index 000000000..b6a0c6377 --- /dev/null +++ b/listers/discovery/v1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1 diff --git a/listers/discovery/v1beta1/endpointslice.go b/listers/discovery/v1beta1/endpointslice.go index b3721744d..a767f2722 100644 --- a/listers/discovery/v1beta1/endpointslice.go +++ b/listers/discovery/v1beta1/endpointslice.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" discoveryv1beta1 "k8s.io/api/discovery/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - discoveryv1beta1listers "k8s.io/client-go/listers/discovery/v1beta1" + listersdiscoveryv1beta1 "k8s.io/client-go/listers/discovery/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// EndpointSliceClusterLister can list EndpointSlices across all workspaces, or scope down to a EndpointSliceLister for one workspace. +// EndpointSliceClusterLister helps list EndpointSlices across all workspaces, +// or scope down to a EndpointSliceLister for one workspace. // All objects returned here must be treated as read-only. type EndpointSliceClusterLister interface { // List lists all EndpointSlices in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*discoveryv1beta1.EndpointSlice, err error) // Cluster returns a lister that can list and get EndpointSlices in one workspace. - Cluster(clusterName logicalcluster.Name) discoveryv1beta1listers.EndpointSliceLister + Cluster(clusterName logicalcluster.Name) listersdiscoveryv1beta1.EndpointSliceLister EndpointSliceClusterListerExpansion } +// endpointSliceClusterLister implements the EndpointSliceClusterLister interface. type endpointSliceClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*discoveryv1beta1.EndpointSlice] } +var _ EndpointSliceClusterLister = new(endpointSliceClusterLister) + // NewEndpointSliceClusterLister returns a new EndpointSliceClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewEndpointSliceClusterLister(indexer cache.Indexer) *endpointSliceClusterLister { - return &endpointSliceClusterLister{indexer: indexer} -} - -// List lists all EndpointSlices in the indexer across all workspaces. -func (s *endpointSliceClusterLister) List(selector labels.Selector) (ret []*discoveryv1beta1.EndpointSlice, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*discoveryv1beta1.EndpointSlice)) - }) - return ret, err +func NewEndpointSliceClusterLister(indexer cache.Indexer) EndpointSliceClusterLister { + return &endpointSliceClusterLister{ + kcplisters.NewCluster[*discoveryv1beta1.EndpointSlice](indexer, discoveryv1beta1.Resource("endpointslice")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get EndpointSlices. -func (s *endpointSliceClusterLister) Cluster(clusterName logicalcluster.Name) discoveryv1beta1listers.EndpointSliceLister { - return &endpointSliceLister{indexer: s.indexer, clusterName: clusterName} +func (l *endpointSliceClusterLister) Cluster(clusterName logicalcluster.Name) listersdiscoveryv1beta1.EndpointSliceLister { + return &endpointSliceLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// endpointSliceLister implements the discoveryv1beta1listers.EndpointSliceLister interface. +// endpointSliceLister can list all EndpointSlices inside a workspace +// or scope down to a listersdiscoveryv1beta1.EndpointSliceNamespaceLister for one namespace. type endpointSliceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*discoveryv1beta1.EndpointSlice] } -// List lists all EndpointSlices in the indexer for a workspace. -func (s *endpointSliceLister) List(selector labels.Selector) (ret []*discoveryv1beta1.EndpointSlice, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*discoveryv1beta1.EndpointSlice)) - }) - return ret, err -} +var _ listersdiscoveryv1beta1.EndpointSliceLister = new(endpointSliceLister) // EndpointSlices returns an object that can list and get EndpointSlices in one namespace. -func (s *endpointSliceLister) EndpointSlices(namespace string) discoveryv1beta1listers.EndpointSliceNamespaceLister { - return &endpointSliceNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *endpointSliceLister) EndpointSlices(namespace string) listersdiscoveryv1beta1.EndpointSliceNamespaceLister { + return &endpointSliceNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// endpointSliceNamespaceLister implements the discoveryv1beta1listers.EndpointSliceNamespaceLister interface. +// endpointSliceNamespaceLister implements the listersdiscoveryv1beta1.EndpointSliceNamespaceLister +// interface. type endpointSliceNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*discoveryv1beta1.EndpointSlice] } -// List lists all EndpointSlices in the indexer for a given workspace and namespace. -func (s *endpointSliceNamespaceLister) List(selector labels.Selector) (ret []*discoveryv1beta1.EndpointSlice, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*discoveryv1beta1.EndpointSlice)) - }) - return ret, err -} +var _ listersdiscoveryv1beta1.EndpointSliceNamespaceLister = new(endpointSliceNamespaceLister) -// Get retrieves the EndpointSlice from the indexer for a given workspace, namespace and name. -func (s *endpointSliceNamespaceLister) Get(name string) (*discoveryv1beta1.EndpointSlice, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewEndpointSliceLister returns a new EndpointSliceLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewEndpointSliceLister(indexer cache.Indexer) listersdiscoveryv1beta1.EndpointSliceLister { + return &endpointSliceLister{ + kcplisters.New[*discoveryv1beta1.EndpointSlice](indexer, discoveryv1beta1.Resource("endpointslice")), } - if !exists { - return nil, errors.NewNotFound(discoveryv1beta1.Resource("endpointslices"), name) +} + +// endpointSliceScopedLister can list all EndpointSlices inside a workspace +// or scope down to a listersdiscoveryv1beta1.EndpointSliceNamespaceLister for one namespace. +type endpointSliceScopedLister struct { + kcplisters.ResourceIndexer[*discoveryv1beta1.EndpointSlice] +} + +// EndpointSlices returns an object that can list and get EndpointSlices in one namespace. +func (l *endpointSliceScopedLister) EndpointSlices(namespace string) listersdiscoveryv1beta1.EndpointSliceLister { + return &endpointSliceLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*discoveryv1beta1.EndpointSlice), nil } diff --git a/listers/discovery/v1beta1/expansion_generated.go b/listers/discovery/v1beta1/expansion_generated.go new file mode 100644 index 000000000..23cac805b --- /dev/null +++ b/listers/discovery/v1beta1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1beta1 diff --git a/listers/events/v1/event.go b/listers/events/v1/event.go index a3c9a48c0..e924b419c 100644 --- a/listers/events/v1/event.go +++ b/listers/events/v1/event.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" eventsv1 "k8s.io/api/events/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - eventsv1listers "k8s.io/client-go/listers/events/v1" + listerseventsv1 "k8s.io/client-go/listers/events/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// EventClusterLister can list Events across all workspaces, or scope down to a EventLister for one workspace. +// EventClusterLister helps list Events across all workspaces, +// or scope down to a EventLister for one workspace. // All objects returned here must be treated as read-only. type EventClusterLister interface { // List lists all Events in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*eventsv1.Event, err error) // Cluster returns a lister that can list and get Events in one workspace. - Cluster(clusterName logicalcluster.Name) eventsv1listers.EventLister + Cluster(clusterName logicalcluster.Name) listerseventsv1.EventLister EventClusterListerExpansion } +// eventClusterLister implements the EventClusterLister interface. type eventClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*eventsv1.Event] } +var _ EventClusterLister = new(eventClusterLister) + // NewEventClusterLister returns a new EventClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewEventClusterLister(indexer cache.Indexer) *eventClusterLister { - return &eventClusterLister{indexer: indexer} -} - -// List lists all Events in the indexer across all workspaces. -func (s *eventClusterLister) List(selector labels.Selector) (ret []*eventsv1.Event, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*eventsv1.Event)) - }) - return ret, err +func NewEventClusterLister(indexer cache.Indexer) EventClusterLister { + return &eventClusterLister{ + kcplisters.NewCluster[*eventsv1.Event](indexer, eventsv1.Resource("event")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get Events. -func (s *eventClusterLister) Cluster(clusterName logicalcluster.Name) eventsv1listers.EventLister { - return &eventLister{indexer: s.indexer, clusterName: clusterName} +func (l *eventClusterLister) Cluster(clusterName logicalcluster.Name) listerseventsv1.EventLister { + return &eventLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// eventLister implements the eventsv1listers.EventLister interface. +// eventLister can list all Events inside a workspace +// or scope down to a listerseventsv1.EventNamespaceLister for one namespace. type eventLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*eventsv1.Event] } -// List lists all Events in the indexer for a workspace. -func (s *eventLister) List(selector labels.Selector) (ret []*eventsv1.Event, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*eventsv1.Event)) - }) - return ret, err -} +var _ listerseventsv1.EventLister = new(eventLister) // Events returns an object that can list and get Events in one namespace. -func (s *eventLister) Events(namespace string) eventsv1listers.EventNamespaceLister { - return &eventNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *eventLister) Events(namespace string) listerseventsv1.EventNamespaceLister { + return &eventNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// eventNamespaceLister implements the eventsv1listers.EventNamespaceLister interface. +// eventNamespaceLister implements the listerseventsv1.EventNamespaceLister +// interface. type eventNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*eventsv1.Event] } -// List lists all Events in the indexer for a given workspace and namespace. -func (s *eventNamespaceLister) List(selector labels.Selector) (ret []*eventsv1.Event, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*eventsv1.Event)) - }) - return ret, err -} +var _ listerseventsv1.EventNamespaceLister = new(eventNamespaceLister) -// Get retrieves the Event from the indexer for a given workspace, namespace and name. -func (s *eventNamespaceLister) Get(name string) (*eventsv1.Event, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewEventLister returns a new EventLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewEventLister(indexer cache.Indexer) listerseventsv1.EventLister { + return &eventLister{ + kcplisters.New[*eventsv1.Event](indexer, eventsv1.Resource("event")), } - if !exists { - return nil, errors.NewNotFound(eventsv1.Resource("events"), name) +} + +// eventScopedLister can list all Events inside a workspace +// or scope down to a listerseventsv1.EventNamespaceLister for one namespace. +type eventScopedLister struct { + kcplisters.ResourceIndexer[*eventsv1.Event] +} + +// Events returns an object that can list and get Events in one namespace. +func (l *eventScopedLister) Events(namespace string) listerseventsv1.EventLister { + return &eventLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*eventsv1.Event), nil } diff --git a/listers/events/v1/expansion_generated.go b/listers/events/v1/expansion_generated.go new file mode 100644 index 000000000..b6a0c6377 --- /dev/null +++ b/listers/events/v1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1 diff --git a/listers/events/v1beta1/event.go b/listers/events/v1beta1/event.go index 647f1f624..d65fe47ed 100644 --- a/listers/events/v1beta1/event.go +++ b/listers/events/v1beta1/event.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" eventsv1beta1 "k8s.io/api/events/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - eventsv1beta1listers "k8s.io/client-go/listers/events/v1beta1" + listerseventsv1beta1 "k8s.io/client-go/listers/events/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// EventClusterLister can list Events across all workspaces, or scope down to a EventLister for one workspace. +// EventClusterLister helps list Events across all workspaces, +// or scope down to a EventLister for one workspace. // All objects returned here must be treated as read-only. type EventClusterLister interface { // List lists all Events in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*eventsv1beta1.Event, err error) // Cluster returns a lister that can list and get Events in one workspace. - Cluster(clusterName logicalcluster.Name) eventsv1beta1listers.EventLister + Cluster(clusterName logicalcluster.Name) listerseventsv1beta1.EventLister EventClusterListerExpansion } +// eventClusterLister implements the EventClusterLister interface. type eventClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*eventsv1beta1.Event] } +var _ EventClusterLister = new(eventClusterLister) + // NewEventClusterLister returns a new EventClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewEventClusterLister(indexer cache.Indexer) *eventClusterLister { - return &eventClusterLister{indexer: indexer} -} - -// List lists all Events in the indexer across all workspaces. -func (s *eventClusterLister) List(selector labels.Selector) (ret []*eventsv1beta1.Event, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*eventsv1beta1.Event)) - }) - return ret, err +func NewEventClusterLister(indexer cache.Indexer) EventClusterLister { + return &eventClusterLister{ + kcplisters.NewCluster[*eventsv1beta1.Event](indexer, eventsv1beta1.Resource("event")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get Events. -func (s *eventClusterLister) Cluster(clusterName logicalcluster.Name) eventsv1beta1listers.EventLister { - return &eventLister{indexer: s.indexer, clusterName: clusterName} +func (l *eventClusterLister) Cluster(clusterName logicalcluster.Name) listerseventsv1beta1.EventLister { + return &eventLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// eventLister implements the eventsv1beta1listers.EventLister interface. +// eventLister can list all Events inside a workspace +// or scope down to a listerseventsv1beta1.EventNamespaceLister for one namespace. type eventLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*eventsv1beta1.Event] } -// List lists all Events in the indexer for a workspace. -func (s *eventLister) List(selector labels.Selector) (ret []*eventsv1beta1.Event, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*eventsv1beta1.Event)) - }) - return ret, err -} +var _ listerseventsv1beta1.EventLister = new(eventLister) // Events returns an object that can list and get Events in one namespace. -func (s *eventLister) Events(namespace string) eventsv1beta1listers.EventNamespaceLister { - return &eventNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *eventLister) Events(namespace string) listerseventsv1beta1.EventNamespaceLister { + return &eventNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// eventNamespaceLister implements the eventsv1beta1listers.EventNamespaceLister interface. +// eventNamespaceLister implements the listerseventsv1beta1.EventNamespaceLister +// interface. type eventNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*eventsv1beta1.Event] } -// List lists all Events in the indexer for a given workspace and namespace. -func (s *eventNamespaceLister) List(selector labels.Selector) (ret []*eventsv1beta1.Event, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*eventsv1beta1.Event)) - }) - return ret, err -} +var _ listerseventsv1beta1.EventNamespaceLister = new(eventNamespaceLister) -// Get retrieves the Event from the indexer for a given workspace, namespace and name. -func (s *eventNamespaceLister) Get(name string) (*eventsv1beta1.Event, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewEventLister returns a new EventLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewEventLister(indexer cache.Indexer) listerseventsv1beta1.EventLister { + return &eventLister{ + kcplisters.New[*eventsv1beta1.Event](indexer, eventsv1beta1.Resource("event")), } - if !exists { - return nil, errors.NewNotFound(eventsv1beta1.Resource("events"), name) +} + +// eventScopedLister can list all Events inside a workspace +// or scope down to a listerseventsv1beta1.EventNamespaceLister for one namespace. +type eventScopedLister struct { + kcplisters.ResourceIndexer[*eventsv1beta1.Event] +} + +// Events returns an object that can list and get Events in one namespace. +func (l *eventScopedLister) Events(namespace string) listerseventsv1beta1.EventLister { + return &eventLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*eventsv1beta1.Event), nil } diff --git a/listers/events/v1beta1/expansion_generated.go b/listers/events/v1beta1/expansion_generated.go new file mode 100644 index 000000000..23cac805b --- /dev/null +++ b/listers/events/v1beta1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1beta1 diff --git a/listers/extensions/v1beta1/daemonset.go b/listers/extensions/v1beta1/daemonset.go index c6ea7ff87..901b0f644 100644 --- a/listers/extensions/v1beta1/daemonset.go +++ b/listers/extensions/v1beta1/daemonset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" extensionsv1beta1 "k8s.io/api/extensions/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - extensionsv1beta1listers "k8s.io/client-go/listers/extensions/v1beta1" + listersextensionsv1beta1 "k8s.io/client-go/listers/extensions/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// DaemonSetClusterLister can list DaemonSets across all workspaces, or scope down to a DaemonSetLister for one workspace. +// DaemonSetClusterLister helps list DaemonSets across all workspaces, +// or scope down to a DaemonSetLister for one workspace. // All objects returned here must be treated as read-only. type DaemonSetClusterLister interface { // List lists all DaemonSets in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*extensionsv1beta1.DaemonSet, err error) // Cluster returns a lister that can list and get DaemonSets in one workspace. - Cluster(clusterName logicalcluster.Name) extensionsv1beta1listers.DaemonSetLister + Cluster(clusterName logicalcluster.Name) listersextensionsv1beta1.DaemonSetLister DaemonSetClusterListerExpansion } +// daemonSetClusterLister implements the DaemonSetClusterLister interface. type daemonSetClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*extensionsv1beta1.DaemonSet] } +var _ DaemonSetClusterLister = new(daemonSetClusterLister) + // NewDaemonSetClusterLister returns a new DaemonSetClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewDaemonSetClusterLister(indexer cache.Indexer) *daemonSetClusterLister { - return &daemonSetClusterLister{indexer: indexer} -} - -// List lists all DaemonSets in the indexer across all workspaces. -func (s *daemonSetClusterLister) List(selector labels.Selector) (ret []*extensionsv1beta1.DaemonSet, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*extensionsv1beta1.DaemonSet)) - }) - return ret, err +func NewDaemonSetClusterLister(indexer cache.Indexer) DaemonSetClusterLister { + return &daemonSetClusterLister{ + kcplisters.NewCluster[*extensionsv1beta1.DaemonSet](indexer, extensionsv1beta1.Resource("daemonset")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get DaemonSets. -func (s *daemonSetClusterLister) Cluster(clusterName logicalcluster.Name) extensionsv1beta1listers.DaemonSetLister { - return &daemonSetLister{indexer: s.indexer, clusterName: clusterName} +func (l *daemonSetClusterLister) Cluster(clusterName logicalcluster.Name) listersextensionsv1beta1.DaemonSetLister { + return &daemonSetLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// daemonSetLister implements the extensionsv1beta1listers.DaemonSetLister interface. +// daemonSetLister can list all DaemonSets inside a workspace +// or scope down to a listersextensionsv1beta1.DaemonSetNamespaceLister for one namespace. type daemonSetLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*extensionsv1beta1.DaemonSet] } -// List lists all DaemonSets in the indexer for a workspace. -func (s *daemonSetLister) List(selector labels.Selector) (ret []*extensionsv1beta1.DaemonSet, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*extensionsv1beta1.DaemonSet)) - }) - return ret, err -} +var _ listersextensionsv1beta1.DaemonSetLister = new(daemonSetLister) // DaemonSets returns an object that can list and get DaemonSets in one namespace. -func (s *daemonSetLister) DaemonSets(namespace string) extensionsv1beta1listers.DaemonSetNamespaceLister { - return &daemonSetNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *daemonSetLister) DaemonSets(namespace string) listersextensionsv1beta1.DaemonSetNamespaceLister { + return &daemonSetNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// daemonSetNamespaceLister implements the extensionsv1beta1listers.DaemonSetNamespaceLister interface. +// daemonSetNamespaceLister implements the listersextensionsv1beta1.DaemonSetNamespaceLister +// interface. type daemonSetNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*extensionsv1beta1.DaemonSet] } -// List lists all DaemonSets in the indexer for a given workspace and namespace. -func (s *daemonSetNamespaceLister) List(selector labels.Selector) (ret []*extensionsv1beta1.DaemonSet, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*extensionsv1beta1.DaemonSet)) - }) - return ret, err -} +var _ listersextensionsv1beta1.DaemonSetNamespaceLister = new(daemonSetNamespaceLister) -// Get retrieves the DaemonSet from the indexer for a given workspace, namespace and name. -func (s *daemonSetNamespaceLister) Get(name string) (*extensionsv1beta1.DaemonSet, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewDaemonSetLister returns a new DaemonSetLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewDaemonSetLister(indexer cache.Indexer) listersextensionsv1beta1.DaemonSetLister { + return &daemonSetLister{ + kcplisters.New[*extensionsv1beta1.DaemonSet](indexer, extensionsv1beta1.Resource("daemonset")), } - if !exists { - return nil, errors.NewNotFound(extensionsv1beta1.Resource("daemonsets"), name) +} + +// daemonSetScopedLister can list all DaemonSets inside a workspace +// or scope down to a listersextensionsv1beta1.DaemonSetNamespaceLister for one namespace. +type daemonSetScopedLister struct { + kcplisters.ResourceIndexer[*extensionsv1beta1.DaemonSet] +} + +// DaemonSets returns an object that can list and get DaemonSets in one namespace. +func (l *daemonSetScopedLister) DaemonSets(namespace string) listersextensionsv1beta1.DaemonSetLister { + return &daemonSetLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*extensionsv1beta1.DaemonSet), nil } diff --git a/listers/extensions/v1beta1/daemonset_expansion.go b/listers/extensions/v1beta1/daemonset_expansion.go index 3b2a9e39f..7166f131d 100644 --- a/listers/extensions/v1beta1/daemonset_expansion.go +++ b/listers/extensions/v1beta1/daemonset_expansion.go @@ -20,7 +20,7 @@ import ( "fmt" apps "k8s.io/api/apps/v1beta1" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" "k8s.io/api/extensions/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" diff --git a/listers/extensions/v1beta1/deployment.go b/listers/extensions/v1beta1/deployment.go index b103de463..a84877a31 100644 --- a/listers/extensions/v1beta1/deployment.go +++ b/listers/extensions/v1beta1/deployment.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" extensionsv1beta1 "k8s.io/api/extensions/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - extensionsv1beta1listers "k8s.io/client-go/listers/extensions/v1beta1" + listersextensionsv1beta1 "k8s.io/client-go/listers/extensions/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// DeploymentClusterLister can list Deployments across all workspaces, or scope down to a DeploymentLister for one workspace. +// DeploymentClusterLister helps list Deployments across all workspaces, +// or scope down to a DeploymentLister for one workspace. // All objects returned here must be treated as read-only. type DeploymentClusterLister interface { // List lists all Deployments in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*extensionsv1beta1.Deployment, err error) // Cluster returns a lister that can list and get Deployments in one workspace. - Cluster(clusterName logicalcluster.Name) extensionsv1beta1listers.DeploymentLister + Cluster(clusterName logicalcluster.Name) listersextensionsv1beta1.DeploymentLister DeploymentClusterListerExpansion } +// deploymentClusterLister implements the DeploymentClusterLister interface. type deploymentClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*extensionsv1beta1.Deployment] } +var _ DeploymentClusterLister = new(deploymentClusterLister) + // NewDeploymentClusterLister returns a new DeploymentClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewDeploymentClusterLister(indexer cache.Indexer) *deploymentClusterLister { - return &deploymentClusterLister{indexer: indexer} -} - -// List lists all Deployments in the indexer across all workspaces. -func (s *deploymentClusterLister) List(selector labels.Selector) (ret []*extensionsv1beta1.Deployment, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*extensionsv1beta1.Deployment)) - }) - return ret, err +func NewDeploymentClusterLister(indexer cache.Indexer) DeploymentClusterLister { + return &deploymentClusterLister{ + kcplisters.NewCluster[*extensionsv1beta1.Deployment](indexer, extensionsv1beta1.Resource("deployment")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get Deployments. -func (s *deploymentClusterLister) Cluster(clusterName logicalcluster.Name) extensionsv1beta1listers.DeploymentLister { - return &deploymentLister{indexer: s.indexer, clusterName: clusterName} +func (l *deploymentClusterLister) Cluster(clusterName logicalcluster.Name) listersextensionsv1beta1.DeploymentLister { + return &deploymentLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// deploymentLister implements the extensionsv1beta1listers.DeploymentLister interface. +// deploymentLister can list all Deployments inside a workspace +// or scope down to a listersextensionsv1beta1.DeploymentNamespaceLister for one namespace. type deploymentLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*extensionsv1beta1.Deployment] } -// List lists all Deployments in the indexer for a workspace. -func (s *deploymentLister) List(selector labels.Selector) (ret []*extensionsv1beta1.Deployment, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*extensionsv1beta1.Deployment)) - }) - return ret, err -} +var _ listersextensionsv1beta1.DeploymentLister = new(deploymentLister) // Deployments returns an object that can list and get Deployments in one namespace. -func (s *deploymentLister) Deployments(namespace string) extensionsv1beta1listers.DeploymentNamespaceLister { - return &deploymentNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *deploymentLister) Deployments(namespace string) listersextensionsv1beta1.DeploymentNamespaceLister { + return &deploymentNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// deploymentNamespaceLister implements the extensionsv1beta1listers.DeploymentNamespaceLister interface. +// deploymentNamespaceLister implements the listersextensionsv1beta1.DeploymentNamespaceLister +// interface. type deploymentNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*extensionsv1beta1.Deployment] } -// List lists all Deployments in the indexer for a given workspace and namespace. -func (s *deploymentNamespaceLister) List(selector labels.Selector) (ret []*extensionsv1beta1.Deployment, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*extensionsv1beta1.Deployment)) - }) - return ret, err -} +var _ listersextensionsv1beta1.DeploymentNamespaceLister = new(deploymentNamespaceLister) -// Get retrieves the Deployment from the indexer for a given workspace, namespace and name. -func (s *deploymentNamespaceLister) Get(name string) (*extensionsv1beta1.Deployment, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewDeploymentLister returns a new DeploymentLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewDeploymentLister(indexer cache.Indexer) listersextensionsv1beta1.DeploymentLister { + return &deploymentLister{ + kcplisters.New[*extensionsv1beta1.Deployment](indexer, extensionsv1beta1.Resource("deployment")), } - if !exists { - return nil, errors.NewNotFound(extensionsv1beta1.Resource("deployments"), name) +} + +// deploymentScopedLister can list all Deployments inside a workspace +// or scope down to a listersextensionsv1beta1.DeploymentNamespaceLister for one namespace. +type deploymentScopedLister struct { + kcplisters.ResourceIndexer[*extensionsv1beta1.Deployment] +} + +// Deployments returns an object that can list and get Deployments in one namespace. +func (l *deploymentScopedLister) Deployments(namespace string) listersextensionsv1beta1.DeploymentLister { + return &deploymentLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*extensionsv1beta1.Deployment), nil } diff --git a/listers/extensions/v1beta1/expansion_generated.go b/listers/extensions/v1beta1/expansion_generated.go new file mode 100644 index 000000000..23cac805b --- /dev/null +++ b/listers/extensions/v1beta1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1beta1 diff --git a/listers/extensions/v1beta1/ingress.go b/listers/extensions/v1beta1/ingress.go index 7af48ea54..792448cea 100644 --- a/listers/extensions/v1beta1/ingress.go +++ b/listers/extensions/v1beta1/ingress.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" extensionsv1beta1 "k8s.io/api/extensions/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - extensionsv1beta1listers "k8s.io/client-go/listers/extensions/v1beta1" + listersextensionsv1beta1 "k8s.io/client-go/listers/extensions/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// IngressClusterLister can list Ingresses across all workspaces, or scope down to a IngressLister for one workspace. +// IngressClusterLister helps list Ingresses across all workspaces, +// or scope down to a IngressLister for one workspace. // All objects returned here must be treated as read-only. type IngressClusterLister interface { // List lists all Ingresses in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*extensionsv1beta1.Ingress, err error) // Cluster returns a lister that can list and get Ingresses in one workspace. - Cluster(clusterName logicalcluster.Name) extensionsv1beta1listers.IngressLister + Cluster(clusterName logicalcluster.Name) listersextensionsv1beta1.IngressLister IngressClusterListerExpansion } +// ingressClusterLister implements the IngressClusterLister interface. type ingressClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*extensionsv1beta1.Ingress] } +var _ IngressClusterLister = new(ingressClusterLister) + // NewIngressClusterLister returns a new IngressClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewIngressClusterLister(indexer cache.Indexer) *ingressClusterLister { - return &ingressClusterLister{indexer: indexer} -} - -// List lists all Ingresses in the indexer across all workspaces. -func (s *ingressClusterLister) List(selector labels.Selector) (ret []*extensionsv1beta1.Ingress, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*extensionsv1beta1.Ingress)) - }) - return ret, err +func NewIngressClusterLister(indexer cache.Indexer) IngressClusterLister { + return &ingressClusterLister{ + kcplisters.NewCluster[*extensionsv1beta1.Ingress](indexer, extensionsv1beta1.Resource("ingress")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get Ingresses. -func (s *ingressClusterLister) Cluster(clusterName logicalcluster.Name) extensionsv1beta1listers.IngressLister { - return &ingressLister{indexer: s.indexer, clusterName: clusterName} +func (l *ingressClusterLister) Cluster(clusterName logicalcluster.Name) listersextensionsv1beta1.IngressLister { + return &ingressLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// ingressLister implements the extensionsv1beta1listers.IngressLister interface. +// ingressLister can list all Ingresses inside a workspace +// or scope down to a listersextensionsv1beta1.IngressNamespaceLister for one namespace. type ingressLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*extensionsv1beta1.Ingress] } -// List lists all Ingresses in the indexer for a workspace. -func (s *ingressLister) List(selector labels.Selector) (ret []*extensionsv1beta1.Ingress, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*extensionsv1beta1.Ingress)) - }) - return ret, err -} +var _ listersextensionsv1beta1.IngressLister = new(ingressLister) // Ingresses returns an object that can list and get Ingresses in one namespace. -func (s *ingressLister) Ingresses(namespace string) extensionsv1beta1listers.IngressNamespaceLister { - return &ingressNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *ingressLister) Ingresses(namespace string) listersextensionsv1beta1.IngressNamespaceLister { + return &ingressNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// ingressNamespaceLister implements the extensionsv1beta1listers.IngressNamespaceLister interface. +// ingressNamespaceLister implements the listersextensionsv1beta1.IngressNamespaceLister +// interface. type ingressNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*extensionsv1beta1.Ingress] } -// List lists all Ingresses in the indexer for a given workspace and namespace. -func (s *ingressNamespaceLister) List(selector labels.Selector) (ret []*extensionsv1beta1.Ingress, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*extensionsv1beta1.Ingress)) - }) - return ret, err -} +var _ listersextensionsv1beta1.IngressNamespaceLister = new(ingressNamespaceLister) -// Get retrieves the Ingress from the indexer for a given workspace, namespace and name. -func (s *ingressNamespaceLister) Get(name string) (*extensionsv1beta1.Ingress, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewIngressLister returns a new IngressLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewIngressLister(indexer cache.Indexer) listersextensionsv1beta1.IngressLister { + return &ingressLister{ + kcplisters.New[*extensionsv1beta1.Ingress](indexer, extensionsv1beta1.Resource("ingress")), } - if !exists { - return nil, errors.NewNotFound(extensionsv1beta1.Resource("ingresses"), name) +} + +// ingressScopedLister can list all Ingresses inside a workspace +// or scope down to a listersextensionsv1beta1.IngressNamespaceLister for one namespace. +type ingressScopedLister struct { + kcplisters.ResourceIndexer[*extensionsv1beta1.Ingress] +} + +// Ingresses returns an object that can list and get Ingresses in one namespace. +func (l *ingressScopedLister) Ingresses(namespace string) listersextensionsv1beta1.IngressLister { + return &ingressLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*extensionsv1beta1.Ingress), nil } diff --git a/listers/extensions/v1beta1/networkpolicy.go b/listers/extensions/v1beta1/networkpolicy.go index 36dad6262..e9c61ebdb 100644 --- a/listers/extensions/v1beta1/networkpolicy.go +++ b/listers/extensions/v1beta1/networkpolicy.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" extensionsv1beta1 "k8s.io/api/extensions/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - extensionsv1beta1listers "k8s.io/client-go/listers/extensions/v1beta1" + listersextensionsv1beta1 "k8s.io/client-go/listers/extensions/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// NetworkPolicyClusterLister can list NetworkPolicies across all workspaces, or scope down to a NetworkPolicyLister for one workspace. +// NetworkPolicyClusterLister helps list NetworkPolicies across all workspaces, +// or scope down to a NetworkPolicyLister for one workspace. // All objects returned here must be treated as read-only. type NetworkPolicyClusterLister interface { // List lists all NetworkPolicies in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*extensionsv1beta1.NetworkPolicy, err error) // Cluster returns a lister that can list and get NetworkPolicies in one workspace. - Cluster(clusterName logicalcluster.Name) extensionsv1beta1listers.NetworkPolicyLister + Cluster(clusterName logicalcluster.Name) listersextensionsv1beta1.NetworkPolicyLister NetworkPolicyClusterListerExpansion } +// networkPolicyClusterLister implements the NetworkPolicyClusterLister interface. type networkPolicyClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*extensionsv1beta1.NetworkPolicy] } +var _ NetworkPolicyClusterLister = new(networkPolicyClusterLister) + // NewNetworkPolicyClusterLister returns a new NetworkPolicyClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewNetworkPolicyClusterLister(indexer cache.Indexer) *networkPolicyClusterLister { - return &networkPolicyClusterLister{indexer: indexer} -} - -// List lists all NetworkPolicies in the indexer across all workspaces. -func (s *networkPolicyClusterLister) List(selector labels.Selector) (ret []*extensionsv1beta1.NetworkPolicy, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*extensionsv1beta1.NetworkPolicy)) - }) - return ret, err +func NewNetworkPolicyClusterLister(indexer cache.Indexer) NetworkPolicyClusterLister { + return &networkPolicyClusterLister{ + kcplisters.NewCluster[*extensionsv1beta1.NetworkPolicy](indexer, extensionsv1beta1.Resource("networkpolicy")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get NetworkPolicies. -func (s *networkPolicyClusterLister) Cluster(clusterName logicalcluster.Name) extensionsv1beta1listers.NetworkPolicyLister { - return &networkPolicyLister{indexer: s.indexer, clusterName: clusterName} +func (l *networkPolicyClusterLister) Cluster(clusterName logicalcluster.Name) listersextensionsv1beta1.NetworkPolicyLister { + return &networkPolicyLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// networkPolicyLister implements the extensionsv1beta1listers.NetworkPolicyLister interface. +// networkPolicyLister can list all NetworkPolicies inside a workspace +// or scope down to a listersextensionsv1beta1.NetworkPolicyNamespaceLister for one namespace. type networkPolicyLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*extensionsv1beta1.NetworkPolicy] } -// List lists all NetworkPolicies in the indexer for a workspace. -func (s *networkPolicyLister) List(selector labels.Selector) (ret []*extensionsv1beta1.NetworkPolicy, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*extensionsv1beta1.NetworkPolicy)) - }) - return ret, err -} +var _ listersextensionsv1beta1.NetworkPolicyLister = new(networkPolicyLister) // NetworkPolicies returns an object that can list and get NetworkPolicies in one namespace. -func (s *networkPolicyLister) NetworkPolicies(namespace string) extensionsv1beta1listers.NetworkPolicyNamespaceLister { - return &networkPolicyNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *networkPolicyLister) NetworkPolicies(namespace string) listersextensionsv1beta1.NetworkPolicyNamespaceLister { + return &networkPolicyNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// networkPolicyNamespaceLister implements the extensionsv1beta1listers.NetworkPolicyNamespaceLister interface. +// networkPolicyNamespaceLister implements the listersextensionsv1beta1.NetworkPolicyNamespaceLister +// interface. type networkPolicyNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*extensionsv1beta1.NetworkPolicy] } -// List lists all NetworkPolicies in the indexer for a given workspace and namespace. -func (s *networkPolicyNamespaceLister) List(selector labels.Selector) (ret []*extensionsv1beta1.NetworkPolicy, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*extensionsv1beta1.NetworkPolicy)) - }) - return ret, err -} +var _ listersextensionsv1beta1.NetworkPolicyNamespaceLister = new(networkPolicyNamespaceLister) -// Get retrieves the NetworkPolicy from the indexer for a given workspace, namespace and name. -func (s *networkPolicyNamespaceLister) Get(name string) (*extensionsv1beta1.NetworkPolicy, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewNetworkPolicyLister returns a new NetworkPolicyLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewNetworkPolicyLister(indexer cache.Indexer) listersextensionsv1beta1.NetworkPolicyLister { + return &networkPolicyLister{ + kcplisters.New[*extensionsv1beta1.NetworkPolicy](indexer, extensionsv1beta1.Resource("networkpolicy")), } - if !exists { - return nil, errors.NewNotFound(extensionsv1beta1.Resource("networkpolicies"), name) +} + +// networkPolicyScopedLister can list all NetworkPolicies inside a workspace +// or scope down to a listersextensionsv1beta1.NetworkPolicyNamespaceLister for one namespace. +type networkPolicyScopedLister struct { + kcplisters.ResourceIndexer[*extensionsv1beta1.NetworkPolicy] +} + +// NetworkPolicies returns an object that can list and get NetworkPolicies in one namespace. +func (l *networkPolicyScopedLister) NetworkPolicies(namespace string) listersextensionsv1beta1.NetworkPolicyLister { + return &networkPolicyLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*extensionsv1beta1.NetworkPolicy), nil } diff --git a/listers/extensions/v1beta1/replicaset.go b/listers/extensions/v1beta1/replicaset.go index 05ad2cf56..38399c350 100644 --- a/listers/extensions/v1beta1/replicaset.go +++ b/listers/extensions/v1beta1/replicaset.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" extensionsv1beta1 "k8s.io/api/extensions/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - extensionsv1beta1listers "k8s.io/client-go/listers/extensions/v1beta1" + listersextensionsv1beta1 "k8s.io/client-go/listers/extensions/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ReplicaSetClusterLister can list ReplicaSets across all workspaces, or scope down to a ReplicaSetLister for one workspace. +// ReplicaSetClusterLister helps list ReplicaSets across all workspaces, +// or scope down to a ReplicaSetLister for one workspace. // All objects returned here must be treated as read-only. type ReplicaSetClusterLister interface { // List lists all ReplicaSets in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*extensionsv1beta1.ReplicaSet, err error) // Cluster returns a lister that can list and get ReplicaSets in one workspace. - Cluster(clusterName logicalcluster.Name) extensionsv1beta1listers.ReplicaSetLister + Cluster(clusterName logicalcluster.Name) listersextensionsv1beta1.ReplicaSetLister ReplicaSetClusterListerExpansion } +// replicaSetClusterLister implements the ReplicaSetClusterLister interface. type replicaSetClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*extensionsv1beta1.ReplicaSet] } +var _ ReplicaSetClusterLister = new(replicaSetClusterLister) + // NewReplicaSetClusterLister returns a new ReplicaSetClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewReplicaSetClusterLister(indexer cache.Indexer) *replicaSetClusterLister { - return &replicaSetClusterLister{indexer: indexer} -} - -// List lists all ReplicaSets in the indexer across all workspaces. -func (s *replicaSetClusterLister) List(selector labels.Selector) (ret []*extensionsv1beta1.ReplicaSet, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*extensionsv1beta1.ReplicaSet)) - }) - return ret, err +func NewReplicaSetClusterLister(indexer cache.Indexer) ReplicaSetClusterLister { + return &replicaSetClusterLister{ + kcplisters.NewCluster[*extensionsv1beta1.ReplicaSet](indexer, extensionsv1beta1.Resource("replicaset")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ReplicaSets. -func (s *replicaSetClusterLister) Cluster(clusterName logicalcluster.Name) extensionsv1beta1listers.ReplicaSetLister { - return &replicaSetLister{indexer: s.indexer, clusterName: clusterName} +func (l *replicaSetClusterLister) Cluster(clusterName logicalcluster.Name) listersextensionsv1beta1.ReplicaSetLister { + return &replicaSetLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// replicaSetLister implements the extensionsv1beta1listers.ReplicaSetLister interface. +// replicaSetLister can list all ReplicaSets inside a workspace +// or scope down to a listersextensionsv1beta1.ReplicaSetNamespaceLister for one namespace. type replicaSetLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*extensionsv1beta1.ReplicaSet] } -// List lists all ReplicaSets in the indexer for a workspace. -func (s *replicaSetLister) List(selector labels.Selector) (ret []*extensionsv1beta1.ReplicaSet, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*extensionsv1beta1.ReplicaSet)) - }) - return ret, err -} +var _ listersextensionsv1beta1.ReplicaSetLister = new(replicaSetLister) // ReplicaSets returns an object that can list and get ReplicaSets in one namespace. -func (s *replicaSetLister) ReplicaSets(namespace string) extensionsv1beta1listers.ReplicaSetNamespaceLister { - return &replicaSetNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *replicaSetLister) ReplicaSets(namespace string) listersextensionsv1beta1.ReplicaSetNamespaceLister { + return &replicaSetNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// replicaSetNamespaceLister implements the extensionsv1beta1listers.ReplicaSetNamespaceLister interface. +// replicaSetNamespaceLister implements the listersextensionsv1beta1.ReplicaSetNamespaceLister +// interface. type replicaSetNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*extensionsv1beta1.ReplicaSet] } -// List lists all ReplicaSets in the indexer for a given workspace and namespace. -func (s *replicaSetNamespaceLister) List(selector labels.Selector) (ret []*extensionsv1beta1.ReplicaSet, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*extensionsv1beta1.ReplicaSet)) - }) - return ret, err -} +var _ listersextensionsv1beta1.ReplicaSetNamespaceLister = new(replicaSetNamespaceLister) -// Get retrieves the ReplicaSet from the indexer for a given workspace, namespace and name. -func (s *replicaSetNamespaceLister) Get(name string) (*extensionsv1beta1.ReplicaSet, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewReplicaSetLister returns a new ReplicaSetLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewReplicaSetLister(indexer cache.Indexer) listersextensionsv1beta1.ReplicaSetLister { + return &replicaSetLister{ + kcplisters.New[*extensionsv1beta1.ReplicaSet](indexer, extensionsv1beta1.Resource("replicaset")), } - if !exists { - return nil, errors.NewNotFound(extensionsv1beta1.Resource("replicasets"), name) +} + +// replicaSetScopedLister can list all ReplicaSets inside a workspace +// or scope down to a listersextensionsv1beta1.ReplicaSetNamespaceLister for one namespace. +type replicaSetScopedLister struct { + kcplisters.ResourceIndexer[*extensionsv1beta1.ReplicaSet] +} + +// ReplicaSets returns an object that can list and get ReplicaSets in one namespace. +func (l *replicaSetScopedLister) ReplicaSets(namespace string) listersextensionsv1beta1.ReplicaSetLister { + return &replicaSetLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*extensionsv1beta1.ReplicaSet), nil } diff --git a/listers/extensions/v1beta1/replicaset_expansion.go b/listers/extensions/v1beta1/replicaset_expansion.go index 53f5b3e1c..0b7c0fb23 100644 --- a/listers/extensions/v1beta1/replicaset_expansion.go +++ b/listers/extensions/v1beta1/replicaset_expansion.go @@ -19,7 +19,7 @@ package v1beta1 import ( "fmt" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" extensions "k8s.io/api/extensions/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" diff --git a/listers/flowcontrol/v1/expansion_generated.go b/listers/flowcontrol/v1/expansion_generated.go new file mode 100644 index 000000000..b6a0c6377 --- /dev/null +++ b/listers/flowcontrol/v1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1 diff --git a/listers/flowcontrol/v1/flowschema.go b/listers/flowcontrol/v1/flowschema.go index 5ba214ae8..337a571f1 100644 --- a/listers/flowcontrol/v1/flowschema.go +++ b/listers/flowcontrol/v1/flowschema.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" flowcontrolv1 "k8s.io/api/flowcontrol/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - flowcontrolv1listers "k8s.io/client-go/listers/flowcontrol/v1" + listersflowcontrolv1 "k8s.io/client-go/listers/flowcontrol/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// FlowSchemaClusterLister can list FlowSchemas across all workspaces, or scope down to a FlowSchemaLister for one workspace. +// FlowSchemaClusterLister helps list FlowSchemas across all workspaces, +// or scope down to a FlowSchemaLister for one workspace. // All objects returned here must be treated as read-only. type FlowSchemaClusterLister interface { // List lists all FlowSchemas in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*flowcontrolv1.FlowSchema, err error) // Cluster returns a lister that can list and get FlowSchemas in one workspace. - Cluster(clusterName logicalcluster.Name) flowcontrolv1listers.FlowSchemaLister + Cluster(clusterName logicalcluster.Name) listersflowcontrolv1.FlowSchemaLister FlowSchemaClusterListerExpansion } +// flowSchemaClusterLister implements the FlowSchemaClusterLister interface. type flowSchemaClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*flowcontrolv1.FlowSchema] } +var _ FlowSchemaClusterLister = new(flowSchemaClusterLister) + // NewFlowSchemaClusterLister returns a new FlowSchemaClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewFlowSchemaClusterLister(indexer cache.Indexer) *flowSchemaClusterLister { - return &flowSchemaClusterLister{indexer: indexer} -} - -// List lists all FlowSchemas in the indexer across all workspaces. -func (s *flowSchemaClusterLister) List(selector labels.Selector) (ret []*flowcontrolv1.FlowSchema, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*flowcontrolv1.FlowSchema)) - }) - return ret, err +func NewFlowSchemaClusterLister(indexer cache.Indexer) FlowSchemaClusterLister { + return &flowSchemaClusterLister{ + kcplisters.NewCluster[*flowcontrolv1.FlowSchema](indexer, flowcontrolv1.Resource("flowschema")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get FlowSchemas. -func (s *flowSchemaClusterLister) Cluster(clusterName logicalcluster.Name) flowcontrolv1listers.FlowSchemaLister { - return &flowSchemaLister{indexer: s.indexer, clusterName: clusterName} +func (l *flowSchemaClusterLister) Cluster(clusterName logicalcluster.Name) listersflowcontrolv1.FlowSchemaLister { + return &flowSchemaLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// flowSchemaLister implements the flowcontrolv1listers.FlowSchemaLister interface. +// flowSchemaLister can list all FlowSchemas inside a workspace +// or scope down to a listersflowcontrolv1.FlowSchemaNamespaceLister for one namespace. type flowSchemaLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*flowcontrolv1.FlowSchema] } -// List lists all FlowSchemas in the indexer for a workspace. -func (s *flowSchemaLister) List(selector labels.Selector) (ret []*flowcontrolv1.FlowSchema, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*flowcontrolv1.FlowSchema)) - }) - return ret, err -} +var _ listersflowcontrolv1.FlowSchemaLister = new(flowSchemaLister) -// Get retrieves the FlowSchema from the indexer for a given workspace and name. -func (s *flowSchemaLister) Get(name string) (*flowcontrolv1.FlowSchema, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(flowcontrolv1.Resource("flowschemas"), name) +// NewFlowSchemaLister returns a new FlowSchemaLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewFlowSchemaLister(indexer cache.Indexer) listersflowcontrolv1.FlowSchemaLister { + return &flowSchemaLister{ + kcplisters.New[*flowcontrolv1.FlowSchema](indexer, flowcontrolv1.Resource("flowschema")), } - return obj.(*flowcontrolv1.FlowSchema), nil +} + +// flowSchemaScopedLister can list all FlowSchemas inside a workspace +// or scope down to a listersflowcontrolv1.FlowSchemaNamespaceLister. +type flowSchemaScopedLister struct { + kcplisters.ResourceIndexer[*flowcontrolv1.FlowSchema] } diff --git a/listers/flowcontrol/v1/prioritylevelconfiguration.go b/listers/flowcontrol/v1/prioritylevelconfiguration.go index 5334a7df4..35c7f7d4e 100644 --- a/listers/flowcontrol/v1/prioritylevelconfiguration.go +++ b/listers/flowcontrol/v1/prioritylevelconfiguration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" flowcontrolv1 "k8s.io/api/flowcontrol/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - flowcontrolv1listers "k8s.io/client-go/listers/flowcontrol/v1" + listersflowcontrolv1 "k8s.io/client-go/listers/flowcontrol/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// PriorityLevelConfigurationClusterLister can list PriorityLevelConfigurations across all workspaces, or scope down to a PriorityLevelConfigurationLister for one workspace. +// PriorityLevelConfigurationClusterLister helps list PriorityLevelConfigurations across all workspaces, +// or scope down to a PriorityLevelConfigurationLister for one workspace. // All objects returned here must be treated as read-only. type PriorityLevelConfigurationClusterLister interface { // List lists all PriorityLevelConfigurations in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*flowcontrolv1.PriorityLevelConfiguration, err error) // Cluster returns a lister that can list and get PriorityLevelConfigurations in one workspace. - Cluster(clusterName logicalcluster.Name) flowcontrolv1listers.PriorityLevelConfigurationLister + Cluster(clusterName logicalcluster.Name) listersflowcontrolv1.PriorityLevelConfigurationLister PriorityLevelConfigurationClusterListerExpansion } +// priorityLevelConfigurationClusterLister implements the PriorityLevelConfigurationClusterLister interface. type priorityLevelConfigurationClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*flowcontrolv1.PriorityLevelConfiguration] } +var _ PriorityLevelConfigurationClusterLister = new(priorityLevelConfigurationClusterLister) + // NewPriorityLevelConfigurationClusterLister returns a new PriorityLevelConfigurationClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewPriorityLevelConfigurationClusterLister(indexer cache.Indexer) *priorityLevelConfigurationClusterLister { - return &priorityLevelConfigurationClusterLister{indexer: indexer} -} - -// List lists all PriorityLevelConfigurations in the indexer across all workspaces. -func (s *priorityLevelConfigurationClusterLister) List(selector labels.Selector) (ret []*flowcontrolv1.PriorityLevelConfiguration, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*flowcontrolv1.PriorityLevelConfiguration)) - }) - return ret, err +func NewPriorityLevelConfigurationClusterLister(indexer cache.Indexer) PriorityLevelConfigurationClusterLister { + return &priorityLevelConfigurationClusterLister{ + kcplisters.NewCluster[*flowcontrolv1.PriorityLevelConfiguration](indexer, flowcontrolv1.Resource("prioritylevelconfiguration")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get PriorityLevelConfigurations. -func (s *priorityLevelConfigurationClusterLister) Cluster(clusterName logicalcluster.Name) flowcontrolv1listers.PriorityLevelConfigurationLister { - return &priorityLevelConfigurationLister{indexer: s.indexer, clusterName: clusterName} +func (l *priorityLevelConfigurationClusterLister) Cluster(clusterName logicalcluster.Name) listersflowcontrolv1.PriorityLevelConfigurationLister { + return &priorityLevelConfigurationLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// priorityLevelConfigurationLister implements the flowcontrolv1listers.PriorityLevelConfigurationLister interface. +// priorityLevelConfigurationLister can list all PriorityLevelConfigurations inside a workspace +// or scope down to a listersflowcontrolv1.PriorityLevelConfigurationNamespaceLister for one namespace. type priorityLevelConfigurationLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*flowcontrolv1.PriorityLevelConfiguration] } -// List lists all PriorityLevelConfigurations in the indexer for a workspace. -func (s *priorityLevelConfigurationLister) List(selector labels.Selector) (ret []*flowcontrolv1.PriorityLevelConfiguration, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*flowcontrolv1.PriorityLevelConfiguration)) - }) - return ret, err -} +var _ listersflowcontrolv1.PriorityLevelConfigurationLister = new(priorityLevelConfigurationLister) -// Get retrieves the PriorityLevelConfiguration from the indexer for a given workspace and name. -func (s *priorityLevelConfigurationLister) Get(name string) (*flowcontrolv1.PriorityLevelConfiguration, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(flowcontrolv1.Resource("prioritylevelconfigurations"), name) +// NewPriorityLevelConfigurationLister returns a new PriorityLevelConfigurationLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewPriorityLevelConfigurationLister(indexer cache.Indexer) listersflowcontrolv1.PriorityLevelConfigurationLister { + return &priorityLevelConfigurationLister{ + kcplisters.New[*flowcontrolv1.PriorityLevelConfiguration](indexer, flowcontrolv1.Resource("prioritylevelconfiguration")), } - return obj.(*flowcontrolv1.PriorityLevelConfiguration), nil +} + +// priorityLevelConfigurationScopedLister can list all PriorityLevelConfigurations inside a workspace +// or scope down to a listersflowcontrolv1.PriorityLevelConfigurationNamespaceLister. +type priorityLevelConfigurationScopedLister struct { + kcplisters.ResourceIndexer[*flowcontrolv1.PriorityLevelConfiguration] } diff --git a/listers/flowcontrol/v1beta1/expansion_generated.go b/listers/flowcontrol/v1beta1/expansion_generated.go new file mode 100644 index 000000000..23cac805b --- /dev/null +++ b/listers/flowcontrol/v1beta1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1beta1 diff --git a/listers/flowcontrol/v1beta1/flowschema.go b/listers/flowcontrol/v1beta1/flowschema.go index 429f903ad..b4cf7c859 100644 --- a/listers/flowcontrol/v1beta1/flowschema.go +++ b/listers/flowcontrol/v1beta1/flowschema.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" flowcontrolv1beta1 "k8s.io/api/flowcontrol/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - flowcontrolv1beta1listers "k8s.io/client-go/listers/flowcontrol/v1beta1" + listersflowcontrolv1beta1 "k8s.io/client-go/listers/flowcontrol/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// FlowSchemaClusterLister can list FlowSchemas across all workspaces, or scope down to a FlowSchemaLister for one workspace. +// FlowSchemaClusterLister helps list FlowSchemas across all workspaces, +// or scope down to a FlowSchemaLister for one workspace. // All objects returned here must be treated as read-only. type FlowSchemaClusterLister interface { // List lists all FlowSchemas in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*flowcontrolv1beta1.FlowSchema, err error) // Cluster returns a lister that can list and get FlowSchemas in one workspace. - Cluster(clusterName logicalcluster.Name) flowcontrolv1beta1listers.FlowSchemaLister + Cluster(clusterName logicalcluster.Name) listersflowcontrolv1beta1.FlowSchemaLister FlowSchemaClusterListerExpansion } +// flowSchemaClusterLister implements the FlowSchemaClusterLister interface. type flowSchemaClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*flowcontrolv1beta1.FlowSchema] } +var _ FlowSchemaClusterLister = new(flowSchemaClusterLister) + // NewFlowSchemaClusterLister returns a new FlowSchemaClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewFlowSchemaClusterLister(indexer cache.Indexer) *flowSchemaClusterLister { - return &flowSchemaClusterLister{indexer: indexer} -} - -// List lists all FlowSchemas in the indexer across all workspaces. -func (s *flowSchemaClusterLister) List(selector labels.Selector) (ret []*flowcontrolv1beta1.FlowSchema, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*flowcontrolv1beta1.FlowSchema)) - }) - return ret, err +func NewFlowSchemaClusterLister(indexer cache.Indexer) FlowSchemaClusterLister { + return &flowSchemaClusterLister{ + kcplisters.NewCluster[*flowcontrolv1beta1.FlowSchema](indexer, flowcontrolv1beta1.Resource("flowschema")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get FlowSchemas. -func (s *flowSchemaClusterLister) Cluster(clusterName logicalcluster.Name) flowcontrolv1beta1listers.FlowSchemaLister { - return &flowSchemaLister{indexer: s.indexer, clusterName: clusterName} +func (l *flowSchemaClusterLister) Cluster(clusterName logicalcluster.Name) listersflowcontrolv1beta1.FlowSchemaLister { + return &flowSchemaLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// flowSchemaLister implements the flowcontrolv1beta1listers.FlowSchemaLister interface. +// flowSchemaLister can list all FlowSchemas inside a workspace +// or scope down to a listersflowcontrolv1beta1.FlowSchemaNamespaceLister for one namespace. type flowSchemaLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*flowcontrolv1beta1.FlowSchema] } -// List lists all FlowSchemas in the indexer for a workspace. -func (s *flowSchemaLister) List(selector labels.Selector) (ret []*flowcontrolv1beta1.FlowSchema, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*flowcontrolv1beta1.FlowSchema)) - }) - return ret, err -} +var _ listersflowcontrolv1beta1.FlowSchemaLister = new(flowSchemaLister) -// Get retrieves the FlowSchema from the indexer for a given workspace and name. -func (s *flowSchemaLister) Get(name string) (*flowcontrolv1beta1.FlowSchema, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(flowcontrolv1beta1.Resource("flowschemas"), name) +// NewFlowSchemaLister returns a new FlowSchemaLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewFlowSchemaLister(indexer cache.Indexer) listersflowcontrolv1beta1.FlowSchemaLister { + return &flowSchemaLister{ + kcplisters.New[*flowcontrolv1beta1.FlowSchema](indexer, flowcontrolv1beta1.Resource("flowschema")), } - return obj.(*flowcontrolv1beta1.FlowSchema), nil +} + +// flowSchemaScopedLister can list all FlowSchemas inside a workspace +// or scope down to a listersflowcontrolv1beta1.FlowSchemaNamespaceLister. +type flowSchemaScopedLister struct { + kcplisters.ResourceIndexer[*flowcontrolv1beta1.FlowSchema] } diff --git a/listers/flowcontrol/v1beta1/prioritylevelconfiguration.go b/listers/flowcontrol/v1beta1/prioritylevelconfiguration.go index d45f28306..65e897b49 100644 --- a/listers/flowcontrol/v1beta1/prioritylevelconfiguration.go +++ b/listers/flowcontrol/v1beta1/prioritylevelconfiguration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" flowcontrolv1beta1 "k8s.io/api/flowcontrol/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - flowcontrolv1beta1listers "k8s.io/client-go/listers/flowcontrol/v1beta1" + listersflowcontrolv1beta1 "k8s.io/client-go/listers/flowcontrol/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// PriorityLevelConfigurationClusterLister can list PriorityLevelConfigurations across all workspaces, or scope down to a PriorityLevelConfigurationLister for one workspace. +// PriorityLevelConfigurationClusterLister helps list PriorityLevelConfigurations across all workspaces, +// or scope down to a PriorityLevelConfigurationLister for one workspace. // All objects returned here must be treated as read-only. type PriorityLevelConfigurationClusterLister interface { // List lists all PriorityLevelConfigurations in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*flowcontrolv1beta1.PriorityLevelConfiguration, err error) // Cluster returns a lister that can list and get PriorityLevelConfigurations in one workspace. - Cluster(clusterName logicalcluster.Name) flowcontrolv1beta1listers.PriorityLevelConfigurationLister + Cluster(clusterName logicalcluster.Name) listersflowcontrolv1beta1.PriorityLevelConfigurationLister PriorityLevelConfigurationClusterListerExpansion } +// priorityLevelConfigurationClusterLister implements the PriorityLevelConfigurationClusterLister interface. type priorityLevelConfigurationClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*flowcontrolv1beta1.PriorityLevelConfiguration] } +var _ PriorityLevelConfigurationClusterLister = new(priorityLevelConfigurationClusterLister) + // NewPriorityLevelConfigurationClusterLister returns a new PriorityLevelConfigurationClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewPriorityLevelConfigurationClusterLister(indexer cache.Indexer) *priorityLevelConfigurationClusterLister { - return &priorityLevelConfigurationClusterLister{indexer: indexer} -} - -// List lists all PriorityLevelConfigurations in the indexer across all workspaces. -func (s *priorityLevelConfigurationClusterLister) List(selector labels.Selector) (ret []*flowcontrolv1beta1.PriorityLevelConfiguration, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*flowcontrolv1beta1.PriorityLevelConfiguration)) - }) - return ret, err +func NewPriorityLevelConfigurationClusterLister(indexer cache.Indexer) PriorityLevelConfigurationClusterLister { + return &priorityLevelConfigurationClusterLister{ + kcplisters.NewCluster[*flowcontrolv1beta1.PriorityLevelConfiguration](indexer, flowcontrolv1beta1.Resource("prioritylevelconfiguration")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get PriorityLevelConfigurations. -func (s *priorityLevelConfigurationClusterLister) Cluster(clusterName logicalcluster.Name) flowcontrolv1beta1listers.PriorityLevelConfigurationLister { - return &priorityLevelConfigurationLister{indexer: s.indexer, clusterName: clusterName} +func (l *priorityLevelConfigurationClusterLister) Cluster(clusterName logicalcluster.Name) listersflowcontrolv1beta1.PriorityLevelConfigurationLister { + return &priorityLevelConfigurationLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// priorityLevelConfigurationLister implements the flowcontrolv1beta1listers.PriorityLevelConfigurationLister interface. +// priorityLevelConfigurationLister can list all PriorityLevelConfigurations inside a workspace +// or scope down to a listersflowcontrolv1beta1.PriorityLevelConfigurationNamespaceLister for one namespace. type priorityLevelConfigurationLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*flowcontrolv1beta1.PriorityLevelConfiguration] } -// List lists all PriorityLevelConfigurations in the indexer for a workspace. -func (s *priorityLevelConfigurationLister) List(selector labels.Selector) (ret []*flowcontrolv1beta1.PriorityLevelConfiguration, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*flowcontrolv1beta1.PriorityLevelConfiguration)) - }) - return ret, err -} +var _ listersflowcontrolv1beta1.PriorityLevelConfigurationLister = new(priorityLevelConfigurationLister) -// Get retrieves the PriorityLevelConfiguration from the indexer for a given workspace and name. -func (s *priorityLevelConfigurationLister) Get(name string) (*flowcontrolv1beta1.PriorityLevelConfiguration, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(flowcontrolv1beta1.Resource("prioritylevelconfigurations"), name) +// NewPriorityLevelConfigurationLister returns a new PriorityLevelConfigurationLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewPriorityLevelConfigurationLister(indexer cache.Indexer) listersflowcontrolv1beta1.PriorityLevelConfigurationLister { + return &priorityLevelConfigurationLister{ + kcplisters.New[*flowcontrolv1beta1.PriorityLevelConfiguration](indexer, flowcontrolv1beta1.Resource("prioritylevelconfiguration")), } - return obj.(*flowcontrolv1beta1.PriorityLevelConfiguration), nil +} + +// priorityLevelConfigurationScopedLister can list all PriorityLevelConfigurations inside a workspace +// or scope down to a listersflowcontrolv1beta1.PriorityLevelConfigurationNamespaceLister. +type priorityLevelConfigurationScopedLister struct { + kcplisters.ResourceIndexer[*flowcontrolv1beta1.PriorityLevelConfiguration] } diff --git a/listers/flowcontrol/v1beta2/expansion_generated.go b/listers/flowcontrol/v1beta2/expansion_generated.go new file mode 100644 index 000000000..3e58e545a --- /dev/null +++ b/listers/flowcontrol/v1beta2/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1beta2 diff --git a/listers/flowcontrol/v1beta2/flowschema.go b/listers/flowcontrol/v1beta2/flowschema.go index 6585710c4..a7f36c508 100644 --- a/listers/flowcontrol/v1beta2/flowschema.go +++ b/listers/flowcontrol/v1beta2/flowschema.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta2 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" flowcontrolv1beta2 "k8s.io/api/flowcontrol/v1beta2" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - flowcontrolv1beta2listers "k8s.io/client-go/listers/flowcontrol/v1beta2" + listersflowcontrolv1beta2 "k8s.io/client-go/listers/flowcontrol/v1beta2" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// FlowSchemaClusterLister can list FlowSchemas across all workspaces, or scope down to a FlowSchemaLister for one workspace. +// FlowSchemaClusterLister helps list FlowSchemas across all workspaces, +// or scope down to a FlowSchemaLister for one workspace. // All objects returned here must be treated as read-only. type FlowSchemaClusterLister interface { // List lists all FlowSchemas in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*flowcontrolv1beta2.FlowSchema, err error) // Cluster returns a lister that can list and get FlowSchemas in one workspace. - Cluster(clusterName logicalcluster.Name) flowcontrolv1beta2listers.FlowSchemaLister + Cluster(clusterName logicalcluster.Name) listersflowcontrolv1beta2.FlowSchemaLister FlowSchemaClusterListerExpansion } +// flowSchemaClusterLister implements the FlowSchemaClusterLister interface. type flowSchemaClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*flowcontrolv1beta2.FlowSchema] } +var _ FlowSchemaClusterLister = new(flowSchemaClusterLister) + // NewFlowSchemaClusterLister returns a new FlowSchemaClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewFlowSchemaClusterLister(indexer cache.Indexer) *flowSchemaClusterLister { - return &flowSchemaClusterLister{indexer: indexer} -} - -// List lists all FlowSchemas in the indexer across all workspaces. -func (s *flowSchemaClusterLister) List(selector labels.Selector) (ret []*flowcontrolv1beta2.FlowSchema, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*flowcontrolv1beta2.FlowSchema)) - }) - return ret, err +func NewFlowSchemaClusterLister(indexer cache.Indexer) FlowSchemaClusterLister { + return &flowSchemaClusterLister{ + kcplisters.NewCluster[*flowcontrolv1beta2.FlowSchema](indexer, flowcontrolv1beta2.Resource("flowschema")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get FlowSchemas. -func (s *flowSchemaClusterLister) Cluster(clusterName logicalcluster.Name) flowcontrolv1beta2listers.FlowSchemaLister { - return &flowSchemaLister{indexer: s.indexer, clusterName: clusterName} +func (l *flowSchemaClusterLister) Cluster(clusterName logicalcluster.Name) listersflowcontrolv1beta2.FlowSchemaLister { + return &flowSchemaLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// flowSchemaLister implements the flowcontrolv1beta2listers.FlowSchemaLister interface. +// flowSchemaLister can list all FlowSchemas inside a workspace +// or scope down to a listersflowcontrolv1beta2.FlowSchemaNamespaceLister for one namespace. type flowSchemaLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*flowcontrolv1beta2.FlowSchema] } -// List lists all FlowSchemas in the indexer for a workspace. -func (s *flowSchemaLister) List(selector labels.Selector) (ret []*flowcontrolv1beta2.FlowSchema, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*flowcontrolv1beta2.FlowSchema)) - }) - return ret, err -} +var _ listersflowcontrolv1beta2.FlowSchemaLister = new(flowSchemaLister) -// Get retrieves the FlowSchema from the indexer for a given workspace and name. -func (s *flowSchemaLister) Get(name string) (*flowcontrolv1beta2.FlowSchema, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(flowcontrolv1beta2.Resource("flowschemas"), name) +// NewFlowSchemaLister returns a new FlowSchemaLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewFlowSchemaLister(indexer cache.Indexer) listersflowcontrolv1beta2.FlowSchemaLister { + return &flowSchemaLister{ + kcplisters.New[*flowcontrolv1beta2.FlowSchema](indexer, flowcontrolv1beta2.Resource("flowschema")), } - return obj.(*flowcontrolv1beta2.FlowSchema), nil +} + +// flowSchemaScopedLister can list all FlowSchemas inside a workspace +// or scope down to a listersflowcontrolv1beta2.FlowSchemaNamespaceLister. +type flowSchemaScopedLister struct { + kcplisters.ResourceIndexer[*flowcontrolv1beta2.FlowSchema] } diff --git a/listers/flowcontrol/v1beta2/prioritylevelconfiguration.go b/listers/flowcontrol/v1beta2/prioritylevelconfiguration.go index 1236baac2..f9618b903 100644 --- a/listers/flowcontrol/v1beta2/prioritylevelconfiguration.go +++ b/listers/flowcontrol/v1beta2/prioritylevelconfiguration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta2 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" flowcontrolv1beta2 "k8s.io/api/flowcontrol/v1beta2" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - flowcontrolv1beta2listers "k8s.io/client-go/listers/flowcontrol/v1beta2" + listersflowcontrolv1beta2 "k8s.io/client-go/listers/flowcontrol/v1beta2" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// PriorityLevelConfigurationClusterLister can list PriorityLevelConfigurations across all workspaces, or scope down to a PriorityLevelConfigurationLister for one workspace. +// PriorityLevelConfigurationClusterLister helps list PriorityLevelConfigurations across all workspaces, +// or scope down to a PriorityLevelConfigurationLister for one workspace. // All objects returned here must be treated as read-only. type PriorityLevelConfigurationClusterLister interface { // List lists all PriorityLevelConfigurations in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*flowcontrolv1beta2.PriorityLevelConfiguration, err error) // Cluster returns a lister that can list and get PriorityLevelConfigurations in one workspace. - Cluster(clusterName logicalcluster.Name) flowcontrolv1beta2listers.PriorityLevelConfigurationLister + Cluster(clusterName logicalcluster.Name) listersflowcontrolv1beta2.PriorityLevelConfigurationLister PriorityLevelConfigurationClusterListerExpansion } +// priorityLevelConfigurationClusterLister implements the PriorityLevelConfigurationClusterLister interface. type priorityLevelConfigurationClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*flowcontrolv1beta2.PriorityLevelConfiguration] } +var _ PriorityLevelConfigurationClusterLister = new(priorityLevelConfigurationClusterLister) + // NewPriorityLevelConfigurationClusterLister returns a new PriorityLevelConfigurationClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewPriorityLevelConfigurationClusterLister(indexer cache.Indexer) *priorityLevelConfigurationClusterLister { - return &priorityLevelConfigurationClusterLister{indexer: indexer} -} - -// List lists all PriorityLevelConfigurations in the indexer across all workspaces. -func (s *priorityLevelConfigurationClusterLister) List(selector labels.Selector) (ret []*flowcontrolv1beta2.PriorityLevelConfiguration, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*flowcontrolv1beta2.PriorityLevelConfiguration)) - }) - return ret, err +func NewPriorityLevelConfigurationClusterLister(indexer cache.Indexer) PriorityLevelConfigurationClusterLister { + return &priorityLevelConfigurationClusterLister{ + kcplisters.NewCluster[*flowcontrolv1beta2.PriorityLevelConfiguration](indexer, flowcontrolv1beta2.Resource("prioritylevelconfiguration")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get PriorityLevelConfigurations. -func (s *priorityLevelConfigurationClusterLister) Cluster(clusterName logicalcluster.Name) flowcontrolv1beta2listers.PriorityLevelConfigurationLister { - return &priorityLevelConfigurationLister{indexer: s.indexer, clusterName: clusterName} +func (l *priorityLevelConfigurationClusterLister) Cluster(clusterName logicalcluster.Name) listersflowcontrolv1beta2.PriorityLevelConfigurationLister { + return &priorityLevelConfigurationLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// priorityLevelConfigurationLister implements the flowcontrolv1beta2listers.PriorityLevelConfigurationLister interface. +// priorityLevelConfigurationLister can list all PriorityLevelConfigurations inside a workspace +// or scope down to a listersflowcontrolv1beta2.PriorityLevelConfigurationNamespaceLister for one namespace. type priorityLevelConfigurationLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*flowcontrolv1beta2.PriorityLevelConfiguration] } -// List lists all PriorityLevelConfigurations in the indexer for a workspace. -func (s *priorityLevelConfigurationLister) List(selector labels.Selector) (ret []*flowcontrolv1beta2.PriorityLevelConfiguration, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*flowcontrolv1beta2.PriorityLevelConfiguration)) - }) - return ret, err -} +var _ listersflowcontrolv1beta2.PriorityLevelConfigurationLister = new(priorityLevelConfigurationLister) -// Get retrieves the PriorityLevelConfiguration from the indexer for a given workspace and name. -func (s *priorityLevelConfigurationLister) Get(name string) (*flowcontrolv1beta2.PriorityLevelConfiguration, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(flowcontrolv1beta2.Resource("prioritylevelconfigurations"), name) +// NewPriorityLevelConfigurationLister returns a new PriorityLevelConfigurationLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewPriorityLevelConfigurationLister(indexer cache.Indexer) listersflowcontrolv1beta2.PriorityLevelConfigurationLister { + return &priorityLevelConfigurationLister{ + kcplisters.New[*flowcontrolv1beta2.PriorityLevelConfiguration](indexer, flowcontrolv1beta2.Resource("prioritylevelconfiguration")), } - return obj.(*flowcontrolv1beta2.PriorityLevelConfiguration), nil +} + +// priorityLevelConfigurationScopedLister can list all PriorityLevelConfigurations inside a workspace +// or scope down to a listersflowcontrolv1beta2.PriorityLevelConfigurationNamespaceLister. +type priorityLevelConfigurationScopedLister struct { + kcplisters.ResourceIndexer[*flowcontrolv1beta2.PriorityLevelConfiguration] } diff --git a/listers/flowcontrol/v1beta3/expansion_generated.go b/listers/flowcontrol/v1beta3/expansion_generated.go new file mode 100644 index 000000000..a7b2c2f60 --- /dev/null +++ b/listers/flowcontrol/v1beta3/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1beta3 diff --git a/listers/flowcontrol/v1beta3/flowschema.go b/listers/flowcontrol/v1beta3/flowschema.go index 1e8e6bd03..f0420741f 100644 --- a/listers/flowcontrol/v1beta3/flowschema.go +++ b/listers/flowcontrol/v1beta3/flowschema.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta3 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - flowcontrolv1beta3listers "k8s.io/client-go/listers/flowcontrol/v1beta3" + listersflowcontrolv1beta3 "k8s.io/client-go/listers/flowcontrol/v1beta3" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// FlowSchemaClusterLister can list FlowSchemas across all workspaces, or scope down to a FlowSchemaLister for one workspace. +// FlowSchemaClusterLister helps list FlowSchemas across all workspaces, +// or scope down to a FlowSchemaLister for one workspace. // All objects returned here must be treated as read-only. type FlowSchemaClusterLister interface { // List lists all FlowSchemas in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*flowcontrolv1beta3.FlowSchema, err error) // Cluster returns a lister that can list and get FlowSchemas in one workspace. - Cluster(clusterName logicalcluster.Name) flowcontrolv1beta3listers.FlowSchemaLister + Cluster(clusterName logicalcluster.Name) listersflowcontrolv1beta3.FlowSchemaLister FlowSchemaClusterListerExpansion } +// flowSchemaClusterLister implements the FlowSchemaClusterLister interface. type flowSchemaClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*flowcontrolv1beta3.FlowSchema] } +var _ FlowSchemaClusterLister = new(flowSchemaClusterLister) + // NewFlowSchemaClusterLister returns a new FlowSchemaClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewFlowSchemaClusterLister(indexer cache.Indexer) *flowSchemaClusterLister { - return &flowSchemaClusterLister{indexer: indexer} -} - -// List lists all FlowSchemas in the indexer across all workspaces. -func (s *flowSchemaClusterLister) List(selector labels.Selector) (ret []*flowcontrolv1beta3.FlowSchema, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*flowcontrolv1beta3.FlowSchema)) - }) - return ret, err +func NewFlowSchemaClusterLister(indexer cache.Indexer) FlowSchemaClusterLister { + return &flowSchemaClusterLister{ + kcplisters.NewCluster[*flowcontrolv1beta3.FlowSchema](indexer, flowcontrolv1beta3.Resource("flowschema")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get FlowSchemas. -func (s *flowSchemaClusterLister) Cluster(clusterName logicalcluster.Name) flowcontrolv1beta3listers.FlowSchemaLister { - return &flowSchemaLister{indexer: s.indexer, clusterName: clusterName} +func (l *flowSchemaClusterLister) Cluster(clusterName logicalcluster.Name) listersflowcontrolv1beta3.FlowSchemaLister { + return &flowSchemaLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// flowSchemaLister implements the flowcontrolv1beta3listers.FlowSchemaLister interface. +// flowSchemaLister can list all FlowSchemas inside a workspace +// or scope down to a listersflowcontrolv1beta3.FlowSchemaNamespaceLister for one namespace. type flowSchemaLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*flowcontrolv1beta3.FlowSchema] } -// List lists all FlowSchemas in the indexer for a workspace. -func (s *flowSchemaLister) List(selector labels.Selector) (ret []*flowcontrolv1beta3.FlowSchema, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*flowcontrolv1beta3.FlowSchema)) - }) - return ret, err -} +var _ listersflowcontrolv1beta3.FlowSchemaLister = new(flowSchemaLister) -// Get retrieves the FlowSchema from the indexer for a given workspace and name. -func (s *flowSchemaLister) Get(name string) (*flowcontrolv1beta3.FlowSchema, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(flowcontrolv1beta3.Resource("flowschemas"), name) +// NewFlowSchemaLister returns a new FlowSchemaLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewFlowSchemaLister(indexer cache.Indexer) listersflowcontrolv1beta3.FlowSchemaLister { + return &flowSchemaLister{ + kcplisters.New[*flowcontrolv1beta3.FlowSchema](indexer, flowcontrolv1beta3.Resource("flowschema")), } - return obj.(*flowcontrolv1beta3.FlowSchema), nil +} + +// flowSchemaScopedLister can list all FlowSchemas inside a workspace +// or scope down to a listersflowcontrolv1beta3.FlowSchemaNamespaceLister. +type flowSchemaScopedLister struct { + kcplisters.ResourceIndexer[*flowcontrolv1beta3.FlowSchema] } diff --git a/listers/flowcontrol/v1beta3/prioritylevelconfiguration.go b/listers/flowcontrol/v1beta3/prioritylevelconfiguration.go index 3e1a0dd6b..509b83efb 100644 --- a/listers/flowcontrol/v1beta3/prioritylevelconfiguration.go +++ b/listers/flowcontrol/v1beta3/prioritylevelconfiguration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta3 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - flowcontrolv1beta3listers "k8s.io/client-go/listers/flowcontrol/v1beta3" + listersflowcontrolv1beta3 "k8s.io/client-go/listers/flowcontrol/v1beta3" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// PriorityLevelConfigurationClusterLister can list PriorityLevelConfigurations across all workspaces, or scope down to a PriorityLevelConfigurationLister for one workspace. +// PriorityLevelConfigurationClusterLister helps list PriorityLevelConfigurations across all workspaces, +// or scope down to a PriorityLevelConfigurationLister for one workspace. // All objects returned here must be treated as read-only. type PriorityLevelConfigurationClusterLister interface { // List lists all PriorityLevelConfigurations in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*flowcontrolv1beta3.PriorityLevelConfiguration, err error) // Cluster returns a lister that can list and get PriorityLevelConfigurations in one workspace. - Cluster(clusterName logicalcluster.Name) flowcontrolv1beta3listers.PriorityLevelConfigurationLister + Cluster(clusterName logicalcluster.Name) listersflowcontrolv1beta3.PriorityLevelConfigurationLister PriorityLevelConfigurationClusterListerExpansion } +// priorityLevelConfigurationClusterLister implements the PriorityLevelConfigurationClusterLister interface. type priorityLevelConfigurationClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*flowcontrolv1beta3.PriorityLevelConfiguration] } +var _ PriorityLevelConfigurationClusterLister = new(priorityLevelConfigurationClusterLister) + // NewPriorityLevelConfigurationClusterLister returns a new PriorityLevelConfigurationClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewPriorityLevelConfigurationClusterLister(indexer cache.Indexer) *priorityLevelConfigurationClusterLister { - return &priorityLevelConfigurationClusterLister{indexer: indexer} -} - -// List lists all PriorityLevelConfigurations in the indexer across all workspaces. -func (s *priorityLevelConfigurationClusterLister) List(selector labels.Selector) (ret []*flowcontrolv1beta3.PriorityLevelConfiguration, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*flowcontrolv1beta3.PriorityLevelConfiguration)) - }) - return ret, err +func NewPriorityLevelConfigurationClusterLister(indexer cache.Indexer) PriorityLevelConfigurationClusterLister { + return &priorityLevelConfigurationClusterLister{ + kcplisters.NewCluster[*flowcontrolv1beta3.PriorityLevelConfiguration](indexer, flowcontrolv1beta3.Resource("prioritylevelconfiguration")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get PriorityLevelConfigurations. -func (s *priorityLevelConfigurationClusterLister) Cluster(clusterName logicalcluster.Name) flowcontrolv1beta3listers.PriorityLevelConfigurationLister { - return &priorityLevelConfigurationLister{indexer: s.indexer, clusterName: clusterName} +func (l *priorityLevelConfigurationClusterLister) Cluster(clusterName logicalcluster.Name) listersflowcontrolv1beta3.PriorityLevelConfigurationLister { + return &priorityLevelConfigurationLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// priorityLevelConfigurationLister implements the flowcontrolv1beta3listers.PriorityLevelConfigurationLister interface. +// priorityLevelConfigurationLister can list all PriorityLevelConfigurations inside a workspace +// or scope down to a listersflowcontrolv1beta3.PriorityLevelConfigurationNamespaceLister for one namespace. type priorityLevelConfigurationLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*flowcontrolv1beta3.PriorityLevelConfiguration] } -// List lists all PriorityLevelConfigurations in the indexer for a workspace. -func (s *priorityLevelConfigurationLister) List(selector labels.Selector) (ret []*flowcontrolv1beta3.PriorityLevelConfiguration, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*flowcontrolv1beta3.PriorityLevelConfiguration)) - }) - return ret, err -} +var _ listersflowcontrolv1beta3.PriorityLevelConfigurationLister = new(priorityLevelConfigurationLister) -// Get retrieves the PriorityLevelConfiguration from the indexer for a given workspace and name. -func (s *priorityLevelConfigurationLister) Get(name string) (*flowcontrolv1beta3.PriorityLevelConfiguration, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(flowcontrolv1beta3.Resource("prioritylevelconfigurations"), name) +// NewPriorityLevelConfigurationLister returns a new PriorityLevelConfigurationLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewPriorityLevelConfigurationLister(indexer cache.Indexer) listersflowcontrolv1beta3.PriorityLevelConfigurationLister { + return &priorityLevelConfigurationLister{ + kcplisters.New[*flowcontrolv1beta3.PriorityLevelConfiguration](indexer, flowcontrolv1beta3.Resource("prioritylevelconfiguration")), } - return obj.(*flowcontrolv1beta3.PriorityLevelConfiguration), nil +} + +// priorityLevelConfigurationScopedLister can list all PriorityLevelConfigurations inside a workspace +// or scope down to a listersflowcontrolv1beta3.PriorityLevelConfigurationNamespaceLister. +type priorityLevelConfigurationScopedLister struct { + kcplisters.ResourceIndexer[*flowcontrolv1beta3.PriorityLevelConfiguration] } diff --git a/listers/imagepolicy/v1alpha1/expansion_generated.go b/listers/imagepolicy/v1alpha1/expansion_generated.go new file mode 100644 index 000000000..eca451197 --- /dev/null +++ b/listers/imagepolicy/v1alpha1/expansion_generated.go @@ -0,0 +1,23 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1alpha1 + +// ImageReviewClusterListerExpansion allows custom methods to be added to +// ImageReviewClusterLister. +type ImageReviewClusterListerExpansion interface{} diff --git a/listers/imagepolicy/v1alpha1/imagereview.go b/listers/imagepolicy/v1alpha1/imagereview.go new file mode 100644 index 000000000..8871a27e1 --- /dev/null +++ b/listers/imagepolicy/v1alpha1/imagereview.go @@ -0,0 +1,92 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "github.com/kcp-dev/logicalcluster/v3" + + imagepolicyv1alpha1 "k8s.io/api/imagepolicy/v1alpha1" + "k8s.io/apimachinery/pkg/labels" + listersimagepolicyv1alpha1 "k8s.io/client-go/listers/imagepolicy/v1alpha1" + "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" +) + +// ImageReviewClusterLister helps list ImageReviews across all workspaces, +// or scope down to a ImageReviewLister for one workspace. +// All objects returned here must be treated as read-only. +type ImageReviewClusterLister interface { + // List lists all ImageReviews in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*imagepolicyv1alpha1.ImageReview, err error) + // Cluster returns a lister that can list and get ImageReviews in one workspace. + Cluster(clusterName logicalcluster.Name) listersimagepolicyv1alpha1.ImageReviewLister + ImageReviewClusterListerExpansion +} + +// imageReviewClusterLister implements the ImageReviewClusterLister interface. +type imageReviewClusterLister struct { + kcplisters.ResourceClusterIndexer[*imagepolicyv1alpha1.ImageReview] +} + +var _ ImageReviewClusterLister = new(imageReviewClusterLister) + +// NewImageReviewClusterLister returns a new ImageReviewClusterLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewImageReviewClusterLister(indexer cache.Indexer) ImageReviewClusterLister { + return &imageReviewClusterLister{ + kcplisters.NewCluster[*imagepolicyv1alpha1.ImageReview](indexer, imagepolicyv1alpha1.Resource("imagereview")), + } +} + +// Cluster scopes the lister to one workspace, allowing users to list and get ImageReviews. +func (l *imageReviewClusterLister) Cluster(clusterName logicalcluster.Name) listersimagepolicyv1alpha1.ImageReviewLister { + return &imageReviewLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } +} + +// imageReviewLister can list all ImageReviews inside a workspace +// or scope down to a listersimagepolicyv1alpha1.ImageReviewNamespaceLister for one namespace. +type imageReviewLister struct { + kcplisters.ResourceIndexer[*imagepolicyv1alpha1.ImageReview] +} + +var _ listersimagepolicyv1alpha1.ImageReviewLister = new(imageReviewLister) + +// NewImageReviewLister returns a new ImageReviewLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewImageReviewLister(indexer cache.Indexer) listersimagepolicyv1alpha1.ImageReviewLister { + return &imageReviewLister{ + kcplisters.New[*imagepolicyv1alpha1.ImageReview](indexer, imagepolicyv1alpha1.Resource("imagereview")), + } +} + +// imageReviewScopedLister can list all ImageReviews inside a workspace +// or scope down to a listersimagepolicyv1alpha1.ImageReviewNamespaceLister. +type imageReviewScopedLister struct { + kcplisters.ResourceIndexer[*imagepolicyv1alpha1.ImageReview] +} diff --git a/listers/networking/v1/expansion_generated.go b/listers/networking/v1/expansion_generated.go new file mode 100644 index 000000000..b6a0c6377 --- /dev/null +++ b/listers/networking/v1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1 diff --git a/listers/networking/v1/ingress.go b/listers/networking/v1/ingress.go index 673653fed..bb09975da 100644 --- a/listers/networking/v1/ingress.go +++ b/listers/networking/v1/ingress.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" networkingv1 "k8s.io/api/networking/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - networkingv1listers "k8s.io/client-go/listers/networking/v1" + listersnetworkingv1 "k8s.io/client-go/listers/networking/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// IngressClusterLister can list Ingresses across all workspaces, or scope down to a IngressLister for one workspace. +// IngressClusterLister helps list Ingresses across all workspaces, +// or scope down to a IngressLister for one workspace. // All objects returned here must be treated as read-only. type IngressClusterLister interface { // List lists all Ingresses in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*networkingv1.Ingress, err error) // Cluster returns a lister that can list and get Ingresses in one workspace. - Cluster(clusterName logicalcluster.Name) networkingv1listers.IngressLister + Cluster(clusterName logicalcluster.Name) listersnetworkingv1.IngressLister IngressClusterListerExpansion } +// ingressClusterLister implements the IngressClusterLister interface. type ingressClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*networkingv1.Ingress] } +var _ IngressClusterLister = new(ingressClusterLister) + // NewIngressClusterLister returns a new IngressClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewIngressClusterLister(indexer cache.Indexer) *ingressClusterLister { - return &ingressClusterLister{indexer: indexer} -} - -// List lists all Ingresses in the indexer across all workspaces. -func (s *ingressClusterLister) List(selector labels.Selector) (ret []*networkingv1.Ingress, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*networkingv1.Ingress)) - }) - return ret, err +func NewIngressClusterLister(indexer cache.Indexer) IngressClusterLister { + return &ingressClusterLister{ + kcplisters.NewCluster[*networkingv1.Ingress](indexer, networkingv1.Resource("ingress")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get Ingresses. -func (s *ingressClusterLister) Cluster(clusterName logicalcluster.Name) networkingv1listers.IngressLister { - return &ingressLister{indexer: s.indexer, clusterName: clusterName} +func (l *ingressClusterLister) Cluster(clusterName logicalcluster.Name) listersnetworkingv1.IngressLister { + return &ingressLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// ingressLister implements the networkingv1listers.IngressLister interface. +// ingressLister can list all Ingresses inside a workspace +// or scope down to a listersnetworkingv1.IngressNamespaceLister for one namespace. type ingressLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*networkingv1.Ingress] } -// List lists all Ingresses in the indexer for a workspace. -func (s *ingressLister) List(selector labels.Selector) (ret []*networkingv1.Ingress, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*networkingv1.Ingress)) - }) - return ret, err -} +var _ listersnetworkingv1.IngressLister = new(ingressLister) // Ingresses returns an object that can list and get Ingresses in one namespace. -func (s *ingressLister) Ingresses(namespace string) networkingv1listers.IngressNamespaceLister { - return &ingressNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *ingressLister) Ingresses(namespace string) listersnetworkingv1.IngressNamespaceLister { + return &ingressNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// ingressNamespaceLister implements the networkingv1listers.IngressNamespaceLister interface. +// ingressNamespaceLister implements the listersnetworkingv1.IngressNamespaceLister +// interface. type ingressNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*networkingv1.Ingress] } -// List lists all Ingresses in the indexer for a given workspace and namespace. -func (s *ingressNamespaceLister) List(selector labels.Selector) (ret []*networkingv1.Ingress, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*networkingv1.Ingress)) - }) - return ret, err -} +var _ listersnetworkingv1.IngressNamespaceLister = new(ingressNamespaceLister) -// Get retrieves the Ingress from the indexer for a given workspace, namespace and name. -func (s *ingressNamespaceLister) Get(name string) (*networkingv1.Ingress, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewIngressLister returns a new IngressLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewIngressLister(indexer cache.Indexer) listersnetworkingv1.IngressLister { + return &ingressLister{ + kcplisters.New[*networkingv1.Ingress](indexer, networkingv1.Resource("ingress")), } - if !exists { - return nil, errors.NewNotFound(networkingv1.Resource("ingresses"), name) +} + +// ingressScopedLister can list all Ingresses inside a workspace +// or scope down to a listersnetworkingv1.IngressNamespaceLister for one namespace. +type ingressScopedLister struct { + kcplisters.ResourceIndexer[*networkingv1.Ingress] +} + +// Ingresses returns an object that can list and get Ingresses in one namespace. +func (l *ingressScopedLister) Ingresses(namespace string) listersnetworkingv1.IngressLister { + return &ingressLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*networkingv1.Ingress), nil } diff --git a/listers/networking/v1/ingressclass.go b/listers/networking/v1/ingressclass.go index b4cfabf27..46296102d 100644 --- a/listers/networking/v1/ingressclass.go +++ b/listers/networking/v1/ingressclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" networkingv1 "k8s.io/api/networking/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - networkingv1listers "k8s.io/client-go/listers/networking/v1" + listersnetworkingv1 "k8s.io/client-go/listers/networking/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// IngressClassClusterLister can list IngressClasses across all workspaces, or scope down to a IngressClassLister for one workspace. +// IngressClassClusterLister helps list IngressClasses across all workspaces, +// or scope down to a IngressClassLister for one workspace. // All objects returned here must be treated as read-only. type IngressClassClusterLister interface { // List lists all IngressClasses in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*networkingv1.IngressClass, err error) // Cluster returns a lister that can list and get IngressClasses in one workspace. - Cluster(clusterName logicalcluster.Name) networkingv1listers.IngressClassLister + Cluster(clusterName logicalcluster.Name) listersnetworkingv1.IngressClassLister IngressClassClusterListerExpansion } +// ingressClassClusterLister implements the IngressClassClusterLister interface. type ingressClassClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*networkingv1.IngressClass] } +var _ IngressClassClusterLister = new(ingressClassClusterLister) + // NewIngressClassClusterLister returns a new IngressClassClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewIngressClassClusterLister(indexer cache.Indexer) *ingressClassClusterLister { - return &ingressClassClusterLister{indexer: indexer} -} - -// List lists all IngressClasses in the indexer across all workspaces. -func (s *ingressClassClusterLister) List(selector labels.Selector) (ret []*networkingv1.IngressClass, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*networkingv1.IngressClass)) - }) - return ret, err +func NewIngressClassClusterLister(indexer cache.Indexer) IngressClassClusterLister { + return &ingressClassClusterLister{ + kcplisters.NewCluster[*networkingv1.IngressClass](indexer, networkingv1.Resource("ingressclass")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get IngressClasses. -func (s *ingressClassClusterLister) Cluster(clusterName logicalcluster.Name) networkingv1listers.IngressClassLister { - return &ingressClassLister{indexer: s.indexer, clusterName: clusterName} +func (l *ingressClassClusterLister) Cluster(clusterName logicalcluster.Name) listersnetworkingv1.IngressClassLister { + return &ingressClassLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// ingressClassLister implements the networkingv1listers.IngressClassLister interface. +// ingressClassLister can list all IngressClasses inside a workspace +// or scope down to a listersnetworkingv1.IngressClassNamespaceLister for one namespace. type ingressClassLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*networkingv1.IngressClass] } -// List lists all IngressClasses in the indexer for a workspace. -func (s *ingressClassLister) List(selector labels.Selector) (ret []*networkingv1.IngressClass, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*networkingv1.IngressClass)) - }) - return ret, err -} +var _ listersnetworkingv1.IngressClassLister = new(ingressClassLister) -// Get retrieves the IngressClass from the indexer for a given workspace and name. -func (s *ingressClassLister) Get(name string) (*networkingv1.IngressClass, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(networkingv1.Resource("ingressclasses"), name) +// NewIngressClassLister returns a new IngressClassLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewIngressClassLister(indexer cache.Indexer) listersnetworkingv1.IngressClassLister { + return &ingressClassLister{ + kcplisters.New[*networkingv1.IngressClass](indexer, networkingv1.Resource("ingressclass")), } - return obj.(*networkingv1.IngressClass), nil +} + +// ingressClassScopedLister can list all IngressClasses inside a workspace +// or scope down to a listersnetworkingv1.IngressClassNamespaceLister. +type ingressClassScopedLister struct { + kcplisters.ResourceIndexer[*networkingv1.IngressClass] } diff --git a/listers/networking/v1/networkpolicy.go b/listers/networking/v1/networkpolicy.go index 902bf59bb..8f13015eb 100644 --- a/listers/networking/v1/networkpolicy.go +++ b/listers/networking/v1/networkpolicy.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" networkingv1 "k8s.io/api/networking/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - networkingv1listers "k8s.io/client-go/listers/networking/v1" + listersnetworkingv1 "k8s.io/client-go/listers/networking/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// NetworkPolicyClusterLister can list NetworkPolicies across all workspaces, or scope down to a NetworkPolicyLister for one workspace. +// NetworkPolicyClusterLister helps list NetworkPolicies across all workspaces, +// or scope down to a NetworkPolicyLister for one workspace. // All objects returned here must be treated as read-only. type NetworkPolicyClusterLister interface { // List lists all NetworkPolicies in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*networkingv1.NetworkPolicy, err error) // Cluster returns a lister that can list and get NetworkPolicies in one workspace. - Cluster(clusterName logicalcluster.Name) networkingv1listers.NetworkPolicyLister + Cluster(clusterName logicalcluster.Name) listersnetworkingv1.NetworkPolicyLister NetworkPolicyClusterListerExpansion } +// networkPolicyClusterLister implements the NetworkPolicyClusterLister interface. type networkPolicyClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*networkingv1.NetworkPolicy] } +var _ NetworkPolicyClusterLister = new(networkPolicyClusterLister) + // NewNetworkPolicyClusterLister returns a new NetworkPolicyClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewNetworkPolicyClusterLister(indexer cache.Indexer) *networkPolicyClusterLister { - return &networkPolicyClusterLister{indexer: indexer} -} - -// List lists all NetworkPolicies in the indexer across all workspaces. -func (s *networkPolicyClusterLister) List(selector labels.Selector) (ret []*networkingv1.NetworkPolicy, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*networkingv1.NetworkPolicy)) - }) - return ret, err +func NewNetworkPolicyClusterLister(indexer cache.Indexer) NetworkPolicyClusterLister { + return &networkPolicyClusterLister{ + kcplisters.NewCluster[*networkingv1.NetworkPolicy](indexer, networkingv1.Resource("networkpolicy")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get NetworkPolicies. -func (s *networkPolicyClusterLister) Cluster(clusterName logicalcluster.Name) networkingv1listers.NetworkPolicyLister { - return &networkPolicyLister{indexer: s.indexer, clusterName: clusterName} +func (l *networkPolicyClusterLister) Cluster(clusterName logicalcluster.Name) listersnetworkingv1.NetworkPolicyLister { + return &networkPolicyLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// networkPolicyLister implements the networkingv1listers.NetworkPolicyLister interface. +// networkPolicyLister can list all NetworkPolicies inside a workspace +// or scope down to a listersnetworkingv1.NetworkPolicyNamespaceLister for one namespace. type networkPolicyLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*networkingv1.NetworkPolicy] } -// List lists all NetworkPolicies in the indexer for a workspace. -func (s *networkPolicyLister) List(selector labels.Selector) (ret []*networkingv1.NetworkPolicy, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*networkingv1.NetworkPolicy)) - }) - return ret, err -} +var _ listersnetworkingv1.NetworkPolicyLister = new(networkPolicyLister) // NetworkPolicies returns an object that can list and get NetworkPolicies in one namespace. -func (s *networkPolicyLister) NetworkPolicies(namespace string) networkingv1listers.NetworkPolicyNamespaceLister { - return &networkPolicyNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *networkPolicyLister) NetworkPolicies(namespace string) listersnetworkingv1.NetworkPolicyNamespaceLister { + return &networkPolicyNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// networkPolicyNamespaceLister implements the networkingv1listers.NetworkPolicyNamespaceLister interface. +// networkPolicyNamespaceLister implements the listersnetworkingv1.NetworkPolicyNamespaceLister +// interface. type networkPolicyNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*networkingv1.NetworkPolicy] } -// List lists all NetworkPolicies in the indexer for a given workspace and namespace. -func (s *networkPolicyNamespaceLister) List(selector labels.Selector) (ret []*networkingv1.NetworkPolicy, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*networkingv1.NetworkPolicy)) - }) - return ret, err -} +var _ listersnetworkingv1.NetworkPolicyNamespaceLister = new(networkPolicyNamespaceLister) -// Get retrieves the NetworkPolicy from the indexer for a given workspace, namespace and name. -func (s *networkPolicyNamespaceLister) Get(name string) (*networkingv1.NetworkPolicy, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewNetworkPolicyLister returns a new NetworkPolicyLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewNetworkPolicyLister(indexer cache.Indexer) listersnetworkingv1.NetworkPolicyLister { + return &networkPolicyLister{ + kcplisters.New[*networkingv1.NetworkPolicy](indexer, networkingv1.Resource("networkpolicy")), } - if !exists { - return nil, errors.NewNotFound(networkingv1.Resource("networkpolicies"), name) +} + +// networkPolicyScopedLister can list all NetworkPolicies inside a workspace +// or scope down to a listersnetworkingv1.NetworkPolicyNamespaceLister for one namespace. +type networkPolicyScopedLister struct { + kcplisters.ResourceIndexer[*networkingv1.NetworkPolicy] +} + +// NetworkPolicies returns an object that can list and get NetworkPolicies in one namespace. +func (l *networkPolicyScopedLister) NetworkPolicies(namespace string) listersnetworkingv1.NetworkPolicyLister { + return &networkPolicyLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*networkingv1.NetworkPolicy), nil } diff --git a/listers/networking/v1alpha1/expansion_generated.go b/listers/networking/v1alpha1/expansion_generated.go new file mode 100644 index 000000000..3b8521c00 --- /dev/null +++ b/listers/networking/v1alpha1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1alpha1 diff --git a/listers/networking/v1alpha1/ipaddress.go b/listers/networking/v1alpha1/ipaddress.go index cc877d7e3..caae2c796 100644 --- a/listers/networking/v1alpha1/ipaddress.go +++ b/listers/networking/v1alpha1/ipaddress.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1alpha1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" networkingv1alpha1 "k8s.io/api/networking/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - networkingv1alpha1listers "k8s.io/client-go/listers/networking/v1alpha1" + listersnetworkingv1alpha1 "k8s.io/client-go/listers/networking/v1alpha1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// IPAddressClusterLister can list IPAddresses across all workspaces, or scope down to a IPAddressLister for one workspace. +// IPAddressClusterLister helps list IPAddresses across all workspaces, +// or scope down to a IPAddressLister for one workspace. // All objects returned here must be treated as read-only. type IPAddressClusterLister interface { // List lists all IPAddresses in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*networkingv1alpha1.IPAddress, err error) // Cluster returns a lister that can list and get IPAddresses in one workspace. - Cluster(clusterName logicalcluster.Name) networkingv1alpha1listers.IPAddressLister + Cluster(clusterName logicalcluster.Name) listersnetworkingv1alpha1.IPAddressLister IPAddressClusterListerExpansion } +// iPAddressClusterLister implements the IPAddressClusterLister interface. type iPAddressClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*networkingv1alpha1.IPAddress] } +var _ IPAddressClusterLister = new(iPAddressClusterLister) + // NewIPAddressClusterLister returns a new IPAddressClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewIPAddressClusterLister(indexer cache.Indexer) *iPAddressClusterLister { - return &iPAddressClusterLister{indexer: indexer} -} - -// List lists all IPAddresses in the indexer across all workspaces. -func (s *iPAddressClusterLister) List(selector labels.Selector) (ret []*networkingv1alpha1.IPAddress, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*networkingv1alpha1.IPAddress)) - }) - return ret, err +func NewIPAddressClusterLister(indexer cache.Indexer) IPAddressClusterLister { + return &iPAddressClusterLister{ + kcplisters.NewCluster[*networkingv1alpha1.IPAddress](indexer, networkingv1alpha1.Resource("ipaddress")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get IPAddresses. -func (s *iPAddressClusterLister) Cluster(clusterName logicalcluster.Name) networkingv1alpha1listers.IPAddressLister { - return &iPAddressLister{indexer: s.indexer, clusterName: clusterName} +func (l *iPAddressClusterLister) Cluster(clusterName logicalcluster.Name) listersnetworkingv1alpha1.IPAddressLister { + return &iPAddressLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// iPAddressLister implements the networkingv1alpha1listers.IPAddressLister interface. +// iPAddressLister can list all IPAddresses inside a workspace +// or scope down to a listersnetworkingv1alpha1.IPAddressNamespaceLister for one namespace. type iPAddressLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*networkingv1alpha1.IPAddress] } -// List lists all IPAddresses in the indexer for a workspace. -func (s *iPAddressLister) List(selector labels.Selector) (ret []*networkingv1alpha1.IPAddress, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*networkingv1alpha1.IPAddress)) - }) - return ret, err -} +var _ listersnetworkingv1alpha1.IPAddressLister = new(iPAddressLister) -// Get retrieves the IPAddress from the indexer for a given workspace and name. -func (s *iPAddressLister) Get(name string) (*networkingv1alpha1.IPAddress, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(networkingv1alpha1.Resource("ipaddresses"), name) +// NewIPAddressLister returns a new IPAddressLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewIPAddressLister(indexer cache.Indexer) listersnetworkingv1alpha1.IPAddressLister { + return &iPAddressLister{ + kcplisters.New[*networkingv1alpha1.IPAddress](indexer, networkingv1alpha1.Resource("ipaddress")), } - return obj.(*networkingv1alpha1.IPAddress), nil +} + +// iPAddressScopedLister can list all IPAddresses inside a workspace +// or scope down to a listersnetworkingv1alpha1.IPAddressNamespaceLister. +type iPAddressScopedLister struct { + kcplisters.ResourceIndexer[*networkingv1alpha1.IPAddress] } diff --git a/listers/networking/v1alpha1/servicecidr.go b/listers/networking/v1alpha1/servicecidr.go index 370270f33..00706db44 100644 --- a/listers/networking/v1alpha1/servicecidr.go +++ b/listers/networking/v1alpha1/servicecidr.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1alpha1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" networkingv1alpha1 "k8s.io/api/networking/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - networkingv1alpha1listers "k8s.io/client-go/listers/networking/v1alpha1" + listersnetworkingv1alpha1 "k8s.io/client-go/listers/networking/v1alpha1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ServiceCIDRClusterLister can list ServiceCIDRs across all workspaces, or scope down to a ServiceCIDRLister for one workspace. +// ServiceCIDRClusterLister helps list ServiceCIDRs across all workspaces, +// or scope down to a ServiceCIDRLister for one workspace. // All objects returned here must be treated as read-only. type ServiceCIDRClusterLister interface { // List lists all ServiceCIDRs in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*networkingv1alpha1.ServiceCIDR, err error) // Cluster returns a lister that can list and get ServiceCIDRs in one workspace. - Cluster(clusterName logicalcluster.Name) networkingv1alpha1listers.ServiceCIDRLister + Cluster(clusterName logicalcluster.Name) listersnetworkingv1alpha1.ServiceCIDRLister ServiceCIDRClusterListerExpansion } +// serviceCIDRClusterLister implements the ServiceCIDRClusterLister interface. type serviceCIDRClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*networkingv1alpha1.ServiceCIDR] } +var _ ServiceCIDRClusterLister = new(serviceCIDRClusterLister) + // NewServiceCIDRClusterLister returns a new ServiceCIDRClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewServiceCIDRClusterLister(indexer cache.Indexer) *serviceCIDRClusterLister { - return &serviceCIDRClusterLister{indexer: indexer} -} - -// List lists all ServiceCIDRs in the indexer across all workspaces. -func (s *serviceCIDRClusterLister) List(selector labels.Selector) (ret []*networkingv1alpha1.ServiceCIDR, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*networkingv1alpha1.ServiceCIDR)) - }) - return ret, err +func NewServiceCIDRClusterLister(indexer cache.Indexer) ServiceCIDRClusterLister { + return &serviceCIDRClusterLister{ + kcplisters.NewCluster[*networkingv1alpha1.ServiceCIDR](indexer, networkingv1alpha1.Resource("servicecidr")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ServiceCIDRs. -func (s *serviceCIDRClusterLister) Cluster(clusterName logicalcluster.Name) networkingv1alpha1listers.ServiceCIDRLister { - return &serviceCIDRLister{indexer: s.indexer, clusterName: clusterName} +func (l *serviceCIDRClusterLister) Cluster(clusterName logicalcluster.Name) listersnetworkingv1alpha1.ServiceCIDRLister { + return &serviceCIDRLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// serviceCIDRLister implements the networkingv1alpha1listers.ServiceCIDRLister interface. +// serviceCIDRLister can list all ServiceCIDRs inside a workspace +// or scope down to a listersnetworkingv1alpha1.ServiceCIDRNamespaceLister for one namespace. type serviceCIDRLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*networkingv1alpha1.ServiceCIDR] } -// List lists all ServiceCIDRs in the indexer for a workspace. -func (s *serviceCIDRLister) List(selector labels.Selector) (ret []*networkingv1alpha1.ServiceCIDR, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*networkingv1alpha1.ServiceCIDR)) - }) - return ret, err -} +var _ listersnetworkingv1alpha1.ServiceCIDRLister = new(serviceCIDRLister) -// Get retrieves the ServiceCIDR from the indexer for a given workspace and name. -func (s *serviceCIDRLister) Get(name string) (*networkingv1alpha1.ServiceCIDR, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(networkingv1alpha1.Resource("servicecidrs"), name) +// NewServiceCIDRLister returns a new ServiceCIDRLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewServiceCIDRLister(indexer cache.Indexer) listersnetworkingv1alpha1.ServiceCIDRLister { + return &serviceCIDRLister{ + kcplisters.New[*networkingv1alpha1.ServiceCIDR](indexer, networkingv1alpha1.Resource("servicecidr")), } - return obj.(*networkingv1alpha1.ServiceCIDR), nil +} + +// serviceCIDRScopedLister can list all ServiceCIDRs inside a workspace +// or scope down to a listersnetworkingv1alpha1.ServiceCIDRNamespaceLister. +type serviceCIDRScopedLister struct { + kcplisters.ResourceIndexer[*networkingv1alpha1.ServiceCIDR] } diff --git a/listers/networking/v1beta1/expansion_generated.go b/listers/networking/v1beta1/expansion_generated.go new file mode 100644 index 000000000..23cac805b --- /dev/null +++ b/listers/networking/v1beta1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1beta1 diff --git a/listers/networking/v1beta1/ingress.go b/listers/networking/v1beta1/ingress.go index 9193e7a4c..6f3459921 100644 --- a/listers/networking/v1beta1/ingress.go +++ b/listers/networking/v1beta1/ingress.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" networkingv1beta1 "k8s.io/api/networking/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - networkingv1beta1listers "k8s.io/client-go/listers/networking/v1beta1" + listersnetworkingv1beta1 "k8s.io/client-go/listers/networking/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// IngressClusterLister can list Ingresses across all workspaces, or scope down to a IngressLister for one workspace. +// IngressClusterLister helps list Ingresses across all workspaces, +// or scope down to a IngressLister for one workspace. // All objects returned here must be treated as read-only. type IngressClusterLister interface { // List lists all Ingresses in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*networkingv1beta1.Ingress, err error) // Cluster returns a lister that can list and get Ingresses in one workspace. - Cluster(clusterName logicalcluster.Name) networkingv1beta1listers.IngressLister + Cluster(clusterName logicalcluster.Name) listersnetworkingv1beta1.IngressLister IngressClusterListerExpansion } +// ingressClusterLister implements the IngressClusterLister interface. type ingressClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*networkingv1beta1.Ingress] } +var _ IngressClusterLister = new(ingressClusterLister) + // NewIngressClusterLister returns a new IngressClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewIngressClusterLister(indexer cache.Indexer) *ingressClusterLister { - return &ingressClusterLister{indexer: indexer} -} - -// List lists all Ingresses in the indexer across all workspaces. -func (s *ingressClusterLister) List(selector labels.Selector) (ret []*networkingv1beta1.Ingress, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*networkingv1beta1.Ingress)) - }) - return ret, err +func NewIngressClusterLister(indexer cache.Indexer) IngressClusterLister { + return &ingressClusterLister{ + kcplisters.NewCluster[*networkingv1beta1.Ingress](indexer, networkingv1beta1.Resource("ingress")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get Ingresses. -func (s *ingressClusterLister) Cluster(clusterName logicalcluster.Name) networkingv1beta1listers.IngressLister { - return &ingressLister{indexer: s.indexer, clusterName: clusterName} +func (l *ingressClusterLister) Cluster(clusterName logicalcluster.Name) listersnetworkingv1beta1.IngressLister { + return &ingressLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// ingressLister implements the networkingv1beta1listers.IngressLister interface. +// ingressLister can list all Ingresses inside a workspace +// or scope down to a listersnetworkingv1beta1.IngressNamespaceLister for one namespace. type ingressLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*networkingv1beta1.Ingress] } -// List lists all Ingresses in the indexer for a workspace. -func (s *ingressLister) List(selector labels.Selector) (ret []*networkingv1beta1.Ingress, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*networkingv1beta1.Ingress)) - }) - return ret, err -} +var _ listersnetworkingv1beta1.IngressLister = new(ingressLister) // Ingresses returns an object that can list and get Ingresses in one namespace. -func (s *ingressLister) Ingresses(namespace string) networkingv1beta1listers.IngressNamespaceLister { - return &ingressNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *ingressLister) Ingresses(namespace string) listersnetworkingv1beta1.IngressNamespaceLister { + return &ingressNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// ingressNamespaceLister implements the networkingv1beta1listers.IngressNamespaceLister interface. +// ingressNamespaceLister implements the listersnetworkingv1beta1.IngressNamespaceLister +// interface. type ingressNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*networkingv1beta1.Ingress] } -// List lists all Ingresses in the indexer for a given workspace and namespace. -func (s *ingressNamespaceLister) List(selector labels.Selector) (ret []*networkingv1beta1.Ingress, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*networkingv1beta1.Ingress)) - }) - return ret, err -} +var _ listersnetworkingv1beta1.IngressNamespaceLister = new(ingressNamespaceLister) -// Get retrieves the Ingress from the indexer for a given workspace, namespace and name. -func (s *ingressNamespaceLister) Get(name string) (*networkingv1beta1.Ingress, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewIngressLister returns a new IngressLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewIngressLister(indexer cache.Indexer) listersnetworkingv1beta1.IngressLister { + return &ingressLister{ + kcplisters.New[*networkingv1beta1.Ingress](indexer, networkingv1beta1.Resource("ingress")), } - if !exists { - return nil, errors.NewNotFound(networkingv1beta1.Resource("ingresses"), name) +} + +// ingressScopedLister can list all Ingresses inside a workspace +// or scope down to a listersnetworkingv1beta1.IngressNamespaceLister for one namespace. +type ingressScopedLister struct { + kcplisters.ResourceIndexer[*networkingv1beta1.Ingress] +} + +// Ingresses returns an object that can list and get Ingresses in one namespace. +func (l *ingressScopedLister) Ingresses(namespace string) listersnetworkingv1beta1.IngressLister { + return &ingressLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*networkingv1beta1.Ingress), nil } diff --git a/listers/networking/v1beta1/ingressclass.go b/listers/networking/v1beta1/ingressclass.go index 4a36e1703..d858f2de5 100644 --- a/listers/networking/v1beta1/ingressclass.go +++ b/listers/networking/v1beta1/ingressclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" networkingv1beta1 "k8s.io/api/networking/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - networkingv1beta1listers "k8s.io/client-go/listers/networking/v1beta1" + listersnetworkingv1beta1 "k8s.io/client-go/listers/networking/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// IngressClassClusterLister can list IngressClasses across all workspaces, or scope down to a IngressClassLister for one workspace. +// IngressClassClusterLister helps list IngressClasses across all workspaces, +// or scope down to a IngressClassLister for one workspace. // All objects returned here must be treated as read-only. type IngressClassClusterLister interface { // List lists all IngressClasses in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*networkingv1beta1.IngressClass, err error) // Cluster returns a lister that can list and get IngressClasses in one workspace. - Cluster(clusterName logicalcluster.Name) networkingv1beta1listers.IngressClassLister + Cluster(clusterName logicalcluster.Name) listersnetworkingv1beta1.IngressClassLister IngressClassClusterListerExpansion } +// ingressClassClusterLister implements the IngressClassClusterLister interface. type ingressClassClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*networkingv1beta1.IngressClass] } +var _ IngressClassClusterLister = new(ingressClassClusterLister) + // NewIngressClassClusterLister returns a new IngressClassClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewIngressClassClusterLister(indexer cache.Indexer) *ingressClassClusterLister { - return &ingressClassClusterLister{indexer: indexer} -} - -// List lists all IngressClasses in the indexer across all workspaces. -func (s *ingressClassClusterLister) List(selector labels.Selector) (ret []*networkingv1beta1.IngressClass, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*networkingv1beta1.IngressClass)) - }) - return ret, err +func NewIngressClassClusterLister(indexer cache.Indexer) IngressClassClusterLister { + return &ingressClassClusterLister{ + kcplisters.NewCluster[*networkingv1beta1.IngressClass](indexer, networkingv1beta1.Resource("ingressclass")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get IngressClasses. -func (s *ingressClassClusterLister) Cluster(clusterName logicalcluster.Name) networkingv1beta1listers.IngressClassLister { - return &ingressClassLister{indexer: s.indexer, clusterName: clusterName} +func (l *ingressClassClusterLister) Cluster(clusterName logicalcluster.Name) listersnetworkingv1beta1.IngressClassLister { + return &ingressClassLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// ingressClassLister implements the networkingv1beta1listers.IngressClassLister interface. +// ingressClassLister can list all IngressClasses inside a workspace +// or scope down to a listersnetworkingv1beta1.IngressClassNamespaceLister for one namespace. type ingressClassLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*networkingv1beta1.IngressClass] } -// List lists all IngressClasses in the indexer for a workspace. -func (s *ingressClassLister) List(selector labels.Selector) (ret []*networkingv1beta1.IngressClass, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*networkingv1beta1.IngressClass)) - }) - return ret, err -} +var _ listersnetworkingv1beta1.IngressClassLister = new(ingressClassLister) -// Get retrieves the IngressClass from the indexer for a given workspace and name. -func (s *ingressClassLister) Get(name string) (*networkingv1beta1.IngressClass, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(networkingv1beta1.Resource("ingressclasses"), name) +// NewIngressClassLister returns a new IngressClassLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewIngressClassLister(indexer cache.Indexer) listersnetworkingv1beta1.IngressClassLister { + return &ingressClassLister{ + kcplisters.New[*networkingv1beta1.IngressClass](indexer, networkingv1beta1.Resource("ingressclass")), } - return obj.(*networkingv1beta1.IngressClass), nil +} + +// ingressClassScopedLister can list all IngressClasses inside a workspace +// or scope down to a listersnetworkingv1beta1.IngressClassNamespaceLister. +type ingressClassScopedLister struct { + kcplisters.ResourceIndexer[*networkingv1beta1.IngressClass] } diff --git a/listers/networking/v1beta1/ipaddress.go b/listers/networking/v1beta1/ipaddress.go index e1375cf8d..539cac944 100644 --- a/listers/networking/v1beta1/ipaddress.go +++ b/listers/networking/v1beta1/ipaddress.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" networkingv1beta1 "k8s.io/api/networking/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - networkingv1beta1listers "k8s.io/client-go/listers/networking/v1beta1" + listersnetworkingv1beta1 "k8s.io/client-go/listers/networking/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// IPAddressClusterLister can list IPAddresses across all workspaces, or scope down to a IPAddressLister for one workspace. +// IPAddressClusterLister helps list IPAddresses across all workspaces, +// or scope down to a IPAddressLister for one workspace. // All objects returned here must be treated as read-only. type IPAddressClusterLister interface { // List lists all IPAddresses in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*networkingv1beta1.IPAddress, err error) // Cluster returns a lister that can list and get IPAddresses in one workspace. - Cluster(clusterName logicalcluster.Name) networkingv1beta1listers.IPAddressLister + Cluster(clusterName logicalcluster.Name) listersnetworkingv1beta1.IPAddressLister IPAddressClusterListerExpansion } +// iPAddressClusterLister implements the IPAddressClusterLister interface. type iPAddressClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*networkingv1beta1.IPAddress] } +var _ IPAddressClusterLister = new(iPAddressClusterLister) + // NewIPAddressClusterLister returns a new IPAddressClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewIPAddressClusterLister(indexer cache.Indexer) *iPAddressClusterLister { - return &iPAddressClusterLister{indexer: indexer} -} - -// List lists all IPAddresses in the indexer across all workspaces. -func (s *iPAddressClusterLister) List(selector labels.Selector) (ret []*networkingv1beta1.IPAddress, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*networkingv1beta1.IPAddress)) - }) - return ret, err +func NewIPAddressClusterLister(indexer cache.Indexer) IPAddressClusterLister { + return &iPAddressClusterLister{ + kcplisters.NewCluster[*networkingv1beta1.IPAddress](indexer, networkingv1beta1.Resource("ipaddress")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get IPAddresses. -func (s *iPAddressClusterLister) Cluster(clusterName logicalcluster.Name) networkingv1beta1listers.IPAddressLister { - return &iPAddressLister{indexer: s.indexer, clusterName: clusterName} +func (l *iPAddressClusterLister) Cluster(clusterName logicalcluster.Name) listersnetworkingv1beta1.IPAddressLister { + return &iPAddressLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// iPAddressLister implements the networkingv1beta1listers.IPAddressLister interface. +// iPAddressLister can list all IPAddresses inside a workspace +// or scope down to a listersnetworkingv1beta1.IPAddressNamespaceLister for one namespace. type iPAddressLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*networkingv1beta1.IPAddress] } -// List lists all IPAddresses in the indexer for a workspace. -func (s *iPAddressLister) List(selector labels.Selector) (ret []*networkingv1beta1.IPAddress, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*networkingv1beta1.IPAddress)) - }) - return ret, err -} +var _ listersnetworkingv1beta1.IPAddressLister = new(iPAddressLister) -// Get retrieves the IPAddress from the indexer for a given workspace and name. -func (s *iPAddressLister) Get(name string) (*networkingv1beta1.IPAddress, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(networkingv1beta1.Resource("ipaddresses"), name) +// NewIPAddressLister returns a new IPAddressLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewIPAddressLister(indexer cache.Indexer) listersnetworkingv1beta1.IPAddressLister { + return &iPAddressLister{ + kcplisters.New[*networkingv1beta1.IPAddress](indexer, networkingv1beta1.Resource("ipaddress")), } - return obj.(*networkingv1beta1.IPAddress), nil +} + +// iPAddressScopedLister can list all IPAddresses inside a workspace +// or scope down to a listersnetworkingv1beta1.IPAddressNamespaceLister. +type iPAddressScopedLister struct { + kcplisters.ResourceIndexer[*networkingv1beta1.IPAddress] } diff --git a/listers/networking/v1beta1/servicecidr.go b/listers/networking/v1beta1/servicecidr.go index 5238b320c..09464da33 100644 --- a/listers/networking/v1beta1/servicecidr.go +++ b/listers/networking/v1beta1/servicecidr.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" networkingv1beta1 "k8s.io/api/networking/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - networkingv1beta1listers "k8s.io/client-go/listers/networking/v1beta1" + listersnetworkingv1beta1 "k8s.io/client-go/listers/networking/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ServiceCIDRClusterLister can list ServiceCIDRs across all workspaces, or scope down to a ServiceCIDRLister for one workspace. +// ServiceCIDRClusterLister helps list ServiceCIDRs across all workspaces, +// or scope down to a ServiceCIDRLister for one workspace. // All objects returned here must be treated as read-only. type ServiceCIDRClusterLister interface { // List lists all ServiceCIDRs in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*networkingv1beta1.ServiceCIDR, err error) // Cluster returns a lister that can list and get ServiceCIDRs in one workspace. - Cluster(clusterName logicalcluster.Name) networkingv1beta1listers.ServiceCIDRLister + Cluster(clusterName logicalcluster.Name) listersnetworkingv1beta1.ServiceCIDRLister ServiceCIDRClusterListerExpansion } +// serviceCIDRClusterLister implements the ServiceCIDRClusterLister interface. type serviceCIDRClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*networkingv1beta1.ServiceCIDR] } +var _ ServiceCIDRClusterLister = new(serviceCIDRClusterLister) + // NewServiceCIDRClusterLister returns a new ServiceCIDRClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewServiceCIDRClusterLister(indexer cache.Indexer) *serviceCIDRClusterLister { - return &serviceCIDRClusterLister{indexer: indexer} -} - -// List lists all ServiceCIDRs in the indexer across all workspaces. -func (s *serviceCIDRClusterLister) List(selector labels.Selector) (ret []*networkingv1beta1.ServiceCIDR, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*networkingv1beta1.ServiceCIDR)) - }) - return ret, err +func NewServiceCIDRClusterLister(indexer cache.Indexer) ServiceCIDRClusterLister { + return &serviceCIDRClusterLister{ + kcplisters.NewCluster[*networkingv1beta1.ServiceCIDR](indexer, networkingv1beta1.Resource("servicecidr")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ServiceCIDRs. -func (s *serviceCIDRClusterLister) Cluster(clusterName logicalcluster.Name) networkingv1beta1listers.ServiceCIDRLister { - return &serviceCIDRLister{indexer: s.indexer, clusterName: clusterName} +func (l *serviceCIDRClusterLister) Cluster(clusterName logicalcluster.Name) listersnetworkingv1beta1.ServiceCIDRLister { + return &serviceCIDRLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// serviceCIDRLister implements the networkingv1beta1listers.ServiceCIDRLister interface. +// serviceCIDRLister can list all ServiceCIDRs inside a workspace +// or scope down to a listersnetworkingv1beta1.ServiceCIDRNamespaceLister for one namespace. type serviceCIDRLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*networkingv1beta1.ServiceCIDR] } -// List lists all ServiceCIDRs in the indexer for a workspace. -func (s *serviceCIDRLister) List(selector labels.Selector) (ret []*networkingv1beta1.ServiceCIDR, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*networkingv1beta1.ServiceCIDR)) - }) - return ret, err -} +var _ listersnetworkingv1beta1.ServiceCIDRLister = new(serviceCIDRLister) -// Get retrieves the ServiceCIDR from the indexer for a given workspace and name. -func (s *serviceCIDRLister) Get(name string) (*networkingv1beta1.ServiceCIDR, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(networkingv1beta1.Resource("servicecidrs"), name) +// NewServiceCIDRLister returns a new ServiceCIDRLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewServiceCIDRLister(indexer cache.Indexer) listersnetworkingv1beta1.ServiceCIDRLister { + return &serviceCIDRLister{ + kcplisters.New[*networkingv1beta1.ServiceCIDR](indexer, networkingv1beta1.Resource("servicecidr")), } - return obj.(*networkingv1beta1.ServiceCIDR), nil +} + +// serviceCIDRScopedLister can list all ServiceCIDRs inside a workspace +// or scope down to a listersnetworkingv1beta1.ServiceCIDRNamespaceLister. +type serviceCIDRScopedLister struct { + kcplisters.ResourceIndexer[*networkingv1beta1.ServiceCIDR] } diff --git a/listers/node/v1/expansion_generated.go b/listers/node/v1/expansion_generated.go new file mode 100644 index 000000000..b6a0c6377 --- /dev/null +++ b/listers/node/v1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1 diff --git a/listers/node/v1/runtimeclass.go b/listers/node/v1/runtimeclass.go index 57eb8ce71..ab8f5a863 100644 --- a/listers/node/v1/runtimeclass.go +++ b/listers/node/v1/runtimeclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" nodev1 "k8s.io/api/node/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - nodev1listers "k8s.io/client-go/listers/node/v1" + listersnodev1 "k8s.io/client-go/listers/node/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// RuntimeClassClusterLister can list RuntimeClasses across all workspaces, or scope down to a RuntimeClassLister for one workspace. +// RuntimeClassClusterLister helps list RuntimeClasses across all workspaces, +// or scope down to a RuntimeClassLister for one workspace. // All objects returned here must be treated as read-only. type RuntimeClassClusterLister interface { // List lists all RuntimeClasses in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*nodev1.RuntimeClass, err error) // Cluster returns a lister that can list and get RuntimeClasses in one workspace. - Cluster(clusterName logicalcluster.Name) nodev1listers.RuntimeClassLister + Cluster(clusterName logicalcluster.Name) listersnodev1.RuntimeClassLister RuntimeClassClusterListerExpansion } +// runtimeClassClusterLister implements the RuntimeClassClusterLister interface. type runtimeClassClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*nodev1.RuntimeClass] } +var _ RuntimeClassClusterLister = new(runtimeClassClusterLister) + // NewRuntimeClassClusterLister returns a new RuntimeClassClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewRuntimeClassClusterLister(indexer cache.Indexer) *runtimeClassClusterLister { - return &runtimeClassClusterLister{indexer: indexer} -} - -// List lists all RuntimeClasses in the indexer across all workspaces. -func (s *runtimeClassClusterLister) List(selector labels.Selector) (ret []*nodev1.RuntimeClass, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*nodev1.RuntimeClass)) - }) - return ret, err +func NewRuntimeClassClusterLister(indexer cache.Indexer) RuntimeClassClusterLister { + return &runtimeClassClusterLister{ + kcplisters.NewCluster[*nodev1.RuntimeClass](indexer, nodev1.Resource("runtimeclass")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get RuntimeClasses. -func (s *runtimeClassClusterLister) Cluster(clusterName logicalcluster.Name) nodev1listers.RuntimeClassLister { - return &runtimeClassLister{indexer: s.indexer, clusterName: clusterName} +func (l *runtimeClassClusterLister) Cluster(clusterName logicalcluster.Name) listersnodev1.RuntimeClassLister { + return &runtimeClassLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// runtimeClassLister implements the nodev1listers.RuntimeClassLister interface. +// runtimeClassLister can list all RuntimeClasses inside a workspace +// or scope down to a listersnodev1.RuntimeClassNamespaceLister for one namespace. type runtimeClassLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*nodev1.RuntimeClass] } -// List lists all RuntimeClasses in the indexer for a workspace. -func (s *runtimeClassLister) List(selector labels.Selector) (ret []*nodev1.RuntimeClass, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*nodev1.RuntimeClass)) - }) - return ret, err -} +var _ listersnodev1.RuntimeClassLister = new(runtimeClassLister) -// Get retrieves the RuntimeClass from the indexer for a given workspace and name. -func (s *runtimeClassLister) Get(name string) (*nodev1.RuntimeClass, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(nodev1.Resource("runtimeclasses"), name) +// NewRuntimeClassLister returns a new RuntimeClassLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewRuntimeClassLister(indexer cache.Indexer) listersnodev1.RuntimeClassLister { + return &runtimeClassLister{ + kcplisters.New[*nodev1.RuntimeClass](indexer, nodev1.Resource("runtimeclass")), } - return obj.(*nodev1.RuntimeClass), nil +} + +// runtimeClassScopedLister can list all RuntimeClasses inside a workspace +// or scope down to a listersnodev1.RuntimeClassNamespaceLister. +type runtimeClassScopedLister struct { + kcplisters.ResourceIndexer[*nodev1.RuntimeClass] } diff --git a/listers/node/v1alpha1/expansion_generated.go b/listers/node/v1alpha1/expansion_generated.go new file mode 100644 index 000000000..3b8521c00 --- /dev/null +++ b/listers/node/v1alpha1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1alpha1 diff --git a/listers/node/v1alpha1/runtimeclass.go b/listers/node/v1alpha1/runtimeclass.go index a60f75d23..64f864aa1 100644 --- a/listers/node/v1alpha1/runtimeclass.go +++ b/listers/node/v1alpha1/runtimeclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1alpha1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" nodev1alpha1 "k8s.io/api/node/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - nodev1alpha1listers "k8s.io/client-go/listers/node/v1alpha1" + listersnodev1alpha1 "k8s.io/client-go/listers/node/v1alpha1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// RuntimeClassClusterLister can list RuntimeClasses across all workspaces, or scope down to a RuntimeClassLister for one workspace. +// RuntimeClassClusterLister helps list RuntimeClasses across all workspaces, +// or scope down to a RuntimeClassLister for one workspace. // All objects returned here must be treated as read-only. type RuntimeClassClusterLister interface { // List lists all RuntimeClasses in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*nodev1alpha1.RuntimeClass, err error) // Cluster returns a lister that can list and get RuntimeClasses in one workspace. - Cluster(clusterName logicalcluster.Name) nodev1alpha1listers.RuntimeClassLister + Cluster(clusterName logicalcluster.Name) listersnodev1alpha1.RuntimeClassLister RuntimeClassClusterListerExpansion } +// runtimeClassClusterLister implements the RuntimeClassClusterLister interface. type runtimeClassClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*nodev1alpha1.RuntimeClass] } +var _ RuntimeClassClusterLister = new(runtimeClassClusterLister) + // NewRuntimeClassClusterLister returns a new RuntimeClassClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewRuntimeClassClusterLister(indexer cache.Indexer) *runtimeClassClusterLister { - return &runtimeClassClusterLister{indexer: indexer} -} - -// List lists all RuntimeClasses in the indexer across all workspaces. -func (s *runtimeClassClusterLister) List(selector labels.Selector) (ret []*nodev1alpha1.RuntimeClass, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*nodev1alpha1.RuntimeClass)) - }) - return ret, err +func NewRuntimeClassClusterLister(indexer cache.Indexer) RuntimeClassClusterLister { + return &runtimeClassClusterLister{ + kcplisters.NewCluster[*nodev1alpha1.RuntimeClass](indexer, nodev1alpha1.Resource("runtimeclass")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get RuntimeClasses. -func (s *runtimeClassClusterLister) Cluster(clusterName logicalcluster.Name) nodev1alpha1listers.RuntimeClassLister { - return &runtimeClassLister{indexer: s.indexer, clusterName: clusterName} +func (l *runtimeClassClusterLister) Cluster(clusterName logicalcluster.Name) listersnodev1alpha1.RuntimeClassLister { + return &runtimeClassLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// runtimeClassLister implements the nodev1alpha1listers.RuntimeClassLister interface. +// runtimeClassLister can list all RuntimeClasses inside a workspace +// or scope down to a listersnodev1alpha1.RuntimeClassNamespaceLister for one namespace. type runtimeClassLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*nodev1alpha1.RuntimeClass] } -// List lists all RuntimeClasses in the indexer for a workspace. -func (s *runtimeClassLister) List(selector labels.Selector) (ret []*nodev1alpha1.RuntimeClass, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*nodev1alpha1.RuntimeClass)) - }) - return ret, err -} +var _ listersnodev1alpha1.RuntimeClassLister = new(runtimeClassLister) -// Get retrieves the RuntimeClass from the indexer for a given workspace and name. -func (s *runtimeClassLister) Get(name string) (*nodev1alpha1.RuntimeClass, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(nodev1alpha1.Resource("runtimeclasses"), name) +// NewRuntimeClassLister returns a new RuntimeClassLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewRuntimeClassLister(indexer cache.Indexer) listersnodev1alpha1.RuntimeClassLister { + return &runtimeClassLister{ + kcplisters.New[*nodev1alpha1.RuntimeClass](indexer, nodev1alpha1.Resource("runtimeclass")), } - return obj.(*nodev1alpha1.RuntimeClass), nil +} + +// runtimeClassScopedLister can list all RuntimeClasses inside a workspace +// or scope down to a listersnodev1alpha1.RuntimeClassNamespaceLister. +type runtimeClassScopedLister struct { + kcplisters.ResourceIndexer[*nodev1alpha1.RuntimeClass] } diff --git a/listers/node/v1beta1/expansion_generated.go b/listers/node/v1beta1/expansion_generated.go new file mode 100644 index 000000000..23cac805b --- /dev/null +++ b/listers/node/v1beta1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1beta1 diff --git a/listers/node/v1beta1/runtimeclass.go b/listers/node/v1beta1/runtimeclass.go index ba89858b9..8d755c58b 100644 --- a/listers/node/v1beta1/runtimeclass.go +++ b/listers/node/v1beta1/runtimeclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" nodev1beta1 "k8s.io/api/node/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - nodev1beta1listers "k8s.io/client-go/listers/node/v1beta1" + listersnodev1beta1 "k8s.io/client-go/listers/node/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// RuntimeClassClusterLister can list RuntimeClasses across all workspaces, or scope down to a RuntimeClassLister for one workspace. +// RuntimeClassClusterLister helps list RuntimeClasses across all workspaces, +// or scope down to a RuntimeClassLister for one workspace. // All objects returned here must be treated as read-only. type RuntimeClassClusterLister interface { // List lists all RuntimeClasses in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*nodev1beta1.RuntimeClass, err error) // Cluster returns a lister that can list and get RuntimeClasses in one workspace. - Cluster(clusterName logicalcluster.Name) nodev1beta1listers.RuntimeClassLister + Cluster(clusterName logicalcluster.Name) listersnodev1beta1.RuntimeClassLister RuntimeClassClusterListerExpansion } +// runtimeClassClusterLister implements the RuntimeClassClusterLister interface. type runtimeClassClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*nodev1beta1.RuntimeClass] } +var _ RuntimeClassClusterLister = new(runtimeClassClusterLister) + // NewRuntimeClassClusterLister returns a new RuntimeClassClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewRuntimeClassClusterLister(indexer cache.Indexer) *runtimeClassClusterLister { - return &runtimeClassClusterLister{indexer: indexer} -} - -// List lists all RuntimeClasses in the indexer across all workspaces. -func (s *runtimeClassClusterLister) List(selector labels.Selector) (ret []*nodev1beta1.RuntimeClass, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*nodev1beta1.RuntimeClass)) - }) - return ret, err +func NewRuntimeClassClusterLister(indexer cache.Indexer) RuntimeClassClusterLister { + return &runtimeClassClusterLister{ + kcplisters.NewCluster[*nodev1beta1.RuntimeClass](indexer, nodev1beta1.Resource("runtimeclass")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get RuntimeClasses. -func (s *runtimeClassClusterLister) Cluster(clusterName logicalcluster.Name) nodev1beta1listers.RuntimeClassLister { - return &runtimeClassLister{indexer: s.indexer, clusterName: clusterName} +func (l *runtimeClassClusterLister) Cluster(clusterName logicalcluster.Name) listersnodev1beta1.RuntimeClassLister { + return &runtimeClassLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// runtimeClassLister implements the nodev1beta1listers.RuntimeClassLister interface. +// runtimeClassLister can list all RuntimeClasses inside a workspace +// or scope down to a listersnodev1beta1.RuntimeClassNamespaceLister for one namespace. type runtimeClassLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*nodev1beta1.RuntimeClass] } -// List lists all RuntimeClasses in the indexer for a workspace. -func (s *runtimeClassLister) List(selector labels.Selector) (ret []*nodev1beta1.RuntimeClass, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*nodev1beta1.RuntimeClass)) - }) - return ret, err -} +var _ listersnodev1beta1.RuntimeClassLister = new(runtimeClassLister) -// Get retrieves the RuntimeClass from the indexer for a given workspace and name. -func (s *runtimeClassLister) Get(name string) (*nodev1beta1.RuntimeClass, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(nodev1beta1.Resource("runtimeclasses"), name) +// NewRuntimeClassLister returns a new RuntimeClassLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewRuntimeClassLister(indexer cache.Indexer) listersnodev1beta1.RuntimeClassLister { + return &runtimeClassLister{ + kcplisters.New[*nodev1beta1.RuntimeClass](indexer, nodev1beta1.Resource("runtimeclass")), } - return obj.(*nodev1beta1.RuntimeClass), nil +} + +// runtimeClassScopedLister can list all RuntimeClasses inside a workspace +// or scope down to a listersnodev1beta1.RuntimeClassNamespaceLister. +type runtimeClassScopedLister struct { + kcplisters.ResourceIndexer[*nodev1beta1.RuntimeClass] } diff --git a/listers/policy/v1/eviction.go b/listers/policy/v1/eviction.go new file mode 100644 index 000000000..07551c3b3 --- /dev/null +++ b/listers/policy/v1/eviction.go @@ -0,0 +1,116 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1 + +import ( + "github.com/kcp-dev/logicalcluster/v3" + + policyv1 "k8s.io/api/policy/v1" + "k8s.io/apimachinery/pkg/labels" + listerspolicyv1 "k8s.io/client-go/listers/policy/v1" + "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" +) + +// EvictionClusterLister helps list Evictions across all workspaces, +// or scope down to a EvictionLister for one workspace. +// All objects returned here must be treated as read-only. +type EvictionClusterLister interface { + // List lists all Evictions in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*policyv1.Eviction, err error) + // Cluster returns a lister that can list and get Evictions in one workspace. + Cluster(clusterName logicalcluster.Name) listerspolicyv1.EvictionLister + EvictionClusterListerExpansion +} + +// evictionClusterLister implements the EvictionClusterLister interface. +type evictionClusterLister struct { + kcplisters.ResourceClusterIndexer[*policyv1.Eviction] +} + +var _ EvictionClusterLister = new(evictionClusterLister) + +// NewEvictionClusterLister returns a new EvictionClusterLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewEvictionClusterLister(indexer cache.Indexer) EvictionClusterLister { + return &evictionClusterLister{ + kcplisters.NewCluster[*policyv1.Eviction](indexer, policyv1.Resource("eviction")), + } +} + +// Cluster scopes the lister to one workspace, allowing users to list and get Evictions. +func (l *evictionClusterLister) Cluster(clusterName logicalcluster.Name) listerspolicyv1.EvictionLister { + return &evictionLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } +} + +// evictionLister can list all Evictions inside a workspace +// or scope down to a listerspolicyv1.EvictionNamespaceLister for one namespace. +type evictionLister struct { + kcplisters.ResourceIndexer[*policyv1.Eviction] +} + +var _ listerspolicyv1.EvictionLister = new(evictionLister) + +// Evictions returns an object that can list and get Evictions in one namespace. +func (l *evictionLister) Evictions(namespace string) listerspolicyv1.EvictionNamespaceLister { + return &evictionNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } +} + +// evictionNamespaceLister implements the listerspolicyv1.EvictionNamespaceLister +// interface. +type evictionNamespaceLister struct { + kcplisters.ResourceIndexer[*policyv1.Eviction] +} + +var _ listerspolicyv1.EvictionNamespaceLister = new(evictionNamespaceLister) + +// NewEvictionLister returns a new EvictionLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewEvictionLister(indexer cache.Indexer) listerspolicyv1.EvictionLister { + return &evictionLister{ + kcplisters.New[*policyv1.Eviction](indexer, policyv1.Resource("eviction")), + } +} + +// evictionScopedLister can list all Evictions inside a workspace +// or scope down to a listerspolicyv1.EvictionNamespaceLister for one namespace. +type evictionScopedLister struct { + kcplisters.ResourceIndexer[*policyv1.Eviction] +} + +// Evictions returns an object that can list and get Evictions in one namespace. +func (l *evictionScopedLister) Evictions(namespace string) listerspolicyv1.EvictionLister { + return &evictionLister{ + l.ResourceIndexer.WithNamespace(namespace), + } +} diff --git a/listers/policy/v1/expansion_generated.go b/listers/policy/v1/expansion_generated.go new file mode 100644 index 000000000..4bc71b259 --- /dev/null +++ b/listers/policy/v1/expansion_generated.go @@ -0,0 +1,23 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1 + +// EvictionClusterListerExpansion allows custom methods to be added to +// EvictionClusterLister. +type EvictionClusterListerExpansion interface{} diff --git a/listers/policy/v1/poddisruptionbudget.go b/listers/policy/v1/poddisruptionbudget.go index 30037eab8..39e9df627 100644 --- a/listers/policy/v1/poddisruptionbudget.go +++ b/listers/policy/v1/poddisruptionbudget.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" policyv1 "k8s.io/api/policy/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - policyv1listers "k8s.io/client-go/listers/policy/v1" + listerspolicyv1 "k8s.io/client-go/listers/policy/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// PodDisruptionBudgetClusterLister can list PodDisruptionBudgets across all workspaces, or scope down to a PodDisruptionBudgetLister for one workspace. +// PodDisruptionBudgetClusterLister helps list PodDisruptionBudgets across all workspaces, +// or scope down to a PodDisruptionBudgetLister for one workspace. // All objects returned here must be treated as read-only. type PodDisruptionBudgetClusterLister interface { // List lists all PodDisruptionBudgets in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*policyv1.PodDisruptionBudget, err error) // Cluster returns a lister that can list and get PodDisruptionBudgets in one workspace. - Cluster(clusterName logicalcluster.Name) policyv1listers.PodDisruptionBudgetLister + Cluster(clusterName logicalcluster.Name) listerspolicyv1.PodDisruptionBudgetLister PodDisruptionBudgetClusterListerExpansion } +// podDisruptionBudgetClusterLister implements the PodDisruptionBudgetClusterLister interface. type podDisruptionBudgetClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*policyv1.PodDisruptionBudget] } +var _ PodDisruptionBudgetClusterLister = new(podDisruptionBudgetClusterLister) + // NewPodDisruptionBudgetClusterLister returns a new PodDisruptionBudgetClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewPodDisruptionBudgetClusterLister(indexer cache.Indexer) *podDisruptionBudgetClusterLister { - return &podDisruptionBudgetClusterLister{indexer: indexer} -} - -// List lists all PodDisruptionBudgets in the indexer across all workspaces. -func (s *podDisruptionBudgetClusterLister) List(selector labels.Selector) (ret []*policyv1.PodDisruptionBudget, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*policyv1.PodDisruptionBudget)) - }) - return ret, err +func NewPodDisruptionBudgetClusterLister(indexer cache.Indexer) PodDisruptionBudgetClusterLister { + return &podDisruptionBudgetClusterLister{ + kcplisters.NewCluster[*policyv1.PodDisruptionBudget](indexer, policyv1.Resource("poddisruptionbudget")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get PodDisruptionBudgets. -func (s *podDisruptionBudgetClusterLister) Cluster(clusterName logicalcluster.Name) policyv1listers.PodDisruptionBudgetLister { - return &podDisruptionBudgetLister{indexer: s.indexer, clusterName: clusterName} +func (l *podDisruptionBudgetClusterLister) Cluster(clusterName logicalcluster.Name) listerspolicyv1.PodDisruptionBudgetLister { + return &podDisruptionBudgetLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// podDisruptionBudgetLister implements the policyv1listers.PodDisruptionBudgetLister interface. +// podDisruptionBudgetLister can list all PodDisruptionBudgets inside a workspace +// or scope down to a listerspolicyv1.PodDisruptionBudgetNamespaceLister for one namespace. type podDisruptionBudgetLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*policyv1.PodDisruptionBudget] } -// List lists all PodDisruptionBudgets in the indexer for a workspace. -func (s *podDisruptionBudgetLister) List(selector labels.Selector) (ret []*policyv1.PodDisruptionBudget, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*policyv1.PodDisruptionBudget)) - }) - return ret, err -} +var _ listerspolicyv1.PodDisruptionBudgetLister = new(podDisruptionBudgetLister) // PodDisruptionBudgets returns an object that can list and get PodDisruptionBudgets in one namespace. -func (s *podDisruptionBudgetLister) PodDisruptionBudgets(namespace string) policyv1listers.PodDisruptionBudgetNamespaceLister { - return &podDisruptionBudgetNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *podDisruptionBudgetLister) PodDisruptionBudgets(namespace string) listerspolicyv1.PodDisruptionBudgetNamespaceLister { + return &podDisruptionBudgetNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// podDisruptionBudgetNamespaceLister implements the policyv1listers.PodDisruptionBudgetNamespaceLister interface. +// podDisruptionBudgetNamespaceLister implements the listerspolicyv1.PodDisruptionBudgetNamespaceLister +// interface. type podDisruptionBudgetNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*policyv1.PodDisruptionBudget] } -// List lists all PodDisruptionBudgets in the indexer for a given workspace and namespace. -func (s *podDisruptionBudgetNamespaceLister) List(selector labels.Selector) (ret []*policyv1.PodDisruptionBudget, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*policyv1.PodDisruptionBudget)) - }) - return ret, err -} +var _ listerspolicyv1.PodDisruptionBudgetNamespaceLister = new(podDisruptionBudgetNamespaceLister) -// Get retrieves the PodDisruptionBudget from the indexer for a given workspace, namespace and name. -func (s *podDisruptionBudgetNamespaceLister) Get(name string) (*policyv1.PodDisruptionBudget, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewPodDisruptionBudgetLister returns a new PodDisruptionBudgetLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewPodDisruptionBudgetLister(indexer cache.Indexer) listerspolicyv1.PodDisruptionBudgetLister { + return &podDisruptionBudgetLister{ + kcplisters.New[*policyv1.PodDisruptionBudget](indexer, policyv1.Resource("poddisruptionbudget")), } - if !exists { - return nil, errors.NewNotFound(policyv1.Resource("poddisruptionbudgets"), name) +} + +// podDisruptionBudgetScopedLister can list all PodDisruptionBudgets inside a workspace +// or scope down to a listerspolicyv1.PodDisruptionBudgetNamespaceLister for one namespace. +type podDisruptionBudgetScopedLister struct { + kcplisters.ResourceIndexer[*policyv1.PodDisruptionBudget] +} + +// PodDisruptionBudgets returns an object that can list and get PodDisruptionBudgets in one namespace. +func (l *podDisruptionBudgetScopedLister) PodDisruptionBudgets(namespace string) listerspolicyv1.PodDisruptionBudgetLister { + return &podDisruptionBudgetLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*policyv1.PodDisruptionBudget), nil } diff --git a/listers/policy/v1/poddisruptionbudget_expansion.go b/listers/policy/v1/poddisruptionbudget_expansion.go index c947b7f70..af730cd07 100644 --- a/listers/policy/v1/poddisruptionbudget_expansion.go +++ b/listers/policy/v1/poddisruptionbudget_expansion.go @@ -19,7 +19,7 @@ package v1 import ( "fmt" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" policy "k8s.io/api/policy/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" diff --git a/listers/policy/v1beta1/eviction.go b/listers/policy/v1beta1/eviction.go new file mode 100644 index 000000000..457af21c9 --- /dev/null +++ b/listers/policy/v1beta1/eviction.go @@ -0,0 +1,116 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "github.com/kcp-dev/logicalcluster/v3" + + policyv1beta1 "k8s.io/api/policy/v1beta1" + "k8s.io/apimachinery/pkg/labels" + listerspolicyv1beta1 "k8s.io/client-go/listers/policy/v1beta1" + "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" +) + +// EvictionClusterLister helps list Evictions across all workspaces, +// or scope down to a EvictionLister for one workspace. +// All objects returned here must be treated as read-only. +type EvictionClusterLister interface { + // List lists all Evictions in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*policyv1beta1.Eviction, err error) + // Cluster returns a lister that can list and get Evictions in one workspace. + Cluster(clusterName logicalcluster.Name) listerspolicyv1beta1.EvictionLister + EvictionClusterListerExpansion +} + +// evictionClusterLister implements the EvictionClusterLister interface. +type evictionClusterLister struct { + kcplisters.ResourceClusterIndexer[*policyv1beta1.Eviction] +} + +var _ EvictionClusterLister = new(evictionClusterLister) + +// NewEvictionClusterLister returns a new EvictionClusterLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewEvictionClusterLister(indexer cache.Indexer) EvictionClusterLister { + return &evictionClusterLister{ + kcplisters.NewCluster[*policyv1beta1.Eviction](indexer, policyv1beta1.Resource("eviction")), + } +} + +// Cluster scopes the lister to one workspace, allowing users to list and get Evictions. +func (l *evictionClusterLister) Cluster(clusterName logicalcluster.Name) listerspolicyv1beta1.EvictionLister { + return &evictionLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } +} + +// evictionLister can list all Evictions inside a workspace +// or scope down to a listerspolicyv1beta1.EvictionNamespaceLister for one namespace. +type evictionLister struct { + kcplisters.ResourceIndexer[*policyv1beta1.Eviction] +} + +var _ listerspolicyv1beta1.EvictionLister = new(evictionLister) + +// Evictions returns an object that can list and get Evictions in one namespace. +func (l *evictionLister) Evictions(namespace string) listerspolicyv1beta1.EvictionNamespaceLister { + return &evictionNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } +} + +// evictionNamespaceLister implements the listerspolicyv1beta1.EvictionNamespaceLister +// interface. +type evictionNamespaceLister struct { + kcplisters.ResourceIndexer[*policyv1beta1.Eviction] +} + +var _ listerspolicyv1beta1.EvictionNamespaceLister = new(evictionNamespaceLister) + +// NewEvictionLister returns a new EvictionLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewEvictionLister(indexer cache.Indexer) listerspolicyv1beta1.EvictionLister { + return &evictionLister{ + kcplisters.New[*policyv1beta1.Eviction](indexer, policyv1beta1.Resource("eviction")), + } +} + +// evictionScopedLister can list all Evictions inside a workspace +// or scope down to a listerspolicyv1beta1.EvictionNamespaceLister for one namespace. +type evictionScopedLister struct { + kcplisters.ResourceIndexer[*policyv1beta1.Eviction] +} + +// Evictions returns an object that can list and get Evictions in one namespace. +func (l *evictionScopedLister) Evictions(namespace string) listerspolicyv1beta1.EvictionLister { + return &evictionLister{ + l.ResourceIndexer.WithNamespace(namespace), + } +} diff --git a/listers/policy/v1beta1/expansion_generated.go b/listers/policy/v1beta1/expansion_generated.go new file mode 100644 index 000000000..d3f5cc7fe --- /dev/null +++ b/listers/policy/v1beta1/expansion_generated.go @@ -0,0 +1,23 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1beta1 + +// EvictionClusterListerExpansion allows custom methods to be added to +// EvictionClusterLister. +type EvictionClusterListerExpansion interface{} diff --git a/listers/policy/v1beta1/poddisruptionbudget.go b/listers/policy/v1beta1/poddisruptionbudget.go index 09b531825..87c2e7d8f 100644 --- a/listers/policy/v1beta1/poddisruptionbudget.go +++ b/listers/policy/v1beta1/poddisruptionbudget.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" policyv1beta1 "k8s.io/api/policy/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - policyv1beta1listers "k8s.io/client-go/listers/policy/v1beta1" + listerspolicyv1beta1 "k8s.io/client-go/listers/policy/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// PodDisruptionBudgetClusterLister can list PodDisruptionBudgets across all workspaces, or scope down to a PodDisruptionBudgetLister for one workspace. +// PodDisruptionBudgetClusterLister helps list PodDisruptionBudgets across all workspaces, +// or scope down to a PodDisruptionBudgetLister for one workspace. // All objects returned here must be treated as read-only. type PodDisruptionBudgetClusterLister interface { // List lists all PodDisruptionBudgets in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*policyv1beta1.PodDisruptionBudget, err error) // Cluster returns a lister that can list and get PodDisruptionBudgets in one workspace. - Cluster(clusterName logicalcluster.Name) policyv1beta1listers.PodDisruptionBudgetLister + Cluster(clusterName logicalcluster.Name) listerspolicyv1beta1.PodDisruptionBudgetLister PodDisruptionBudgetClusterListerExpansion } +// podDisruptionBudgetClusterLister implements the PodDisruptionBudgetClusterLister interface. type podDisruptionBudgetClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*policyv1beta1.PodDisruptionBudget] } +var _ PodDisruptionBudgetClusterLister = new(podDisruptionBudgetClusterLister) + // NewPodDisruptionBudgetClusterLister returns a new PodDisruptionBudgetClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewPodDisruptionBudgetClusterLister(indexer cache.Indexer) *podDisruptionBudgetClusterLister { - return &podDisruptionBudgetClusterLister{indexer: indexer} -} - -// List lists all PodDisruptionBudgets in the indexer across all workspaces. -func (s *podDisruptionBudgetClusterLister) List(selector labels.Selector) (ret []*policyv1beta1.PodDisruptionBudget, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*policyv1beta1.PodDisruptionBudget)) - }) - return ret, err +func NewPodDisruptionBudgetClusterLister(indexer cache.Indexer) PodDisruptionBudgetClusterLister { + return &podDisruptionBudgetClusterLister{ + kcplisters.NewCluster[*policyv1beta1.PodDisruptionBudget](indexer, policyv1beta1.Resource("poddisruptionbudget")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get PodDisruptionBudgets. -func (s *podDisruptionBudgetClusterLister) Cluster(clusterName logicalcluster.Name) policyv1beta1listers.PodDisruptionBudgetLister { - return &podDisruptionBudgetLister{indexer: s.indexer, clusterName: clusterName} +func (l *podDisruptionBudgetClusterLister) Cluster(clusterName logicalcluster.Name) listerspolicyv1beta1.PodDisruptionBudgetLister { + return &podDisruptionBudgetLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// podDisruptionBudgetLister implements the policyv1beta1listers.PodDisruptionBudgetLister interface. +// podDisruptionBudgetLister can list all PodDisruptionBudgets inside a workspace +// or scope down to a listerspolicyv1beta1.PodDisruptionBudgetNamespaceLister for one namespace. type podDisruptionBudgetLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*policyv1beta1.PodDisruptionBudget] } -// List lists all PodDisruptionBudgets in the indexer for a workspace. -func (s *podDisruptionBudgetLister) List(selector labels.Selector) (ret []*policyv1beta1.PodDisruptionBudget, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*policyv1beta1.PodDisruptionBudget)) - }) - return ret, err -} +var _ listerspolicyv1beta1.PodDisruptionBudgetLister = new(podDisruptionBudgetLister) // PodDisruptionBudgets returns an object that can list and get PodDisruptionBudgets in one namespace. -func (s *podDisruptionBudgetLister) PodDisruptionBudgets(namespace string) policyv1beta1listers.PodDisruptionBudgetNamespaceLister { - return &podDisruptionBudgetNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *podDisruptionBudgetLister) PodDisruptionBudgets(namespace string) listerspolicyv1beta1.PodDisruptionBudgetNamespaceLister { + return &podDisruptionBudgetNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// podDisruptionBudgetNamespaceLister implements the policyv1beta1listers.PodDisruptionBudgetNamespaceLister interface. +// podDisruptionBudgetNamespaceLister implements the listerspolicyv1beta1.PodDisruptionBudgetNamespaceLister +// interface. type podDisruptionBudgetNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*policyv1beta1.PodDisruptionBudget] } -// List lists all PodDisruptionBudgets in the indexer for a given workspace and namespace. -func (s *podDisruptionBudgetNamespaceLister) List(selector labels.Selector) (ret []*policyv1beta1.PodDisruptionBudget, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*policyv1beta1.PodDisruptionBudget)) - }) - return ret, err -} +var _ listerspolicyv1beta1.PodDisruptionBudgetNamespaceLister = new(podDisruptionBudgetNamespaceLister) -// Get retrieves the PodDisruptionBudget from the indexer for a given workspace, namespace and name. -func (s *podDisruptionBudgetNamespaceLister) Get(name string) (*policyv1beta1.PodDisruptionBudget, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewPodDisruptionBudgetLister returns a new PodDisruptionBudgetLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewPodDisruptionBudgetLister(indexer cache.Indexer) listerspolicyv1beta1.PodDisruptionBudgetLister { + return &podDisruptionBudgetLister{ + kcplisters.New[*policyv1beta1.PodDisruptionBudget](indexer, policyv1beta1.Resource("poddisruptionbudget")), } - if !exists { - return nil, errors.NewNotFound(policyv1beta1.Resource("poddisruptionbudgets"), name) +} + +// podDisruptionBudgetScopedLister can list all PodDisruptionBudgets inside a workspace +// or scope down to a listerspolicyv1beta1.PodDisruptionBudgetNamespaceLister for one namespace. +type podDisruptionBudgetScopedLister struct { + kcplisters.ResourceIndexer[*policyv1beta1.PodDisruptionBudget] +} + +// PodDisruptionBudgets returns an object that can list and get PodDisruptionBudgets in one namespace. +func (l *podDisruptionBudgetScopedLister) PodDisruptionBudgets(namespace string) listerspolicyv1beta1.PodDisruptionBudgetLister { + return &podDisruptionBudgetLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*policyv1beta1.PodDisruptionBudget), nil } diff --git a/listers/policy/v1beta1/poddisruptionbudget_expansion.go b/listers/policy/v1beta1/poddisruptionbudget_expansion.go index 38f4e08ae..86f85d84c 100644 --- a/listers/policy/v1beta1/poddisruptionbudget_expansion.go +++ b/listers/policy/v1beta1/poddisruptionbudget_expansion.go @@ -19,7 +19,7 @@ package v1beta1 import ( "fmt" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" policy "k8s.io/api/policy/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" diff --git a/listers/rbac/v1/clusterrole.go b/listers/rbac/v1/clusterrole.go index 5f0639d51..7fa581f1e 100644 --- a/listers/rbac/v1/clusterrole.go +++ b/listers/rbac/v1/clusterrole.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" rbacv1 "k8s.io/api/rbac/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - rbacv1listers "k8s.io/client-go/listers/rbac/v1" + listersrbacv1 "k8s.io/client-go/listers/rbac/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ClusterRoleClusterLister can list ClusterRoles across all workspaces, or scope down to a ClusterRoleLister for one workspace. +// ClusterRoleClusterLister helps list ClusterRoles across all workspaces, +// or scope down to a ClusterRoleLister for one workspace. // All objects returned here must be treated as read-only. type ClusterRoleClusterLister interface { // List lists all ClusterRoles in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*rbacv1.ClusterRole, err error) // Cluster returns a lister that can list and get ClusterRoles in one workspace. - Cluster(clusterName logicalcluster.Name) rbacv1listers.ClusterRoleLister + Cluster(clusterName logicalcluster.Name) listersrbacv1.ClusterRoleLister ClusterRoleClusterListerExpansion } +// clusterRoleClusterLister implements the ClusterRoleClusterLister interface. type clusterRoleClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*rbacv1.ClusterRole] } +var _ ClusterRoleClusterLister = new(clusterRoleClusterLister) + // NewClusterRoleClusterLister returns a new ClusterRoleClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewClusterRoleClusterLister(indexer cache.Indexer) *clusterRoleClusterLister { - return &clusterRoleClusterLister{indexer: indexer} -} - -// List lists all ClusterRoles in the indexer across all workspaces. -func (s *clusterRoleClusterLister) List(selector labels.Selector) (ret []*rbacv1.ClusterRole, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*rbacv1.ClusterRole)) - }) - return ret, err +func NewClusterRoleClusterLister(indexer cache.Indexer) ClusterRoleClusterLister { + return &clusterRoleClusterLister{ + kcplisters.NewCluster[*rbacv1.ClusterRole](indexer, rbacv1.Resource("clusterrole")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ClusterRoles. -func (s *clusterRoleClusterLister) Cluster(clusterName logicalcluster.Name) rbacv1listers.ClusterRoleLister { - return &clusterRoleLister{indexer: s.indexer, clusterName: clusterName} +func (l *clusterRoleClusterLister) Cluster(clusterName logicalcluster.Name) listersrbacv1.ClusterRoleLister { + return &clusterRoleLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// clusterRoleLister implements the rbacv1listers.ClusterRoleLister interface. +// clusterRoleLister can list all ClusterRoles inside a workspace +// or scope down to a listersrbacv1.ClusterRoleNamespaceLister for one namespace. type clusterRoleLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*rbacv1.ClusterRole] } -// List lists all ClusterRoles in the indexer for a workspace. -func (s *clusterRoleLister) List(selector labels.Selector) (ret []*rbacv1.ClusterRole, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*rbacv1.ClusterRole)) - }) - return ret, err -} +var _ listersrbacv1.ClusterRoleLister = new(clusterRoleLister) -// Get retrieves the ClusterRole from the indexer for a given workspace and name. -func (s *clusterRoleLister) Get(name string) (*rbacv1.ClusterRole, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(rbacv1.Resource("clusterroles"), name) +// NewClusterRoleLister returns a new ClusterRoleLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewClusterRoleLister(indexer cache.Indexer) listersrbacv1.ClusterRoleLister { + return &clusterRoleLister{ + kcplisters.New[*rbacv1.ClusterRole](indexer, rbacv1.Resource("clusterrole")), } - return obj.(*rbacv1.ClusterRole), nil +} + +// clusterRoleScopedLister can list all ClusterRoles inside a workspace +// or scope down to a listersrbacv1.ClusterRoleNamespaceLister. +type clusterRoleScopedLister struct { + kcplisters.ResourceIndexer[*rbacv1.ClusterRole] } diff --git a/listers/rbac/v1/clusterrolebinding.go b/listers/rbac/v1/clusterrolebinding.go index 90486790c..f6c6e8281 100644 --- a/listers/rbac/v1/clusterrolebinding.go +++ b/listers/rbac/v1/clusterrolebinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" rbacv1 "k8s.io/api/rbac/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - rbacv1listers "k8s.io/client-go/listers/rbac/v1" + listersrbacv1 "k8s.io/client-go/listers/rbac/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ClusterRoleBindingClusterLister can list ClusterRoleBindings across all workspaces, or scope down to a ClusterRoleBindingLister for one workspace. +// ClusterRoleBindingClusterLister helps list ClusterRoleBindings across all workspaces, +// or scope down to a ClusterRoleBindingLister for one workspace. // All objects returned here must be treated as read-only. type ClusterRoleBindingClusterLister interface { // List lists all ClusterRoleBindings in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*rbacv1.ClusterRoleBinding, err error) // Cluster returns a lister that can list and get ClusterRoleBindings in one workspace. - Cluster(clusterName logicalcluster.Name) rbacv1listers.ClusterRoleBindingLister + Cluster(clusterName logicalcluster.Name) listersrbacv1.ClusterRoleBindingLister ClusterRoleBindingClusterListerExpansion } +// clusterRoleBindingClusterLister implements the ClusterRoleBindingClusterLister interface. type clusterRoleBindingClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*rbacv1.ClusterRoleBinding] } +var _ ClusterRoleBindingClusterLister = new(clusterRoleBindingClusterLister) + // NewClusterRoleBindingClusterLister returns a new ClusterRoleBindingClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewClusterRoleBindingClusterLister(indexer cache.Indexer) *clusterRoleBindingClusterLister { - return &clusterRoleBindingClusterLister{indexer: indexer} -} - -// List lists all ClusterRoleBindings in the indexer across all workspaces. -func (s *clusterRoleBindingClusterLister) List(selector labels.Selector) (ret []*rbacv1.ClusterRoleBinding, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*rbacv1.ClusterRoleBinding)) - }) - return ret, err +func NewClusterRoleBindingClusterLister(indexer cache.Indexer) ClusterRoleBindingClusterLister { + return &clusterRoleBindingClusterLister{ + kcplisters.NewCluster[*rbacv1.ClusterRoleBinding](indexer, rbacv1.Resource("clusterrolebinding")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ClusterRoleBindings. -func (s *clusterRoleBindingClusterLister) Cluster(clusterName logicalcluster.Name) rbacv1listers.ClusterRoleBindingLister { - return &clusterRoleBindingLister{indexer: s.indexer, clusterName: clusterName} +func (l *clusterRoleBindingClusterLister) Cluster(clusterName logicalcluster.Name) listersrbacv1.ClusterRoleBindingLister { + return &clusterRoleBindingLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// clusterRoleBindingLister implements the rbacv1listers.ClusterRoleBindingLister interface. +// clusterRoleBindingLister can list all ClusterRoleBindings inside a workspace +// or scope down to a listersrbacv1.ClusterRoleBindingNamespaceLister for one namespace. type clusterRoleBindingLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*rbacv1.ClusterRoleBinding] } -// List lists all ClusterRoleBindings in the indexer for a workspace. -func (s *clusterRoleBindingLister) List(selector labels.Selector) (ret []*rbacv1.ClusterRoleBinding, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*rbacv1.ClusterRoleBinding)) - }) - return ret, err -} +var _ listersrbacv1.ClusterRoleBindingLister = new(clusterRoleBindingLister) -// Get retrieves the ClusterRoleBinding from the indexer for a given workspace and name. -func (s *clusterRoleBindingLister) Get(name string) (*rbacv1.ClusterRoleBinding, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(rbacv1.Resource("clusterrolebindings"), name) +// NewClusterRoleBindingLister returns a new ClusterRoleBindingLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewClusterRoleBindingLister(indexer cache.Indexer) listersrbacv1.ClusterRoleBindingLister { + return &clusterRoleBindingLister{ + kcplisters.New[*rbacv1.ClusterRoleBinding](indexer, rbacv1.Resource("clusterrolebinding")), } - return obj.(*rbacv1.ClusterRoleBinding), nil +} + +// clusterRoleBindingScopedLister can list all ClusterRoleBindings inside a workspace +// or scope down to a listersrbacv1.ClusterRoleBindingNamespaceLister. +type clusterRoleBindingScopedLister struct { + kcplisters.ResourceIndexer[*rbacv1.ClusterRoleBinding] } diff --git a/listers/rbac/v1/expansion_generated.go b/listers/rbac/v1/expansion_generated.go new file mode 100644 index 000000000..b6a0c6377 --- /dev/null +++ b/listers/rbac/v1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1 diff --git a/listers/rbac/v1/role.go b/listers/rbac/v1/role.go index eb6bc2f74..280233b40 100644 --- a/listers/rbac/v1/role.go +++ b/listers/rbac/v1/role.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" rbacv1 "k8s.io/api/rbac/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - rbacv1listers "k8s.io/client-go/listers/rbac/v1" + listersrbacv1 "k8s.io/client-go/listers/rbac/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// RoleClusterLister can list Roles across all workspaces, or scope down to a RoleLister for one workspace. +// RoleClusterLister helps list Roles across all workspaces, +// or scope down to a RoleLister for one workspace. // All objects returned here must be treated as read-only. type RoleClusterLister interface { // List lists all Roles in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*rbacv1.Role, err error) // Cluster returns a lister that can list and get Roles in one workspace. - Cluster(clusterName logicalcluster.Name) rbacv1listers.RoleLister + Cluster(clusterName logicalcluster.Name) listersrbacv1.RoleLister RoleClusterListerExpansion } +// roleClusterLister implements the RoleClusterLister interface. type roleClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*rbacv1.Role] } +var _ RoleClusterLister = new(roleClusterLister) + // NewRoleClusterLister returns a new RoleClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewRoleClusterLister(indexer cache.Indexer) *roleClusterLister { - return &roleClusterLister{indexer: indexer} -} - -// List lists all Roles in the indexer across all workspaces. -func (s *roleClusterLister) List(selector labels.Selector) (ret []*rbacv1.Role, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*rbacv1.Role)) - }) - return ret, err +func NewRoleClusterLister(indexer cache.Indexer) RoleClusterLister { + return &roleClusterLister{ + kcplisters.NewCluster[*rbacv1.Role](indexer, rbacv1.Resource("role")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get Roles. -func (s *roleClusterLister) Cluster(clusterName logicalcluster.Name) rbacv1listers.RoleLister { - return &roleLister{indexer: s.indexer, clusterName: clusterName} +func (l *roleClusterLister) Cluster(clusterName logicalcluster.Name) listersrbacv1.RoleLister { + return &roleLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// roleLister implements the rbacv1listers.RoleLister interface. +// roleLister can list all Roles inside a workspace +// or scope down to a listersrbacv1.RoleNamespaceLister for one namespace. type roleLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*rbacv1.Role] } -// List lists all Roles in the indexer for a workspace. -func (s *roleLister) List(selector labels.Selector) (ret []*rbacv1.Role, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*rbacv1.Role)) - }) - return ret, err -} +var _ listersrbacv1.RoleLister = new(roleLister) // Roles returns an object that can list and get Roles in one namespace. -func (s *roleLister) Roles(namespace string) rbacv1listers.RoleNamespaceLister { - return &roleNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *roleLister) Roles(namespace string) listersrbacv1.RoleNamespaceLister { + return &roleNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// roleNamespaceLister implements the rbacv1listers.RoleNamespaceLister interface. +// roleNamespaceLister implements the listersrbacv1.RoleNamespaceLister +// interface. type roleNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*rbacv1.Role] } -// List lists all Roles in the indexer for a given workspace and namespace. -func (s *roleNamespaceLister) List(selector labels.Selector) (ret []*rbacv1.Role, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*rbacv1.Role)) - }) - return ret, err -} +var _ listersrbacv1.RoleNamespaceLister = new(roleNamespaceLister) -// Get retrieves the Role from the indexer for a given workspace, namespace and name. -func (s *roleNamespaceLister) Get(name string) (*rbacv1.Role, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewRoleLister returns a new RoleLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewRoleLister(indexer cache.Indexer) listersrbacv1.RoleLister { + return &roleLister{ + kcplisters.New[*rbacv1.Role](indexer, rbacv1.Resource("role")), } - if !exists { - return nil, errors.NewNotFound(rbacv1.Resource("roles"), name) +} + +// roleScopedLister can list all Roles inside a workspace +// or scope down to a listersrbacv1.RoleNamespaceLister for one namespace. +type roleScopedLister struct { + kcplisters.ResourceIndexer[*rbacv1.Role] +} + +// Roles returns an object that can list and get Roles in one namespace. +func (l *roleScopedLister) Roles(namespace string) listersrbacv1.RoleLister { + return &roleLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*rbacv1.Role), nil } diff --git a/listers/rbac/v1/rolebinding.go b/listers/rbac/v1/rolebinding.go index 564d6e5d6..cb9984a95 100644 --- a/listers/rbac/v1/rolebinding.go +++ b/listers/rbac/v1/rolebinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" rbacv1 "k8s.io/api/rbac/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - rbacv1listers "k8s.io/client-go/listers/rbac/v1" + listersrbacv1 "k8s.io/client-go/listers/rbac/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// RoleBindingClusterLister can list RoleBindings across all workspaces, or scope down to a RoleBindingLister for one workspace. +// RoleBindingClusterLister helps list RoleBindings across all workspaces, +// or scope down to a RoleBindingLister for one workspace. // All objects returned here must be treated as read-only. type RoleBindingClusterLister interface { // List lists all RoleBindings in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*rbacv1.RoleBinding, err error) // Cluster returns a lister that can list and get RoleBindings in one workspace. - Cluster(clusterName logicalcluster.Name) rbacv1listers.RoleBindingLister + Cluster(clusterName logicalcluster.Name) listersrbacv1.RoleBindingLister RoleBindingClusterListerExpansion } +// roleBindingClusterLister implements the RoleBindingClusterLister interface. type roleBindingClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*rbacv1.RoleBinding] } +var _ RoleBindingClusterLister = new(roleBindingClusterLister) + // NewRoleBindingClusterLister returns a new RoleBindingClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewRoleBindingClusterLister(indexer cache.Indexer) *roleBindingClusterLister { - return &roleBindingClusterLister{indexer: indexer} -} - -// List lists all RoleBindings in the indexer across all workspaces. -func (s *roleBindingClusterLister) List(selector labels.Selector) (ret []*rbacv1.RoleBinding, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*rbacv1.RoleBinding)) - }) - return ret, err +func NewRoleBindingClusterLister(indexer cache.Indexer) RoleBindingClusterLister { + return &roleBindingClusterLister{ + kcplisters.NewCluster[*rbacv1.RoleBinding](indexer, rbacv1.Resource("rolebinding")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get RoleBindings. -func (s *roleBindingClusterLister) Cluster(clusterName logicalcluster.Name) rbacv1listers.RoleBindingLister { - return &roleBindingLister{indexer: s.indexer, clusterName: clusterName} +func (l *roleBindingClusterLister) Cluster(clusterName logicalcluster.Name) listersrbacv1.RoleBindingLister { + return &roleBindingLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// roleBindingLister implements the rbacv1listers.RoleBindingLister interface. +// roleBindingLister can list all RoleBindings inside a workspace +// or scope down to a listersrbacv1.RoleBindingNamespaceLister for one namespace. type roleBindingLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*rbacv1.RoleBinding] } -// List lists all RoleBindings in the indexer for a workspace. -func (s *roleBindingLister) List(selector labels.Selector) (ret []*rbacv1.RoleBinding, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*rbacv1.RoleBinding)) - }) - return ret, err -} +var _ listersrbacv1.RoleBindingLister = new(roleBindingLister) // RoleBindings returns an object that can list and get RoleBindings in one namespace. -func (s *roleBindingLister) RoleBindings(namespace string) rbacv1listers.RoleBindingNamespaceLister { - return &roleBindingNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *roleBindingLister) RoleBindings(namespace string) listersrbacv1.RoleBindingNamespaceLister { + return &roleBindingNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// roleBindingNamespaceLister implements the rbacv1listers.RoleBindingNamespaceLister interface. +// roleBindingNamespaceLister implements the listersrbacv1.RoleBindingNamespaceLister +// interface. type roleBindingNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*rbacv1.RoleBinding] } -// List lists all RoleBindings in the indexer for a given workspace and namespace. -func (s *roleBindingNamespaceLister) List(selector labels.Selector) (ret []*rbacv1.RoleBinding, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*rbacv1.RoleBinding)) - }) - return ret, err -} +var _ listersrbacv1.RoleBindingNamespaceLister = new(roleBindingNamespaceLister) -// Get retrieves the RoleBinding from the indexer for a given workspace, namespace and name. -func (s *roleBindingNamespaceLister) Get(name string) (*rbacv1.RoleBinding, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewRoleBindingLister returns a new RoleBindingLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewRoleBindingLister(indexer cache.Indexer) listersrbacv1.RoleBindingLister { + return &roleBindingLister{ + kcplisters.New[*rbacv1.RoleBinding](indexer, rbacv1.Resource("rolebinding")), } - if !exists { - return nil, errors.NewNotFound(rbacv1.Resource("rolebindings"), name) +} + +// roleBindingScopedLister can list all RoleBindings inside a workspace +// or scope down to a listersrbacv1.RoleBindingNamespaceLister for one namespace. +type roleBindingScopedLister struct { + kcplisters.ResourceIndexer[*rbacv1.RoleBinding] +} + +// RoleBindings returns an object that can list and get RoleBindings in one namespace. +func (l *roleBindingScopedLister) RoleBindings(namespace string) listersrbacv1.RoleBindingLister { + return &roleBindingLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*rbacv1.RoleBinding), nil } diff --git a/listers/rbac/v1alpha1/clusterrole.go b/listers/rbac/v1alpha1/clusterrole.go index 66031de39..75f1e4f9d 100644 --- a/listers/rbac/v1alpha1/clusterrole.go +++ b/listers/rbac/v1alpha1/clusterrole.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1alpha1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" rbacv1alpha1 "k8s.io/api/rbac/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - rbacv1alpha1listers "k8s.io/client-go/listers/rbac/v1alpha1" + listersrbacv1alpha1 "k8s.io/client-go/listers/rbac/v1alpha1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ClusterRoleClusterLister can list ClusterRoles across all workspaces, or scope down to a ClusterRoleLister for one workspace. +// ClusterRoleClusterLister helps list ClusterRoles across all workspaces, +// or scope down to a ClusterRoleLister for one workspace. // All objects returned here must be treated as read-only. type ClusterRoleClusterLister interface { // List lists all ClusterRoles in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*rbacv1alpha1.ClusterRole, err error) // Cluster returns a lister that can list and get ClusterRoles in one workspace. - Cluster(clusterName logicalcluster.Name) rbacv1alpha1listers.ClusterRoleLister + Cluster(clusterName logicalcluster.Name) listersrbacv1alpha1.ClusterRoleLister ClusterRoleClusterListerExpansion } +// clusterRoleClusterLister implements the ClusterRoleClusterLister interface. type clusterRoleClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*rbacv1alpha1.ClusterRole] } +var _ ClusterRoleClusterLister = new(clusterRoleClusterLister) + // NewClusterRoleClusterLister returns a new ClusterRoleClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewClusterRoleClusterLister(indexer cache.Indexer) *clusterRoleClusterLister { - return &clusterRoleClusterLister{indexer: indexer} -} - -// List lists all ClusterRoles in the indexer across all workspaces. -func (s *clusterRoleClusterLister) List(selector labels.Selector) (ret []*rbacv1alpha1.ClusterRole, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*rbacv1alpha1.ClusterRole)) - }) - return ret, err +func NewClusterRoleClusterLister(indexer cache.Indexer) ClusterRoleClusterLister { + return &clusterRoleClusterLister{ + kcplisters.NewCluster[*rbacv1alpha1.ClusterRole](indexer, rbacv1alpha1.Resource("clusterrole")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ClusterRoles. -func (s *clusterRoleClusterLister) Cluster(clusterName logicalcluster.Name) rbacv1alpha1listers.ClusterRoleLister { - return &clusterRoleLister{indexer: s.indexer, clusterName: clusterName} +func (l *clusterRoleClusterLister) Cluster(clusterName logicalcluster.Name) listersrbacv1alpha1.ClusterRoleLister { + return &clusterRoleLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// clusterRoleLister implements the rbacv1alpha1listers.ClusterRoleLister interface. +// clusterRoleLister can list all ClusterRoles inside a workspace +// or scope down to a listersrbacv1alpha1.ClusterRoleNamespaceLister for one namespace. type clusterRoleLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*rbacv1alpha1.ClusterRole] } -// List lists all ClusterRoles in the indexer for a workspace. -func (s *clusterRoleLister) List(selector labels.Selector) (ret []*rbacv1alpha1.ClusterRole, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*rbacv1alpha1.ClusterRole)) - }) - return ret, err -} +var _ listersrbacv1alpha1.ClusterRoleLister = new(clusterRoleLister) -// Get retrieves the ClusterRole from the indexer for a given workspace and name. -func (s *clusterRoleLister) Get(name string) (*rbacv1alpha1.ClusterRole, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(rbacv1alpha1.Resource("clusterroles"), name) +// NewClusterRoleLister returns a new ClusterRoleLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewClusterRoleLister(indexer cache.Indexer) listersrbacv1alpha1.ClusterRoleLister { + return &clusterRoleLister{ + kcplisters.New[*rbacv1alpha1.ClusterRole](indexer, rbacv1alpha1.Resource("clusterrole")), } - return obj.(*rbacv1alpha1.ClusterRole), nil +} + +// clusterRoleScopedLister can list all ClusterRoles inside a workspace +// or scope down to a listersrbacv1alpha1.ClusterRoleNamespaceLister. +type clusterRoleScopedLister struct { + kcplisters.ResourceIndexer[*rbacv1alpha1.ClusterRole] } diff --git a/listers/rbac/v1alpha1/clusterrolebinding.go b/listers/rbac/v1alpha1/clusterrolebinding.go index 673ac23e3..81a10b70a 100644 --- a/listers/rbac/v1alpha1/clusterrolebinding.go +++ b/listers/rbac/v1alpha1/clusterrolebinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1alpha1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" rbacv1alpha1 "k8s.io/api/rbac/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - rbacv1alpha1listers "k8s.io/client-go/listers/rbac/v1alpha1" + listersrbacv1alpha1 "k8s.io/client-go/listers/rbac/v1alpha1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ClusterRoleBindingClusterLister can list ClusterRoleBindings across all workspaces, or scope down to a ClusterRoleBindingLister for one workspace. +// ClusterRoleBindingClusterLister helps list ClusterRoleBindings across all workspaces, +// or scope down to a ClusterRoleBindingLister for one workspace. // All objects returned here must be treated as read-only. type ClusterRoleBindingClusterLister interface { // List lists all ClusterRoleBindings in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*rbacv1alpha1.ClusterRoleBinding, err error) // Cluster returns a lister that can list and get ClusterRoleBindings in one workspace. - Cluster(clusterName logicalcluster.Name) rbacv1alpha1listers.ClusterRoleBindingLister + Cluster(clusterName logicalcluster.Name) listersrbacv1alpha1.ClusterRoleBindingLister ClusterRoleBindingClusterListerExpansion } +// clusterRoleBindingClusterLister implements the ClusterRoleBindingClusterLister interface. type clusterRoleBindingClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*rbacv1alpha1.ClusterRoleBinding] } +var _ ClusterRoleBindingClusterLister = new(clusterRoleBindingClusterLister) + // NewClusterRoleBindingClusterLister returns a new ClusterRoleBindingClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewClusterRoleBindingClusterLister(indexer cache.Indexer) *clusterRoleBindingClusterLister { - return &clusterRoleBindingClusterLister{indexer: indexer} -} - -// List lists all ClusterRoleBindings in the indexer across all workspaces. -func (s *clusterRoleBindingClusterLister) List(selector labels.Selector) (ret []*rbacv1alpha1.ClusterRoleBinding, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*rbacv1alpha1.ClusterRoleBinding)) - }) - return ret, err +func NewClusterRoleBindingClusterLister(indexer cache.Indexer) ClusterRoleBindingClusterLister { + return &clusterRoleBindingClusterLister{ + kcplisters.NewCluster[*rbacv1alpha1.ClusterRoleBinding](indexer, rbacv1alpha1.Resource("clusterrolebinding")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ClusterRoleBindings. -func (s *clusterRoleBindingClusterLister) Cluster(clusterName logicalcluster.Name) rbacv1alpha1listers.ClusterRoleBindingLister { - return &clusterRoleBindingLister{indexer: s.indexer, clusterName: clusterName} +func (l *clusterRoleBindingClusterLister) Cluster(clusterName logicalcluster.Name) listersrbacv1alpha1.ClusterRoleBindingLister { + return &clusterRoleBindingLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// clusterRoleBindingLister implements the rbacv1alpha1listers.ClusterRoleBindingLister interface. +// clusterRoleBindingLister can list all ClusterRoleBindings inside a workspace +// or scope down to a listersrbacv1alpha1.ClusterRoleBindingNamespaceLister for one namespace. type clusterRoleBindingLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*rbacv1alpha1.ClusterRoleBinding] } -// List lists all ClusterRoleBindings in the indexer for a workspace. -func (s *clusterRoleBindingLister) List(selector labels.Selector) (ret []*rbacv1alpha1.ClusterRoleBinding, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*rbacv1alpha1.ClusterRoleBinding)) - }) - return ret, err -} +var _ listersrbacv1alpha1.ClusterRoleBindingLister = new(clusterRoleBindingLister) -// Get retrieves the ClusterRoleBinding from the indexer for a given workspace and name. -func (s *clusterRoleBindingLister) Get(name string) (*rbacv1alpha1.ClusterRoleBinding, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(rbacv1alpha1.Resource("clusterrolebindings"), name) +// NewClusterRoleBindingLister returns a new ClusterRoleBindingLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewClusterRoleBindingLister(indexer cache.Indexer) listersrbacv1alpha1.ClusterRoleBindingLister { + return &clusterRoleBindingLister{ + kcplisters.New[*rbacv1alpha1.ClusterRoleBinding](indexer, rbacv1alpha1.Resource("clusterrolebinding")), } - return obj.(*rbacv1alpha1.ClusterRoleBinding), nil +} + +// clusterRoleBindingScopedLister can list all ClusterRoleBindings inside a workspace +// or scope down to a listersrbacv1alpha1.ClusterRoleBindingNamespaceLister. +type clusterRoleBindingScopedLister struct { + kcplisters.ResourceIndexer[*rbacv1alpha1.ClusterRoleBinding] } diff --git a/listers/rbac/v1alpha1/expansion_generated.go b/listers/rbac/v1alpha1/expansion_generated.go new file mode 100644 index 000000000..3b8521c00 --- /dev/null +++ b/listers/rbac/v1alpha1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1alpha1 diff --git a/listers/rbac/v1alpha1/role.go b/listers/rbac/v1alpha1/role.go index c5480dee0..3e74c849b 100644 --- a/listers/rbac/v1alpha1/role.go +++ b/listers/rbac/v1alpha1/role.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1alpha1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" rbacv1alpha1 "k8s.io/api/rbac/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - rbacv1alpha1listers "k8s.io/client-go/listers/rbac/v1alpha1" + listersrbacv1alpha1 "k8s.io/client-go/listers/rbac/v1alpha1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// RoleClusterLister can list Roles across all workspaces, or scope down to a RoleLister for one workspace. +// RoleClusterLister helps list Roles across all workspaces, +// or scope down to a RoleLister for one workspace. // All objects returned here must be treated as read-only. type RoleClusterLister interface { // List lists all Roles in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*rbacv1alpha1.Role, err error) // Cluster returns a lister that can list and get Roles in one workspace. - Cluster(clusterName logicalcluster.Name) rbacv1alpha1listers.RoleLister + Cluster(clusterName logicalcluster.Name) listersrbacv1alpha1.RoleLister RoleClusterListerExpansion } +// roleClusterLister implements the RoleClusterLister interface. type roleClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*rbacv1alpha1.Role] } +var _ RoleClusterLister = new(roleClusterLister) + // NewRoleClusterLister returns a new RoleClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewRoleClusterLister(indexer cache.Indexer) *roleClusterLister { - return &roleClusterLister{indexer: indexer} -} - -// List lists all Roles in the indexer across all workspaces. -func (s *roleClusterLister) List(selector labels.Selector) (ret []*rbacv1alpha1.Role, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*rbacv1alpha1.Role)) - }) - return ret, err +func NewRoleClusterLister(indexer cache.Indexer) RoleClusterLister { + return &roleClusterLister{ + kcplisters.NewCluster[*rbacv1alpha1.Role](indexer, rbacv1alpha1.Resource("role")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get Roles. -func (s *roleClusterLister) Cluster(clusterName logicalcluster.Name) rbacv1alpha1listers.RoleLister { - return &roleLister{indexer: s.indexer, clusterName: clusterName} +func (l *roleClusterLister) Cluster(clusterName logicalcluster.Name) listersrbacv1alpha1.RoleLister { + return &roleLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// roleLister implements the rbacv1alpha1listers.RoleLister interface. +// roleLister can list all Roles inside a workspace +// or scope down to a listersrbacv1alpha1.RoleNamespaceLister for one namespace. type roleLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*rbacv1alpha1.Role] } -// List lists all Roles in the indexer for a workspace. -func (s *roleLister) List(selector labels.Selector) (ret []*rbacv1alpha1.Role, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*rbacv1alpha1.Role)) - }) - return ret, err -} +var _ listersrbacv1alpha1.RoleLister = new(roleLister) // Roles returns an object that can list and get Roles in one namespace. -func (s *roleLister) Roles(namespace string) rbacv1alpha1listers.RoleNamespaceLister { - return &roleNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *roleLister) Roles(namespace string) listersrbacv1alpha1.RoleNamespaceLister { + return &roleNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// roleNamespaceLister implements the rbacv1alpha1listers.RoleNamespaceLister interface. +// roleNamespaceLister implements the listersrbacv1alpha1.RoleNamespaceLister +// interface. type roleNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*rbacv1alpha1.Role] } -// List lists all Roles in the indexer for a given workspace and namespace. -func (s *roleNamespaceLister) List(selector labels.Selector) (ret []*rbacv1alpha1.Role, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*rbacv1alpha1.Role)) - }) - return ret, err -} +var _ listersrbacv1alpha1.RoleNamespaceLister = new(roleNamespaceLister) -// Get retrieves the Role from the indexer for a given workspace, namespace and name. -func (s *roleNamespaceLister) Get(name string) (*rbacv1alpha1.Role, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewRoleLister returns a new RoleLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewRoleLister(indexer cache.Indexer) listersrbacv1alpha1.RoleLister { + return &roleLister{ + kcplisters.New[*rbacv1alpha1.Role](indexer, rbacv1alpha1.Resource("role")), } - if !exists { - return nil, errors.NewNotFound(rbacv1alpha1.Resource("roles"), name) +} + +// roleScopedLister can list all Roles inside a workspace +// or scope down to a listersrbacv1alpha1.RoleNamespaceLister for one namespace. +type roleScopedLister struct { + kcplisters.ResourceIndexer[*rbacv1alpha1.Role] +} + +// Roles returns an object that can list and get Roles in one namespace. +func (l *roleScopedLister) Roles(namespace string) listersrbacv1alpha1.RoleLister { + return &roleLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*rbacv1alpha1.Role), nil } diff --git a/listers/rbac/v1alpha1/rolebinding.go b/listers/rbac/v1alpha1/rolebinding.go index b2054c32f..867d4129b 100644 --- a/listers/rbac/v1alpha1/rolebinding.go +++ b/listers/rbac/v1alpha1/rolebinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1alpha1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" rbacv1alpha1 "k8s.io/api/rbac/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - rbacv1alpha1listers "k8s.io/client-go/listers/rbac/v1alpha1" + listersrbacv1alpha1 "k8s.io/client-go/listers/rbac/v1alpha1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// RoleBindingClusterLister can list RoleBindings across all workspaces, or scope down to a RoleBindingLister for one workspace. +// RoleBindingClusterLister helps list RoleBindings across all workspaces, +// or scope down to a RoleBindingLister for one workspace. // All objects returned here must be treated as read-only. type RoleBindingClusterLister interface { // List lists all RoleBindings in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*rbacv1alpha1.RoleBinding, err error) // Cluster returns a lister that can list and get RoleBindings in one workspace. - Cluster(clusterName logicalcluster.Name) rbacv1alpha1listers.RoleBindingLister + Cluster(clusterName logicalcluster.Name) listersrbacv1alpha1.RoleBindingLister RoleBindingClusterListerExpansion } +// roleBindingClusterLister implements the RoleBindingClusterLister interface. type roleBindingClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*rbacv1alpha1.RoleBinding] } +var _ RoleBindingClusterLister = new(roleBindingClusterLister) + // NewRoleBindingClusterLister returns a new RoleBindingClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewRoleBindingClusterLister(indexer cache.Indexer) *roleBindingClusterLister { - return &roleBindingClusterLister{indexer: indexer} -} - -// List lists all RoleBindings in the indexer across all workspaces. -func (s *roleBindingClusterLister) List(selector labels.Selector) (ret []*rbacv1alpha1.RoleBinding, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*rbacv1alpha1.RoleBinding)) - }) - return ret, err +func NewRoleBindingClusterLister(indexer cache.Indexer) RoleBindingClusterLister { + return &roleBindingClusterLister{ + kcplisters.NewCluster[*rbacv1alpha1.RoleBinding](indexer, rbacv1alpha1.Resource("rolebinding")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get RoleBindings. -func (s *roleBindingClusterLister) Cluster(clusterName logicalcluster.Name) rbacv1alpha1listers.RoleBindingLister { - return &roleBindingLister{indexer: s.indexer, clusterName: clusterName} +func (l *roleBindingClusterLister) Cluster(clusterName logicalcluster.Name) listersrbacv1alpha1.RoleBindingLister { + return &roleBindingLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// roleBindingLister implements the rbacv1alpha1listers.RoleBindingLister interface. +// roleBindingLister can list all RoleBindings inside a workspace +// or scope down to a listersrbacv1alpha1.RoleBindingNamespaceLister for one namespace. type roleBindingLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*rbacv1alpha1.RoleBinding] } -// List lists all RoleBindings in the indexer for a workspace. -func (s *roleBindingLister) List(selector labels.Selector) (ret []*rbacv1alpha1.RoleBinding, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*rbacv1alpha1.RoleBinding)) - }) - return ret, err -} +var _ listersrbacv1alpha1.RoleBindingLister = new(roleBindingLister) // RoleBindings returns an object that can list and get RoleBindings in one namespace. -func (s *roleBindingLister) RoleBindings(namespace string) rbacv1alpha1listers.RoleBindingNamespaceLister { - return &roleBindingNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *roleBindingLister) RoleBindings(namespace string) listersrbacv1alpha1.RoleBindingNamespaceLister { + return &roleBindingNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// roleBindingNamespaceLister implements the rbacv1alpha1listers.RoleBindingNamespaceLister interface. +// roleBindingNamespaceLister implements the listersrbacv1alpha1.RoleBindingNamespaceLister +// interface. type roleBindingNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*rbacv1alpha1.RoleBinding] } -// List lists all RoleBindings in the indexer for a given workspace and namespace. -func (s *roleBindingNamespaceLister) List(selector labels.Selector) (ret []*rbacv1alpha1.RoleBinding, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*rbacv1alpha1.RoleBinding)) - }) - return ret, err -} +var _ listersrbacv1alpha1.RoleBindingNamespaceLister = new(roleBindingNamespaceLister) -// Get retrieves the RoleBinding from the indexer for a given workspace, namespace and name. -func (s *roleBindingNamespaceLister) Get(name string) (*rbacv1alpha1.RoleBinding, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewRoleBindingLister returns a new RoleBindingLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewRoleBindingLister(indexer cache.Indexer) listersrbacv1alpha1.RoleBindingLister { + return &roleBindingLister{ + kcplisters.New[*rbacv1alpha1.RoleBinding](indexer, rbacv1alpha1.Resource("rolebinding")), } - if !exists { - return nil, errors.NewNotFound(rbacv1alpha1.Resource("rolebindings"), name) +} + +// roleBindingScopedLister can list all RoleBindings inside a workspace +// or scope down to a listersrbacv1alpha1.RoleBindingNamespaceLister for one namespace. +type roleBindingScopedLister struct { + kcplisters.ResourceIndexer[*rbacv1alpha1.RoleBinding] +} + +// RoleBindings returns an object that can list and get RoleBindings in one namespace. +func (l *roleBindingScopedLister) RoleBindings(namespace string) listersrbacv1alpha1.RoleBindingLister { + return &roleBindingLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*rbacv1alpha1.RoleBinding), nil } diff --git a/listers/rbac/v1beta1/clusterrole.go b/listers/rbac/v1beta1/clusterrole.go index c752ec05d..de3feab6f 100644 --- a/listers/rbac/v1beta1/clusterrole.go +++ b/listers/rbac/v1beta1/clusterrole.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" rbacv1beta1 "k8s.io/api/rbac/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - rbacv1beta1listers "k8s.io/client-go/listers/rbac/v1beta1" + listersrbacv1beta1 "k8s.io/client-go/listers/rbac/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ClusterRoleClusterLister can list ClusterRoles across all workspaces, or scope down to a ClusterRoleLister for one workspace. +// ClusterRoleClusterLister helps list ClusterRoles across all workspaces, +// or scope down to a ClusterRoleLister for one workspace. // All objects returned here must be treated as read-only. type ClusterRoleClusterLister interface { // List lists all ClusterRoles in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*rbacv1beta1.ClusterRole, err error) // Cluster returns a lister that can list and get ClusterRoles in one workspace. - Cluster(clusterName logicalcluster.Name) rbacv1beta1listers.ClusterRoleLister + Cluster(clusterName logicalcluster.Name) listersrbacv1beta1.ClusterRoleLister ClusterRoleClusterListerExpansion } +// clusterRoleClusterLister implements the ClusterRoleClusterLister interface. type clusterRoleClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*rbacv1beta1.ClusterRole] } +var _ ClusterRoleClusterLister = new(clusterRoleClusterLister) + // NewClusterRoleClusterLister returns a new ClusterRoleClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewClusterRoleClusterLister(indexer cache.Indexer) *clusterRoleClusterLister { - return &clusterRoleClusterLister{indexer: indexer} -} - -// List lists all ClusterRoles in the indexer across all workspaces. -func (s *clusterRoleClusterLister) List(selector labels.Selector) (ret []*rbacv1beta1.ClusterRole, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*rbacv1beta1.ClusterRole)) - }) - return ret, err +func NewClusterRoleClusterLister(indexer cache.Indexer) ClusterRoleClusterLister { + return &clusterRoleClusterLister{ + kcplisters.NewCluster[*rbacv1beta1.ClusterRole](indexer, rbacv1beta1.Resource("clusterrole")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ClusterRoles. -func (s *clusterRoleClusterLister) Cluster(clusterName logicalcluster.Name) rbacv1beta1listers.ClusterRoleLister { - return &clusterRoleLister{indexer: s.indexer, clusterName: clusterName} +func (l *clusterRoleClusterLister) Cluster(clusterName logicalcluster.Name) listersrbacv1beta1.ClusterRoleLister { + return &clusterRoleLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// clusterRoleLister implements the rbacv1beta1listers.ClusterRoleLister interface. +// clusterRoleLister can list all ClusterRoles inside a workspace +// or scope down to a listersrbacv1beta1.ClusterRoleNamespaceLister for one namespace. type clusterRoleLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*rbacv1beta1.ClusterRole] } -// List lists all ClusterRoles in the indexer for a workspace. -func (s *clusterRoleLister) List(selector labels.Selector) (ret []*rbacv1beta1.ClusterRole, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*rbacv1beta1.ClusterRole)) - }) - return ret, err -} +var _ listersrbacv1beta1.ClusterRoleLister = new(clusterRoleLister) -// Get retrieves the ClusterRole from the indexer for a given workspace and name. -func (s *clusterRoleLister) Get(name string) (*rbacv1beta1.ClusterRole, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(rbacv1beta1.Resource("clusterroles"), name) +// NewClusterRoleLister returns a new ClusterRoleLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewClusterRoleLister(indexer cache.Indexer) listersrbacv1beta1.ClusterRoleLister { + return &clusterRoleLister{ + kcplisters.New[*rbacv1beta1.ClusterRole](indexer, rbacv1beta1.Resource("clusterrole")), } - return obj.(*rbacv1beta1.ClusterRole), nil +} + +// clusterRoleScopedLister can list all ClusterRoles inside a workspace +// or scope down to a listersrbacv1beta1.ClusterRoleNamespaceLister. +type clusterRoleScopedLister struct { + kcplisters.ResourceIndexer[*rbacv1beta1.ClusterRole] } diff --git a/listers/rbac/v1beta1/clusterrolebinding.go b/listers/rbac/v1beta1/clusterrolebinding.go index b07022607..3a692b3c1 100644 --- a/listers/rbac/v1beta1/clusterrolebinding.go +++ b/listers/rbac/v1beta1/clusterrolebinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" rbacv1beta1 "k8s.io/api/rbac/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - rbacv1beta1listers "k8s.io/client-go/listers/rbac/v1beta1" + listersrbacv1beta1 "k8s.io/client-go/listers/rbac/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ClusterRoleBindingClusterLister can list ClusterRoleBindings across all workspaces, or scope down to a ClusterRoleBindingLister for one workspace. +// ClusterRoleBindingClusterLister helps list ClusterRoleBindings across all workspaces, +// or scope down to a ClusterRoleBindingLister for one workspace. // All objects returned here must be treated as read-only. type ClusterRoleBindingClusterLister interface { // List lists all ClusterRoleBindings in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*rbacv1beta1.ClusterRoleBinding, err error) // Cluster returns a lister that can list and get ClusterRoleBindings in one workspace. - Cluster(clusterName logicalcluster.Name) rbacv1beta1listers.ClusterRoleBindingLister + Cluster(clusterName logicalcluster.Name) listersrbacv1beta1.ClusterRoleBindingLister ClusterRoleBindingClusterListerExpansion } +// clusterRoleBindingClusterLister implements the ClusterRoleBindingClusterLister interface. type clusterRoleBindingClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*rbacv1beta1.ClusterRoleBinding] } +var _ ClusterRoleBindingClusterLister = new(clusterRoleBindingClusterLister) + // NewClusterRoleBindingClusterLister returns a new ClusterRoleBindingClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewClusterRoleBindingClusterLister(indexer cache.Indexer) *clusterRoleBindingClusterLister { - return &clusterRoleBindingClusterLister{indexer: indexer} -} - -// List lists all ClusterRoleBindings in the indexer across all workspaces. -func (s *clusterRoleBindingClusterLister) List(selector labels.Selector) (ret []*rbacv1beta1.ClusterRoleBinding, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*rbacv1beta1.ClusterRoleBinding)) - }) - return ret, err +func NewClusterRoleBindingClusterLister(indexer cache.Indexer) ClusterRoleBindingClusterLister { + return &clusterRoleBindingClusterLister{ + kcplisters.NewCluster[*rbacv1beta1.ClusterRoleBinding](indexer, rbacv1beta1.Resource("clusterrolebinding")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ClusterRoleBindings. -func (s *clusterRoleBindingClusterLister) Cluster(clusterName logicalcluster.Name) rbacv1beta1listers.ClusterRoleBindingLister { - return &clusterRoleBindingLister{indexer: s.indexer, clusterName: clusterName} +func (l *clusterRoleBindingClusterLister) Cluster(clusterName logicalcluster.Name) listersrbacv1beta1.ClusterRoleBindingLister { + return &clusterRoleBindingLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// clusterRoleBindingLister implements the rbacv1beta1listers.ClusterRoleBindingLister interface. +// clusterRoleBindingLister can list all ClusterRoleBindings inside a workspace +// or scope down to a listersrbacv1beta1.ClusterRoleBindingNamespaceLister for one namespace. type clusterRoleBindingLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*rbacv1beta1.ClusterRoleBinding] } -// List lists all ClusterRoleBindings in the indexer for a workspace. -func (s *clusterRoleBindingLister) List(selector labels.Selector) (ret []*rbacv1beta1.ClusterRoleBinding, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*rbacv1beta1.ClusterRoleBinding)) - }) - return ret, err -} +var _ listersrbacv1beta1.ClusterRoleBindingLister = new(clusterRoleBindingLister) -// Get retrieves the ClusterRoleBinding from the indexer for a given workspace and name. -func (s *clusterRoleBindingLister) Get(name string) (*rbacv1beta1.ClusterRoleBinding, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(rbacv1beta1.Resource("clusterrolebindings"), name) +// NewClusterRoleBindingLister returns a new ClusterRoleBindingLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewClusterRoleBindingLister(indexer cache.Indexer) listersrbacv1beta1.ClusterRoleBindingLister { + return &clusterRoleBindingLister{ + kcplisters.New[*rbacv1beta1.ClusterRoleBinding](indexer, rbacv1beta1.Resource("clusterrolebinding")), } - return obj.(*rbacv1beta1.ClusterRoleBinding), nil +} + +// clusterRoleBindingScopedLister can list all ClusterRoleBindings inside a workspace +// or scope down to a listersrbacv1beta1.ClusterRoleBindingNamespaceLister. +type clusterRoleBindingScopedLister struct { + kcplisters.ResourceIndexer[*rbacv1beta1.ClusterRoleBinding] } diff --git a/listers/rbac/v1beta1/expansion_generated.go b/listers/rbac/v1beta1/expansion_generated.go new file mode 100644 index 000000000..23cac805b --- /dev/null +++ b/listers/rbac/v1beta1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1beta1 diff --git a/listers/rbac/v1beta1/role.go b/listers/rbac/v1beta1/role.go index 451f5f5a3..fc66906ee 100644 --- a/listers/rbac/v1beta1/role.go +++ b/listers/rbac/v1beta1/role.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" rbacv1beta1 "k8s.io/api/rbac/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - rbacv1beta1listers "k8s.io/client-go/listers/rbac/v1beta1" + listersrbacv1beta1 "k8s.io/client-go/listers/rbac/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// RoleClusterLister can list Roles across all workspaces, or scope down to a RoleLister for one workspace. +// RoleClusterLister helps list Roles across all workspaces, +// or scope down to a RoleLister for one workspace. // All objects returned here must be treated as read-only. type RoleClusterLister interface { // List lists all Roles in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*rbacv1beta1.Role, err error) // Cluster returns a lister that can list and get Roles in one workspace. - Cluster(clusterName logicalcluster.Name) rbacv1beta1listers.RoleLister + Cluster(clusterName logicalcluster.Name) listersrbacv1beta1.RoleLister RoleClusterListerExpansion } +// roleClusterLister implements the RoleClusterLister interface. type roleClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*rbacv1beta1.Role] } +var _ RoleClusterLister = new(roleClusterLister) + // NewRoleClusterLister returns a new RoleClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewRoleClusterLister(indexer cache.Indexer) *roleClusterLister { - return &roleClusterLister{indexer: indexer} -} - -// List lists all Roles in the indexer across all workspaces. -func (s *roleClusterLister) List(selector labels.Selector) (ret []*rbacv1beta1.Role, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*rbacv1beta1.Role)) - }) - return ret, err +func NewRoleClusterLister(indexer cache.Indexer) RoleClusterLister { + return &roleClusterLister{ + kcplisters.NewCluster[*rbacv1beta1.Role](indexer, rbacv1beta1.Resource("role")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get Roles. -func (s *roleClusterLister) Cluster(clusterName logicalcluster.Name) rbacv1beta1listers.RoleLister { - return &roleLister{indexer: s.indexer, clusterName: clusterName} +func (l *roleClusterLister) Cluster(clusterName logicalcluster.Name) listersrbacv1beta1.RoleLister { + return &roleLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// roleLister implements the rbacv1beta1listers.RoleLister interface. +// roleLister can list all Roles inside a workspace +// or scope down to a listersrbacv1beta1.RoleNamespaceLister for one namespace. type roleLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*rbacv1beta1.Role] } -// List lists all Roles in the indexer for a workspace. -func (s *roleLister) List(selector labels.Selector) (ret []*rbacv1beta1.Role, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*rbacv1beta1.Role)) - }) - return ret, err -} +var _ listersrbacv1beta1.RoleLister = new(roleLister) // Roles returns an object that can list and get Roles in one namespace. -func (s *roleLister) Roles(namespace string) rbacv1beta1listers.RoleNamespaceLister { - return &roleNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *roleLister) Roles(namespace string) listersrbacv1beta1.RoleNamespaceLister { + return &roleNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// roleNamespaceLister implements the rbacv1beta1listers.RoleNamespaceLister interface. +// roleNamespaceLister implements the listersrbacv1beta1.RoleNamespaceLister +// interface. type roleNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*rbacv1beta1.Role] } -// List lists all Roles in the indexer for a given workspace and namespace. -func (s *roleNamespaceLister) List(selector labels.Selector) (ret []*rbacv1beta1.Role, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*rbacv1beta1.Role)) - }) - return ret, err -} +var _ listersrbacv1beta1.RoleNamespaceLister = new(roleNamespaceLister) -// Get retrieves the Role from the indexer for a given workspace, namespace and name. -func (s *roleNamespaceLister) Get(name string) (*rbacv1beta1.Role, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewRoleLister returns a new RoleLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewRoleLister(indexer cache.Indexer) listersrbacv1beta1.RoleLister { + return &roleLister{ + kcplisters.New[*rbacv1beta1.Role](indexer, rbacv1beta1.Resource("role")), } - if !exists { - return nil, errors.NewNotFound(rbacv1beta1.Resource("roles"), name) +} + +// roleScopedLister can list all Roles inside a workspace +// or scope down to a listersrbacv1beta1.RoleNamespaceLister for one namespace. +type roleScopedLister struct { + kcplisters.ResourceIndexer[*rbacv1beta1.Role] +} + +// Roles returns an object that can list and get Roles in one namespace. +func (l *roleScopedLister) Roles(namespace string) listersrbacv1beta1.RoleLister { + return &roleLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*rbacv1beta1.Role), nil } diff --git a/listers/rbac/v1beta1/rolebinding.go b/listers/rbac/v1beta1/rolebinding.go index 2fad520c6..4c6e50be6 100644 --- a/listers/rbac/v1beta1/rolebinding.go +++ b/listers/rbac/v1beta1/rolebinding.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" rbacv1beta1 "k8s.io/api/rbac/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - rbacv1beta1listers "k8s.io/client-go/listers/rbac/v1beta1" + listersrbacv1beta1 "k8s.io/client-go/listers/rbac/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// RoleBindingClusterLister can list RoleBindings across all workspaces, or scope down to a RoleBindingLister for one workspace. +// RoleBindingClusterLister helps list RoleBindings across all workspaces, +// or scope down to a RoleBindingLister for one workspace. // All objects returned here must be treated as read-only. type RoleBindingClusterLister interface { // List lists all RoleBindings in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*rbacv1beta1.RoleBinding, err error) // Cluster returns a lister that can list and get RoleBindings in one workspace. - Cluster(clusterName logicalcluster.Name) rbacv1beta1listers.RoleBindingLister + Cluster(clusterName logicalcluster.Name) listersrbacv1beta1.RoleBindingLister RoleBindingClusterListerExpansion } +// roleBindingClusterLister implements the RoleBindingClusterLister interface. type roleBindingClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*rbacv1beta1.RoleBinding] } +var _ RoleBindingClusterLister = new(roleBindingClusterLister) + // NewRoleBindingClusterLister returns a new RoleBindingClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewRoleBindingClusterLister(indexer cache.Indexer) *roleBindingClusterLister { - return &roleBindingClusterLister{indexer: indexer} -} - -// List lists all RoleBindings in the indexer across all workspaces. -func (s *roleBindingClusterLister) List(selector labels.Selector) (ret []*rbacv1beta1.RoleBinding, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*rbacv1beta1.RoleBinding)) - }) - return ret, err +func NewRoleBindingClusterLister(indexer cache.Indexer) RoleBindingClusterLister { + return &roleBindingClusterLister{ + kcplisters.NewCluster[*rbacv1beta1.RoleBinding](indexer, rbacv1beta1.Resource("rolebinding")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get RoleBindings. -func (s *roleBindingClusterLister) Cluster(clusterName logicalcluster.Name) rbacv1beta1listers.RoleBindingLister { - return &roleBindingLister{indexer: s.indexer, clusterName: clusterName} +func (l *roleBindingClusterLister) Cluster(clusterName logicalcluster.Name) listersrbacv1beta1.RoleBindingLister { + return &roleBindingLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// roleBindingLister implements the rbacv1beta1listers.RoleBindingLister interface. +// roleBindingLister can list all RoleBindings inside a workspace +// or scope down to a listersrbacv1beta1.RoleBindingNamespaceLister for one namespace. type roleBindingLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*rbacv1beta1.RoleBinding] } -// List lists all RoleBindings in the indexer for a workspace. -func (s *roleBindingLister) List(selector labels.Selector) (ret []*rbacv1beta1.RoleBinding, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*rbacv1beta1.RoleBinding)) - }) - return ret, err -} +var _ listersrbacv1beta1.RoleBindingLister = new(roleBindingLister) // RoleBindings returns an object that can list and get RoleBindings in one namespace. -func (s *roleBindingLister) RoleBindings(namespace string) rbacv1beta1listers.RoleBindingNamespaceLister { - return &roleBindingNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *roleBindingLister) RoleBindings(namespace string) listersrbacv1beta1.RoleBindingNamespaceLister { + return &roleBindingNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// roleBindingNamespaceLister implements the rbacv1beta1listers.RoleBindingNamespaceLister interface. +// roleBindingNamespaceLister implements the listersrbacv1beta1.RoleBindingNamespaceLister +// interface. type roleBindingNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*rbacv1beta1.RoleBinding] } -// List lists all RoleBindings in the indexer for a given workspace and namespace. -func (s *roleBindingNamespaceLister) List(selector labels.Selector) (ret []*rbacv1beta1.RoleBinding, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*rbacv1beta1.RoleBinding)) - }) - return ret, err -} +var _ listersrbacv1beta1.RoleBindingNamespaceLister = new(roleBindingNamespaceLister) -// Get retrieves the RoleBinding from the indexer for a given workspace, namespace and name. -func (s *roleBindingNamespaceLister) Get(name string) (*rbacv1beta1.RoleBinding, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewRoleBindingLister returns a new RoleBindingLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewRoleBindingLister(indexer cache.Indexer) listersrbacv1beta1.RoleBindingLister { + return &roleBindingLister{ + kcplisters.New[*rbacv1beta1.RoleBinding](indexer, rbacv1beta1.Resource("rolebinding")), } - if !exists { - return nil, errors.NewNotFound(rbacv1beta1.Resource("rolebindings"), name) +} + +// roleBindingScopedLister can list all RoleBindings inside a workspace +// or scope down to a listersrbacv1beta1.RoleBindingNamespaceLister for one namespace. +type roleBindingScopedLister struct { + kcplisters.ResourceIndexer[*rbacv1beta1.RoleBinding] +} + +// RoleBindings returns an object that can list and get RoleBindings in one namespace. +func (l *roleBindingScopedLister) RoleBindings(namespace string) listersrbacv1beta1.RoleBindingLister { + return &roleBindingLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*rbacv1beta1.RoleBinding), nil } diff --git a/listers/resource/v1alpha3/deviceclass.go b/listers/resource/v1alpha3/deviceclass.go index d3769464d..87719871a 100644 --- a/listers/resource/v1alpha3/deviceclass.go +++ b/listers/resource/v1alpha3/deviceclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1alpha3 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" resourcev1alpha3 "k8s.io/api/resource/v1alpha3" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - resourcev1alpha3listers "k8s.io/client-go/listers/resource/v1alpha3" + listersresourcev1alpha3 "k8s.io/client-go/listers/resource/v1alpha3" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// DeviceClassClusterLister can list DeviceClasses across all workspaces, or scope down to a DeviceClassLister for one workspace. +// DeviceClassClusterLister helps list DeviceClasses across all workspaces, +// or scope down to a DeviceClassLister for one workspace. // All objects returned here must be treated as read-only. type DeviceClassClusterLister interface { // List lists all DeviceClasses in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*resourcev1alpha3.DeviceClass, err error) // Cluster returns a lister that can list and get DeviceClasses in one workspace. - Cluster(clusterName logicalcluster.Name) resourcev1alpha3listers.DeviceClassLister + Cluster(clusterName logicalcluster.Name) listersresourcev1alpha3.DeviceClassLister DeviceClassClusterListerExpansion } +// deviceClassClusterLister implements the DeviceClassClusterLister interface. type deviceClassClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*resourcev1alpha3.DeviceClass] } +var _ DeviceClassClusterLister = new(deviceClassClusterLister) + // NewDeviceClassClusterLister returns a new DeviceClassClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewDeviceClassClusterLister(indexer cache.Indexer) *deviceClassClusterLister { - return &deviceClassClusterLister{indexer: indexer} -} - -// List lists all DeviceClasses in the indexer across all workspaces. -func (s *deviceClassClusterLister) List(selector labels.Selector) (ret []*resourcev1alpha3.DeviceClass, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*resourcev1alpha3.DeviceClass)) - }) - return ret, err +func NewDeviceClassClusterLister(indexer cache.Indexer) DeviceClassClusterLister { + return &deviceClassClusterLister{ + kcplisters.NewCluster[*resourcev1alpha3.DeviceClass](indexer, resourcev1alpha3.Resource("deviceclass")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get DeviceClasses. -func (s *deviceClassClusterLister) Cluster(clusterName logicalcluster.Name) resourcev1alpha3listers.DeviceClassLister { - return &deviceClassLister{indexer: s.indexer, clusterName: clusterName} +func (l *deviceClassClusterLister) Cluster(clusterName logicalcluster.Name) listersresourcev1alpha3.DeviceClassLister { + return &deviceClassLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// deviceClassLister implements the resourcev1alpha3listers.DeviceClassLister interface. +// deviceClassLister can list all DeviceClasses inside a workspace +// or scope down to a listersresourcev1alpha3.DeviceClassNamespaceLister for one namespace. type deviceClassLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*resourcev1alpha3.DeviceClass] } -// List lists all DeviceClasses in the indexer for a workspace. -func (s *deviceClassLister) List(selector labels.Selector) (ret []*resourcev1alpha3.DeviceClass, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*resourcev1alpha3.DeviceClass)) - }) - return ret, err -} +var _ listersresourcev1alpha3.DeviceClassLister = new(deviceClassLister) -// Get retrieves the DeviceClass from the indexer for a given workspace and name. -func (s *deviceClassLister) Get(name string) (*resourcev1alpha3.DeviceClass, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(resourcev1alpha3.Resource("deviceclasses"), name) +// NewDeviceClassLister returns a new DeviceClassLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewDeviceClassLister(indexer cache.Indexer) listersresourcev1alpha3.DeviceClassLister { + return &deviceClassLister{ + kcplisters.New[*resourcev1alpha3.DeviceClass](indexer, resourcev1alpha3.Resource("deviceclass")), } - return obj.(*resourcev1alpha3.DeviceClass), nil +} + +// deviceClassScopedLister can list all DeviceClasses inside a workspace +// or scope down to a listersresourcev1alpha3.DeviceClassNamespaceLister. +type deviceClassScopedLister struct { + kcplisters.ResourceIndexer[*resourcev1alpha3.DeviceClass] } diff --git a/listers/resource/v1alpha3/expansion_generated.go b/listers/resource/v1alpha3/expansion_generated.go new file mode 100644 index 000000000..04ad1a3da --- /dev/null +++ b/listers/resource/v1alpha3/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1alpha3 diff --git a/listers/resource/v1alpha3/resourceclaim.go b/listers/resource/v1alpha3/resourceclaim.go index 532421226..39f0f0757 100644 --- a/listers/resource/v1alpha3/resourceclaim.go +++ b/listers/resource/v1alpha3/resourceclaim.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1alpha3 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" resourcev1alpha3 "k8s.io/api/resource/v1alpha3" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - resourcev1alpha3listers "k8s.io/client-go/listers/resource/v1alpha3" + listersresourcev1alpha3 "k8s.io/client-go/listers/resource/v1alpha3" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ResourceClaimClusterLister can list ResourceClaims across all workspaces, or scope down to a ResourceClaimLister for one workspace. +// ResourceClaimClusterLister helps list ResourceClaims across all workspaces, +// or scope down to a ResourceClaimLister for one workspace. // All objects returned here must be treated as read-only. type ResourceClaimClusterLister interface { // List lists all ResourceClaims in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*resourcev1alpha3.ResourceClaim, err error) // Cluster returns a lister that can list and get ResourceClaims in one workspace. - Cluster(clusterName logicalcluster.Name) resourcev1alpha3listers.ResourceClaimLister + Cluster(clusterName logicalcluster.Name) listersresourcev1alpha3.ResourceClaimLister ResourceClaimClusterListerExpansion } +// resourceClaimClusterLister implements the ResourceClaimClusterLister interface. type resourceClaimClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*resourcev1alpha3.ResourceClaim] } +var _ ResourceClaimClusterLister = new(resourceClaimClusterLister) + // NewResourceClaimClusterLister returns a new ResourceClaimClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewResourceClaimClusterLister(indexer cache.Indexer) *resourceClaimClusterLister { - return &resourceClaimClusterLister{indexer: indexer} -} - -// List lists all ResourceClaims in the indexer across all workspaces. -func (s *resourceClaimClusterLister) List(selector labels.Selector) (ret []*resourcev1alpha3.ResourceClaim, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*resourcev1alpha3.ResourceClaim)) - }) - return ret, err +func NewResourceClaimClusterLister(indexer cache.Indexer) ResourceClaimClusterLister { + return &resourceClaimClusterLister{ + kcplisters.NewCluster[*resourcev1alpha3.ResourceClaim](indexer, resourcev1alpha3.Resource("resourceclaim")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ResourceClaims. -func (s *resourceClaimClusterLister) Cluster(clusterName logicalcluster.Name) resourcev1alpha3listers.ResourceClaimLister { - return &resourceClaimLister{indexer: s.indexer, clusterName: clusterName} +func (l *resourceClaimClusterLister) Cluster(clusterName logicalcluster.Name) listersresourcev1alpha3.ResourceClaimLister { + return &resourceClaimLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// resourceClaimLister implements the resourcev1alpha3listers.ResourceClaimLister interface. +// resourceClaimLister can list all ResourceClaims inside a workspace +// or scope down to a listersresourcev1alpha3.ResourceClaimNamespaceLister for one namespace. type resourceClaimLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*resourcev1alpha3.ResourceClaim] } -// List lists all ResourceClaims in the indexer for a workspace. -func (s *resourceClaimLister) List(selector labels.Selector) (ret []*resourcev1alpha3.ResourceClaim, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*resourcev1alpha3.ResourceClaim)) - }) - return ret, err -} +var _ listersresourcev1alpha3.ResourceClaimLister = new(resourceClaimLister) // ResourceClaims returns an object that can list and get ResourceClaims in one namespace. -func (s *resourceClaimLister) ResourceClaims(namespace string) resourcev1alpha3listers.ResourceClaimNamespaceLister { - return &resourceClaimNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *resourceClaimLister) ResourceClaims(namespace string) listersresourcev1alpha3.ResourceClaimNamespaceLister { + return &resourceClaimNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// resourceClaimNamespaceLister implements the resourcev1alpha3listers.ResourceClaimNamespaceLister interface. +// resourceClaimNamespaceLister implements the listersresourcev1alpha3.ResourceClaimNamespaceLister +// interface. type resourceClaimNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*resourcev1alpha3.ResourceClaim] } -// List lists all ResourceClaims in the indexer for a given workspace and namespace. -func (s *resourceClaimNamespaceLister) List(selector labels.Selector) (ret []*resourcev1alpha3.ResourceClaim, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*resourcev1alpha3.ResourceClaim)) - }) - return ret, err -} +var _ listersresourcev1alpha3.ResourceClaimNamespaceLister = new(resourceClaimNamespaceLister) -// Get retrieves the ResourceClaim from the indexer for a given workspace, namespace and name. -func (s *resourceClaimNamespaceLister) Get(name string) (*resourcev1alpha3.ResourceClaim, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewResourceClaimLister returns a new ResourceClaimLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewResourceClaimLister(indexer cache.Indexer) listersresourcev1alpha3.ResourceClaimLister { + return &resourceClaimLister{ + kcplisters.New[*resourcev1alpha3.ResourceClaim](indexer, resourcev1alpha3.Resource("resourceclaim")), } - if !exists { - return nil, errors.NewNotFound(resourcev1alpha3.Resource("resourceclaims"), name) +} + +// resourceClaimScopedLister can list all ResourceClaims inside a workspace +// or scope down to a listersresourcev1alpha3.ResourceClaimNamespaceLister for one namespace. +type resourceClaimScopedLister struct { + kcplisters.ResourceIndexer[*resourcev1alpha3.ResourceClaim] +} + +// ResourceClaims returns an object that can list and get ResourceClaims in one namespace. +func (l *resourceClaimScopedLister) ResourceClaims(namespace string) listersresourcev1alpha3.ResourceClaimLister { + return &resourceClaimLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*resourcev1alpha3.ResourceClaim), nil } diff --git a/listers/resource/v1alpha3/resourceclaimtemplate.go b/listers/resource/v1alpha3/resourceclaimtemplate.go index 4900e31cb..164d285f8 100644 --- a/listers/resource/v1alpha3/resourceclaimtemplate.go +++ b/listers/resource/v1alpha3/resourceclaimtemplate.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1alpha3 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" resourcev1alpha3 "k8s.io/api/resource/v1alpha3" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - resourcev1alpha3listers "k8s.io/client-go/listers/resource/v1alpha3" + listersresourcev1alpha3 "k8s.io/client-go/listers/resource/v1alpha3" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ResourceClaimTemplateClusterLister can list ResourceClaimTemplates across all workspaces, or scope down to a ResourceClaimTemplateLister for one workspace. +// ResourceClaimTemplateClusterLister helps list ResourceClaimTemplates across all workspaces, +// or scope down to a ResourceClaimTemplateLister for one workspace. // All objects returned here must be treated as read-only. type ResourceClaimTemplateClusterLister interface { // List lists all ResourceClaimTemplates in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*resourcev1alpha3.ResourceClaimTemplate, err error) // Cluster returns a lister that can list and get ResourceClaimTemplates in one workspace. - Cluster(clusterName logicalcluster.Name) resourcev1alpha3listers.ResourceClaimTemplateLister + Cluster(clusterName logicalcluster.Name) listersresourcev1alpha3.ResourceClaimTemplateLister ResourceClaimTemplateClusterListerExpansion } +// resourceClaimTemplateClusterLister implements the ResourceClaimTemplateClusterLister interface. type resourceClaimTemplateClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*resourcev1alpha3.ResourceClaimTemplate] } +var _ ResourceClaimTemplateClusterLister = new(resourceClaimTemplateClusterLister) + // NewResourceClaimTemplateClusterLister returns a new ResourceClaimTemplateClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewResourceClaimTemplateClusterLister(indexer cache.Indexer) *resourceClaimTemplateClusterLister { - return &resourceClaimTemplateClusterLister{indexer: indexer} -} - -// List lists all ResourceClaimTemplates in the indexer across all workspaces. -func (s *resourceClaimTemplateClusterLister) List(selector labels.Selector) (ret []*resourcev1alpha3.ResourceClaimTemplate, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*resourcev1alpha3.ResourceClaimTemplate)) - }) - return ret, err +func NewResourceClaimTemplateClusterLister(indexer cache.Indexer) ResourceClaimTemplateClusterLister { + return &resourceClaimTemplateClusterLister{ + kcplisters.NewCluster[*resourcev1alpha3.ResourceClaimTemplate](indexer, resourcev1alpha3.Resource("resourceclaimtemplate")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ResourceClaimTemplates. -func (s *resourceClaimTemplateClusterLister) Cluster(clusterName logicalcluster.Name) resourcev1alpha3listers.ResourceClaimTemplateLister { - return &resourceClaimTemplateLister{indexer: s.indexer, clusterName: clusterName} +func (l *resourceClaimTemplateClusterLister) Cluster(clusterName logicalcluster.Name) listersresourcev1alpha3.ResourceClaimTemplateLister { + return &resourceClaimTemplateLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// resourceClaimTemplateLister implements the resourcev1alpha3listers.ResourceClaimTemplateLister interface. +// resourceClaimTemplateLister can list all ResourceClaimTemplates inside a workspace +// or scope down to a listersresourcev1alpha3.ResourceClaimTemplateNamespaceLister for one namespace. type resourceClaimTemplateLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*resourcev1alpha3.ResourceClaimTemplate] } -// List lists all ResourceClaimTemplates in the indexer for a workspace. -func (s *resourceClaimTemplateLister) List(selector labels.Selector) (ret []*resourcev1alpha3.ResourceClaimTemplate, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*resourcev1alpha3.ResourceClaimTemplate)) - }) - return ret, err -} +var _ listersresourcev1alpha3.ResourceClaimTemplateLister = new(resourceClaimTemplateLister) // ResourceClaimTemplates returns an object that can list and get ResourceClaimTemplates in one namespace. -func (s *resourceClaimTemplateLister) ResourceClaimTemplates(namespace string) resourcev1alpha3listers.ResourceClaimTemplateNamespaceLister { - return &resourceClaimTemplateNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *resourceClaimTemplateLister) ResourceClaimTemplates(namespace string) listersresourcev1alpha3.ResourceClaimTemplateNamespaceLister { + return &resourceClaimTemplateNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// resourceClaimTemplateNamespaceLister implements the resourcev1alpha3listers.ResourceClaimTemplateNamespaceLister interface. +// resourceClaimTemplateNamespaceLister implements the listersresourcev1alpha3.ResourceClaimTemplateNamespaceLister +// interface. type resourceClaimTemplateNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*resourcev1alpha3.ResourceClaimTemplate] } -// List lists all ResourceClaimTemplates in the indexer for a given workspace and namespace. -func (s *resourceClaimTemplateNamespaceLister) List(selector labels.Selector) (ret []*resourcev1alpha3.ResourceClaimTemplate, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*resourcev1alpha3.ResourceClaimTemplate)) - }) - return ret, err -} +var _ listersresourcev1alpha3.ResourceClaimTemplateNamespaceLister = new(resourceClaimTemplateNamespaceLister) -// Get retrieves the ResourceClaimTemplate from the indexer for a given workspace, namespace and name. -func (s *resourceClaimTemplateNamespaceLister) Get(name string) (*resourcev1alpha3.ResourceClaimTemplate, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewResourceClaimTemplateLister returns a new ResourceClaimTemplateLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewResourceClaimTemplateLister(indexer cache.Indexer) listersresourcev1alpha3.ResourceClaimTemplateLister { + return &resourceClaimTemplateLister{ + kcplisters.New[*resourcev1alpha3.ResourceClaimTemplate](indexer, resourcev1alpha3.Resource("resourceclaimtemplate")), } - if !exists { - return nil, errors.NewNotFound(resourcev1alpha3.Resource("resourceclaimtemplates"), name) +} + +// resourceClaimTemplateScopedLister can list all ResourceClaimTemplates inside a workspace +// or scope down to a listersresourcev1alpha3.ResourceClaimTemplateNamespaceLister for one namespace. +type resourceClaimTemplateScopedLister struct { + kcplisters.ResourceIndexer[*resourcev1alpha3.ResourceClaimTemplate] +} + +// ResourceClaimTemplates returns an object that can list and get ResourceClaimTemplates in one namespace. +func (l *resourceClaimTemplateScopedLister) ResourceClaimTemplates(namespace string) listersresourcev1alpha3.ResourceClaimTemplateLister { + return &resourceClaimTemplateLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*resourcev1alpha3.ResourceClaimTemplate), nil } diff --git a/listers/resource/v1alpha3/resourceslice.go b/listers/resource/v1alpha3/resourceslice.go index 1dfcf0bae..d76e21f89 100644 --- a/listers/resource/v1alpha3/resourceslice.go +++ b/listers/resource/v1alpha3/resourceslice.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1alpha3 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" resourcev1alpha3 "k8s.io/api/resource/v1alpha3" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - resourcev1alpha3listers "k8s.io/client-go/listers/resource/v1alpha3" + listersresourcev1alpha3 "k8s.io/client-go/listers/resource/v1alpha3" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ResourceSliceClusterLister can list ResourceSlices across all workspaces, or scope down to a ResourceSliceLister for one workspace. +// ResourceSliceClusterLister helps list ResourceSlices across all workspaces, +// or scope down to a ResourceSliceLister for one workspace. // All objects returned here must be treated as read-only. type ResourceSliceClusterLister interface { // List lists all ResourceSlices in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*resourcev1alpha3.ResourceSlice, err error) // Cluster returns a lister that can list and get ResourceSlices in one workspace. - Cluster(clusterName logicalcluster.Name) resourcev1alpha3listers.ResourceSliceLister + Cluster(clusterName logicalcluster.Name) listersresourcev1alpha3.ResourceSliceLister ResourceSliceClusterListerExpansion } +// resourceSliceClusterLister implements the ResourceSliceClusterLister interface. type resourceSliceClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*resourcev1alpha3.ResourceSlice] } +var _ ResourceSliceClusterLister = new(resourceSliceClusterLister) + // NewResourceSliceClusterLister returns a new ResourceSliceClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewResourceSliceClusterLister(indexer cache.Indexer) *resourceSliceClusterLister { - return &resourceSliceClusterLister{indexer: indexer} -} - -// List lists all ResourceSlices in the indexer across all workspaces. -func (s *resourceSliceClusterLister) List(selector labels.Selector) (ret []*resourcev1alpha3.ResourceSlice, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*resourcev1alpha3.ResourceSlice)) - }) - return ret, err +func NewResourceSliceClusterLister(indexer cache.Indexer) ResourceSliceClusterLister { + return &resourceSliceClusterLister{ + kcplisters.NewCluster[*resourcev1alpha3.ResourceSlice](indexer, resourcev1alpha3.Resource("resourceslice")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ResourceSlices. -func (s *resourceSliceClusterLister) Cluster(clusterName logicalcluster.Name) resourcev1alpha3listers.ResourceSliceLister { - return &resourceSliceLister{indexer: s.indexer, clusterName: clusterName} +func (l *resourceSliceClusterLister) Cluster(clusterName logicalcluster.Name) listersresourcev1alpha3.ResourceSliceLister { + return &resourceSliceLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// resourceSliceLister implements the resourcev1alpha3listers.ResourceSliceLister interface. +// resourceSliceLister can list all ResourceSlices inside a workspace +// or scope down to a listersresourcev1alpha3.ResourceSliceNamespaceLister for one namespace. type resourceSliceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*resourcev1alpha3.ResourceSlice] } -// List lists all ResourceSlices in the indexer for a workspace. -func (s *resourceSliceLister) List(selector labels.Selector) (ret []*resourcev1alpha3.ResourceSlice, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*resourcev1alpha3.ResourceSlice)) - }) - return ret, err -} +var _ listersresourcev1alpha3.ResourceSliceLister = new(resourceSliceLister) -// Get retrieves the ResourceSlice from the indexer for a given workspace and name. -func (s *resourceSliceLister) Get(name string) (*resourcev1alpha3.ResourceSlice, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(resourcev1alpha3.Resource("resourceslices"), name) +// NewResourceSliceLister returns a new ResourceSliceLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewResourceSliceLister(indexer cache.Indexer) listersresourcev1alpha3.ResourceSliceLister { + return &resourceSliceLister{ + kcplisters.New[*resourcev1alpha3.ResourceSlice](indexer, resourcev1alpha3.Resource("resourceslice")), } - return obj.(*resourcev1alpha3.ResourceSlice), nil +} + +// resourceSliceScopedLister can list all ResourceSlices inside a workspace +// or scope down to a listersresourcev1alpha3.ResourceSliceNamespaceLister. +type resourceSliceScopedLister struct { + kcplisters.ResourceIndexer[*resourcev1alpha3.ResourceSlice] } diff --git a/listers/resource/v1beta1/deviceclass.go b/listers/resource/v1beta1/deviceclass.go index abe11f03a..04f94b360 100644 --- a/listers/resource/v1beta1/deviceclass.go +++ b/listers/resource/v1beta1/deviceclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" resourcev1beta1 "k8s.io/api/resource/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - resourcev1beta1listers "k8s.io/client-go/listers/resource/v1beta1" + listersresourcev1beta1 "k8s.io/client-go/listers/resource/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// DeviceClassClusterLister can list DeviceClasses across all workspaces, or scope down to a DeviceClassLister for one workspace. +// DeviceClassClusterLister helps list DeviceClasses across all workspaces, +// or scope down to a DeviceClassLister for one workspace. // All objects returned here must be treated as read-only. type DeviceClassClusterLister interface { // List lists all DeviceClasses in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*resourcev1beta1.DeviceClass, err error) // Cluster returns a lister that can list and get DeviceClasses in one workspace. - Cluster(clusterName logicalcluster.Name) resourcev1beta1listers.DeviceClassLister + Cluster(clusterName logicalcluster.Name) listersresourcev1beta1.DeviceClassLister DeviceClassClusterListerExpansion } +// deviceClassClusterLister implements the DeviceClassClusterLister interface. type deviceClassClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*resourcev1beta1.DeviceClass] } +var _ DeviceClassClusterLister = new(deviceClassClusterLister) + // NewDeviceClassClusterLister returns a new DeviceClassClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewDeviceClassClusterLister(indexer cache.Indexer) *deviceClassClusterLister { - return &deviceClassClusterLister{indexer: indexer} -} - -// List lists all DeviceClasses in the indexer across all workspaces. -func (s *deviceClassClusterLister) List(selector labels.Selector) (ret []*resourcev1beta1.DeviceClass, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*resourcev1beta1.DeviceClass)) - }) - return ret, err +func NewDeviceClassClusterLister(indexer cache.Indexer) DeviceClassClusterLister { + return &deviceClassClusterLister{ + kcplisters.NewCluster[*resourcev1beta1.DeviceClass](indexer, resourcev1beta1.Resource("deviceclass")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get DeviceClasses. -func (s *deviceClassClusterLister) Cluster(clusterName logicalcluster.Name) resourcev1beta1listers.DeviceClassLister { - return &deviceClassLister{indexer: s.indexer, clusterName: clusterName} +func (l *deviceClassClusterLister) Cluster(clusterName logicalcluster.Name) listersresourcev1beta1.DeviceClassLister { + return &deviceClassLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// deviceClassLister implements the resourcev1beta1listers.DeviceClassLister interface. +// deviceClassLister can list all DeviceClasses inside a workspace +// or scope down to a listersresourcev1beta1.DeviceClassNamespaceLister for one namespace. type deviceClassLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*resourcev1beta1.DeviceClass] } -// List lists all DeviceClasses in the indexer for a workspace. -func (s *deviceClassLister) List(selector labels.Selector) (ret []*resourcev1beta1.DeviceClass, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*resourcev1beta1.DeviceClass)) - }) - return ret, err -} +var _ listersresourcev1beta1.DeviceClassLister = new(deviceClassLister) -// Get retrieves the DeviceClass from the indexer for a given workspace and name. -func (s *deviceClassLister) Get(name string) (*resourcev1beta1.DeviceClass, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(resourcev1beta1.Resource("deviceclasses"), name) +// NewDeviceClassLister returns a new DeviceClassLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewDeviceClassLister(indexer cache.Indexer) listersresourcev1beta1.DeviceClassLister { + return &deviceClassLister{ + kcplisters.New[*resourcev1beta1.DeviceClass](indexer, resourcev1beta1.Resource("deviceclass")), } - return obj.(*resourcev1beta1.DeviceClass), nil +} + +// deviceClassScopedLister can list all DeviceClasses inside a workspace +// or scope down to a listersresourcev1beta1.DeviceClassNamespaceLister. +type deviceClassScopedLister struct { + kcplisters.ResourceIndexer[*resourcev1beta1.DeviceClass] } diff --git a/listers/resource/v1beta1/expansion_generated.go b/listers/resource/v1beta1/expansion_generated.go new file mode 100644 index 000000000..23cac805b --- /dev/null +++ b/listers/resource/v1beta1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1beta1 diff --git a/listers/resource/v1beta1/resourceclaim.go b/listers/resource/v1beta1/resourceclaim.go index c86f56e0b..26d783bd8 100644 --- a/listers/resource/v1beta1/resourceclaim.go +++ b/listers/resource/v1beta1/resourceclaim.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" resourcev1beta1 "k8s.io/api/resource/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - resourcev1beta1listers "k8s.io/client-go/listers/resource/v1beta1" + listersresourcev1beta1 "k8s.io/client-go/listers/resource/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ResourceClaimClusterLister can list ResourceClaims across all workspaces, or scope down to a ResourceClaimLister for one workspace. +// ResourceClaimClusterLister helps list ResourceClaims across all workspaces, +// or scope down to a ResourceClaimLister for one workspace. // All objects returned here must be treated as read-only. type ResourceClaimClusterLister interface { // List lists all ResourceClaims in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*resourcev1beta1.ResourceClaim, err error) // Cluster returns a lister that can list and get ResourceClaims in one workspace. - Cluster(clusterName logicalcluster.Name) resourcev1beta1listers.ResourceClaimLister + Cluster(clusterName logicalcluster.Name) listersresourcev1beta1.ResourceClaimLister ResourceClaimClusterListerExpansion } +// resourceClaimClusterLister implements the ResourceClaimClusterLister interface. type resourceClaimClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*resourcev1beta1.ResourceClaim] } +var _ ResourceClaimClusterLister = new(resourceClaimClusterLister) + // NewResourceClaimClusterLister returns a new ResourceClaimClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewResourceClaimClusterLister(indexer cache.Indexer) *resourceClaimClusterLister { - return &resourceClaimClusterLister{indexer: indexer} -} - -// List lists all ResourceClaims in the indexer across all workspaces. -func (s *resourceClaimClusterLister) List(selector labels.Selector) (ret []*resourcev1beta1.ResourceClaim, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*resourcev1beta1.ResourceClaim)) - }) - return ret, err +func NewResourceClaimClusterLister(indexer cache.Indexer) ResourceClaimClusterLister { + return &resourceClaimClusterLister{ + kcplisters.NewCluster[*resourcev1beta1.ResourceClaim](indexer, resourcev1beta1.Resource("resourceclaim")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ResourceClaims. -func (s *resourceClaimClusterLister) Cluster(clusterName logicalcluster.Name) resourcev1beta1listers.ResourceClaimLister { - return &resourceClaimLister{indexer: s.indexer, clusterName: clusterName} +func (l *resourceClaimClusterLister) Cluster(clusterName logicalcluster.Name) listersresourcev1beta1.ResourceClaimLister { + return &resourceClaimLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// resourceClaimLister implements the resourcev1beta1listers.ResourceClaimLister interface. +// resourceClaimLister can list all ResourceClaims inside a workspace +// or scope down to a listersresourcev1beta1.ResourceClaimNamespaceLister for one namespace. type resourceClaimLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*resourcev1beta1.ResourceClaim] } -// List lists all ResourceClaims in the indexer for a workspace. -func (s *resourceClaimLister) List(selector labels.Selector) (ret []*resourcev1beta1.ResourceClaim, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*resourcev1beta1.ResourceClaim)) - }) - return ret, err -} +var _ listersresourcev1beta1.ResourceClaimLister = new(resourceClaimLister) // ResourceClaims returns an object that can list and get ResourceClaims in one namespace. -func (s *resourceClaimLister) ResourceClaims(namespace string) resourcev1beta1listers.ResourceClaimNamespaceLister { - return &resourceClaimNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *resourceClaimLister) ResourceClaims(namespace string) listersresourcev1beta1.ResourceClaimNamespaceLister { + return &resourceClaimNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// resourceClaimNamespaceLister implements the resourcev1beta1listers.ResourceClaimNamespaceLister interface. +// resourceClaimNamespaceLister implements the listersresourcev1beta1.ResourceClaimNamespaceLister +// interface. type resourceClaimNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*resourcev1beta1.ResourceClaim] } -// List lists all ResourceClaims in the indexer for a given workspace and namespace. -func (s *resourceClaimNamespaceLister) List(selector labels.Selector) (ret []*resourcev1beta1.ResourceClaim, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*resourcev1beta1.ResourceClaim)) - }) - return ret, err -} +var _ listersresourcev1beta1.ResourceClaimNamespaceLister = new(resourceClaimNamespaceLister) -// Get retrieves the ResourceClaim from the indexer for a given workspace, namespace and name. -func (s *resourceClaimNamespaceLister) Get(name string) (*resourcev1beta1.ResourceClaim, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewResourceClaimLister returns a new ResourceClaimLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewResourceClaimLister(indexer cache.Indexer) listersresourcev1beta1.ResourceClaimLister { + return &resourceClaimLister{ + kcplisters.New[*resourcev1beta1.ResourceClaim](indexer, resourcev1beta1.Resource("resourceclaim")), } - if !exists { - return nil, errors.NewNotFound(resourcev1beta1.Resource("resourceclaims"), name) +} + +// resourceClaimScopedLister can list all ResourceClaims inside a workspace +// or scope down to a listersresourcev1beta1.ResourceClaimNamespaceLister for one namespace. +type resourceClaimScopedLister struct { + kcplisters.ResourceIndexer[*resourcev1beta1.ResourceClaim] +} + +// ResourceClaims returns an object that can list and get ResourceClaims in one namespace. +func (l *resourceClaimScopedLister) ResourceClaims(namespace string) listersresourcev1beta1.ResourceClaimLister { + return &resourceClaimLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*resourcev1beta1.ResourceClaim), nil } diff --git a/listers/resource/v1beta1/resourceclaimtemplate.go b/listers/resource/v1beta1/resourceclaimtemplate.go index ef54878cd..1f0b805b7 100644 --- a/listers/resource/v1beta1/resourceclaimtemplate.go +++ b/listers/resource/v1beta1/resourceclaimtemplate.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" resourcev1beta1 "k8s.io/api/resource/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - resourcev1beta1listers "k8s.io/client-go/listers/resource/v1beta1" + listersresourcev1beta1 "k8s.io/client-go/listers/resource/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ResourceClaimTemplateClusterLister can list ResourceClaimTemplates across all workspaces, or scope down to a ResourceClaimTemplateLister for one workspace. +// ResourceClaimTemplateClusterLister helps list ResourceClaimTemplates across all workspaces, +// or scope down to a ResourceClaimTemplateLister for one workspace. // All objects returned here must be treated as read-only. type ResourceClaimTemplateClusterLister interface { // List lists all ResourceClaimTemplates in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*resourcev1beta1.ResourceClaimTemplate, err error) // Cluster returns a lister that can list and get ResourceClaimTemplates in one workspace. - Cluster(clusterName logicalcluster.Name) resourcev1beta1listers.ResourceClaimTemplateLister + Cluster(clusterName logicalcluster.Name) listersresourcev1beta1.ResourceClaimTemplateLister ResourceClaimTemplateClusterListerExpansion } +// resourceClaimTemplateClusterLister implements the ResourceClaimTemplateClusterLister interface. type resourceClaimTemplateClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*resourcev1beta1.ResourceClaimTemplate] } +var _ ResourceClaimTemplateClusterLister = new(resourceClaimTemplateClusterLister) + // NewResourceClaimTemplateClusterLister returns a new ResourceClaimTemplateClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewResourceClaimTemplateClusterLister(indexer cache.Indexer) *resourceClaimTemplateClusterLister { - return &resourceClaimTemplateClusterLister{indexer: indexer} -} - -// List lists all ResourceClaimTemplates in the indexer across all workspaces. -func (s *resourceClaimTemplateClusterLister) List(selector labels.Selector) (ret []*resourcev1beta1.ResourceClaimTemplate, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*resourcev1beta1.ResourceClaimTemplate)) - }) - return ret, err +func NewResourceClaimTemplateClusterLister(indexer cache.Indexer) ResourceClaimTemplateClusterLister { + return &resourceClaimTemplateClusterLister{ + kcplisters.NewCluster[*resourcev1beta1.ResourceClaimTemplate](indexer, resourcev1beta1.Resource("resourceclaimtemplate")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ResourceClaimTemplates. -func (s *resourceClaimTemplateClusterLister) Cluster(clusterName logicalcluster.Name) resourcev1beta1listers.ResourceClaimTemplateLister { - return &resourceClaimTemplateLister{indexer: s.indexer, clusterName: clusterName} +func (l *resourceClaimTemplateClusterLister) Cluster(clusterName logicalcluster.Name) listersresourcev1beta1.ResourceClaimTemplateLister { + return &resourceClaimTemplateLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// resourceClaimTemplateLister implements the resourcev1beta1listers.ResourceClaimTemplateLister interface. +// resourceClaimTemplateLister can list all ResourceClaimTemplates inside a workspace +// or scope down to a listersresourcev1beta1.ResourceClaimTemplateNamespaceLister for one namespace. type resourceClaimTemplateLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*resourcev1beta1.ResourceClaimTemplate] } -// List lists all ResourceClaimTemplates in the indexer for a workspace. -func (s *resourceClaimTemplateLister) List(selector labels.Selector) (ret []*resourcev1beta1.ResourceClaimTemplate, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*resourcev1beta1.ResourceClaimTemplate)) - }) - return ret, err -} +var _ listersresourcev1beta1.ResourceClaimTemplateLister = new(resourceClaimTemplateLister) // ResourceClaimTemplates returns an object that can list and get ResourceClaimTemplates in one namespace. -func (s *resourceClaimTemplateLister) ResourceClaimTemplates(namespace string) resourcev1beta1listers.ResourceClaimTemplateNamespaceLister { - return &resourceClaimTemplateNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *resourceClaimTemplateLister) ResourceClaimTemplates(namespace string) listersresourcev1beta1.ResourceClaimTemplateNamespaceLister { + return &resourceClaimTemplateNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// resourceClaimTemplateNamespaceLister implements the resourcev1beta1listers.ResourceClaimTemplateNamespaceLister interface. +// resourceClaimTemplateNamespaceLister implements the listersresourcev1beta1.ResourceClaimTemplateNamespaceLister +// interface. type resourceClaimTemplateNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*resourcev1beta1.ResourceClaimTemplate] } -// List lists all ResourceClaimTemplates in the indexer for a given workspace and namespace. -func (s *resourceClaimTemplateNamespaceLister) List(selector labels.Selector) (ret []*resourcev1beta1.ResourceClaimTemplate, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*resourcev1beta1.ResourceClaimTemplate)) - }) - return ret, err -} +var _ listersresourcev1beta1.ResourceClaimTemplateNamespaceLister = new(resourceClaimTemplateNamespaceLister) -// Get retrieves the ResourceClaimTemplate from the indexer for a given workspace, namespace and name. -func (s *resourceClaimTemplateNamespaceLister) Get(name string) (*resourcev1beta1.ResourceClaimTemplate, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewResourceClaimTemplateLister returns a new ResourceClaimTemplateLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewResourceClaimTemplateLister(indexer cache.Indexer) listersresourcev1beta1.ResourceClaimTemplateLister { + return &resourceClaimTemplateLister{ + kcplisters.New[*resourcev1beta1.ResourceClaimTemplate](indexer, resourcev1beta1.Resource("resourceclaimtemplate")), } - if !exists { - return nil, errors.NewNotFound(resourcev1beta1.Resource("resourceclaimtemplates"), name) +} + +// resourceClaimTemplateScopedLister can list all ResourceClaimTemplates inside a workspace +// or scope down to a listersresourcev1beta1.ResourceClaimTemplateNamespaceLister for one namespace. +type resourceClaimTemplateScopedLister struct { + kcplisters.ResourceIndexer[*resourcev1beta1.ResourceClaimTemplate] +} + +// ResourceClaimTemplates returns an object that can list and get ResourceClaimTemplates in one namespace. +func (l *resourceClaimTemplateScopedLister) ResourceClaimTemplates(namespace string) listersresourcev1beta1.ResourceClaimTemplateLister { + return &resourceClaimTemplateLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*resourcev1beta1.ResourceClaimTemplate), nil } diff --git a/listers/resource/v1beta1/resourceslice.go b/listers/resource/v1beta1/resourceslice.go index cc0870317..7d25f1c75 100644 --- a/listers/resource/v1beta1/resourceslice.go +++ b/listers/resource/v1beta1/resourceslice.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" resourcev1beta1 "k8s.io/api/resource/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - resourcev1beta1listers "k8s.io/client-go/listers/resource/v1beta1" + listersresourcev1beta1 "k8s.io/client-go/listers/resource/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// ResourceSliceClusterLister can list ResourceSlices across all workspaces, or scope down to a ResourceSliceLister for one workspace. +// ResourceSliceClusterLister helps list ResourceSlices across all workspaces, +// or scope down to a ResourceSliceLister for one workspace. // All objects returned here must be treated as read-only. type ResourceSliceClusterLister interface { // List lists all ResourceSlices in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*resourcev1beta1.ResourceSlice, err error) // Cluster returns a lister that can list and get ResourceSlices in one workspace. - Cluster(clusterName logicalcluster.Name) resourcev1beta1listers.ResourceSliceLister + Cluster(clusterName logicalcluster.Name) listersresourcev1beta1.ResourceSliceLister ResourceSliceClusterListerExpansion } +// resourceSliceClusterLister implements the ResourceSliceClusterLister interface. type resourceSliceClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*resourcev1beta1.ResourceSlice] } +var _ ResourceSliceClusterLister = new(resourceSliceClusterLister) + // NewResourceSliceClusterLister returns a new ResourceSliceClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewResourceSliceClusterLister(indexer cache.Indexer) *resourceSliceClusterLister { - return &resourceSliceClusterLister{indexer: indexer} -} - -// List lists all ResourceSlices in the indexer across all workspaces. -func (s *resourceSliceClusterLister) List(selector labels.Selector) (ret []*resourcev1beta1.ResourceSlice, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*resourcev1beta1.ResourceSlice)) - }) - return ret, err +func NewResourceSliceClusterLister(indexer cache.Indexer) ResourceSliceClusterLister { + return &resourceSliceClusterLister{ + kcplisters.NewCluster[*resourcev1beta1.ResourceSlice](indexer, resourcev1beta1.Resource("resourceslice")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get ResourceSlices. -func (s *resourceSliceClusterLister) Cluster(clusterName logicalcluster.Name) resourcev1beta1listers.ResourceSliceLister { - return &resourceSliceLister{indexer: s.indexer, clusterName: clusterName} +func (l *resourceSliceClusterLister) Cluster(clusterName logicalcluster.Name) listersresourcev1beta1.ResourceSliceLister { + return &resourceSliceLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// resourceSliceLister implements the resourcev1beta1listers.ResourceSliceLister interface. +// resourceSliceLister can list all ResourceSlices inside a workspace +// or scope down to a listersresourcev1beta1.ResourceSliceNamespaceLister for one namespace. type resourceSliceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*resourcev1beta1.ResourceSlice] } -// List lists all ResourceSlices in the indexer for a workspace. -func (s *resourceSliceLister) List(selector labels.Selector) (ret []*resourcev1beta1.ResourceSlice, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*resourcev1beta1.ResourceSlice)) - }) - return ret, err -} +var _ listersresourcev1beta1.ResourceSliceLister = new(resourceSliceLister) -// Get retrieves the ResourceSlice from the indexer for a given workspace and name. -func (s *resourceSliceLister) Get(name string) (*resourcev1beta1.ResourceSlice, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(resourcev1beta1.Resource("resourceslices"), name) +// NewResourceSliceLister returns a new ResourceSliceLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewResourceSliceLister(indexer cache.Indexer) listersresourcev1beta1.ResourceSliceLister { + return &resourceSliceLister{ + kcplisters.New[*resourcev1beta1.ResourceSlice](indexer, resourcev1beta1.Resource("resourceslice")), } - return obj.(*resourcev1beta1.ResourceSlice), nil +} + +// resourceSliceScopedLister can list all ResourceSlices inside a workspace +// or scope down to a listersresourcev1beta1.ResourceSliceNamespaceLister. +type resourceSliceScopedLister struct { + kcplisters.ResourceIndexer[*resourcev1beta1.ResourceSlice] } diff --git a/listers/scheduling/v1/expansion_generated.go b/listers/scheduling/v1/expansion_generated.go new file mode 100644 index 000000000..b6a0c6377 --- /dev/null +++ b/listers/scheduling/v1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1 diff --git a/listers/scheduling/v1/priorityclass.go b/listers/scheduling/v1/priorityclass.go index e96ea4a08..747ccf2c3 100644 --- a/listers/scheduling/v1/priorityclass.go +++ b/listers/scheduling/v1/priorityclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" schedulingv1 "k8s.io/api/scheduling/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - schedulingv1listers "k8s.io/client-go/listers/scheduling/v1" + listersschedulingv1 "k8s.io/client-go/listers/scheduling/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// PriorityClassClusterLister can list PriorityClasses across all workspaces, or scope down to a PriorityClassLister for one workspace. +// PriorityClassClusterLister helps list PriorityClasses across all workspaces, +// or scope down to a PriorityClassLister for one workspace. // All objects returned here must be treated as read-only. type PriorityClassClusterLister interface { // List lists all PriorityClasses in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*schedulingv1.PriorityClass, err error) // Cluster returns a lister that can list and get PriorityClasses in one workspace. - Cluster(clusterName logicalcluster.Name) schedulingv1listers.PriorityClassLister + Cluster(clusterName logicalcluster.Name) listersschedulingv1.PriorityClassLister PriorityClassClusterListerExpansion } +// priorityClassClusterLister implements the PriorityClassClusterLister interface. type priorityClassClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*schedulingv1.PriorityClass] } +var _ PriorityClassClusterLister = new(priorityClassClusterLister) + // NewPriorityClassClusterLister returns a new PriorityClassClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewPriorityClassClusterLister(indexer cache.Indexer) *priorityClassClusterLister { - return &priorityClassClusterLister{indexer: indexer} -} - -// List lists all PriorityClasses in the indexer across all workspaces. -func (s *priorityClassClusterLister) List(selector labels.Selector) (ret []*schedulingv1.PriorityClass, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*schedulingv1.PriorityClass)) - }) - return ret, err +func NewPriorityClassClusterLister(indexer cache.Indexer) PriorityClassClusterLister { + return &priorityClassClusterLister{ + kcplisters.NewCluster[*schedulingv1.PriorityClass](indexer, schedulingv1.Resource("priorityclass")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get PriorityClasses. -func (s *priorityClassClusterLister) Cluster(clusterName logicalcluster.Name) schedulingv1listers.PriorityClassLister { - return &priorityClassLister{indexer: s.indexer, clusterName: clusterName} +func (l *priorityClassClusterLister) Cluster(clusterName logicalcluster.Name) listersschedulingv1.PriorityClassLister { + return &priorityClassLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// priorityClassLister implements the schedulingv1listers.PriorityClassLister interface. +// priorityClassLister can list all PriorityClasses inside a workspace +// or scope down to a listersschedulingv1.PriorityClassNamespaceLister for one namespace. type priorityClassLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*schedulingv1.PriorityClass] } -// List lists all PriorityClasses in the indexer for a workspace. -func (s *priorityClassLister) List(selector labels.Selector) (ret []*schedulingv1.PriorityClass, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*schedulingv1.PriorityClass)) - }) - return ret, err -} +var _ listersschedulingv1.PriorityClassLister = new(priorityClassLister) -// Get retrieves the PriorityClass from the indexer for a given workspace and name. -func (s *priorityClassLister) Get(name string) (*schedulingv1.PriorityClass, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(schedulingv1.Resource("priorityclasses"), name) +// NewPriorityClassLister returns a new PriorityClassLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewPriorityClassLister(indexer cache.Indexer) listersschedulingv1.PriorityClassLister { + return &priorityClassLister{ + kcplisters.New[*schedulingv1.PriorityClass](indexer, schedulingv1.Resource("priorityclass")), } - return obj.(*schedulingv1.PriorityClass), nil +} + +// priorityClassScopedLister can list all PriorityClasses inside a workspace +// or scope down to a listersschedulingv1.PriorityClassNamespaceLister. +type priorityClassScopedLister struct { + kcplisters.ResourceIndexer[*schedulingv1.PriorityClass] } diff --git a/listers/scheduling/v1alpha1/expansion_generated.go b/listers/scheduling/v1alpha1/expansion_generated.go new file mode 100644 index 000000000..3b8521c00 --- /dev/null +++ b/listers/scheduling/v1alpha1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1alpha1 diff --git a/listers/scheduling/v1alpha1/priorityclass.go b/listers/scheduling/v1alpha1/priorityclass.go index 06dd8367a..5ed4703b7 100644 --- a/listers/scheduling/v1alpha1/priorityclass.go +++ b/listers/scheduling/v1alpha1/priorityclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1alpha1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" schedulingv1alpha1 "k8s.io/api/scheduling/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - schedulingv1alpha1listers "k8s.io/client-go/listers/scheduling/v1alpha1" + listersschedulingv1alpha1 "k8s.io/client-go/listers/scheduling/v1alpha1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// PriorityClassClusterLister can list PriorityClasses across all workspaces, or scope down to a PriorityClassLister for one workspace. +// PriorityClassClusterLister helps list PriorityClasses across all workspaces, +// or scope down to a PriorityClassLister for one workspace. // All objects returned here must be treated as read-only. type PriorityClassClusterLister interface { // List lists all PriorityClasses in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*schedulingv1alpha1.PriorityClass, err error) // Cluster returns a lister that can list and get PriorityClasses in one workspace. - Cluster(clusterName logicalcluster.Name) schedulingv1alpha1listers.PriorityClassLister + Cluster(clusterName logicalcluster.Name) listersschedulingv1alpha1.PriorityClassLister PriorityClassClusterListerExpansion } +// priorityClassClusterLister implements the PriorityClassClusterLister interface. type priorityClassClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*schedulingv1alpha1.PriorityClass] } +var _ PriorityClassClusterLister = new(priorityClassClusterLister) + // NewPriorityClassClusterLister returns a new PriorityClassClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewPriorityClassClusterLister(indexer cache.Indexer) *priorityClassClusterLister { - return &priorityClassClusterLister{indexer: indexer} -} - -// List lists all PriorityClasses in the indexer across all workspaces. -func (s *priorityClassClusterLister) List(selector labels.Selector) (ret []*schedulingv1alpha1.PriorityClass, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*schedulingv1alpha1.PriorityClass)) - }) - return ret, err +func NewPriorityClassClusterLister(indexer cache.Indexer) PriorityClassClusterLister { + return &priorityClassClusterLister{ + kcplisters.NewCluster[*schedulingv1alpha1.PriorityClass](indexer, schedulingv1alpha1.Resource("priorityclass")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get PriorityClasses. -func (s *priorityClassClusterLister) Cluster(clusterName logicalcluster.Name) schedulingv1alpha1listers.PriorityClassLister { - return &priorityClassLister{indexer: s.indexer, clusterName: clusterName} +func (l *priorityClassClusterLister) Cluster(clusterName logicalcluster.Name) listersschedulingv1alpha1.PriorityClassLister { + return &priorityClassLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// priorityClassLister implements the schedulingv1alpha1listers.PriorityClassLister interface. +// priorityClassLister can list all PriorityClasses inside a workspace +// or scope down to a listersschedulingv1alpha1.PriorityClassNamespaceLister for one namespace. type priorityClassLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*schedulingv1alpha1.PriorityClass] } -// List lists all PriorityClasses in the indexer for a workspace. -func (s *priorityClassLister) List(selector labels.Selector) (ret []*schedulingv1alpha1.PriorityClass, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*schedulingv1alpha1.PriorityClass)) - }) - return ret, err -} +var _ listersschedulingv1alpha1.PriorityClassLister = new(priorityClassLister) -// Get retrieves the PriorityClass from the indexer for a given workspace and name. -func (s *priorityClassLister) Get(name string) (*schedulingv1alpha1.PriorityClass, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(schedulingv1alpha1.Resource("priorityclasses"), name) +// NewPriorityClassLister returns a new PriorityClassLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewPriorityClassLister(indexer cache.Indexer) listersschedulingv1alpha1.PriorityClassLister { + return &priorityClassLister{ + kcplisters.New[*schedulingv1alpha1.PriorityClass](indexer, schedulingv1alpha1.Resource("priorityclass")), } - return obj.(*schedulingv1alpha1.PriorityClass), nil +} + +// priorityClassScopedLister can list all PriorityClasses inside a workspace +// or scope down to a listersschedulingv1alpha1.PriorityClassNamespaceLister. +type priorityClassScopedLister struct { + kcplisters.ResourceIndexer[*schedulingv1alpha1.PriorityClass] } diff --git a/listers/scheduling/v1beta1/expansion_generated.go b/listers/scheduling/v1beta1/expansion_generated.go new file mode 100644 index 000000000..23cac805b --- /dev/null +++ b/listers/scheduling/v1beta1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1beta1 diff --git a/listers/scheduling/v1beta1/priorityclass.go b/listers/scheduling/v1beta1/priorityclass.go index d86d1f394..6eb02fce9 100644 --- a/listers/scheduling/v1beta1/priorityclass.go +++ b/listers/scheduling/v1beta1/priorityclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" schedulingv1beta1 "k8s.io/api/scheduling/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - schedulingv1beta1listers "k8s.io/client-go/listers/scheduling/v1beta1" + listersschedulingv1beta1 "k8s.io/client-go/listers/scheduling/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// PriorityClassClusterLister can list PriorityClasses across all workspaces, or scope down to a PriorityClassLister for one workspace. +// PriorityClassClusterLister helps list PriorityClasses across all workspaces, +// or scope down to a PriorityClassLister for one workspace. // All objects returned here must be treated as read-only. type PriorityClassClusterLister interface { // List lists all PriorityClasses in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*schedulingv1beta1.PriorityClass, err error) // Cluster returns a lister that can list and get PriorityClasses in one workspace. - Cluster(clusterName logicalcluster.Name) schedulingv1beta1listers.PriorityClassLister + Cluster(clusterName logicalcluster.Name) listersschedulingv1beta1.PriorityClassLister PriorityClassClusterListerExpansion } +// priorityClassClusterLister implements the PriorityClassClusterLister interface. type priorityClassClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*schedulingv1beta1.PriorityClass] } +var _ PriorityClassClusterLister = new(priorityClassClusterLister) + // NewPriorityClassClusterLister returns a new PriorityClassClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewPriorityClassClusterLister(indexer cache.Indexer) *priorityClassClusterLister { - return &priorityClassClusterLister{indexer: indexer} -} - -// List lists all PriorityClasses in the indexer across all workspaces. -func (s *priorityClassClusterLister) List(selector labels.Selector) (ret []*schedulingv1beta1.PriorityClass, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*schedulingv1beta1.PriorityClass)) - }) - return ret, err +func NewPriorityClassClusterLister(indexer cache.Indexer) PriorityClassClusterLister { + return &priorityClassClusterLister{ + kcplisters.NewCluster[*schedulingv1beta1.PriorityClass](indexer, schedulingv1beta1.Resource("priorityclass")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get PriorityClasses. -func (s *priorityClassClusterLister) Cluster(clusterName logicalcluster.Name) schedulingv1beta1listers.PriorityClassLister { - return &priorityClassLister{indexer: s.indexer, clusterName: clusterName} +func (l *priorityClassClusterLister) Cluster(clusterName logicalcluster.Name) listersschedulingv1beta1.PriorityClassLister { + return &priorityClassLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// priorityClassLister implements the schedulingv1beta1listers.PriorityClassLister interface. +// priorityClassLister can list all PriorityClasses inside a workspace +// or scope down to a listersschedulingv1beta1.PriorityClassNamespaceLister for one namespace. type priorityClassLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*schedulingv1beta1.PriorityClass] } -// List lists all PriorityClasses in the indexer for a workspace. -func (s *priorityClassLister) List(selector labels.Selector) (ret []*schedulingv1beta1.PriorityClass, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*schedulingv1beta1.PriorityClass)) - }) - return ret, err -} +var _ listersschedulingv1beta1.PriorityClassLister = new(priorityClassLister) -// Get retrieves the PriorityClass from the indexer for a given workspace and name. -func (s *priorityClassLister) Get(name string) (*schedulingv1beta1.PriorityClass, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(schedulingv1beta1.Resource("priorityclasses"), name) +// NewPriorityClassLister returns a new PriorityClassLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewPriorityClassLister(indexer cache.Indexer) listersschedulingv1beta1.PriorityClassLister { + return &priorityClassLister{ + kcplisters.New[*schedulingv1beta1.PriorityClass](indexer, schedulingv1beta1.Resource("priorityclass")), } - return obj.(*schedulingv1beta1.PriorityClass), nil +} + +// priorityClassScopedLister can list all PriorityClasses inside a workspace +// or scope down to a listersschedulingv1beta1.PriorityClassNamespaceLister. +type priorityClassScopedLister struct { + kcplisters.ResourceIndexer[*schedulingv1beta1.PriorityClass] } diff --git a/listers/storage/v1/csidriver.go b/listers/storage/v1/csidriver.go index a225cf614..b14c66d7d 100644 --- a/listers/storage/v1/csidriver.go +++ b/listers/storage/v1/csidriver.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" storagev1 "k8s.io/api/storage/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - storagev1listers "k8s.io/client-go/listers/storage/v1" + listersstoragev1 "k8s.io/client-go/listers/storage/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// CSIDriverClusterLister can list CSIDrivers across all workspaces, or scope down to a CSIDriverLister for one workspace. +// CSIDriverClusterLister helps list CSIDrivers across all workspaces, +// or scope down to a CSIDriverLister for one workspace. // All objects returned here must be treated as read-only. type CSIDriverClusterLister interface { // List lists all CSIDrivers in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*storagev1.CSIDriver, err error) // Cluster returns a lister that can list and get CSIDrivers in one workspace. - Cluster(clusterName logicalcluster.Name) storagev1listers.CSIDriverLister + Cluster(clusterName logicalcluster.Name) listersstoragev1.CSIDriverLister CSIDriverClusterListerExpansion } +// cSIDriverClusterLister implements the CSIDriverClusterLister interface. type cSIDriverClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*storagev1.CSIDriver] } +var _ CSIDriverClusterLister = new(cSIDriverClusterLister) + // NewCSIDriverClusterLister returns a new CSIDriverClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewCSIDriverClusterLister(indexer cache.Indexer) *cSIDriverClusterLister { - return &cSIDriverClusterLister{indexer: indexer} -} - -// List lists all CSIDrivers in the indexer across all workspaces. -func (s *cSIDriverClusterLister) List(selector labels.Selector) (ret []*storagev1.CSIDriver, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*storagev1.CSIDriver)) - }) - return ret, err +func NewCSIDriverClusterLister(indexer cache.Indexer) CSIDriverClusterLister { + return &cSIDriverClusterLister{ + kcplisters.NewCluster[*storagev1.CSIDriver](indexer, storagev1.Resource("csidriver")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get CSIDrivers. -func (s *cSIDriverClusterLister) Cluster(clusterName logicalcluster.Name) storagev1listers.CSIDriverLister { - return &cSIDriverLister{indexer: s.indexer, clusterName: clusterName} +func (l *cSIDriverClusterLister) Cluster(clusterName logicalcluster.Name) listersstoragev1.CSIDriverLister { + return &cSIDriverLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// cSIDriverLister implements the storagev1listers.CSIDriverLister interface. +// cSIDriverLister can list all CSIDrivers inside a workspace +// or scope down to a listersstoragev1.CSIDriverNamespaceLister for one namespace. type cSIDriverLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*storagev1.CSIDriver] } -// List lists all CSIDrivers in the indexer for a workspace. -func (s *cSIDriverLister) List(selector labels.Selector) (ret []*storagev1.CSIDriver, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*storagev1.CSIDriver)) - }) - return ret, err -} +var _ listersstoragev1.CSIDriverLister = new(cSIDriverLister) -// Get retrieves the CSIDriver from the indexer for a given workspace and name. -func (s *cSIDriverLister) Get(name string) (*storagev1.CSIDriver, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(storagev1.Resource("csidrivers"), name) +// NewCSIDriverLister returns a new CSIDriverLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewCSIDriverLister(indexer cache.Indexer) listersstoragev1.CSIDriverLister { + return &cSIDriverLister{ + kcplisters.New[*storagev1.CSIDriver](indexer, storagev1.Resource("csidriver")), } - return obj.(*storagev1.CSIDriver), nil +} + +// cSIDriverScopedLister can list all CSIDrivers inside a workspace +// or scope down to a listersstoragev1.CSIDriverNamespaceLister. +type cSIDriverScopedLister struct { + kcplisters.ResourceIndexer[*storagev1.CSIDriver] } diff --git a/listers/storage/v1/csinode.go b/listers/storage/v1/csinode.go index a8cc199b6..1351b1771 100644 --- a/listers/storage/v1/csinode.go +++ b/listers/storage/v1/csinode.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" storagev1 "k8s.io/api/storage/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - storagev1listers "k8s.io/client-go/listers/storage/v1" + listersstoragev1 "k8s.io/client-go/listers/storage/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// CSINodeClusterLister can list CSINodes across all workspaces, or scope down to a CSINodeLister for one workspace. +// CSINodeClusterLister helps list CSINodes across all workspaces, +// or scope down to a CSINodeLister for one workspace. // All objects returned here must be treated as read-only. type CSINodeClusterLister interface { // List lists all CSINodes in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*storagev1.CSINode, err error) // Cluster returns a lister that can list and get CSINodes in one workspace. - Cluster(clusterName logicalcluster.Name) storagev1listers.CSINodeLister + Cluster(clusterName logicalcluster.Name) listersstoragev1.CSINodeLister CSINodeClusterListerExpansion } +// cSINodeClusterLister implements the CSINodeClusterLister interface. type cSINodeClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*storagev1.CSINode] } +var _ CSINodeClusterLister = new(cSINodeClusterLister) + // NewCSINodeClusterLister returns a new CSINodeClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewCSINodeClusterLister(indexer cache.Indexer) *cSINodeClusterLister { - return &cSINodeClusterLister{indexer: indexer} -} - -// List lists all CSINodes in the indexer across all workspaces. -func (s *cSINodeClusterLister) List(selector labels.Selector) (ret []*storagev1.CSINode, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*storagev1.CSINode)) - }) - return ret, err +func NewCSINodeClusterLister(indexer cache.Indexer) CSINodeClusterLister { + return &cSINodeClusterLister{ + kcplisters.NewCluster[*storagev1.CSINode](indexer, storagev1.Resource("csinode")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get CSINodes. -func (s *cSINodeClusterLister) Cluster(clusterName logicalcluster.Name) storagev1listers.CSINodeLister { - return &cSINodeLister{indexer: s.indexer, clusterName: clusterName} +func (l *cSINodeClusterLister) Cluster(clusterName logicalcluster.Name) listersstoragev1.CSINodeLister { + return &cSINodeLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// cSINodeLister implements the storagev1listers.CSINodeLister interface. +// cSINodeLister can list all CSINodes inside a workspace +// or scope down to a listersstoragev1.CSINodeNamespaceLister for one namespace. type cSINodeLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*storagev1.CSINode] } -// List lists all CSINodes in the indexer for a workspace. -func (s *cSINodeLister) List(selector labels.Selector) (ret []*storagev1.CSINode, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*storagev1.CSINode)) - }) - return ret, err -} +var _ listersstoragev1.CSINodeLister = new(cSINodeLister) -// Get retrieves the CSINode from the indexer for a given workspace and name. -func (s *cSINodeLister) Get(name string) (*storagev1.CSINode, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(storagev1.Resource("csinodes"), name) +// NewCSINodeLister returns a new CSINodeLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewCSINodeLister(indexer cache.Indexer) listersstoragev1.CSINodeLister { + return &cSINodeLister{ + kcplisters.New[*storagev1.CSINode](indexer, storagev1.Resource("csinode")), } - return obj.(*storagev1.CSINode), nil +} + +// cSINodeScopedLister can list all CSINodes inside a workspace +// or scope down to a listersstoragev1.CSINodeNamespaceLister. +type cSINodeScopedLister struct { + kcplisters.ResourceIndexer[*storagev1.CSINode] } diff --git a/listers/storage/v1/csistoragecapacity.go b/listers/storage/v1/csistoragecapacity.go index cb6bf6b4c..5c5f19fd2 100644 --- a/listers/storage/v1/csistoragecapacity.go +++ b/listers/storage/v1/csistoragecapacity.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" storagev1 "k8s.io/api/storage/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - storagev1listers "k8s.io/client-go/listers/storage/v1" + listersstoragev1 "k8s.io/client-go/listers/storage/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// CSIStorageCapacityClusterLister can list CSIStorageCapacities across all workspaces, or scope down to a CSIStorageCapacityLister for one workspace. +// CSIStorageCapacityClusterLister helps list CSIStorageCapacities across all workspaces, +// or scope down to a CSIStorageCapacityLister for one workspace. // All objects returned here must be treated as read-only. type CSIStorageCapacityClusterLister interface { // List lists all CSIStorageCapacities in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*storagev1.CSIStorageCapacity, err error) // Cluster returns a lister that can list and get CSIStorageCapacities in one workspace. - Cluster(clusterName logicalcluster.Name) storagev1listers.CSIStorageCapacityLister + Cluster(clusterName logicalcluster.Name) listersstoragev1.CSIStorageCapacityLister CSIStorageCapacityClusterListerExpansion } +// cSIStorageCapacityClusterLister implements the CSIStorageCapacityClusterLister interface. type cSIStorageCapacityClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*storagev1.CSIStorageCapacity] } +var _ CSIStorageCapacityClusterLister = new(cSIStorageCapacityClusterLister) + // NewCSIStorageCapacityClusterLister returns a new CSIStorageCapacityClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewCSIStorageCapacityClusterLister(indexer cache.Indexer) *cSIStorageCapacityClusterLister { - return &cSIStorageCapacityClusterLister{indexer: indexer} -} - -// List lists all CSIStorageCapacities in the indexer across all workspaces. -func (s *cSIStorageCapacityClusterLister) List(selector labels.Selector) (ret []*storagev1.CSIStorageCapacity, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*storagev1.CSIStorageCapacity)) - }) - return ret, err +func NewCSIStorageCapacityClusterLister(indexer cache.Indexer) CSIStorageCapacityClusterLister { + return &cSIStorageCapacityClusterLister{ + kcplisters.NewCluster[*storagev1.CSIStorageCapacity](indexer, storagev1.Resource("csistoragecapacity")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get CSIStorageCapacities. -func (s *cSIStorageCapacityClusterLister) Cluster(clusterName logicalcluster.Name) storagev1listers.CSIStorageCapacityLister { - return &cSIStorageCapacityLister{indexer: s.indexer, clusterName: clusterName} +func (l *cSIStorageCapacityClusterLister) Cluster(clusterName logicalcluster.Name) listersstoragev1.CSIStorageCapacityLister { + return &cSIStorageCapacityLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// cSIStorageCapacityLister implements the storagev1listers.CSIStorageCapacityLister interface. +// cSIStorageCapacityLister can list all CSIStorageCapacities inside a workspace +// or scope down to a listersstoragev1.CSIStorageCapacityNamespaceLister for one namespace. type cSIStorageCapacityLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*storagev1.CSIStorageCapacity] } -// List lists all CSIStorageCapacities in the indexer for a workspace. -func (s *cSIStorageCapacityLister) List(selector labels.Selector) (ret []*storagev1.CSIStorageCapacity, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*storagev1.CSIStorageCapacity)) - }) - return ret, err -} +var _ listersstoragev1.CSIStorageCapacityLister = new(cSIStorageCapacityLister) // CSIStorageCapacities returns an object that can list and get CSIStorageCapacities in one namespace. -func (s *cSIStorageCapacityLister) CSIStorageCapacities(namespace string) storagev1listers.CSIStorageCapacityNamespaceLister { - return &cSIStorageCapacityNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *cSIStorageCapacityLister) CSIStorageCapacities(namespace string) listersstoragev1.CSIStorageCapacityNamespaceLister { + return &cSIStorageCapacityNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// cSIStorageCapacityNamespaceLister implements the storagev1listers.CSIStorageCapacityNamespaceLister interface. +// cSIStorageCapacityNamespaceLister implements the listersstoragev1.CSIStorageCapacityNamespaceLister +// interface. type cSIStorageCapacityNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*storagev1.CSIStorageCapacity] } -// List lists all CSIStorageCapacities in the indexer for a given workspace and namespace. -func (s *cSIStorageCapacityNamespaceLister) List(selector labels.Selector) (ret []*storagev1.CSIStorageCapacity, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*storagev1.CSIStorageCapacity)) - }) - return ret, err -} +var _ listersstoragev1.CSIStorageCapacityNamespaceLister = new(cSIStorageCapacityNamespaceLister) -// Get retrieves the CSIStorageCapacity from the indexer for a given workspace, namespace and name. -func (s *cSIStorageCapacityNamespaceLister) Get(name string) (*storagev1.CSIStorageCapacity, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewCSIStorageCapacityLister returns a new CSIStorageCapacityLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewCSIStorageCapacityLister(indexer cache.Indexer) listersstoragev1.CSIStorageCapacityLister { + return &cSIStorageCapacityLister{ + kcplisters.New[*storagev1.CSIStorageCapacity](indexer, storagev1.Resource("csistoragecapacity")), } - if !exists { - return nil, errors.NewNotFound(storagev1.Resource("csistoragecapacities"), name) +} + +// cSIStorageCapacityScopedLister can list all CSIStorageCapacities inside a workspace +// or scope down to a listersstoragev1.CSIStorageCapacityNamespaceLister for one namespace. +type cSIStorageCapacityScopedLister struct { + kcplisters.ResourceIndexer[*storagev1.CSIStorageCapacity] +} + +// CSIStorageCapacities returns an object that can list and get CSIStorageCapacities in one namespace. +func (l *cSIStorageCapacityScopedLister) CSIStorageCapacities(namespace string) listersstoragev1.CSIStorageCapacityLister { + return &cSIStorageCapacityLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*storagev1.CSIStorageCapacity), nil } diff --git a/listers/storage/v1/expansion_generated.go b/listers/storage/v1/expansion_generated.go new file mode 100644 index 000000000..b6a0c6377 --- /dev/null +++ b/listers/storage/v1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1 diff --git a/listers/storage/v1/storageclass.go b/listers/storage/v1/storageclass.go index f6408d082..f1b6a178f 100644 --- a/listers/storage/v1/storageclass.go +++ b/listers/storage/v1/storageclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" storagev1 "k8s.io/api/storage/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - storagev1listers "k8s.io/client-go/listers/storage/v1" + listersstoragev1 "k8s.io/client-go/listers/storage/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// StorageClassClusterLister can list StorageClasses across all workspaces, or scope down to a StorageClassLister for one workspace. +// StorageClassClusterLister helps list StorageClasses across all workspaces, +// or scope down to a StorageClassLister for one workspace. // All objects returned here must be treated as read-only. type StorageClassClusterLister interface { // List lists all StorageClasses in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*storagev1.StorageClass, err error) // Cluster returns a lister that can list and get StorageClasses in one workspace. - Cluster(clusterName logicalcluster.Name) storagev1listers.StorageClassLister + Cluster(clusterName logicalcluster.Name) listersstoragev1.StorageClassLister StorageClassClusterListerExpansion } +// storageClassClusterLister implements the StorageClassClusterLister interface. type storageClassClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*storagev1.StorageClass] } +var _ StorageClassClusterLister = new(storageClassClusterLister) + // NewStorageClassClusterLister returns a new StorageClassClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewStorageClassClusterLister(indexer cache.Indexer) *storageClassClusterLister { - return &storageClassClusterLister{indexer: indexer} -} - -// List lists all StorageClasses in the indexer across all workspaces. -func (s *storageClassClusterLister) List(selector labels.Selector) (ret []*storagev1.StorageClass, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*storagev1.StorageClass)) - }) - return ret, err +func NewStorageClassClusterLister(indexer cache.Indexer) StorageClassClusterLister { + return &storageClassClusterLister{ + kcplisters.NewCluster[*storagev1.StorageClass](indexer, storagev1.Resource("storageclass")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get StorageClasses. -func (s *storageClassClusterLister) Cluster(clusterName logicalcluster.Name) storagev1listers.StorageClassLister { - return &storageClassLister{indexer: s.indexer, clusterName: clusterName} +func (l *storageClassClusterLister) Cluster(clusterName logicalcluster.Name) listersstoragev1.StorageClassLister { + return &storageClassLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// storageClassLister implements the storagev1listers.StorageClassLister interface. +// storageClassLister can list all StorageClasses inside a workspace +// or scope down to a listersstoragev1.StorageClassNamespaceLister for one namespace. type storageClassLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*storagev1.StorageClass] } -// List lists all StorageClasses in the indexer for a workspace. -func (s *storageClassLister) List(selector labels.Selector) (ret []*storagev1.StorageClass, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*storagev1.StorageClass)) - }) - return ret, err -} +var _ listersstoragev1.StorageClassLister = new(storageClassLister) -// Get retrieves the StorageClass from the indexer for a given workspace and name. -func (s *storageClassLister) Get(name string) (*storagev1.StorageClass, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(storagev1.Resource("storageclasses"), name) +// NewStorageClassLister returns a new StorageClassLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewStorageClassLister(indexer cache.Indexer) listersstoragev1.StorageClassLister { + return &storageClassLister{ + kcplisters.New[*storagev1.StorageClass](indexer, storagev1.Resource("storageclass")), } - return obj.(*storagev1.StorageClass), nil +} + +// storageClassScopedLister can list all StorageClasses inside a workspace +// or scope down to a listersstoragev1.StorageClassNamespaceLister. +type storageClassScopedLister struct { + kcplisters.ResourceIndexer[*storagev1.StorageClass] } diff --git a/listers/storage/v1/volumeattachment.go b/listers/storage/v1/volumeattachment.go index a41fe7e86..450be0372 100644 --- a/listers/storage/v1/volumeattachment.go +++ b/listers/storage/v1/volumeattachment.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" storagev1 "k8s.io/api/storage/v1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - storagev1listers "k8s.io/client-go/listers/storage/v1" + listersstoragev1 "k8s.io/client-go/listers/storage/v1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// VolumeAttachmentClusterLister can list VolumeAttachments across all workspaces, or scope down to a VolumeAttachmentLister for one workspace. +// VolumeAttachmentClusterLister helps list VolumeAttachments across all workspaces, +// or scope down to a VolumeAttachmentLister for one workspace. // All objects returned here must be treated as read-only. type VolumeAttachmentClusterLister interface { // List lists all VolumeAttachments in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*storagev1.VolumeAttachment, err error) // Cluster returns a lister that can list and get VolumeAttachments in one workspace. - Cluster(clusterName logicalcluster.Name) storagev1listers.VolumeAttachmentLister + Cluster(clusterName logicalcluster.Name) listersstoragev1.VolumeAttachmentLister VolumeAttachmentClusterListerExpansion } +// volumeAttachmentClusterLister implements the VolumeAttachmentClusterLister interface. type volumeAttachmentClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*storagev1.VolumeAttachment] } +var _ VolumeAttachmentClusterLister = new(volumeAttachmentClusterLister) + // NewVolumeAttachmentClusterLister returns a new VolumeAttachmentClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewVolumeAttachmentClusterLister(indexer cache.Indexer) *volumeAttachmentClusterLister { - return &volumeAttachmentClusterLister{indexer: indexer} -} - -// List lists all VolumeAttachments in the indexer across all workspaces. -func (s *volumeAttachmentClusterLister) List(selector labels.Selector) (ret []*storagev1.VolumeAttachment, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*storagev1.VolumeAttachment)) - }) - return ret, err +func NewVolumeAttachmentClusterLister(indexer cache.Indexer) VolumeAttachmentClusterLister { + return &volumeAttachmentClusterLister{ + kcplisters.NewCluster[*storagev1.VolumeAttachment](indexer, storagev1.Resource("volumeattachment")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get VolumeAttachments. -func (s *volumeAttachmentClusterLister) Cluster(clusterName logicalcluster.Name) storagev1listers.VolumeAttachmentLister { - return &volumeAttachmentLister{indexer: s.indexer, clusterName: clusterName} +func (l *volumeAttachmentClusterLister) Cluster(clusterName logicalcluster.Name) listersstoragev1.VolumeAttachmentLister { + return &volumeAttachmentLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// volumeAttachmentLister implements the storagev1listers.VolumeAttachmentLister interface. +// volumeAttachmentLister can list all VolumeAttachments inside a workspace +// or scope down to a listersstoragev1.VolumeAttachmentNamespaceLister for one namespace. type volumeAttachmentLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*storagev1.VolumeAttachment] } -// List lists all VolumeAttachments in the indexer for a workspace. -func (s *volumeAttachmentLister) List(selector labels.Selector) (ret []*storagev1.VolumeAttachment, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*storagev1.VolumeAttachment)) - }) - return ret, err -} +var _ listersstoragev1.VolumeAttachmentLister = new(volumeAttachmentLister) -// Get retrieves the VolumeAttachment from the indexer for a given workspace and name. -func (s *volumeAttachmentLister) Get(name string) (*storagev1.VolumeAttachment, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(storagev1.Resource("volumeattachments"), name) +// NewVolumeAttachmentLister returns a new VolumeAttachmentLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewVolumeAttachmentLister(indexer cache.Indexer) listersstoragev1.VolumeAttachmentLister { + return &volumeAttachmentLister{ + kcplisters.New[*storagev1.VolumeAttachment](indexer, storagev1.Resource("volumeattachment")), } - return obj.(*storagev1.VolumeAttachment), nil +} + +// volumeAttachmentScopedLister can list all VolumeAttachments inside a workspace +// or scope down to a listersstoragev1.VolumeAttachmentNamespaceLister. +type volumeAttachmentScopedLister struct { + kcplisters.ResourceIndexer[*storagev1.VolumeAttachment] } diff --git a/listers/storage/v1alpha1/csistoragecapacity.go b/listers/storage/v1alpha1/csistoragecapacity.go index 32e224df9..5652d245e 100644 --- a/listers/storage/v1alpha1/csistoragecapacity.go +++ b/listers/storage/v1alpha1/csistoragecapacity.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1alpha1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" storagev1alpha1 "k8s.io/api/storage/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - storagev1alpha1listers "k8s.io/client-go/listers/storage/v1alpha1" + listersstoragev1alpha1 "k8s.io/client-go/listers/storage/v1alpha1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// CSIStorageCapacityClusterLister can list CSIStorageCapacities across all workspaces, or scope down to a CSIStorageCapacityLister for one workspace. +// CSIStorageCapacityClusterLister helps list CSIStorageCapacities across all workspaces, +// or scope down to a CSIStorageCapacityLister for one workspace. // All objects returned here must be treated as read-only. type CSIStorageCapacityClusterLister interface { // List lists all CSIStorageCapacities in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*storagev1alpha1.CSIStorageCapacity, err error) // Cluster returns a lister that can list and get CSIStorageCapacities in one workspace. - Cluster(clusterName logicalcluster.Name) storagev1alpha1listers.CSIStorageCapacityLister + Cluster(clusterName logicalcluster.Name) listersstoragev1alpha1.CSIStorageCapacityLister CSIStorageCapacityClusterListerExpansion } +// cSIStorageCapacityClusterLister implements the CSIStorageCapacityClusterLister interface. type cSIStorageCapacityClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*storagev1alpha1.CSIStorageCapacity] } +var _ CSIStorageCapacityClusterLister = new(cSIStorageCapacityClusterLister) + // NewCSIStorageCapacityClusterLister returns a new CSIStorageCapacityClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewCSIStorageCapacityClusterLister(indexer cache.Indexer) *cSIStorageCapacityClusterLister { - return &cSIStorageCapacityClusterLister{indexer: indexer} -} - -// List lists all CSIStorageCapacities in the indexer across all workspaces. -func (s *cSIStorageCapacityClusterLister) List(selector labels.Selector) (ret []*storagev1alpha1.CSIStorageCapacity, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*storagev1alpha1.CSIStorageCapacity)) - }) - return ret, err +func NewCSIStorageCapacityClusterLister(indexer cache.Indexer) CSIStorageCapacityClusterLister { + return &cSIStorageCapacityClusterLister{ + kcplisters.NewCluster[*storagev1alpha1.CSIStorageCapacity](indexer, storagev1alpha1.Resource("csistoragecapacity")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get CSIStorageCapacities. -func (s *cSIStorageCapacityClusterLister) Cluster(clusterName logicalcluster.Name) storagev1alpha1listers.CSIStorageCapacityLister { - return &cSIStorageCapacityLister{indexer: s.indexer, clusterName: clusterName} +func (l *cSIStorageCapacityClusterLister) Cluster(clusterName logicalcluster.Name) listersstoragev1alpha1.CSIStorageCapacityLister { + return &cSIStorageCapacityLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// cSIStorageCapacityLister implements the storagev1alpha1listers.CSIStorageCapacityLister interface. +// cSIStorageCapacityLister can list all CSIStorageCapacities inside a workspace +// or scope down to a listersstoragev1alpha1.CSIStorageCapacityNamespaceLister for one namespace. type cSIStorageCapacityLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*storagev1alpha1.CSIStorageCapacity] } -// List lists all CSIStorageCapacities in the indexer for a workspace. -func (s *cSIStorageCapacityLister) List(selector labels.Selector) (ret []*storagev1alpha1.CSIStorageCapacity, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*storagev1alpha1.CSIStorageCapacity)) - }) - return ret, err -} +var _ listersstoragev1alpha1.CSIStorageCapacityLister = new(cSIStorageCapacityLister) // CSIStorageCapacities returns an object that can list and get CSIStorageCapacities in one namespace. -func (s *cSIStorageCapacityLister) CSIStorageCapacities(namespace string) storagev1alpha1listers.CSIStorageCapacityNamespaceLister { - return &cSIStorageCapacityNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *cSIStorageCapacityLister) CSIStorageCapacities(namespace string) listersstoragev1alpha1.CSIStorageCapacityNamespaceLister { + return &cSIStorageCapacityNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// cSIStorageCapacityNamespaceLister implements the storagev1alpha1listers.CSIStorageCapacityNamespaceLister interface. +// cSIStorageCapacityNamespaceLister implements the listersstoragev1alpha1.CSIStorageCapacityNamespaceLister +// interface. type cSIStorageCapacityNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*storagev1alpha1.CSIStorageCapacity] } -// List lists all CSIStorageCapacities in the indexer for a given workspace and namespace. -func (s *cSIStorageCapacityNamespaceLister) List(selector labels.Selector) (ret []*storagev1alpha1.CSIStorageCapacity, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*storagev1alpha1.CSIStorageCapacity)) - }) - return ret, err -} +var _ listersstoragev1alpha1.CSIStorageCapacityNamespaceLister = new(cSIStorageCapacityNamespaceLister) -// Get retrieves the CSIStorageCapacity from the indexer for a given workspace, namespace and name. -func (s *cSIStorageCapacityNamespaceLister) Get(name string) (*storagev1alpha1.CSIStorageCapacity, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewCSIStorageCapacityLister returns a new CSIStorageCapacityLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewCSIStorageCapacityLister(indexer cache.Indexer) listersstoragev1alpha1.CSIStorageCapacityLister { + return &cSIStorageCapacityLister{ + kcplisters.New[*storagev1alpha1.CSIStorageCapacity](indexer, storagev1alpha1.Resource("csistoragecapacity")), } - if !exists { - return nil, errors.NewNotFound(storagev1alpha1.Resource("csistoragecapacities"), name) +} + +// cSIStorageCapacityScopedLister can list all CSIStorageCapacities inside a workspace +// or scope down to a listersstoragev1alpha1.CSIStorageCapacityNamespaceLister for one namespace. +type cSIStorageCapacityScopedLister struct { + kcplisters.ResourceIndexer[*storagev1alpha1.CSIStorageCapacity] +} + +// CSIStorageCapacities returns an object that can list and get CSIStorageCapacities in one namespace. +func (l *cSIStorageCapacityScopedLister) CSIStorageCapacities(namespace string) listersstoragev1alpha1.CSIStorageCapacityLister { + return &cSIStorageCapacityLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*storagev1alpha1.CSIStorageCapacity), nil } diff --git a/listers/storage/v1alpha1/expansion_generated.go b/listers/storage/v1alpha1/expansion_generated.go new file mode 100644 index 000000000..3b8521c00 --- /dev/null +++ b/listers/storage/v1alpha1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1alpha1 diff --git a/listers/storage/v1alpha1/volumeattachment.go b/listers/storage/v1alpha1/volumeattachment.go index 977c609a7..71e330d5c 100644 --- a/listers/storage/v1alpha1/volumeattachment.go +++ b/listers/storage/v1alpha1/volumeattachment.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1alpha1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" storagev1alpha1 "k8s.io/api/storage/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - storagev1alpha1listers "k8s.io/client-go/listers/storage/v1alpha1" + listersstoragev1alpha1 "k8s.io/client-go/listers/storage/v1alpha1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// VolumeAttachmentClusterLister can list VolumeAttachments across all workspaces, or scope down to a VolumeAttachmentLister for one workspace. +// VolumeAttachmentClusterLister helps list VolumeAttachments across all workspaces, +// or scope down to a VolumeAttachmentLister for one workspace. // All objects returned here must be treated as read-only. type VolumeAttachmentClusterLister interface { // List lists all VolumeAttachments in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*storagev1alpha1.VolumeAttachment, err error) // Cluster returns a lister that can list and get VolumeAttachments in one workspace. - Cluster(clusterName logicalcluster.Name) storagev1alpha1listers.VolumeAttachmentLister + Cluster(clusterName logicalcluster.Name) listersstoragev1alpha1.VolumeAttachmentLister VolumeAttachmentClusterListerExpansion } +// volumeAttachmentClusterLister implements the VolumeAttachmentClusterLister interface. type volumeAttachmentClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*storagev1alpha1.VolumeAttachment] } +var _ VolumeAttachmentClusterLister = new(volumeAttachmentClusterLister) + // NewVolumeAttachmentClusterLister returns a new VolumeAttachmentClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewVolumeAttachmentClusterLister(indexer cache.Indexer) *volumeAttachmentClusterLister { - return &volumeAttachmentClusterLister{indexer: indexer} -} - -// List lists all VolumeAttachments in the indexer across all workspaces. -func (s *volumeAttachmentClusterLister) List(selector labels.Selector) (ret []*storagev1alpha1.VolumeAttachment, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*storagev1alpha1.VolumeAttachment)) - }) - return ret, err +func NewVolumeAttachmentClusterLister(indexer cache.Indexer) VolumeAttachmentClusterLister { + return &volumeAttachmentClusterLister{ + kcplisters.NewCluster[*storagev1alpha1.VolumeAttachment](indexer, storagev1alpha1.Resource("volumeattachment")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get VolumeAttachments. -func (s *volumeAttachmentClusterLister) Cluster(clusterName logicalcluster.Name) storagev1alpha1listers.VolumeAttachmentLister { - return &volumeAttachmentLister{indexer: s.indexer, clusterName: clusterName} +func (l *volumeAttachmentClusterLister) Cluster(clusterName logicalcluster.Name) listersstoragev1alpha1.VolumeAttachmentLister { + return &volumeAttachmentLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// volumeAttachmentLister implements the storagev1alpha1listers.VolumeAttachmentLister interface. +// volumeAttachmentLister can list all VolumeAttachments inside a workspace +// or scope down to a listersstoragev1alpha1.VolumeAttachmentNamespaceLister for one namespace. type volumeAttachmentLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*storagev1alpha1.VolumeAttachment] } -// List lists all VolumeAttachments in the indexer for a workspace. -func (s *volumeAttachmentLister) List(selector labels.Selector) (ret []*storagev1alpha1.VolumeAttachment, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*storagev1alpha1.VolumeAttachment)) - }) - return ret, err -} +var _ listersstoragev1alpha1.VolumeAttachmentLister = new(volumeAttachmentLister) -// Get retrieves the VolumeAttachment from the indexer for a given workspace and name. -func (s *volumeAttachmentLister) Get(name string) (*storagev1alpha1.VolumeAttachment, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(storagev1alpha1.Resource("volumeattachments"), name) +// NewVolumeAttachmentLister returns a new VolumeAttachmentLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewVolumeAttachmentLister(indexer cache.Indexer) listersstoragev1alpha1.VolumeAttachmentLister { + return &volumeAttachmentLister{ + kcplisters.New[*storagev1alpha1.VolumeAttachment](indexer, storagev1alpha1.Resource("volumeattachment")), } - return obj.(*storagev1alpha1.VolumeAttachment), nil +} + +// volumeAttachmentScopedLister can list all VolumeAttachments inside a workspace +// or scope down to a listersstoragev1alpha1.VolumeAttachmentNamespaceLister. +type volumeAttachmentScopedLister struct { + kcplisters.ResourceIndexer[*storagev1alpha1.VolumeAttachment] } diff --git a/listers/storage/v1alpha1/volumeattributesclass.go b/listers/storage/v1alpha1/volumeattributesclass.go index 9c5d2ac65..049eb5367 100644 --- a/listers/storage/v1alpha1/volumeattributesclass.go +++ b/listers/storage/v1alpha1/volumeattributesclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1alpha1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" storagev1alpha1 "k8s.io/api/storage/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - storagev1alpha1listers "k8s.io/client-go/listers/storage/v1alpha1" + listersstoragev1alpha1 "k8s.io/client-go/listers/storage/v1alpha1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// VolumeAttributesClassClusterLister can list VolumeAttributesClasses across all workspaces, or scope down to a VolumeAttributesClassLister for one workspace. +// VolumeAttributesClassClusterLister helps list VolumeAttributesClasses across all workspaces, +// or scope down to a VolumeAttributesClassLister for one workspace. // All objects returned here must be treated as read-only. type VolumeAttributesClassClusterLister interface { // List lists all VolumeAttributesClasses in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*storagev1alpha1.VolumeAttributesClass, err error) // Cluster returns a lister that can list and get VolumeAttributesClasses in one workspace. - Cluster(clusterName logicalcluster.Name) storagev1alpha1listers.VolumeAttributesClassLister + Cluster(clusterName logicalcluster.Name) listersstoragev1alpha1.VolumeAttributesClassLister VolumeAttributesClassClusterListerExpansion } +// volumeAttributesClassClusterLister implements the VolumeAttributesClassClusterLister interface. type volumeAttributesClassClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*storagev1alpha1.VolumeAttributesClass] } +var _ VolumeAttributesClassClusterLister = new(volumeAttributesClassClusterLister) + // NewVolumeAttributesClassClusterLister returns a new VolumeAttributesClassClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewVolumeAttributesClassClusterLister(indexer cache.Indexer) *volumeAttributesClassClusterLister { - return &volumeAttributesClassClusterLister{indexer: indexer} -} - -// List lists all VolumeAttributesClasses in the indexer across all workspaces. -func (s *volumeAttributesClassClusterLister) List(selector labels.Selector) (ret []*storagev1alpha1.VolumeAttributesClass, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*storagev1alpha1.VolumeAttributesClass)) - }) - return ret, err +func NewVolumeAttributesClassClusterLister(indexer cache.Indexer) VolumeAttributesClassClusterLister { + return &volumeAttributesClassClusterLister{ + kcplisters.NewCluster[*storagev1alpha1.VolumeAttributesClass](indexer, storagev1alpha1.Resource("volumeattributesclass")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get VolumeAttributesClasses. -func (s *volumeAttributesClassClusterLister) Cluster(clusterName logicalcluster.Name) storagev1alpha1listers.VolumeAttributesClassLister { - return &volumeAttributesClassLister{indexer: s.indexer, clusterName: clusterName} +func (l *volumeAttributesClassClusterLister) Cluster(clusterName logicalcluster.Name) listersstoragev1alpha1.VolumeAttributesClassLister { + return &volumeAttributesClassLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// volumeAttributesClassLister implements the storagev1alpha1listers.VolumeAttributesClassLister interface. +// volumeAttributesClassLister can list all VolumeAttributesClasses inside a workspace +// or scope down to a listersstoragev1alpha1.VolumeAttributesClassNamespaceLister for one namespace. type volumeAttributesClassLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*storagev1alpha1.VolumeAttributesClass] } -// List lists all VolumeAttributesClasses in the indexer for a workspace. -func (s *volumeAttributesClassLister) List(selector labels.Selector) (ret []*storagev1alpha1.VolumeAttributesClass, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*storagev1alpha1.VolumeAttributesClass)) - }) - return ret, err -} +var _ listersstoragev1alpha1.VolumeAttributesClassLister = new(volumeAttributesClassLister) -// Get retrieves the VolumeAttributesClass from the indexer for a given workspace and name. -func (s *volumeAttributesClassLister) Get(name string) (*storagev1alpha1.VolumeAttributesClass, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(storagev1alpha1.Resource("volumeattributesclasses"), name) +// NewVolumeAttributesClassLister returns a new VolumeAttributesClassLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewVolumeAttributesClassLister(indexer cache.Indexer) listersstoragev1alpha1.VolumeAttributesClassLister { + return &volumeAttributesClassLister{ + kcplisters.New[*storagev1alpha1.VolumeAttributesClass](indexer, storagev1alpha1.Resource("volumeattributesclass")), } - return obj.(*storagev1alpha1.VolumeAttributesClass), nil +} + +// volumeAttributesClassScopedLister can list all VolumeAttributesClasses inside a workspace +// or scope down to a listersstoragev1alpha1.VolumeAttributesClassNamespaceLister. +type volumeAttributesClassScopedLister struct { + kcplisters.ResourceIndexer[*storagev1alpha1.VolumeAttributesClass] } diff --git a/listers/storage/v1beta1/csidriver.go b/listers/storage/v1beta1/csidriver.go index 054c80073..91a2c5a83 100644 --- a/listers/storage/v1beta1/csidriver.go +++ b/listers/storage/v1beta1/csidriver.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" storagev1beta1 "k8s.io/api/storage/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - storagev1beta1listers "k8s.io/client-go/listers/storage/v1beta1" + listersstoragev1beta1 "k8s.io/client-go/listers/storage/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// CSIDriverClusterLister can list CSIDrivers across all workspaces, or scope down to a CSIDriverLister for one workspace. +// CSIDriverClusterLister helps list CSIDrivers across all workspaces, +// or scope down to a CSIDriverLister for one workspace. // All objects returned here must be treated as read-only. type CSIDriverClusterLister interface { // List lists all CSIDrivers in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*storagev1beta1.CSIDriver, err error) // Cluster returns a lister that can list and get CSIDrivers in one workspace. - Cluster(clusterName logicalcluster.Name) storagev1beta1listers.CSIDriverLister + Cluster(clusterName logicalcluster.Name) listersstoragev1beta1.CSIDriverLister CSIDriverClusterListerExpansion } +// cSIDriverClusterLister implements the CSIDriverClusterLister interface. type cSIDriverClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*storagev1beta1.CSIDriver] } +var _ CSIDriverClusterLister = new(cSIDriverClusterLister) + // NewCSIDriverClusterLister returns a new CSIDriverClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewCSIDriverClusterLister(indexer cache.Indexer) *cSIDriverClusterLister { - return &cSIDriverClusterLister{indexer: indexer} -} - -// List lists all CSIDrivers in the indexer across all workspaces. -func (s *cSIDriverClusterLister) List(selector labels.Selector) (ret []*storagev1beta1.CSIDriver, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*storagev1beta1.CSIDriver)) - }) - return ret, err +func NewCSIDriverClusterLister(indexer cache.Indexer) CSIDriverClusterLister { + return &cSIDriverClusterLister{ + kcplisters.NewCluster[*storagev1beta1.CSIDriver](indexer, storagev1beta1.Resource("csidriver")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get CSIDrivers. -func (s *cSIDriverClusterLister) Cluster(clusterName logicalcluster.Name) storagev1beta1listers.CSIDriverLister { - return &cSIDriverLister{indexer: s.indexer, clusterName: clusterName} +func (l *cSIDriverClusterLister) Cluster(clusterName logicalcluster.Name) listersstoragev1beta1.CSIDriverLister { + return &cSIDriverLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// cSIDriverLister implements the storagev1beta1listers.CSIDriverLister interface. +// cSIDriverLister can list all CSIDrivers inside a workspace +// or scope down to a listersstoragev1beta1.CSIDriverNamespaceLister for one namespace. type cSIDriverLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*storagev1beta1.CSIDriver] } -// List lists all CSIDrivers in the indexer for a workspace. -func (s *cSIDriverLister) List(selector labels.Selector) (ret []*storagev1beta1.CSIDriver, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*storagev1beta1.CSIDriver)) - }) - return ret, err -} +var _ listersstoragev1beta1.CSIDriverLister = new(cSIDriverLister) -// Get retrieves the CSIDriver from the indexer for a given workspace and name. -func (s *cSIDriverLister) Get(name string) (*storagev1beta1.CSIDriver, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(storagev1beta1.Resource("csidrivers"), name) +// NewCSIDriverLister returns a new CSIDriverLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewCSIDriverLister(indexer cache.Indexer) listersstoragev1beta1.CSIDriverLister { + return &cSIDriverLister{ + kcplisters.New[*storagev1beta1.CSIDriver](indexer, storagev1beta1.Resource("csidriver")), } - return obj.(*storagev1beta1.CSIDriver), nil +} + +// cSIDriverScopedLister can list all CSIDrivers inside a workspace +// or scope down to a listersstoragev1beta1.CSIDriverNamespaceLister. +type cSIDriverScopedLister struct { + kcplisters.ResourceIndexer[*storagev1beta1.CSIDriver] } diff --git a/listers/storage/v1beta1/csinode.go b/listers/storage/v1beta1/csinode.go index c5af7cc43..d09e58092 100644 --- a/listers/storage/v1beta1/csinode.go +++ b/listers/storage/v1beta1/csinode.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" storagev1beta1 "k8s.io/api/storage/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - storagev1beta1listers "k8s.io/client-go/listers/storage/v1beta1" + listersstoragev1beta1 "k8s.io/client-go/listers/storage/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// CSINodeClusterLister can list CSINodes across all workspaces, or scope down to a CSINodeLister for one workspace. +// CSINodeClusterLister helps list CSINodes across all workspaces, +// or scope down to a CSINodeLister for one workspace. // All objects returned here must be treated as read-only. type CSINodeClusterLister interface { // List lists all CSINodes in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*storagev1beta1.CSINode, err error) // Cluster returns a lister that can list and get CSINodes in one workspace. - Cluster(clusterName logicalcluster.Name) storagev1beta1listers.CSINodeLister + Cluster(clusterName logicalcluster.Name) listersstoragev1beta1.CSINodeLister CSINodeClusterListerExpansion } +// cSINodeClusterLister implements the CSINodeClusterLister interface. type cSINodeClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*storagev1beta1.CSINode] } +var _ CSINodeClusterLister = new(cSINodeClusterLister) + // NewCSINodeClusterLister returns a new CSINodeClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewCSINodeClusterLister(indexer cache.Indexer) *cSINodeClusterLister { - return &cSINodeClusterLister{indexer: indexer} -} - -// List lists all CSINodes in the indexer across all workspaces. -func (s *cSINodeClusterLister) List(selector labels.Selector) (ret []*storagev1beta1.CSINode, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*storagev1beta1.CSINode)) - }) - return ret, err +func NewCSINodeClusterLister(indexer cache.Indexer) CSINodeClusterLister { + return &cSINodeClusterLister{ + kcplisters.NewCluster[*storagev1beta1.CSINode](indexer, storagev1beta1.Resource("csinode")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get CSINodes. -func (s *cSINodeClusterLister) Cluster(clusterName logicalcluster.Name) storagev1beta1listers.CSINodeLister { - return &cSINodeLister{indexer: s.indexer, clusterName: clusterName} +func (l *cSINodeClusterLister) Cluster(clusterName logicalcluster.Name) listersstoragev1beta1.CSINodeLister { + return &cSINodeLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// cSINodeLister implements the storagev1beta1listers.CSINodeLister interface. +// cSINodeLister can list all CSINodes inside a workspace +// or scope down to a listersstoragev1beta1.CSINodeNamespaceLister for one namespace. type cSINodeLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*storagev1beta1.CSINode] } -// List lists all CSINodes in the indexer for a workspace. -func (s *cSINodeLister) List(selector labels.Selector) (ret []*storagev1beta1.CSINode, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*storagev1beta1.CSINode)) - }) - return ret, err -} +var _ listersstoragev1beta1.CSINodeLister = new(cSINodeLister) -// Get retrieves the CSINode from the indexer for a given workspace and name. -func (s *cSINodeLister) Get(name string) (*storagev1beta1.CSINode, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(storagev1beta1.Resource("csinodes"), name) +// NewCSINodeLister returns a new CSINodeLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewCSINodeLister(indexer cache.Indexer) listersstoragev1beta1.CSINodeLister { + return &cSINodeLister{ + kcplisters.New[*storagev1beta1.CSINode](indexer, storagev1beta1.Resource("csinode")), } - return obj.(*storagev1beta1.CSINode), nil +} + +// cSINodeScopedLister can list all CSINodes inside a workspace +// or scope down to a listersstoragev1beta1.CSINodeNamespaceLister. +type cSINodeScopedLister struct { + kcplisters.ResourceIndexer[*storagev1beta1.CSINode] } diff --git a/listers/storage/v1beta1/csistoragecapacity.go b/listers/storage/v1beta1/csistoragecapacity.go index 5824cff0c..fe7828e30 100644 --- a/listers/storage/v1beta1/csistoragecapacity.go +++ b/listers/storage/v1beta1/csistoragecapacity.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,102 +14,103 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" storagev1beta1 "k8s.io/api/storage/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - storagev1beta1listers "k8s.io/client-go/listers/storage/v1beta1" + listersstoragev1beta1 "k8s.io/client-go/listers/storage/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// CSIStorageCapacityClusterLister can list CSIStorageCapacities across all workspaces, or scope down to a CSIStorageCapacityLister for one workspace. +// CSIStorageCapacityClusterLister helps list CSIStorageCapacities across all workspaces, +// or scope down to a CSIStorageCapacityLister for one workspace. // All objects returned here must be treated as read-only. type CSIStorageCapacityClusterLister interface { // List lists all CSIStorageCapacities in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*storagev1beta1.CSIStorageCapacity, err error) // Cluster returns a lister that can list and get CSIStorageCapacities in one workspace. - Cluster(clusterName logicalcluster.Name) storagev1beta1listers.CSIStorageCapacityLister + Cluster(clusterName logicalcluster.Name) listersstoragev1beta1.CSIStorageCapacityLister CSIStorageCapacityClusterListerExpansion } +// cSIStorageCapacityClusterLister implements the CSIStorageCapacityClusterLister interface. type cSIStorageCapacityClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*storagev1beta1.CSIStorageCapacity] } +var _ CSIStorageCapacityClusterLister = new(cSIStorageCapacityClusterLister) + // NewCSIStorageCapacityClusterLister returns a new CSIStorageCapacityClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index // - has the kcpcache.ClusterAndNamespaceIndex as an index -func NewCSIStorageCapacityClusterLister(indexer cache.Indexer) *cSIStorageCapacityClusterLister { - return &cSIStorageCapacityClusterLister{indexer: indexer} -} - -// List lists all CSIStorageCapacities in the indexer across all workspaces. -func (s *cSIStorageCapacityClusterLister) List(selector labels.Selector) (ret []*storagev1beta1.CSIStorageCapacity, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*storagev1beta1.CSIStorageCapacity)) - }) - return ret, err +func NewCSIStorageCapacityClusterLister(indexer cache.Indexer) CSIStorageCapacityClusterLister { + return &cSIStorageCapacityClusterLister{ + kcplisters.NewCluster[*storagev1beta1.CSIStorageCapacity](indexer, storagev1beta1.Resource("csistoragecapacity")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get CSIStorageCapacities. -func (s *cSIStorageCapacityClusterLister) Cluster(clusterName logicalcluster.Name) storagev1beta1listers.CSIStorageCapacityLister { - return &cSIStorageCapacityLister{indexer: s.indexer, clusterName: clusterName} +func (l *cSIStorageCapacityClusterLister) Cluster(clusterName logicalcluster.Name) listersstoragev1beta1.CSIStorageCapacityLister { + return &cSIStorageCapacityLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// cSIStorageCapacityLister implements the storagev1beta1listers.CSIStorageCapacityLister interface. +// cSIStorageCapacityLister can list all CSIStorageCapacities inside a workspace +// or scope down to a listersstoragev1beta1.CSIStorageCapacityNamespaceLister for one namespace. type cSIStorageCapacityLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*storagev1beta1.CSIStorageCapacity] } -// List lists all CSIStorageCapacities in the indexer for a workspace. -func (s *cSIStorageCapacityLister) List(selector labels.Selector) (ret []*storagev1beta1.CSIStorageCapacity, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*storagev1beta1.CSIStorageCapacity)) - }) - return ret, err -} +var _ listersstoragev1beta1.CSIStorageCapacityLister = new(cSIStorageCapacityLister) // CSIStorageCapacities returns an object that can list and get CSIStorageCapacities in one namespace. -func (s *cSIStorageCapacityLister) CSIStorageCapacities(namespace string) storagev1beta1listers.CSIStorageCapacityNamespaceLister { - return &cSIStorageCapacityNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +func (l *cSIStorageCapacityLister) CSIStorageCapacities(namespace string) listersstoragev1beta1.CSIStorageCapacityNamespaceLister { + return &cSIStorageCapacityNamespaceLister{ + l.ResourceIndexer.WithNamespace(namespace), + } } -// cSIStorageCapacityNamespaceLister implements the storagev1beta1listers.CSIStorageCapacityNamespaceLister interface. +// cSIStorageCapacityNamespaceLister implements the listersstoragev1beta1.CSIStorageCapacityNamespaceLister +// interface. type cSIStorageCapacityNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string + kcplisters.ResourceIndexer[*storagev1beta1.CSIStorageCapacity] } -// List lists all CSIStorageCapacities in the indexer for a given workspace and namespace. -func (s *cSIStorageCapacityNamespaceLister) List(selector labels.Selector) (ret []*storagev1beta1.CSIStorageCapacity, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*storagev1beta1.CSIStorageCapacity)) - }) - return ret, err -} +var _ listersstoragev1beta1.CSIStorageCapacityNamespaceLister = new(cSIStorageCapacityNamespaceLister) -// Get retrieves the CSIStorageCapacity from the indexer for a given workspace, namespace and name. -func (s *cSIStorageCapacityNamespaceLister) Get(name string) (*storagev1beta1.CSIStorageCapacity, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err +// NewCSIStorageCapacityLister returns a new CSIStorageCapacityLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewCSIStorageCapacityLister(indexer cache.Indexer) listersstoragev1beta1.CSIStorageCapacityLister { + return &cSIStorageCapacityLister{ + kcplisters.New[*storagev1beta1.CSIStorageCapacity](indexer, storagev1beta1.Resource("csistoragecapacity")), } - if !exists { - return nil, errors.NewNotFound(storagev1beta1.Resource("csistoragecapacities"), name) +} + +// cSIStorageCapacityScopedLister can list all CSIStorageCapacities inside a workspace +// or scope down to a listersstoragev1beta1.CSIStorageCapacityNamespaceLister for one namespace. +type cSIStorageCapacityScopedLister struct { + kcplisters.ResourceIndexer[*storagev1beta1.CSIStorageCapacity] +} + +// CSIStorageCapacities returns an object that can list and get CSIStorageCapacities in one namespace. +func (l *cSIStorageCapacityScopedLister) CSIStorageCapacities(namespace string) listersstoragev1beta1.CSIStorageCapacityLister { + return &cSIStorageCapacityLister{ + l.ResourceIndexer.WithNamespace(namespace), } - return obj.(*storagev1beta1.CSIStorageCapacity), nil } diff --git a/listers/storage/v1beta1/expansion_generated.go b/listers/storage/v1beta1/expansion_generated.go new file mode 100644 index 000000000..23cac805b --- /dev/null +++ b/listers/storage/v1beta1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1beta1 diff --git a/listers/storage/v1beta1/storageclass.go b/listers/storage/v1beta1/storageclass.go index 0881e511d..d63524acd 100644 --- a/listers/storage/v1beta1/storageclass.go +++ b/listers/storage/v1beta1/storageclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" storagev1beta1 "k8s.io/api/storage/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - storagev1beta1listers "k8s.io/client-go/listers/storage/v1beta1" + listersstoragev1beta1 "k8s.io/client-go/listers/storage/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// StorageClassClusterLister can list StorageClasses across all workspaces, or scope down to a StorageClassLister for one workspace. +// StorageClassClusterLister helps list StorageClasses across all workspaces, +// or scope down to a StorageClassLister for one workspace. // All objects returned here must be treated as read-only. type StorageClassClusterLister interface { // List lists all StorageClasses in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*storagev1beta1.StorageClass, err error) // Cluster returns a lister that can list and get StorageClasses in one workspace. - Cluster(clusterName logicalcluster.Name) storagev1beta1listers.StorageClassLister + Cluster(clusterName logicalcluster.Name) listersstoragev1beta1.StorageClassLister StorageClassClusterListerExpansion } +// storageClassClusterLister implements the StorageClassClusterLister interface. type storageClassClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*storagev1beta1.StorageClass] } +var _ StorageClassClusterLister = new(storageClassClusterLister) + // NewStorageClassClusterLister returns a new StorageClassClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewStorageClassClusterLister(indexer cache.Indexer) *storageClassClusterLister { - return &storageClassClusterLister{indexer: indexer} -} - -// List lists all StorageClasses in the indexer across all workspaces. -func (s *storageClassClusterLister) List(selector labels.Selector) (ret []*storagev1beta1.StorageClass, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*storagev1beta1.StorageClass)) - }) - return ret, err +func NewStorageClassClusterLister(indexer cache.Indexer) StorageClassClusterLister { + return &storageClassClusterLister{ + kcplisters.NewCluster[*storagev1beta1.StorageClass](indexer, storagev1beta1.Resource("storageclass")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get StorageClasses. -func (s *storageClassClusterLister) Cluster(clusterName logicalcluster.Name) storagev1beta1listers.StorageClassLister { - return &storageClassLister{indexer: s.indexer, clusterName: clusterName} +func (l *storageClassClusterLister) Cluster(clusterName logicalcluster.Name) listersstoragev1beta1.StorageClassLister { + return &storageClassLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// storageClassLister implements the storagev1beta1listers.StorageClassLister interface. +// storageClassLister can list all StorageClasses inside a workspace +// or scope down to a listersstoragev1beta1.StorageClassNamespaceLister for one namespace. type storageClassLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*storagev1beta1.StorageClass] } -// List lists all StorageClasses in the indexer for a workspace. -func (s *storageClassLister) List(selector labels.Selector) (ret []*storagev1beta1.StorageClass, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*storagev1beta1.StorageClass)) - }) - return ret, err -} +var _ listersstoragev1beta1.StorageClassLister = new(storageClassLister) -// Get retrieves the StorageClass from the indexer for a given workspace and name. -func (s *storageClassLister) Get(name string) (*storagev1beta1.StorageClass, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(storagev1beta1.Resource("storageclasses"), name) +// NewStorageClassLister returns a new StorageClassLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewStorageClassLister(indexer cache.Indexer) listersstoragev1beta1.StorageClassLister { + return &storageClassLister{ + kcplisters.New[*storagev1beta1.StorageClass](indexer, storagev1beta1.Resource("storageclass")), } - return obj.(*storagev1beta1.StorageClass), nil +} + +// storageClassScopedLister can list all StorageClasses inside a workspace +// or scope down to a listersstoragev1beta1.StorageClassNamespaceLister. +type storageClassScopedLister struct { + kcplisters.ResourceIndexer[*storagev1beta1.StorageClass] } diff --git a/listers/storage/v1beta1/volumeattachment.go b/listers/storage/v1beta1/volumeattachment.go index 5e3575ff9..eef229acd 100644 --- a/listers/storage/v1beta1/volumeattachment.go +++ b/listers/storage/v1beta1/volumeattachment.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" storagev1beta1 "k8s.io/api/storage/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - storagev1beta1listers "k8s.io/client-go/listers/storage/v1beta1" + listersstoragev1beta1 "k8s.io/client-go/listers/storage/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// VolumeAttachmentClusterLister can list VolumeAttachments across all workspaces, or scope down to a VolumeAttachmentLister for one workspace. +// VolumeAttachmentClusterLister helps list VolumeAttachments across all workspaces, +// or scope down to a VolumeAttachmentLister for one workspace. // All objects returned here must be treated as read-only. type VolumeAttachmentClusterLister interface { // List lists all VolumeAttachments in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*storagev1beta1.VolumeAttachment, err error) // Cluster returns a lister that can list and get VolumeAttachments in one workspace. - Cluster(clusterName logicalcluster.Name) storagev1beta1listers.VolumeAttachmentLister + Cluster(clusterName logicalcluster.Name) listersstoragev1beta1.VolumeAttachmentLister VolumeAttachmentClusterListerExpansion } +// volumeAttachmentClusterLister implements the VolumeAttachmentClusterLister interface. type volumeAttachmentClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*storagev1beta1.VolumeAttachment] } +var _ VolumeAttachmentClusterLister = new(volumeAttachmentClusterLister) + // NewVolumeAttachmentClusterLister returns a new VolumeAttachmentClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewVolumeAttachmentClusterLister(indexer cache.Indexer) *volumeAttachmentClusterLister { - return &volumeAttachmentClusterLister{indexer: indexer} -} - -// List lists all VolumeAttachments in the indexer across all workspaces. -func (s *volumeAttachmentClusterLister) List(selector labels.Selector) (ret []*storagev1beta1.VolumeAttachment, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*storagev1beta1.VolumeAttachment)) - }) - return ret, err +func NewVolumeAttachmentClusterLister(indexer cache.Indexer) VolumeAttachmentClusterLister { + return &volumeAttachmentClusterLister{ + kcplisters.NewCluster[*storagev1beta1.VolumeAttachment](indexer, storagev1beta1.Resource("volumeattachment")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get VolumeAttachments. -func (s *volumeAttachmentClusterLister) Cluster(clusterName logicalcluster.Name) storagev1beta1listers.VolumeAttachmentLister { - return &volumeAttachmentLister{indexer: s.indexer, clusterName: clusterName} +func (l *volumeAttachmentClusterLister) Cluster(clusterName logicalcluster.Name) listersstoragev1beta1.VolumeAttachmentLister { + return &volumeAttachmentLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// volumeAttachmentLister implements the storagev1beta1listers.VolumeAttachmentLister interface. +// volumeAttachmentLister can list all VolumeAttachments inside a workspace +// or scope down to a listersstoragev1beta1.VolumeAttachmentNamespaceLister for one namespace. type volumeAttachmentLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*storagev1beta1.VolumeAttachment] } -// List lists all VolumeAttachments in the indexer for a workspace. -func (s *volumeAttachmentLister) List(selector labels.Selector) (ret []*storagev1beta1.VolumeAttachment, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*storagev1beta1.VolumeAttachment)) - }) - return ret, err -} +var _ listersstoragev1beta1.VolumeAttachmentLister = new(volumeAttachmentLister) -// Get retrieves the VolumeAttachment from the indexer for a given workspace and name. -func (s *volumeAttachmentLister) Get(name string) (*storagev1beta1.VolumeAttachment, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(storagev1beta1.Resource("volumeattachments"), name) +// NewVolumeAttachmentLister returns a new VolumeAttachmentLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewVolumeAttachmentLister(indexer cache.Indexer) listersstoragev1beta1.VolumeAttachmentLister { + return &volumeAttachmentLister{ + kcplisters.New[*storagev1beta1.VolumeAttachment](indexer, storagev1beta1.Resource("volumeattachment")), } - return obj.(*storagev1beta1.VolumeAttachment), nil +} + +// volumeAttachmentScopedLister can list all VolumeAttachments inside a workspace +// or scope down to a listersstoragev1beta1.VolumeAttachmentNamespaceLister. +type volumeAttachmentScopedLister struct { + kcplisters.ResourceIndexer[*storagev1beta1.VolumeAttachment] } diff --git a/listers/storage/v1beta1/volumeattributesclass.go b/listers/storage/v1beta1/volumeattributesclass.go index ac8f931fe..ae48b7cee 100644 --- a/listers/storage/v1beta1/volumeattributesclass.go +++ b/listers/storage/v1beta1/volumeattributesclass.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1beta1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" storagev1beta1 "k8s.io/api/storage/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - storagev1beta1listers "k8s.io/client-go/listers/storage/v1beta1" + listersstoragev1beta1 "k8s.io/client-go/listers/storage/v1beta1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// VolumeAttributesClassClusterLister can list VolumeAttributesClasses across all workspaces, or scope down to a VolumeAttributesClassLister for one workspace. +// VolumeAttributesClassClusterLister helps list VolumeAttributesClasses across all workspaces, +// or scope down to a VolumeAttributesClassLister for one workspace. // All objects returned here must be treated as read-only. type VolumeAttributesClassClusterLister interface { // List lists all VolumeAttributesClasses in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*storagev1beta1.VolumeAttributesClass, err error) // Cluster returns a lister that can list and get VolumeAttributesClasses in one workspace. - Cluster(clusterName logicalcluster.Name) storagev1beta1listers.VolumeAttributesClassLister + Cluster(clusterName logicalcluster.Name) listersstoragev1beta1.VolumeAttributesClassLister VolumeAttributesClassClusterListerExpansion } +// volumeAttributesClassClusterLister implements the VolumeAttributesClassClusterLister interface. type volumeAttributesClassClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*storagev1beta1.VolumeAttributesClass] } +var _ VolumeAttributesClassClusterLister = new(volumeAttributesClassClusterLister) + // NewVolumeAttributesClassClusterLister returns a new VolumeAttributesClassClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewVolumeAttributesClassClusterLister(indexer cache.Indexer) *volumeAttributesClassClusterLister { - return &volumeAttributesClassClusterLister{indexer: indexer} -} - -// List lists all VolumeAttributesClasses in the indexer across all workspaces. -func (s *volumeAttributesClassClusterLister) List(selector labels.Selector) (ret []*storagev1beta1.VolumeAttributesClass, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*storagev1beta1.VolumeAttributesClass)) - }) - return ret, err +func NewVolumeAttributesClassClusterLister(indexer cache.Indexer) VolumeAttributesClassClusterLister { + return &volumeAttributesClassClusterLister{ + kcplisters.NewCluster[*storagev1beta1.VolumeAttributesClass](indexer, storagev1beta1.Resource("volumeattributesclass")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get VolumeAttributesClasses. -func (s *volumeAttributesClassClusterLister) Cluster(clusterName logicalcluster.Name) storagev1beta1listers.VolumeAttributesClassLister { - return &volumeAttributesClassLister{indexer: s.indexer, clusterName: clusterName} +func (l *volumeAttributesClassClusterLister) Cluster(clusterName logicalcluster.Name) listersstoragev1beta1.VolumeAttributesClassLister { + return &volumeAttributesClassLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// volumeAttributesClassLister implements the storagev1beta1listers.VolumeAttributesClassLister interface. +// volumeAttributesClassLister can list all VolumeAttributesClasses inside a workspace +// or scope down to a listersstoragev1beta1.VolumeAttributesClassNamespaceLister for one namespace. type volumeAttributesClassLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*storagev1beta1.VolumeAttributesClass] } -// List lists all VolumeAttributesClasses in the indexer for a workspace. -func (s *volumeAttributesClassLister) List(selector labels.Selector) (ret []*storagev1beta1.VolumeAttributesClass, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*storagev1beta1.VolumeAttributesClass)) - }) - return ret, err -} +var _ listersstoragev1beta1.VolumeAttributesClassLister = new(volumeAttributesClassLister) -// Get retrieves the VolumeAttributesClass from the indexer for a given workspace and name. -func (s *volumeAttributesClassLister) Get(name string) (*storagev1beta1.VolumeAttributesClass, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(storagev1beta1.Resource("volumeattributesclasses"), name) +// NewVolumeAttributesClassLister returns a new VolumeAttributesClassLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewVolumeAttributesClassLister(indexer cache.Indexer) listersstoragev1beta1.VolumeAttributesClassLister { + return &volumeAttributesClassLister{ + kcplisters.New[*storagev1beta1.VolumeAttributesClass](indexer, storagev1beta1.Resource("volumeattributesclass")), } - return obj.(*storagev1beta1.VolumeAttributesClass), nil +} + +// volumeAttributesClassScopedLister can list all VolumeAttributesClasses inside a workspace +// or scope down to a listersstoragev1beta1.VolumeAttributesClassNamespaceLister. +type volumeAttributesClassScopedLister struct { + kcplisters.ResourceIndexer[*storagev1beta1.VolumeAttributesClass] } diff --git a/listers/storagemigration/v1alpha1/expansion_generated.go b/listers/storagemigration/v1alpha1/expansion_generated.go new file mode 100644 index 000000000..3b8521c00 --- /dev/null +++ b/listers/storagemigration/v1alpha1/expansion_generated.go @@ -0,0 +1,19 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by cluster-lister-gen. DO NOT EDIT. + +package v1alpha1 diff --git a/listers/storagemigration/v1alpha1/storageversionmigration.go b/listers/storagemigration/v1alpha1/storageversionmigration.go index 278519e3f..b1fbc1a96 100644 --- a/listers/storagemigration/v1alpha1/storageversionmigration.go +++ b/listers/storagemigration/v1alpha1/storageversionmigration.go @@ -1,5 +1,5 @@ /* -Copyright The KCP Authors. +Copyright 2025 The KCP Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,81 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by kcp code-generator. DO NOT EDIT. +// Code generated by cluster-lister-gen. DO NOT EDIT. package v1alpha1 import ( - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" "github.com/kcp-dev/logicalcluster/v3" storagemigrationv1alpha1 "k8s.io/api/storagemigration/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - storagemigrationv1alpha1listers "k8s.io/client-go/listers/storagemigration/v1alpha1" + listersstoragemigrationv1alpha1 "k8s.io/client-go/listers/storagemigration/v1alpha1" "k8s.io/client-go/tools/cache" + + kcplisters "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/listers" ) -// StorageVersionMigrationClusterLister can list StorageVersionMigrations across all workspaces, or scope down to a StorageVersionMigrationLister for one workspace. +// StorageVersionMigrationClusterLister helps list StorageVersionMigrations across all workspaces, +// or scope down to a StorageVersionMigrationLister for one workspace. // All objects returned here must be treated as read-only. type StorageVersionMigrationClusterLister interface { // List lists all StorageVersionMigrations in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*storagemigrationv1alpha1.StorageVersionMigration, err error) // Cluster returns a lister that can list and get StorageVersionMigrations in one workspace. - Cluster(clusterName logicalcluster.Name) storagemigrationv1alpha1listers.StorageVersionMigrationLister + Cluster(clusterName logicalcluster.Name) listersstoragemigrationv1alpha1.StorageVersionMigrationLister StorageVersionMigrationClusterListerExpansion } +// storageVersionMigrationClusterLister implements the StorageVersionMigrationClusterLister interface. type storageVersionMigrationClusterLister struct { - indexer cache.Indexer + kcplisters.ResourceClusterIndexer[*storagemigrationv1alpha1.StorageVersionMigration] } +var _ StorageVersionMigrationClusterLister = new(storageVersionMigrationClusterLister) + // NewStorageVersionMigrationClusterLister returns a new StorageVersionMigrationClusterLister. // We assume that the indexer: // - is fed by a cross-workspace LIST+WATCH // - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function // - has the kcpcache.ClusterIndex as an index -func NewStorageVersionMigrationClusterLister(indexer cache.Indexer) *storageVersionMigrationClusterLister { - return &storageVersionMigrationClusterLister{indexer: indexer} -} - -// List lists all StorageVersionMigrations in the indexer across all workspaces. -func (s *storageVersionMigrationClusterLister) List(selector labels.Selector) (ret []*storagemigrationv1alpha1.StorageVersionMigration, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*storagemigrationv1alpha1.StorageVersionMigration)) - }) - return ret, err +func NewStorageVersionMigrationClusterLister(indexer cache.Indexer) StorageVersionMigrationClusterLister { + return &storageVersionMigrationClusterLister{ + kcplisters.NewCluster[*storagemigrationv1alpha1.StorageVersionMigration](indexer, storagemigrationv1alpha1.Resource("storageversionmigration")), + } } // Cluster scopes the lister to one workspace, allowing users to list and get StorageVersionMigrations. -func (s *storageVersionMigrationClusterLister) Cluster(clusterName logicalcluster.Name) storagemigrationv1alpha1listers.StorageVersionMigrationLister { - return &storageVersionMigrationLister{indexer: s.indexer, clusterName: clusterName} +func (l *storageVersionMigrationClusterLister) Cluster(clusterName logicalcluster.Name) listersstoragemigrationv1alpha1.StorageVersionMigrationLister { + return &storageVersionMigrationLister{ + l.ResourceClusterIndexer.WithCluster(clusterName), + } } -// storageVersionMigrationLister implements the storagemigrationv1alpha1listers.StorageVersionMigrationLister interface. +// storageVersionMigrationLister can list all StorageVersionMigrations inside a workspace +// or scope down to a listersstoragemigrationv1alpha1.StorageVersionMigrationNamespaceLister for one namespace. type storageVersionMigrationLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name + kcplisters.ResourceIndexer[*storagemigrationv1alpha1.StorageVersionMigration] } -// List lists all StorageVersionMigrations in the indexer for a workspace. -func (s *storageVersionMigrationLister) List(selector labels.Selector) (ret []*storagemigrationv1alpha1.StorageVersionMigration, err error) { - err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { - ret = append(ret, i.(*storagemigrationv1alpha1.StorageVersionMigration)) - }) - return ret, err -} +var _ listersstoragemigrationv1alpha1.StorageVersionMigrationLister = new(storageVersionMigrationLister) -// Get retrieves the StorageVersionMigration from the indexer for a given workspace and name. -func (s *storageVersionMigrationLister) Get(name string) (*storagemigrationv1alpha1.StorageVersionMigration, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) - obj, exists, err := s.indexer.GetByKey(key) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(storagemigrationv1alpha1.Resource("storageversionmigrations"), name) +// NewStorageVersionMigrationLister returns a new StorageVersionMigrationLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +func NewStorageVersionMigrationLister(indexer cache.Indexer) listersstoragemigrationv1alpha1.StorageVersionMigrationLister { + return &storageVersionMigrationLister{ + kcplisters.New[*storagemigrationv1alpha1.StorageVersionMigration](indexer, storagemigrationv1alpha1.Resource("storageversionmigration")), } - return obj.(*storagemigrationv1alpha1.StorageVersionMigration), nil +} + +// storageVersionMigrationScopedLister can list all StorageVersionMigrations inside a workspace +// or scope down to a listersstoragemigrationv1alpha1.StorageVersionMigrationNamespaceLister. +type storageVersionMigrationScopedLister struct { + kcplisters.ResourceIndexer[*storagemigrationv1alpha1.StorageVersionMigration] } diff --git a/metadata/metadatainformer/informer.go b/metadata/metadatainformer/informer.go index c685733c4..0d19efb28 100644 --- a/metadata/metadatainformer/informer.go +++ b/metadata/metadatainformer/informer.go @@ -165,8 +165,12 @@ func (d *metadataClusterInformer) Lister() kcpcache.GenericClusterLister { } func (d *metadataClusterInformer) Cluster(clusterName logicalcluster.Name) upstreaminformers.GenericInformer { + return d.ClusterWithContext(context.Background(), clusterName) +} + +func (d *metadataClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) upstreaminformers.GenericInformer { return &metadataInformer{ - informer: d.Informer().Cluster(clusterName), + informer: d.Informer().ClusterWithContext(ctx, clusterName), lister: d.Lister().ByCluster(clusterName), } } diff --git a/third_party/k8s.io/client-go/listers/generic_helpers.go b/third_party/k8s.io/client-go/listers/generic_helpers.go index 576ca7e2c..f673acb1f 100644 --- a/third_party/k8s.io/client-go/listers/generic_helpers.go +++ b/third_party/k8s.io/client-go/listers/generic_helpers.go @@ -49,6 +49,13 @@ func (l ResourceClusterIndexer[T]) List(selector labels.Selector) (ret []T, err return ret, err } +// WithCluster returns a ResourceIndexer with the specified cluster. +func (l ResourceClusterIndexer[T]) WithCluster(cluster logicalcluster.Name) ResourceIndexer[T] { + ret := New[T](l.indexer, l.resource) + ret.cluster = cluster + return ret +} + // ResourceIndexer wraps an indexer, resource, and optional namespace for a given type. // This is intended for use by listers (generated by lister-gen) only. type ResourceIndexer[T runtime.Object] struct { @@ -60,12 +67,35 @@ type ResourceIndexer[T runtime.Object] struct { // New returns a new instance of a lister (resource indexer) wrapping the given indexer and resource for the specified type. // This is intended for use by listers (generated by lister-gen) only. -func New[T runtime.Object](indexer cache.Indexer, cluster logicalcluster.Name, resource schema.GroupResource) ResourceIndexer[T] { - return ResourceIndexer[T]{indexer: indexer, cluster: cluster, resource: resource} +func New[T runtime.Object](indexer cache.Indexer, resource schema.GroupResource) ResourceIndexer[T] { + return ResourceIndexer[T]{indexer: indexer, resource: resource} +} + +// WithCluster returns a new copy of the ResourceIndexer with the +// specified cluster. +func (l ResourceIndexer[T]) WithCluster(cluster logicalcluster.Name) ResourceIndexer[T] { + return ResourceIndexer[T]{ + indexer: l.indexer, + cluster: cluster, + resource: l.resource, + namespace: l.namespace, + } +} + +// WithNamespace returns a new copy of the ResourceIndexer with the +// specified namespace. +func (l ResourceIndexer[T]) WithNamespace(namespace string) ResourceIndexer[T] { + return ResourceIndexer[T]{ + indexer: l.indexer, + cluster: l.cluster, + resource: l.resource, + namespace: namespace, + } } // NewNamespaced returns a new instance of a namespaced lister (resource indexer) wrapping the given parent and namespace for the specified type. // This is intended for use by listers (generated by lister-gen) only. +// Deprecated: Use ResourceIndexer.WithNamespace instead. func NewNamespaced[T runtime.Object](parent ResourceIndexer[T], namespace string) ResourceIndexer[T] { return ResourceIndexer[T]{indexer: parent.indexer, resource: parent.resource, namespace: namespace} }