From 8582664224847e1f1cf1b4a6d448eeac6b8ff21f Mon Sep 17 00:00:00 2001 From: Stephen Kitt Date: Thu, 1 Aug 2024 12:10:10 +0200 Subject: [PATCH] Run codegen Signed-off-by: Stephen Kitt Kubernetes-commit: be03bcf3244e6c280b8aaf7a638d1926f0960eab --- go.mod | 8 +- go.sum | 16 +- .../v1alpha1/fake/fake_foo.go | 137 +++--------------- .../fake/fake_samplecontroller_client.go | 2 +- 4 files changed, 32 insertions(+), 131 deletions(-) diff --git a/go.mod b/go.mod index 6970c619..f11c3a68 100644 --- a/go.mod +++ b/go.mod @@ -8,10 +8,10 @@ godebug default=go1.23 require ( golang.org/x/time v0.7.0 - k8s.io/api v0.0.0-20241105230147-1ddf895d7e74 - k8s.io/apimachinery v0.0.0-20241105225905-b5e810677b4f - k8s.io/client-go v0.0.0-20241105230542-c1010ffd7de3 - k8s.io/code-generator v0.0.0-20241105231402-88802cbe5c31 + k8s.io/api v0.0.0-20241127162655-f8e5e36c84f1 + k8s.io/apimachinery v0.0.0-20240920213627-16af2ff33fbf + k8s.io/client-go v0.0.0-20241127164845-55d23e26d5ef + k8s.io/code-generator v0.0.0-20241127170634-56b470edd059 k8s.io/klog/v2 v2.130.1 ) diff --git a/go.sum b/go.sum index aac8b03c..b1625ac2 100644 --- a/go.sum +++ b/go.sum @@ -140,14 +140,14 @@ gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.0.0-20241105230147-1ddf895d7e74 h1:omoqr99s5DbyApsEajh0iIyKzGL/5vkvEgHn0P/q/NQ= -k8s.io/api v0.0.0-20241105230147-1ddf895d7e74/go.mod h1:QMjNGKwUJOiB0TWCMJWLvhiVAvOrl9I+MTeV0dr56NE= -k8s.io/apimachinery v0.0.0-20241105225905-b5e810677b4f h1:MTmedS366tu07Nh6HBoXS90/6DA5gP62gMyYTF+lT+Q= -k8s.io/apimachinery v0.0.0-20241105225905-b5e810677b4f/go.mod h1:HqhdaJUgQqky29T1V0o2yFkt/pZqLFIDyn9Zi/8rxoY= -k8s.io/client-go v0.0.0-20241105230542-c1010ffd7de3 h1:ZgoctdRlDLgbqPdEdcgyoyBbVGgNmfcokEkFYjpHZ68= -k8s.io/client-go v0.0.0-20241105230542-c1010ffd7de3/go.mod h1:p8opQH8f5aM1YzHrN0yWNcD4qqfAJIaR0+kVTU/TIBw= -k8s.io/code-generator v0.0.0-20241105231402-88802cbe5c31 h1:ZT/yC/53DdhNANUvb1irXAlLf4/v38tGDWFWI0SP2tw= -k8s.io/code-generator v0.0.0-20241105231402-88802cbe5c31/go.mod h1:DjKky2Zt+GJ7WjeZvo+2J4MVUVMMFDkYyZlKKaMANDs= +k8s.io/api v0.0.0-20241127162655-f8e5e36c84f1 h1:MTqd8524+MzN0Kxt42qAvh/aUYC18yz1BJUmfWADaDg= +k8s.io/api v0.0.0-20241127162655-f8e5e36c84f1/go.mod h1:qs155+gTdM43TXy/cV8a8yOjDeNR8kGJc82AraJrh/c= +k8s.io/apimachinery v0.0.0-20240920213627-16af2ff33fbf h1:ZRwu8YHh3bFbQU4NRvHB6fiovWLBouxY86wIcLd7sBA= +k8s.io/apimachinery v0.0.0-20240920213627-16af2ff33fbf/go.mod h1:HqhdaJUgQqky29T1V0o2yFkt/pZqLFIDyn9Zi/8rxoY= +k8s.io/client-go v0.0.0-20241127164845-55d23e26d5ef h1:vruVg7dEUvIzst/cCIMyxHj6Xh2vTpaVH9wrONW6SM4= +k8s.io/client-go v0.0.0-20241127164845-55d23e26d5ef/go.mod h1:DtqcGpVY2YUJlRhkIBvTwD/kYAIV58FrFHjjLlNR4VM= +k8s.io/code-generator v0.0.0-20241127170634-56b470edd059 h1:+pnMqlGoHe5NAep83V1PIXcLxnNoAbKvfuKO/mMJD9o= +k8s.io/code-generator v0.0.0-20241127170634-56b470edd059/go.mod h1:QKSpXtf2PO9wu/OTlRYPsRpbCstvEtj0O0hI+hf6vGM= 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= diff --git a/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake/fake_foo.go b/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake/fake_foo.go index f61c4e28..a3a767f1 100644 --- a/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake/fake_foo.go +++ b/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake/fake_foo.go @@ -19,129 +19,30 @@ limitations under the License. package fake import ( - context "context" - - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - testing "k8s.io/client-go/testing" + gentype "k8s.io/client-go/gentype" v1alpha1 "k8s.io/sample-controller/pkg/apis/samplecontroller/v1alpha1" + samplecontrollerv1alpha1 "k8s.io/sample-controller/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1" ) -// FakeFoos implements FooInterface -type FakeFoos struct { +// fakeFoos implements FooInterface +type fakeFoos struct { + *gentype.FakeClientWithList[*v1alpha1.Foo, *v1alpha1.FooList] Fake *FakeSamplecontrollerV1alpha1 - ns string } -var foosResource = v1alpha1.SchemeGroupVersion.WithResource("foos") - -var foosKind = v1alpha1.SchemeGroupVersion.WithKind("Foo") - -// Get takes name of the foo, and returns the corresponding foo object, and an error if there is any. -func (c *FakeFoos) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Foo, err error) { - emptyResult := &v1alpha1.Foo{} - obj, err := c.Fake. - Invokes(testing.NewGetActionWithOptions(foosResource, c.ns, name, options), emptyResult) - - if obj == nil { - return emptyResult, err +func newFakeFoos(fake *FakeSamplecontrollerV1alpha1, namespace string) samplecontrollerv1alpha1.FooInterface { + return &fakeFoos{ + gentype.NewFakeClientWithList[*v1alpha1.Foo, *v1alpha1.FooList]( + fake.Fake, + namespace, + v1alpha1.SchemeGroupVersion.WithResource("foos"), + v1alpha1.SchemeGroupVersion.WithKind("Foo"), + func() *v1alpha1.Foo { return &v1alpha1.Foo{} }, + func() *v1alpha1.FooList { return &v1alpha1.FooList{} }, + func(dst, src *v1alpha1.FooList) { dst.ListMeta = src.ListMeta }, + func(list *v1alpha1.FooList) []*v1alpha1.Foo { return gentype.ToPointerSlice(list.Items) }, + func(list *v1alpha1.FooList, items []*v1alpha1.Foo) { list.Items = gentype.FromPointerSlice(items) }, + ), + fake, } - return obj.(*v1alpha1.Foo), err -} - -// List takes label and field selectors, and returns the list of Foos that match those selectors. -func (c *FakeFoos) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.FooList, err error) { - emptyResult := &v1alpha1.FooList{} - obj, err := c.Fake. - Invokes(testing.NewListActionWithOptions(foosResource, foosKind, c.ns, opts), emptyResult) - - if obj == nil { - return emptyResult, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &v1alpha1.FooList{ListMeta: obj.(*v1alpha1.FooList).ListMeta} - for _, item := range obj.(*v1alpha1.FooList).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 foos. -func (c *FakeFoos) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewWatchActionWithOptions(foosResource, c.ns, opts)) - -} - -// Create takes the representation of a foo and creates it. Returns the server's representation of the foo, and an error, if there is any. -func (c *FakeFoos) Create(ctx context.Context, foo *v1alpha1.Foo, opts v1.CreateOptions) (result *v1alpha1.Foo, err error) { - emptyResult := &v1alpha1.Foo{} - obj, err := c.Fake. - Invokes(testing.NewCreateActionWithOptions(foosResource, c.ns, foo, opts), emptyResult) - - if obj == nil { - return emptyResult, err - } - return obj.(*v1alpha1.Foo), err -} - -// Update takes the representation of a foo and updates it. Returns the server's representation of the foo, and an error, if there is any. -func (c *FakeFoos) Update(ctx context.Context, foo *v1alpha1.Foo, opts v1.UpdateOptions) (result *v1alpha1.Foo, err error) { - emptyResult := &v1alpha1.Foo{} - obj, err := c.Fake. - Invokes(testing.NewUpdateActionWithOptions(foosResource, c.ns, foo, opts), emptyResult) - - if obj == nil { - return emptyResult, err - } - return obj.(*v1alpha1.Foo), err -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeFoos) UpdateStatus(ctx context.Context, foo *v1alpha1.Foo, opts v1.UpdateOptions) (result *v1alpha1.Foo, err error) { - emptyResult := &v1alpha1.Foo{} - obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceActionWithOptions(foosResource, "status", c.ns, foo, opts), emptyResult) - - if obj == nil { - return emptyResult, err - } - return obj.(*v1alpha1.Foo), err -} - -// Delete takes name of the foo and deletes it. Returns an error if one occurs. -func (c *FakeFoos) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewDeleteActionWithOptions(foosResource, c.ns, name, opts), &v1alpha1.Foo{}) - - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeFoos) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionActionWithOptions(foosResource, c.ns, opts, listOpts) - - _, err := c.Fake.Invokes(action, &v1alpha1.FooList{}) - return err -} - -// Patch applies the patch and returns the patched foo. -func (c *FakeFoos) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Foo, err error) { - emptyResult := &v1alpha1.Foo{} - obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceActionWithOptions(foosResource, c.ns, name, pt, data, opts, subresources...), emptyResult) - - if obj == nil { - return emptyResult, err - } - return obj.(*v1alpha1.Foo), err } diff --git a/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake/fake_samplecontroller_client.go b/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake/fake_samplecontroller_client.go index 02088eba..d5dad62f 100644 --- a/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake/fake_samplecontroller_client.go +++ b/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake/fake_samplecontroller_client.go @@ -29,7 +29,7 @@ type FakeSamplecontrollerV1alpha1 struct { } func (c *FakeSamplecontrollerV1alpha1) Foos(namespace string) v1alpha1.FooInterface { - return &FakeFoos{c, namespace} + return newFakeFoos(c, namespace) } // RESTClient returns a RESTClient that is used to communicate