From daa12ca50530a3744e7e6b0df55f94eaa9606fa7 Mon Sep 17 00:00:00 2001 From: Thomas Ferrandiz Date: Mon, 9 Dec 2024 13:17:43 +0000 Subject: [PATCH] Update code generator script The script we were using is fully deprecated so we need to upgrade to a new code generator. --- .github/workflows/test.yml | 2 +- cmd/controlloop/controlloop.go | 4 +- .../node_slice_controller.go | 4 +- cmd/whereabouts_test.go | 4 +- e2e/client/whereabouts.go | 2 +- hack/update-codegen.sh | 16 +- hack/verify-codegen.sh | 8 +- .../v1alpha1/ippool.go | 177 ---------------- .../v1alpha1/nodeslicepool.go | 194 ------------------ .../v1alpha1/overlappingrangeipreservation.go | 177 ---------------- pkg/controlloop/dummy_controller.go | 4 +- pkg/controlloop/pod.go | 6 +- pkg/controlloop/pod_controller_test.go | 4 +- .../clientset/versioned/clientset.go | 2 +- .../versioned/fake/clientset_generated.go | 12 +- .../clientset/versioned/fake/doc.go | 0 .../clientset/versioned/fake/register.go | 0 .../clientset/versioned/scheme/doc.go | 0 .../clientset/versioned/scheme/register.go | 0 .../whereabouts.cni.cncf.io/v1alpha1/doc.go | 0 .../v1alpha1/fake/doc.go | 0 .../v1alpha1/fake/fake_ippool.go | 29 +-- .../v1alpha1/fake/fake_nodeslicepool.go | 36 ++-- .../fake_overlappingrangeipreservation.go | 29 +-- .../fake_whereabouts.cni.cncf.io_client.go | 2 +- .../v1alpha1/generated_expansion.go | 0 .../v1alpha1/ippool.go | 66 ++++++ .../v1alpha1/nodeslicepool.go | 68 ++++++ .../v1alpha1/overlappingrangeipreservation.go | 68 ++++++ .../whereabouts.cni.cncf.io_client.go | 2 +- .../informers/externalversions/factory.go | 7 +- .../informers/externalversions/generic.go | 0 .../internalinterfaces/factory_interfaces.go | 2 +- .../whereabouts.cni.cncf.io/interface.go | 4 +- .../v1alpha1/interface.go | 2 +- .../v1alpha1/ippool.go | 6 +- .../v1alpha1/nodeslicepool.go | 6 +- .../v1alpha1/overlappingrangeipreservation.go | 6 +- .../v1alpha1/expansion_generated.go | 0 .../v1alpha1/ippool.go | 39 +--- .../v1alpha1/nodeslicepool.go | 39 +--- .../v1alpha1/overlappingrangeipreservation.go | 39 +--- pkg/node-controller/controller.go | 6 +- pkg/node-controller/controller_test.go | 13 +- pkg/reconciler/ip_test.go | 4 +- pkg/storage/kubernetes/client.go | 2 +- pkg/storage/kubernetes/ipam.go | 2 +- 47 files changed, 343 insertions(+), 750 deletions(-) delete mode 100644 pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/ippool.go delete mode 100644 pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/nodeslicepool.go delete mode 100644 pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/overlappingrangeipreservation.go rename pkg/{client => generated}/clientset/versioned/clientset.go (98%) rename pkg/{client => generated}/clientset/versioned/fake/clientset_generated.go (81%) rename pkg/{client => generated}/clientset/versioned/fake/doc.go (100%) rename pkg/{client => generated}/clientset/versioned/fake/register.go (100%) rename pkg/{client => generated}/clientset/versioned/scheme/doc.go (100%) rename pkg/{client => generated}/clientset/versioned/scheme/register.go (100%) rename pkg/{client => generated}/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/doc.go (100%) rename pkg/{client => generated}/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/doc.go (100%) rename pkg/{client => generated}/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/fake_ippool.go (79%) rename pkg/{client => generated}/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/fake_nodeslicepool.go (76%) rename pkg/{client => generated}/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/fake_overlappingrangeipreservation.go (78%) rename pkg/{client => generated}/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/fake_whereabouts.cni.cncf.io_client.go (91%) rename pkg/{client => generated}/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/generated_expansion.go (100%) create mode 100644 pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/ippool.go create mode 100644 pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/nodeslicepool.go create mode 100644 pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/overlappingrangeipreservation.go rename pkg/{client => generated}/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/whereabouts.cni.cncf.io_client.go (97%) rename pkg/{client => generated}/informers/externalversions/factory.go (96%) rename pkg/{client => generated}/informers/externalversions/generic.go (100%) rename pkg/{client => generated}/informers/externalversions/internalinterfaces/factory_interfaces.go (93%) rename pkg/{client => generated}/informers/externalversions/whereabouts.cni.cncf.io/interface.go (88%) rename pkg/{client => generated}/informers/externalversions/whereabouts.cni.cncf.io/v1alpha1/interface.go (97%) rename pkg/{client => generated}/informers/externalversions/whereabouts.cni.cncf.io/v1alpha1/ippool.go (92%) rename pkg/{client => generated}/informers/externalversions/whereabouts.cni.cncf.io/v1alpha1/nodeslicepool.go (93%) rename pkg/{client => generated}/informers/externalversions/whereabouts.cni.cncf.io/v1alpha1/overlappingrangeipreservation.go (93%) rename pkg/{client => generated}/listers/whereabouts.cni.cncf.io/v1alpha1/expansion_generated.go (100%) rename pkg/{client => generated}/listers/whereabouts.cni.cncf.io/v1alpha1/ippool.go (65%) rename pkg/{client => generated}/listers/whereabouts.cni.cncf.io/v1alpha1/nodeslicepool.go (65%) rename pkg/{client => generated}/listers/whereabouts.cni.cncf.io/v1alpha1/overlappingrangeipreservation.go (66%) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 48e3b59b1..efde4a3d2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,7 +36,7 @@ jobs: - name: Generate code if: steps.changed-files.outputs.any_changed == 'true' - run: chmod +x vendor/k8s.io/code-generator/generate-internal-groups.sh && ./hack/generate-code.sh && hack/verify-codegen.sh + run: ./hack/generate-code.sh && hack/verify-codegen.sh - name: Run go fmt if: steps.changed-files.outputs.any_changed == 'true' diff --git a/cmd/controlloop/controlloop.go b/cmd/controlloop/controlloop.go index e6a72c3ea..d94dec855 100644 --- a/cmd/controlloop/controlloop.go +++ b/cmd/controlloop/controlloop.go @@ -19,9 +19,9 @@ import ( nadclient "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/client/clientset/versioned" nadinformers "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/client/informers/externalversions" - wbclient "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned" - wbinformers "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/informers/externalversions" "github.com/k8snetworkplumbingwg/whereabouts/pkg/controlloop" + wbclient "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned" + wbinformers "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/informers/externalversions" "github.com/k8snetworkplumbingwg/whereabouts/pkg/logging" "github.com/k8snetworkplumbingwg/whereabouts/pkg/reconciler" ) diff --git a/cmd/nodeslicecontroller/node_slice_controller.go b/cmd/nodeslicecontroller/node_slice_controller.go index deec48f4b..4dbf09cb3 100644 --- a/cmd/nodeslicecontroller/node_slice_controller.go +++ b/cmd/nodeslicecontroller/node_slice_controller.go @@ -13,8 +13,8 @@ import ( "k8s.io/client-go/tools/clientcmd" "k8s.io/klog/v2" - clientset "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned" - informers "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/informers/externalversions" + clientset "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned" + informers "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/informers/externalversions" node_controller "github.com/k8snetworkplumbingwg/whereabouts/pkg/node-controller" "github.com/k8snetworkplumbingwg/whereabouts/pkg/node-controller/signals" ) diff --git a/cmd/whereabouts_test.go b/cmd/whereabouts_test.go index bf73f36f3..e93a1c54f 100644 --- a/cmd/whereabouts_test.go +++ b/cmd/whereabouts_test.go @@ -25,9 +25,9 @@ import ( "github.com/k8snetworkplumbingwg/whereabouts/pkg/allocate" "github.com/k8snetworkplumbingwg/whereabouts/pkg/api/whereabouts.cni.cncf.io/v1alpha1" - wbclientset "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned" - "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned/fake" "github.com/k8snetworkplumbingwg/whereabouts/pkg/config" + wbclientset "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned" + "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned/fake" "github.com/k8snetworkplumbingwg/whereabouts/pkg/storage/kubernetes" whereaboutstypes "github.com/k8snetworkplumbingwg/whereabouts/pkg/types" ) diff --git a/e2e/client/whereabouts.go b/e2e/client/whereabouts.go index 9ee4feb2a..09f5fef04 100644 --- a/e2e/client/whereabouts.go +++ b/e2e/client/whereabouts.go @@ -17,7 +17,7 @@ import ( "github.com/k8snetworkplumbingwg/whereabouts/e2e/entities" whereaboutscnicncfiov1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/api/whereabouts.cni.cncf.io/v1alpha1" - wbclient "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned" + wbclient "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned" ) const ( diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index 7d5eeee37..727bbe188 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -20,11 +20,15 @@ set -o pipefail SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. -bash ./vendor/k8s.io/code-generator/generate-groups.sh "client,informer,lister" \ - github.com/k8snetworkplumbingwg/whereabouts/pkg/client \ - github.com/k8snetworkplumbingwg/whereabouts/pkg/api \ - whereabouts.cni.cncf.io:v1alpha1 \ - --go-header-file "${SCRIPT_ROOT}"/hack/boilerplate.go.txt +CODEGEN_PKG=${CODEGEN_PKG:-$(cd "${SCRIPT_ROOT}"; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo ../code-generator)} +source "${CODEGEN_PKG}/kube_codegen.sh" -cp -r github.com/k8snetworkplumbingwg/whereabouts/pkg/client/* pkg/client +THIS_PKG="github.com/k8snetworkplumbingwg/whereabouts" + +kube::codegen::gen_client \ + --with-watch \ + --output-dir "${SCRIPT_ROOT}/pkg/generated" \ + --output-pkg "${THIS_PKG}/pkg/generated" \ + --boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \ + "${SCRIPT_ROOT}/pkg/api" diff --git a/hack/verify-codegen.sh b/hack/verify-codegen.sh index 5f0936a3e..23b6699e3 100755 --- a/hack/verify-codegen.sh +++ b/hack/verify-codegen.sh @@ -4,13 +4,12 @@ set -o errexit set -o nounset set -o pipefail -SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")/.. +SCRIPT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)" DIFFROOT="${SCRIPT_ROOT}/pkg" -TMP_DIFFROOT="${SCRIPT_ROOT}/_tmp/pkg" -_tmp="${SCRIPT_ROOT}/_tmp" +TMP_DIFFROOT="$(mktemp -d -t "$(basename "$0").XXXXXX")/pkg" cleanup() { - rm -rf "${_tmp}" + rm -rf "${TMP_DIFFROOT}" } trap "cleanup" EXIT SIGINT @@ -20,6 +19,7 @@ mkdir -p "${TMP_DIFFROOT}" cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}" "${SCRIPT_ROOT}/hack/update-codegen.sh" + echo "diffing ${DIFFROOT} against freshly generated codegen" ret=0 diff -Naupr "${DIFFROOT}" "${TMP_DIFFROOT}" || ret=$? diff --git a/pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/ippool.go b/pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/ippool.go deleted file mode 100644 index 2b1121ab5..000000000 --- a/pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/ippool.go +++ /dev/null @@ -1,177 +0,0 @@ -/* -Copyright 2024 The Kubernetes 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 client-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - "context" - "time" - - v1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/api/whereabouts.cni.cncf.io/v1alpha1" - scheme "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned/scheme" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" -) - -// IPPoolsGetter has a method to return a IPPoolInterface. -// A group's client should implement this interface. -type IPPoolsGetter interface { - IPPools(namespace string) IPPoolInterface -} - -// IPPoolInterface has methods to work with IPPool resources. -type IPPoolInterface interface { - Create(ctx context.Context, iPPool *v1alpha1.IPPool, opts v1.CreateOptions) (*v1alpha1.IPPool, error) - Update(ctx context.Context, iPPool *v1alpha1.IPPool, opts v1.UpdateOptions) (*v1alpha1.IPPool, error) - Delete(ctx context.Context, name string, opts v1.DeleteOptions) error - DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error - Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.IPPool, error) - List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.IPPoolList, error) - Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) - Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.IPPool, err error) - IPPoolExpansion -} - -// iPPools implements IPPoolInterface -type iPPools struct { - client rest.Interface - ns string -} - -// newIPPools returns a IPPools -func newIPPools(c *WhereaboutsV1alpha1Client, namespace string) *iPPools { - return &iPPools{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the iPPool, and returns the corresponding iPPool object, and an error if there is any. -func (c *iPPools) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.IPPool, err error) { - result = &v1alpha1.IPPool{} - err = c.client.Get(). - Namespace(c.ns). - Resource("ippools"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of IPPools that match those selectors. -func (c *iPPools) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.IPPoolList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.IPPoolList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("ippools"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested iPPools. -func (c *iPPools) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("ippools"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a iPPool and creates it. Returns the server's representation of the iPPool, and an error, if there is any. -func (c *iPPools) Create(ctx context.Context, iPPool *v1alpha1.IPPool, opts v1.CreateOptions) (result *v1alpha1.IPPool, err error) { - result = &v1alpha1.IPPool{} - err = c.client.Post(). - Namespace(c.ns). - Resource("ippools"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(iPPool). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a iPPool and updates it. Returns the server's representation of the iPPool, and an error, if there is any. -func (c *iPPools) Update(ctx context.Context, iPPool *v1alpha1.IPPool, opts v1.UpdateOptions) (result *v1alpha1.IPPool, err error) { - result = &v1alpha1.IPPool{} - err = c.client.Put(). - Namespace(c.ns). - Resource("ippools"). - Name(iPPool.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(iPPool). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the iPPool and deletes it. Returns an error if one occurs. -func (c *iPPools) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("ippools"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *iPPools) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("ippools"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched iPPool. -func (c *iPPools) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.IPPool, err error) { - result = &v1alpha1.IPPool{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("ippools"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/nodeslicepool.go b/pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/nodeslicepool.go deleted file mode 100644 index b099dd7f4..000000000 --- a/pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/nodeslicepool.go +++ /dev/null @@ -1,194 +0,0 @@ -/* -Copyright 2024 The Kubernetes 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 client-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - "context" - "time" - - v1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/api/whereabouts.cni.cncf.io/v1alpha1" - scheme "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned/scheme" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" -) - -// NodeSlicePoolsGetter has a method to return a NodeSlicePoolInterface. -// A group's client should implement this interface. -type NodeSlicePoolsGetter interface { - NodeSlicePools(namespace string) NodeSlicePoolInterface -} - -// NodeSlicePoolInterface has methods to work with NodeSlicePool resources. -type NodeSlicePoolInterface interface { - Create(ctx context.Context, nodeSlicePool *v1alpha1.NodeSlicePool, opts v1.CreateOptions) (*v1alpha1.NodeSlicePool, error) - Update(ctx context.Context, nodeSlicePool *v1alpha1.NodeSlicePool, opts v1.UpdateOptions) (*v1alpha1.NodeSlicePool, error) - UpdateStatus(ctx context.Context, nodeSlicePool *v1alpha1.NodeSlicePool, opts v1.UpdateOptions) (*v1alpha1.NodeSlicePool, error) - Delete(ctx context.Context, name string, opts v1.DeleteOptions) error - DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error - Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.NodeSlicePool, error) - List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.NodeSlicePoolList, error) - Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) - Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.NodeSlicePool, err error) - NodeSlicePoolExpansion -} - -// nodeSlicePools implements NodeSlicePoolInterface -type nodeSlicePools struct { - client rest.Interface - ns string -} - -// newNodeSlicePools returns a NodeSlicePools -func newNodeSlicePools(c *WhereaboutsV1alpha1Client, namespace string) *nodeSlicePools { - return &nodeSlicePools{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the nodeSlicePool, and returns the corresponding nodeSlicePool object, and an error if there is any. -func (c *nodeSlicePools) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.NodeSlicePool, err error) { - result = &v1alpha1.NodeSlicePool{} - err = c.client.Get(). - Namespace(c.ns). - Resource("nodeslicepools"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of NodeSlicePools that match those selectors. -func (c *nodeSlicePools) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.NodeSlicePoolList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.NodeSlicePoolList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("nodeslicepools"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested nodeSlicePools. -func (c *nodeSlicePools) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("nodeslicepools"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a nodeSlicePool and creates it. Returns the server's representation of the nodeSlicePool, and an error, if there is any. -func (c *nodeSlicePools) Create(ctx context.Context, nodeSlicePool *v1alpha1.NodeSlicePool, opts v1.CreateOptions) (result *v1alpha1.NodeSlicePool, err error) { - result = &v1alpha1.NodeSlicePool{} - err = c.client.Post(). - Namespace(c.ns). - Resource("nodeslicepools"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(nodeSlicePool). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a nodeSlicePool and updates it. Returns the server's representation of the nodeSlicePool, and an error, if there is any. -func (c *nodeSlicePools) Update(ctx context.Context, nodeSlicePool *v1alpha1.NodeSlicePool, opts v1.UpdateOptions) (result *v1alpha1.NodeSlicePool, err error) { - result = &v1alpha1.NodeSlicePool{} - err = c.client.Put(). - Namespace(c.ns). - Resource("nodeslicepools"). - Name(nodeSlicePool.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(nodeSlicePool). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *nodeSlicePools) UpdateStatus(ctx context.Context, nodeSlicePool *v1alpha1.NodeSlicePool, opts v1.UpdateOptions) (result *v1alpha1.NodeSlicePool, err error) { - result = &v1alpha1.NodeSlicePool{} - err = c.client.Put(). - Namespace(c.ns). - Resource("nodeslicepools"). - Name(nodeSlicePool.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(nodeSlicePool). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the nodeSlicePool and deletes it. Returns an error if one occurs. -func (c *nodeSlicePools) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("nodeslicepools"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *nodeSlicePools) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("nodeslicepools"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched nodeSlicePool. -func (c *nodeSlicePools) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.NodeSlicePool, err error) { - result = &v1alpha1.NodeSlicePool{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("nodeslicepools"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/overlappingrangeipreservation.go b/pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/overlappingrangeipreservation.go deleted file mode 100644 index 270e1dd76..000000000 --- a/pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/overlappingrangeipreservation.go +++ /dev/null @@ -1,177 +0,0 @@ -/* -Copyright 2024 The Kubernetes 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 client-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - "context" - "time" - - v1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/api/whereabouts.cni.cncf.io/v1alpha1" - scheme "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned/scheme" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" -) - -// OverlappingRangeIPReservationsGetter has a method to return a OverlappingRangeIPReservationInterface. -// A group's client should implement this interface. -type OverlappingRangeIPReservationsGetter interface { - OverlappingRangeIPReservations(namespace string) OverlappingRangeIPReservationInterface -} - -// OverlappingRangeIPReservationInterface has methods to work with OverlappingRangeIPReservation resources. -type OverlappingRangeIPReservationInterface interface { - Create(ctx context.Context, overlappingRangeIPReservation *v1alpha1.OverlappingRangeIPReservation, opts v1.CreateOptions) (*v1alpha1.OverlappingRangeIPReservation, error) - Update(ctx context.Context, overlappingRangeIPReservation *v1alpha1.OverlappingRangeIPReservation, opts v1.UpdateOptions) (*v1alpha1.OverlappingRangeIPReservation, error) - Delete(ctx context.Context, name string, opts v1.DeleteOptions) error - DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error - Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.OverlappingRangeIPReservation, error) - List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.OverlappingRangeIPReservationList, error) - Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) - Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.OverlappingRangeIPReservation, err error) - OverlappingRangeIPReservationExpansion -} - -// overlappingRangeIPReservations implements OverlappingRangeIPReservationInterface -type overlappingRangeIPReservations struct { - client rest.Interface - ns string -} - -// newOverlappingRangeIPReservations returns a OverlappingRangeIPReservations -func newOverlappingRangeIPReservations(c *WhereaboutsV1alpha1Client, namespace string) *overlappingRangeIPReservations { - return &overlappingRangeIPReservations{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the overlappingRangeIPReservation, and returns the corresponding overlappingRangeIPReservation object, and an error if there is any. -func (c *overlappingRangeIPReservations) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.OverlappingRangeIPReservation, err error) { - result = &v1alpha1.OverlappingRangeIPReservation{} - err = c.client.Get(). - Namespace(c.ns). - Resource("overlappingrangeipreservations"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of OverlappingRangeIPReservations that match those selectors. -func (c *overlappingRangeIPReservations) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.OverlappingRangeIPReservationList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.OverlappingRangeIPReservationList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("overlappingrangeipreservations"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested overlappingRangeIPReservations. -func (c *overlappingRangeIPReservations) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("overlappingrangeipreservations"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a overlappingRangeIPReservation and creates it. Returns the server's representation of the overlappingRangeIPReservation, and an error, if there is any. -func (c *overlappingRangeIPReservations) Create(ctx context.Context, overlappingRangeIPReservation *v1alpha1.OverlappingRangeIPReservation, opts v1.CreateOptions) (result *v1alpha1.OverlappingRangeIPReservation, err error) { - result = &v1alpha1.OverlappingRangeIPReservation{} - err = c.client.Post(). - Namespace(c.ns). - Resource("overlappingrangeipreservations"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(overlappingRangeIPReservation). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a overlappingRangeIPReservation and updates it. Returns the server's representation of the overlappingRangeIPReservation, and an error, if there is any. -func (c *overlappingRangeIPReservations) Update(ctx context.Context, overlappingRangeIPReservation *v1alpha1.OverlappingRangeIPReservation, opts v1.UpdateOptions) (result *v1alpha1.OverlappingRangeIPReservation, err error) { - result = &v1alpha1.OverlappingRangeIPReservation{} - err = c.client.Put(). - Namespace(c.ns). - Resource("overlappingrangeipreservations"). - Name(overlappingRangeIPReservation.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(overlappingRangeIPReservation). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the overlappingRangeIPReservation and deletes it. Returns an error if one occurs. -func (c *overlappingRangeIPReservations) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("overlappingrangeipreservations"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *overlappingRangeIPReservations) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("overlappingrangeipreservations"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched overlappingRangeIPReservation. -func (c *overlappingRangeIPReservations) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.OverlappingRangeIPReservation, err error) { - result = &v1alpha1.OverlappingRangeIPReservation{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("overlappingrangeipreservations"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/controlloop/dummy_controller.go b/pkg/controlloop/dummy_controller.go index 05e873352..5cc1b065c 100644 --- a/pkg/controlloop/dummy_controller.go +++ b/pkg/controlloop/dummy_controller.go @@ -18,8 +18,8 @@ import ( nadinformers "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/client/informers/externalversions" "github.com/k8snetworkplumbingwg/whereabouts/pkg/api/whereabouts.cni.cncf.io/v1alpha1" - wbclient "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned" - wbinformers "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/informers/externalversions" + wbclient "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned" + wbinformers "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/informers/externalversions" "github.com/k8snetworkplumbingwg/whereabouts/pkg/types" ) diff --git a/pkg/controlloop/pod.go b/pkg/controlloop/pod.go index 06183ae65..666b20e9b 100644 --- a/pkg/controlloop/pod.go +++ b/pkg/controlloop/pod.go @@ -28,10 +28,10 @@ import ( "github.com/pkg/errors" whereaboutsv1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/api/whereabouts.cni.cncf.io/v1alpha1" - wbclientset "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned" - wbinformers "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/informers/externalversions" - wblister "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/listers/whereabouts.cni.cncf.io/v1alpha1" "github.com/k8snetworkplumbingwg/whereabouts/pkg/config" + wbclientset "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned" + wbinformers "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/informers/externalversions" + wblister "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/listers/whereabouts.cni.cncf.io/v1alpha1" "github.com/k8snetworkplumbingwg/whereabouts/pkg/iphelpers" "github.com/k8snetworkplumbingwg/whereabouts/pkg/logging" wbclient "github.com/k8snetworkplumbingwg/whereabouts/pkg/storage/kubernetes" diff --git a/pkg/controlloop/pod_controller_test.go b/pkg/controlloop/pod_controller_test.go index 4d295b335..a0eac3527 100644 --- a/pkg/controlloop/pod_controller_test.go +++ b/pkg/controlloop/pod_controller_test.go @@ -24,8 +24,8 @@ import ( fakenadclient "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/client/clientset/versioned/fake" "github.com/k8snetworkplumbingwg/whereabouts/pkg/api/whereabouts.cni.cncf.io/v1alpha1" - wbclient "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned" - fakewbclient "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned/fake" + wbclient "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned" + fakewbclient "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned/fake" "github.com/k8snetworkplumbingwg/whereabouts/pkg/storage/kubernetes" ) diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/generated/clientset/versioned/clientset.go similarity index 98% rename from pkg/client/clientset/versioned/clientset.go rename to pkg/generated/clientset/versioned/clientset.go index d7428255e..41a23a3e7 100644 --- a/pkg/client/clientset/versioned/clientset.go +++ b/pkg/generated/clientset/versioned/clientset.go @@ -21,7 +21,7 @@ import ( "fmt" "net/http" - whereaboutsv1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1" + whereaboutsv1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" diff --git a/pkg/client/clientset/versioned/fake/clientset_generated.go b/pkg/generated/clientset/versioned/fake/clientset_generated.go similarity index 81% rename from pkg/client/clientset/versioned/fake/clientset_generated.go rename to pkg/generated/clientset/versioned/fake/clientset_generated.go index 48d817aea..1d99b7ea3 100644 --- a/pkg/client/clientset/versioned/fake/clientset_generated.go +++ b/pkg/generated/clientset/versioned/fake/clientset_generated.go @@ -18,9 +18,9 @@ limitations under the License. package fake import ( - clientset "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned" - whereaboutsv1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1" - fakewhereaboutsv1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake" + clientset "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned" + whereaboutsv1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1" + fakewhereaboutsv1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/discovery" @@ -30,8 +30,12 @@ import ( // 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) *Clientset { o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) for _, obj := range objects { diff --git a/pkg/client/clientset/versioned/fake/doc.go b/pkg/generated/clientset/versioned/fake/doc.go similarity index 100% rename from pkg/client/clientset/versioned/fake/doc.go rename to pkg/generated/clientset/versioned/fake/doc.go diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/generated/clientset/versioned/fake/register.go similarity index 100% rename from pkg/client/clientset/versioned/fake/register.go rename to pkg/generated/clientset/versioned/fake/register.go diff --git a/pkg/client/clientset/versioned/scheme/doc.go b/pkg/generated/clientset/versioned/scheme/doc.go similarity index 100% rename from pkg/client/clientset/versioned/scheme/doc.go rename to pkg/generated/clientset/versioned/scheme/doc.go diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/generated/clientset/versioned/scheme/register.go similarity index 100% rename from pkg/client/clientset/versioned/scheme/register.go rename to pkg/generated/clientset/versioned/scheme/register.go diff --git a/pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/doc.go b/pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/doc.go similarity index 100% rename from pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/doc.go rename to pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/doc.go diff --git a/pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/doc.go b/pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/doc.go similarity index 100% rename from pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/doc.go rename to pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/doc.go diff --git a/pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/fake_ippool.go b/pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/fake_ippool.go similarity index 79% rename from pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/fake_ippool.go rename to pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/fake_ippool.go index 01fbd3dfa..aeb84d0e3 100644 --- a/pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/fake_ippool.go +++ b/pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/fake_ippool.go @@ -40,22 +40,24 @@ var ippoolsKind = v1alpha1.SchemeGroupVersion.WithKind("IPPool") // Get takes name of the iPPool, and returns the corresponding iPPool object, and an error if there is any. func (c *FakeIPPools) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.IPPool, err error) { + emptyResult := &v1alpha1.IPPool{} obj, err := c.Fake. - Invokes(testing.NewGetAction(ippoolsResource, c.ns, name), &v1alpha1.IPPool{}) + Invokes(testing.NewGetActionWithOptions(ippoolsResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.IPPool), err } // List takes label and field selectors, and returns the list of IPPools that match those selectors. func (c *FakeIPPools) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.IPPoolList, err error) { + emptyResult := &v1alpha1.IPPoolList{} obj, err := c.Fake. - Invokes(testing.NewListAction(ippoolsResource, ippoolsKind, c.ns, opts), &v1alpha1.IPPoolList{}) + Invokes(testing.NewListActionWithOptions(ippoolsResource, ippoolsKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -74,28 +76,30 @@ func (c *FakeIPPools) List(ctx context.Context, opts v1.ListOptions) (result *v1 // Watch returns a watch.Interface that watches the requested iPPools. func (c *FakeIPPools) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(ippoolsResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(ippoolsResource, c.ns, opts)) } // Create takes the representation of a iPPool and creates it. Returns the server's representation of the iPPool, and an error, if there is any. func (c *FakeIPPools) Create(ctx context.Context, iPPool *v1alpha1.IPPool, opts v1.CreateOptions) (result *v1alpha1.IPPool, err error) { + emptyResult := &v1alpha1.IPPool{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(ippoolsResource, c.ns, iPPool), &v1alpha1.IPPool{}) + Invokes(testing.NewCreateActionWithOptions(ippoolsResource, c.ns, iPPool, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.IPPool), err } // Update takes the representation of a iPPool and updates it. Returns the server's representation of the iPPool, and an error, if there is any. func (c *FakeIPPools) Update(ctx context.Context, iPPool *v1alpha1.IPPool, opts v1.UpdateOptions) (result *v1alpha1.IPPool, err error) { + emptyResult := &v1alpha1.IPPool{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(ippoolsResource, c.ns, iPPool), &v1alpha1.IPPool{}) + Invokes(testing.NewUpdateActionWithOptions(ippoolsResource, c.ns, iPPool, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.IPPool), err } @@ -110,7 +114,7 @@ func (c *FakeIPPools) Delete(ctx context.Context, name string, opts v1.DeleteOpt // DeleteCollection deletes a collection of objects. func (c *FakeIPPools) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(ippoolsResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(ippoolsResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1alpha1.IPPoolList{}) return err @@ -118,11 +122,12 @@ func (c *FakeIPPools) DeleteCollection(ctx context.Context, opts v1.DeleteOption // Patch applies the patch and returns the patched iPPool. func (c *FakeIPPools) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.IPPool, err error) { + emptyResult := &v1alpha1.IPPool{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(ippoolsResource, c.ns, name, pt, data, subresources...), &v1alpha1.IPPool{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(ippoolsResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.IPPool), err } diff --git a/pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/fake_nodeslicepool.go b/pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/fake_nodeslicepool.go similarity index 76% rename from pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/fake_nodeslicepool.go rename to pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/fake_nodeslicepool.go index a12e4a431..c2b729fe4 100644 --- a/pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/fake_nodeslicepool.go +++ b/pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/fake_nodeslicepool.go @@ -40,22 +40,24 @@ var nodeslicepoolsKind = v1alpha1.SchemeGroupVersion.WithKind("NodeSlicePool") // Get takes name of the nodeSlicePool, and returns the corresponding nodeSlicePool object, and an error if there is any. func (c *FakeNodeSlicePools) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.NodeSlicePool, err error) { + emptyResult := &v1alpha1.NodeSlicePool{} obj, err := c.Fake. - Invokes(testing.NewGetAction(nodeslicepoolsResource, c.ns, name), &v1alpha1.NodeSlicePool{}) + Invokes(testing.NewGetActionWithOptions(nodeslicepoolsResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.NodeSlicePool), err } // List takes label and field selectors, and returns the list of NodeSlicePools that match those selectors. func (c *FakeNodeSlicePools) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.NodeSlicePoolList, err error) { + emptyResult := &v1alpha1.NodeSlicePoolList{} obj, err := c.Fake. - Invokes(testing.NewListAction(nodeslicepoolsResource, nodeslicepoolsKind, c.ns, opts), &v1alpha1.NodeSlicePoolList{}) + Invokes(testing.NewListActionWithOptions(nodeslicepoolsResource, nodeslicepoolsKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -74,40 +76,43 @@ func (c *FakeNodeSlicePools) List(ctx context.Context, opts v1.ListOptions) (res // Watch returns a watch.Interface that watches the requested nodeSlicePools. func (c *FakeNodeSlicePools) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(nodeslicepoolsResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(nodeslicepoolsResource, c.ns, opts)) } // Create takes the representation of a nodeSlicePool and creates it. Returns the server's representation of the nodeSlicePool, and an error, if there is any. func (c *FakeNodeSlicePools) Create(ctx context.Context, nodeSlicePool *v1alpha1.NodeSlicePool, opts v1.CreateOptions) (result *v1alpha1.NodeSlicePool, err error) { + emptyResult := &v1alpha1.NodeSlicePool{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(nodeslicepoolsResource, c.ns, nodeSlicePool), &v1alpha1.NodeSlicePool{}) + Invokes(testing.NewCreateActionWithOptions(nodeslicepoolsResource, c.ns, nodeSlicePool, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.NodeSlicePool), err } // Update takes the representation of a nodeSlicePool and updates it. Returns the server's representation of the nodeSlicePool, and an error, if there is any. func (c *FakeNodeSlicePools) Update(ctx context.Context, nodeSlicePool *v1alpha1.NodeSlicePool, opts v1.UpdateOptions) (result *v1alpha1.NodeSlicePool, err error) { + emptyResult := &v1alpha1.NodeSlicePool{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(nodeslicepoolsResource, c.ns, nodeSlicePool), &v1alpha1.NodeSlicePool{}) + Invokes(testing.NewUpdateActionWithOptions(nodeslicepoolsResource, c.ns, nodeSlicePool, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.NodeSlicePool), 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 *FakeNodeSlicePools) UpdateStatus(ctx context.Context, nodeSlicePool *v1alpha1.NodeSlicePool, opts v1.UpdateOptions) (*v1alpha1.NodeSlicePool, error) { +func (c *FakeNodeSlicePools) UpdateStatus(ctx context.Context, nodeSlicePool *v1alpha1.NodeSlicePool, opts v1.UpdateOptions) (result *v1alpha1.NodeSlicePool, err error) { + emptyResult := &v1alpha1.NodeSlicePool{} obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(nodeslicepoolsResource, "status", c.ns, nodeSlicePool), &v1alpha1.NodeSlicePool{}) + Invokes(testing.NewUpdateSubresourceActionWithOptions(nodeslicepoolsResource, "status", c.ns, nodeSlicePool, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.NodeSlicePool), err } @@ -122,7 +127,7 @@ func (c *FakeNodeSlicePools) Delete(ctx context.Context, name string, opts v1.De // DeleteCollection deletes a collection of objects. func (c *FakeNodeSlicePools) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(nodeslicepoolsResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(nodeslicepoolsResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1alpha1.NodeSlicePoolList{}) return err @@ -130,11 +135,12 @@ func (c *FakeNodeSlicePools) DeleteCollection(ctx context.Context, opts v1.Delet // Patch applies the patch and returns the patched nodeSlicePool. func (c *FakeNodeSlicePools) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.NodeSlicePool, err error) { + emptyResult := &v1alpha1.NodeSlicePool{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(nodeslicepoolsResource, c.ns, name, pt, data, subresources...), &v1alpha1.NodeSlicePool{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(nodeslicepoolsResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.NodeSlicePool), err } diff --git a/pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/fake_overlappingrangeipreservation.go b/pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/fake_overlappingrangeipreservation.go similarity index 78% rename from pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/fake_overlappingrangeipreservation.go rename to pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/fake_overlappingrangeipreservation.go index d0869d3d0..1656c08a1 100644 --- a/pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/fake_overlappingrangeipreservation.go +++ b/pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/fake_overlappingrangeipreservation.go @@ -40,22 +40,24 @@ var overlappingrangeipreservationsKind = v1alpha1.SchemeGroupVersion.WithKind("O // Get takes name of the overlappingRangeIPReservation, and returns the corresponding overlappingRangeIPReservation object, and an error if there is any. func (c *FakeOverlappingRangeIPReservations) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.OverlappingRangeIPReservation, err error) { + emptyResult := &v1alpha1.OverlappingRangeIPReservation{} obj, err := c.Fake. - Invokes(testing.NewGetAction(overlappingrangeipreservationsResource, c.ns, name), &v1alpha1.OverlappingRangeIPReservation{}) + Invokes(testing.NewGetActionWithOptions(overlappingrangeipreservationsResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.OverlappingRangeIPReservation), err } // List takes label and field selectors, and returns the list of OverlappingRangeIPReservations that match those selectors. func (c *FakeOverlappingRangeIPReservations) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.OverlappingRangeIPReservationList, err error) { + emptyResult := &v1alpha1.OverlappingRangeIPReservationList{} obj, err := c.Fake. - Invokes(testing.NewListAction(overlappingrangeipreservationsResource, overlappingrangeipreservationsKind, c.ns, opts), &v1alpha1.OverlappingRangeIPReservationList{}) + Invokes(testing.NewListActionWithOptions(overlappingrangeipreservationsResource, overlappingrangeipreservationsKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -74,28 +76,30 @@ func (c *FakeOverlappingRangeIPReservations) List(ctx context.Context, opts v1.L // Watch returns a watch.Interface that watches the requested overlappingRangeIPReservations. func (c *FakeOverlappingRangeIPReservations) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(overlappingrangeipreservationsResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(overlappingrangeipreservationsResource, c.ns, opts)) } // Create takes the representation of a overlappingRangeIPReservation and creates it. Returns the server's representation of the overlappingRangeIPReservation, and an error, if there is any. func (c *FakeOverlappingRangeIPReservations) Create(ctx context.Context, overlappingRangeIPReservation *v1alpha1.OverlappingRangeIPReservation, opts v1.CreateOptions) (result *v1alpha1.OverlappingRangeIPReservation, err error) { + emptyResult := &v1alpha1.OverlappingRangeIPReservation{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(overlappingrangeipreservationsResource, c.ns, overlappingRangeIPReservation), &v1alpha1.OverlappingRangeIPReservation{}) + Invokes(testing.NewCreateActionWithOptions(overlappingrangeipreservationsResource, c.ns, overlappingRangeIPReservation, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.OverlappingRangeIPReservation), err } // Update takes the representation of a overlappingRangeIPReservation and updates it. Returns the server's representation of the overlappingRangeIPReservation, and an error, if there is any. func (c *FakeOverlappingRangeIPReservations) Update(ctx context.Context, overlappingRangeIPReservation *v1alpha1.OverlappingRangeIPReservation, opts v1.UpdateOptions) (result *v1alpha1.OverlappingRangeIPReservation, err error) { + emptyResult := &v1alpha1.OverlappingRangeIPReservation{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(overlappingrangeipreservationsResource, c.ns, overlappingRangeIPReservation), &v1alpha1.OverlappingRangeIPReservation{}) + Invokes(testing.NewUpdateActionWithOptions(overlappingrangeipreservationsResource, c.ns, overlappingRangeIPReservation, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.OverlappingRangeIPReservation), err } @@ -110,7 +114,7 @@ func (c *FakeOverlappingRangeIPReservations) Delete(ctx context.Context, name st // DeleteCollection deletes a collection of objects. func (c *FakeOverlappingRangeIPReservations) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(overlappingrangeipreservationsResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(overlappingrangeipreservationsResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1alpha1.OverlappingRangeIPReservationList{}) return err @@ -118,11 +122,12 @@ func (c *FakeOverlappingRangeIPReservations) DeleteCollection(ctx context.Contex // Patch applies the patch and returns the patched overlappingRangeIPReservation. func (c *FakeOverlappingRangeIPReservations) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.OverlappingRangeIPReservation, err error) { + emptyResult := &v1alpha1.OverlappingRangeIPReservation{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(overlappingrangeipreservationsResource, c.ns, name, pt, data, subresources...), &v1alpha1.OverlappingRangeIPReservation{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(overlappingrangeipreservationsResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.OverlappingRangeIPReservation), err } diff --git a/pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/fake_whereabouts.cni.cncf.io_client.go b/pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/fake_whereabouts.cni.cncf.io_client.go similarity index 91% rename from pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/fake_whereabouts.cni.cncf.io_client.go rename to pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/fake_whereabouts.cni.cncf.io_client.go index b8aa1b141..79c1bb255 100644 --- a/pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/fake_whereabouts.cni.cncf.io_client.go +++ b/pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/fake/fake_whereabouts.cni.cncf.io_client.go @@ -18,7 +18,7 @@ limitations under the License. package fake import ( - v1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1" + v1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1" rest "k8s.io/client-go/rest" testing "k8s.io/client-go/testing" ) diff --git a/pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/generated_expansion.go b/pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/generated_expansion.go similarity index 100% rename from pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/generated_expansion.go rename to pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/generated_expansion.go diff --git a/pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/ippool.go b/pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/ippool.go new file mode 100644 index 000000000..9fa2ada06 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/ippool.go @@ -0,0 +1,66 @@ +/* +Copyright 2024 The Kubernetes 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 client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + + v1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/api/whereabouts.cni.cncf.io/v1alpha1" + scheme "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + gentype "k8s.io/client-go/gentype" +) + +// IPPoolsGetter has a method to return a IPPoolInterface. +// A group's client should implement this interface. +type IPPoolsGetter interface { + IPPools(namespace string) IPPoolInterface +} + +// IPPoolInterface has methods to work with IPPool resources. +type IPPoolInterface interface { + Create(ctx context.Context, iPPool *v1alpha1.IPPool, opts v1.CreateOptions) (*v1alpha1.IPPool, error) + Update(ctx context.Context, iPPool *v1alpha1.IPPool, opts v1.UpdateOptions) (*v1alpha1.IPPool, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.IPPool, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.IPPoolList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.IPPool, err error) + IPPoolExpansion +} + +// iPPools implements IPPoolInterface +type iPPools struct { + *gentype.ClientWithList[*v1alpha1.IPPool, *v1alpha1.IPPoolList] +} + +// newIPPools returns a IPPools +func newIPPools(c *WhereaboutsV1alpha1Client, namespace string) *iPPools { + return &iPPools{ + gentype.NewClientWithList[*v1alpha1.IPPool, *v1alpha1.IPPoolList]( + "ippools", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1alpha1.IPPool { return &v1alpha1.IPPool{} }, + func() *v1alpha1.IPPoolList { return &v1alpha1.IPPoolList{} }), + } +} diff --git a/pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/nodeslicepool.go b/pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/nodeslicepool.go new file mode 100644 index 000000000..0deaf953d --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/nodeslicepool.go @@ -0,0 +1,68 @@ +/* +Copyright 2024 The Kubernetes 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 client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + + v1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/api/whereabouts.cni.cncf.io/v1alpha1" + scheme "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + gentype "k8s.io/client-go/gentype" +) + +// NodeSlicePoolsGetter has a method to return a NodeSlicePoolInterface. +// A group's client should implement this interface. +type NodeSlicePoolsGetter interface { + NodeSlicePools(namespace string) NodeSlicePoolInterface +} + +// NodeSlicePoolInterface has methods to work with NodeSlicePool resources. +type NodeSlicePoolInterface interface { + Create(ctx context.Context, nodeSlicePool *v1alpha1.NodeSlicePool, opts v1.CreateOptions) (*v1alpha1.NodeSlicePool, error) + Update(ctx context.Context, nodeSlicePool *v1alpha1.NodeSlicePool, opts v1.UpdateOptions) (*v1alpha1.NodeSlicePool, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, nodeSlicePool *v1alpha1.NodeSlicePool, opts v1.UpdateOptions) (*v1alpha1.NodeSlicePool, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.NodeSlicePool, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.NodeSlicePoolList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.NodeSlicePool, err error) + NodeSlicePoolExpansion +} + +// nodeSlicePools implements NodeSlicePoolInterface +type nodeSlicePools struct { + *gentype.ClientWithList[*v1alpha1.NodeSlicePool, *v1alpha1.NodeSlicePoolList] +} + +// newNodeSlicePools returns a NodeSlicePools +func newNodeSlicePools(c *WhereaboutsV1alpha1Client, namespace string) *nodeSlicePools { + return &nodeSlicePools{ + gentype.NewClientWithList[*v1alpha1.NodeSlicePool, *v1alpha1.NodeSlicePoolList]( + "nodeslicepools", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1alpha1.NodeSlicePool { return &v1alpha1.NodeSlicePool{} }, + func() *v1alpha1.NodeSlicePoolList { return &v1alpha1.NodeSlicePoolList{} }), + } +} diff --git a/pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/overlappingrangeipreservation.go b/pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/overlappingrangeipreservation.go new file mode 100644 index 000000000..1883f0708 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/overlappingrangeipreservation.go @@ -0,0 +1,68 @@ +/* +Copyright 2024 The Kubernetes 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 client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + + v1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/api/whereabouts.cni.cncf.io/v1alpha1" + scheme "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + gentype "k8s.io/client-go/gentype" +) + +// OverlappingRangeIPReservationsGetter has a method to return a OverlappingRangeIPReservationInterface. +// A group's client should implement this interface. +type OverlappingRangeIPReservationsGetter interface { + OverlappingRangeIPReservations(namespace string) OverlappingRangeIPReservationInterface +} + +// OverlappingRangeIPReservationInterface has methods to work with OverlappingRangeIPReservation resources. +type OverlappingRangeIPReservationInterface interface { + Create(ctx context.Context, overlappingRangeIPReservation *v1alpha1.OverlappingRangeIPReservation, opts v1.CreateOptions) (*v1alpha1.OverlappingRangeIPReservation, error) + Update(ctx context.Context, overlappingRangeIPReservation *v1alpha1.OverlappingRangeIPReservation, opts v1.UpdateOptions) (*v1alpha1.OverlappingRangeIPReservation, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.OverlappingRangeIPReservation, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.OverlappingRangeIPReservationList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.OverlappingRangeIPReservation, err error) + OverlappingRangeIPReservationExpansion +} + +// overlappingRangeIPReservations implements OverlappingRangeIPReservationInterface +type overlappingRangeIPReservations struct { + *gentype.ClientWithList[*v1alpha1.OverlappingRangeIPReservation, *v1alpha1.OverlappingRangeIPReservationList] +} + +// newOverlappingRangeIPReservations returns a OverlappingRangeIPReservations +func newOverlappingRangeIPReservations(c *WhereaboutsV1alpha1Client, namespace string) *overlappingRangeIPReservations { + return &overlappingRangeIPReservations{ + gentype.NewClientWithList[*v1alpha1.OverlappingRangeIPReservation, *v1alpha1.OverlappingRangeIPReservationList]( + "overlappingrangeipreservations", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1alpha1.OverlappingRangeIPReservation { return &v1alpha1.OverlappingRangeIPReservation{} }, + func() *v1alpha1.OverlappingRangeIPReservationList { + return &v1alpha1.OverlappingRangeIPReservationList{} + }), + } +} diff --git a/pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/whereabouts.cni.cncf.io_client.go b/pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/whereabouts.cni.cncf.io_client.go similarity index 97% rename from pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/whereabouts.cni.cncf.io_client.go rename to pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/whereabouts.cni.cncf.io_client.go index c841c614e..aaaca150c 100644 --- a/pkg/client/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/whereabouts.cni.cncf.io_client.go +++ b/pkg/generated/clientset/versioned/typed/whereabouts.cni.cncf.io/v1alpha1/whereabouts.cni.cncf.io_client.go @@ -21,7 +21,7 @@ import ( "net/http" v1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/api/whereabouts.cni.cncf.io/v1alpha1" - "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned/scheme" + "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned/scheme" rest "k8s.io/client-go/rest" ) diff --git a/pkg/client/informers/externalversions/factory.go b/pkg/generated/informers/externalversions/factory.go similarity index 96% rename from pkg/client/informers/externalversions/factory.go rename to pkg/generated/informers/externalversions/factory.go index 7ef8f0412..2de15ae05 100644 --- a/pkg/client/informers/externalversions/factory.go +++ b/pkg/generated/informers/externalversions/factory.go @@ -22,9 +22,9 @@ import ( sync "sync" time "time" - versioned "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned" - internalinterfaces "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/informers/externalversions/internalinterfaces" - whereaboutscnicncfio "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/informers/externalversions/whereabouts.cni.cncf.io" + versioned "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned" + internalinterfaces "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/informers/externalversions/internalinterfaces" + whereaboutscnicncfio "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/informers/externalversions/whereabouts.cni.cncf.io" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -227,6 +227,7 @@ type SharedInformerFactory interface { // 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 diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/generated/informers/externalversions/generic.go similarity index 100% rename from pkg/client/informers/externalversions/generic.go rename to pkg/generated/informers/externalversions/generic.go diff --git a/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go b/pkg/generated/informers/externalversions/internalinterfaces/factory_interfaces.go similarity index 93% rename from pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go rename to pkg/generated/informers/externalversions/internalinterfaces/factory_interfaces.go index f3aa10f12..67a8af4c0 100644 --- a/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go +++ b/pkg/generated/informers/externalversions/internalinterfaces/factory_interfaces.go @@ -20,7 +20,7 @@ package internalinterfaces import ( time "time" - versioned "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned" + versioned "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" cache "k8s.io/client-go/tools/cache" diff --git a/pkg/client/informers/externalversions/whereabouts.cni.cncf.io/interface.go b/pkg/generated/informers/externalversions/whereabouts.cni.cncf.io/interface.go similarity index 88% rename from pkg/client/informers/externalversions/whereabouts.cni.cncf.io/interface.go rename to pkg/generated/informers/externalversions/whereabouts.cni.cncf.io/interface.go index 169acc062..c9f75307f 100644 --- a/pkg/client/informers/externalversions/whereabouts.cni.cncf.io/interface.go +++ b/pkg/generated/informers/externalversions/whereabouts.cni.cncf.io/interface.go @@ -18,8 +18,8 @@ limitations under the License. package whereabouts import ( - internalinterfaces "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/informers/externalversions/internalinterfaces" - v1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/informers/externalversions/whereabouts.cni.cncf.io/v1alpha1" + internalinterfaces "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/informers/externalversions/whereabouts.cni.cncf.io/v1alpha1" ) // Interface provides access to each of this group's versions. diff --git a/pkg/client/informers/externalversions/whereabouts.cni.cncf.io/v1alpha1/interface.go b/pkg/generated/informers/externalversions/whereabouts.cni.cncf.io/v1alpha1/interface.go similarity index 97% rename from pkg/client/informers/externalversions/whereabouts.cni.cncf.io/v1alpha1/interface.go rename to pkg/generated/informers/externalversions/whereabouts.cni.cncf.io/v1alpha1/interface.go index e2546214d..ede4f8e13 100644 --- a/pkg/client/informers/externalversions/whereabouts.cni.cncf.io/v1alpha1/interface.go +++ b/pkg/generated/informers/externalversions/whereabouts.cni.cncf.io/v1alpha1/interface.go @@ -18,7 +18,7 @@ limitations under the License. package v1alpha1 import ( - internalinterfaces "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/informers/externalversions/internalinterfaces" + internalinterfaces "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/informers/externalversions/internalinterfaces" ) // Interface provides access to all the informers in this group version. diff --git a/pkg/client/informers/externalversions/whereabouts.cni.cncf.io/v1alpha1/ippool.go b/pkg/generated/informers/externalversions/whereabouts.cni.cncf.io/v1alpha1/ippool.go similarity index 92% rename from pkg/client/informers/externalversions/whereabouts.cni.cncf.io/v1alpha1/ippool.go rename to pkg/generated/informers/externalversions/whereabouts.cni.cncf.io/v1alpha1/ippool.go index ecab2edea..8c22e96f0 100644 --- a/pkg/client/informers/externalversions/whereabouts.cni.cncf.io/v1alpha1/ippool.go +++ b/pkg/generated/informers/externalversions/whereabouts.cni.cncf.io/v1alpha1/ippool.go @@ -22,9 +22,9 @@ import ( time "time" whereaboutscnicncfiov1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/api/whereabouts.cni.cncf.io/v1alpha1" - versioned "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned" - internalinterfaces "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/informers/externalversions/internalinterfaces" - v1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/listers/whereabouts.cni.cncf.io/v1alpha1" + versioned "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned" + internalinterfaces "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/listers/whereabouts.cni.cncf.io/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" diff --git a/pkg/client/informers/externalversions/whereabouts.cni.cncf.io/v1alpha1/nodeslicepool.go b/pkg/generated/informers/externalversions/whereabouts.cni.cncf.io/v1alpha1/nodeslicepool.go similarity index 93% rename from pkg/client/informers/externalversions/whereabouts.cni.cncf.io/v1alpha1/nodeslicepool.go rename to pkg/generated/informers/externalversions/whereabouts.cni.cncf.io/v1alpha1/nodeslicepool.go index 39ea336fa..45cb2befd 100644 --- a/pkg/client/informers/externalversions/whereabouts.cni.cncf.io/v1alpha1/nodeslicepool.go +++ b/pkg/generated/informers/externalversions/whereabouts.cni.cncf.io/v1alpha1/nodeslicepool.go @@ -22,9 +22,9 @@ import ( time "time" whereaboutscnicncfiov1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/api/whereabouts.cni.cncf.io/v1alpha1" - versioned "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned" - internalinterfaces "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/informers/externalversions/internalinterfaces" - v1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/listers/whereabouts.cni.cncf.io/v1alpha1" + versioned "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned" + internalinterfaces "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/listers/whereabouts.cni.cncf.io/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" diff --git a/pkg/client/informers/externalversions/whereabouts.cni.cncf.io/v1alpha1/overlappingrangeipreservation.go b/pkg/generated/informers/externalversions/whereabouts.cni.cncf.io/v1alpha1/overlappingrangeipreservation.go similarity index 93% rename from pkg/client/informers/externalversions/whereabouts.cni.cncf.io/v1alpha1/overlappingrangeipreservation.go rename to pkg/generated/informers/externalversions/whereabouts.cni.cncf.io/v1alpha1/overlappingrangeipreservation.go index 11af24ce6..23bd892c4 100644 --- a/pkg/client/informers/externalversions/whereabouts.cni.cncf.io/v1alpha1/overlappingrangeipreservation.go +++ b/pkg/generated/informers/externalversions/whereabouts.cni.cncf.io/v1alpha1/overlappingrangeipreservation.go @@ -22,9 +22,9 @@ import ( time "time" whereaboutscnicncfiov1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/api/whereabouts.cni.cncf.io/v1alpha1" - versioned "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned" - internalinterfaces "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/informers/externalversions/internalinterfaces" - v1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/listers/whereabouts.cni.cncf.io/v1alpha1" + versioned "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned" + internalinterfaces "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/listers/whereabouts.cni.cncf.io/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" diff --git a/pkg/client/listers/whereabouts.cni.cncf.io/v1alpha1/expansion_generated.go b/pkg/generated/listers/whereabouts.cni.cncf.io/v1alpha1/expansion_generated.go similarity index 100% rename from pkg/client/listers/whereabouts.cni.cncf.io/v1alpha1/expansion_generated.go rename to pkg/generated/listers/whereabouts.cni.cncf.io/v1alpha1/expansion_generated.go diff --git a/pkg/client/listers/whereabouts.cni.cncf.io/v1alpha1/ippool.go b/pkg/generated/listers/whereabouts.cni.cncf.io/v1alpha1/ippool.go similarity index 65% rename from pkg/client/listers/whereabouts.cni.cncf.io/v1alpha1/ippool.go rename to pkg/generated/listers/whereabouts.cni.cncf.io/v1alpha1/ippool.go index a5114d0d0..5d8733fc4 100644 --- a/pkg/client/listers/whereabouts.cni.cncf.io/v1alpha1/ippool.go +++ b/pkg/generated/listers/whereabouts.cni.cncf.io/v1alpha1/ippool.go @@ -19,8 +19,8 @@ package v1alpha1 import ( v1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/api/whereabouts.cni.cncf.io/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -37,25 +37,17 @@ type IPPoolLister interface { // iPPoolLister implements the IPPoolLister interface. type iPPoolLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1alpha1.IPPool] } // NewIPPoolLister returns a new IPPoolLister. func NewIPPoolLister(indexer cache.Indexer) IPPoolLister { - return &iPPoolLister{indexer: indexer} -} - -// List lists all IPPools in the indexer. -func (s *iPPoolLister) List(selector labels.Selector) (ret []*v1alpha1.IPPool, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.IPPool)) - }) - return ret, err + return &iPPoolLister{listers.New[*v1alpha1.IPPool](indexer, v1alpha1.Resource("ippool"))} } // IPPools returns an object that can list and get IPPools. func (s *iPPoolLister) IPPools(namespace string) IPPoolNamespaceLister { - return iPPoolNamespaceLister{indexer: s.indexer, namespace: namespace} + return iPPoolNamespaceLister{listers.NewNamespaced[*v1alpha1.IPPool](s.ResourceIndexer, namespace)} } // IPPoolNamespaceLister helps list and get IPPools. @@ -73,26 +65,5 @@ type IPPoolNamespaceLister interface { // iPPoolNamespaceLister implements the IPPoolNamespaceLister // interface. type iPPoolNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all IPPools in the indexer for a given namespace. -func (s iPPoolNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.IPPool, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.IPPool)) - }) - return ret, err -} - -// Get retrieves the IPPool from the indexer for a given namespace and name. -func (s iPPoolNamespaceLister) Get(name string) (*v1alpha1.IPPool, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1alpha1.Resource("ippool"), name) - } - return obj.(*v1alpha1.IPPool), nil + listers.ResourceIndexer[*v1alpha1.IPPool] } diff --git a/pkg/client/listers/whereabouts.cni.cncf.io/v1alpha1/nodeslicepool.go b/pkg/generated/listers/whereabouts.cni.cncf.io/v1alpha1/nodeslicepool.go similarity index 65% rename from pkg/client/listers/whereabouts.cni.cncf.io/v1alpha1/nodeslicepool.go rename to pkg/generated/listers/whereabouts.cni.cncf.io/v1alpha1/nodeslicepool.go index 1e6ae8bb5..c00f5b838 100644 --- a/pkg/client/listers/whereabouts.cni.cncf.io/v1alpha1/nodeslicepool.go +++ b/pkg/generated/listers/whereabouts.cni.cncf.io/v1alpha1/nodeslicepool.go @@ -19,8 +19,8 @@ package v1alpha1 import ( v1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/api/whereabouts.cni.cncf.io/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -37,25 +37,17 @@ type NodeSlicePoolLister interface { // nodeSlicePoolLister implements the NodeSlicePoolLister interface. type nodeSlicePoolLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1alpha1.NodeSlicePool] } // NewNodeSlicePoolLister returns a new NodeSlicePoolLister. func NewNodeSlicePoolLister(indexer cache.Indexer) NodeSlicePoolLister { - return &nodeSlicePoolLister{indexer: indexer} -} - -// List lists all NodeSlicePools in the indexer. -func (s *nodeSlicePoolLister) List(selector labels.Selector) (ret []*v1alpha1.NodeSlicePool, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.NodeSlicePool)) - }) - return ret, err + return &nodeSlicePoolLister{listers.New[*v1alpha1.NodeSlicePool](indexer, v1alpha1.Resource("nodeslicepool"))} } // NodeSlicePools returns an object that can list and get NodeSlicePools. func (s *nodeSlicePoolLister) NodeSlicePools(namespace string) NodeSlicePoolNamespaceLister { - return nodeSlicePoolNamespaceLister{indexer: s.indexer, namespace: namespace} + return nodeSlicePoolNamespaceLister{listers.NewNamespaced[*v1alpha1.NodeSlicePool](s.ResourceIndexer, namespace)} } // NodeSlicePoolNamespaceLister helps list and get NodeSlicePools. @@ -73,26 +65,5 @@ type NodeSlicePoolNamespaceLister interface { // nodeSlicePoolNamespaceLister implements the NodeSlicePoolNamespaceLister // interface. type nodeSlicePoolNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all NodeSlicePools in the indexer for a given namespace. -func (s nodeSlicePoolNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.NodeSlicePool, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.NodeSlicePool)) - }) - return ret, err -} - -// Get retrieves the NodeSlicePool from the indexer for a given namespace and name. -func (s nodeSlicePoolNamespaceLister) Get(name string) (*v1alpha1.NodeSlicePool, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1alpha1.Resource("nodeslicepool"), name) - } - return obj.(*v1alpha1.NodeSlicePool), nil + listers.ResourceIndexer[*v1alpha1.NodeSlicePool] } diff --git a/pkg/client/listers/whereabouts.cni.cncf.io/v1alpha1/overlappingrangeipreservation.go b/pkg/generated/listers/whereabouts.cni.cncf.io/v1alpha1/overlappingrangeipreservation.go similarity index 66% rename from pkg/client/listers/whereabouts.cni.cncf.io/v1alpha1/overlappingrangeipreservation.go rename to pkg/generated/listers/whereabouts.cni.cncf.io/v1alpha1/overlappingrangeipreservation.go index 02b15763a..6298f06f8 100644 --- a/pkg/client/listers/whereabouts.cni.cncf.io/v1alpha1/overlappingrangeipreservation.go +++ b/pkg/generated/listers/whereabouts.cni.cncf.io/v1alpha1/overlappingrangeipreservation.go @@ -19,8 +19,8 @@ package v1alpha1 import ( v1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/api/whereabouts.cni.cncf.io/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -37,25 +37,17 @@ type OverlappingRangeIPReservationLister interface { // overlappingRangeIPReservationLister implements the OverlappingRangeIPReservationLister interface. type overlappingRangeIPReservationLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1alpha1.OverlappingRangeIPReservation] } // NewOverlappingRangeIPReservationLister returns a new OverlappingRangeIPReservationLister. func NewOverlappingRangeIPReservationLister(indexer cache.Indexer) OverlappingRangeIPReservationLister { - return &overlappingRangeIPReservationLister{indexer: indexer} -} - -// List lists all OverlappingRangeIPReservations in the indexer. -func (s *overlappingRangeIPReservationLister) List(selector labels.Selector) (ret []*v1alpha1.OverlappingRangeIPReservation, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.OverlappingRangeIPReservation)) - }) - return ret, err + return &overlappingRangeIPReservationLister{listers.New[*v1alpha1.OverlappingRangeIPReservation](indexer, v1alpha1.Resource("overlappingrangeipreservation"))} } // OverlappingRangeIPReservations returns an object that can list and get OverlappingRangeIPReservations. func (s *overlappingRangeIPReservationLister) OverlappingRangeIPReservations(namespace string) OverlappingRangeIPReservationNamespaceLister { - return overlappingRangeIPReservationNamespaceLister{indexer: s.indexer, namespace: namespace} + return overlappingRangeIPReservationNamespaceLister{listers.NewNamespaced[*v1alpha1.OverlappingRangeIPReservation](s.ResourceIndexer, namespace)} } // OverlappingRangeIPReservationNamespaceLister helps list and get OverlappingRangeIPReservations. @@ -73,26 +65,5 @@ type OverlappingRangeIPReservationNamespaceLister interface { // overlappingRangeIPReservationNamespaceLister implements the OverlappingRangeIPReservationNamespaceLister // interface. type overlappingRangeIPReservationNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all OverlappingRangeIPReservations in the indexer for a given namespace. -func (s overlappingRangeIPReservationNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.OverlappingRangeIPReservation, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.OverlappingRangeIPReservation)) - }) - return ret, err -} - -// Get retrieves the OverlappingRangeIPReservation from the indexer for a given namespace and name. -func (s overlappingRangeIPReservationNamespaceLister) Get(name string) (*v1alpha1.OverlappingRangeIPReservation, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1alpha1.Resource("overlappingrangeipreservation"), name) - } - return obj.(*v1alpha1.OverlappingRangeIPReservation), nil + listers.ResourceIndexer[*v1alpha1.OverlappingRangeIPReservation] } diff --git a/pkg/node-controller/controller.go b/pkg/node-controller/controller.go index 493d10edf..f5e30757d 100644 --- a/pkg/node-controller/controller.go +++ b/pkg/node-controller/controller.go @@ -29,10 +29,10 @@ import ( nadlisters "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/client/listers/k8s.cni.cncf.io/v1" "github.com/k8snetworkplumbingwg/whereabouts/pkg/api/whereabouts.cni.cncf.io/v1alpha1" - clientset "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned" - whereaboutsInformers "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/informers/externalversions/whereabouts.cni.cncf.io/v1alpha1" - whereaboutsListers "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/listers/whereabouts.cni.cncf.io/v1alpha1" "github.com/k8snetworkplumbingwg/whereabouts/pkg/config" + clientset "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned" + whereaboutsInformers "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/informers/externalversions/whereabouts.cni.cncf.io/v1alpha1" + whereaboutsListers "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/listers/whereabouts.cni.cncf.io/v1alpha1" "github.com/k8snetworkplumbingwg/whereabouts/pkg/iphelpers" "github.com/k8snetworkplumbingwg/whereabouts/pkg/types" ) diff --git a/pkg/node-controller/controller_test.go b/pkg/node-controller/controller_test.go index 13dd40f72..ff6b5d260 100644 --- a/pkg/node-controller/controller_test.go +++ b/pkg/node-controller/controller_test.go @@ -19,16 +19,17 @@ package node_controller import ( "context" "fmt" + "os" + "reflect" + "testing" + "time" + k8snetplumbersv1 "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1" "github.com/k8snetworkplumbingwg/whereabouts/pkg/api/whereabouts.cni.cncf.io/v1alpha1" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/tools/cache" - "os" - "reflect" - "testing" - "time" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/diff" @@ -39,8 +40,8 @@ import ( k8snetplumbersv1fake "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/client/clientset/versioned/fake" nadinformers "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/client/informers/externalversions" - "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned/fake" - informers "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/informers/externalversions" + "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned/fake" + informers "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/informers/externalversions" ) var ( diff --git a/pkg/reconciler/ip_test.go b/pkg/reconciler/ip_test.go index 92457b125..330143459 100644 --- a/pkg/reconciler/ip_test.go +++ b/pkg/reconciler/ip_test.go @@ -21,8 +21,8 @@ import ( k8sclient "k8s.io/client-go/kubernetes" fakek8sclient "k8s.io/client-go/kubernetes/fake" - wbclient "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned" - fakewbclient "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned/fake" + wbclient "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned" + fakewbclient "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned/fake" "github.com/k8snetworkplumbingwg/whereabouts/pkg/storage/kubernetes" ) diff --git a/pkg/storage/kubernetes/client.go b/pkg/storage/kubernetes/client.go index 38beba0e2..5826967eb 100644 --- a/pkg/storage/kubernetes/client.go +++ b/pkg/storage/kubernetes/client.go @@ -11,7 +11,7 @@ import ( "k8s.io/client-go/tools/clientcmd" whereaboutsv1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/api/whereabouts.cni.cncf.io/v1alpha1" - wbclient "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned" + wbclient "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned" "github.com/k8snetworkplumbingwg/whereabouts/pkg/logging" "github.com/k8snetworkplumbingwg/whereabouts/pkg/storage" ) diff --git a/pkg/storage/kubernetes/ipam.go b/pkg/storage/kubernetes/ipam.go index dd84ea1c5..3b4be87cf 100644 --- a/pkg/storage/kubernetes/ipam.go +++ b/pkg/storage/kubernetes/ipam.go @@ -22,7 +22,7 @@ import ( "github.com/k8snetworkplumbingwg/whereabouts/pkg/allocate" whereaboutsv1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/api/whereabouts.cni.cncf.io/v1alpha1" - wbclient "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned" + wbclient "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned" "github.com/k8snetworkplumbingwg/whereabouts/pkg/iphelpers" "github.com/k8snetworkplumbingwg/whereabouts/pkg/logging" "github.com/k8snetworkplumbingwg/whereabouts/pkg/storage"