From aa09df9adf068d75f4986f435f4262e90d2a9b65 Mon Sep 17 00:00:00 2001 From: inho Date: Wed, 20 Mar 2024 17:19:48 +0900 Subject: [PATCH 1/3] Add/Del BGP Peer CRD --- cmd/loxilb-agent/agent.go | 16 +- go.mod | 4 +- go.sum | 3 + manifest/crds/bgp-peer-service.yaml | 53 ++++ manifest/crds/bgp-peer.yaml | 8 + pkg/agent/manager/bgppeer/bgppeer.go | 292 ++++++++++++++++++ .../bgppeer/v1/bgppeermodel.go | 57 ++++ .../bgppeer/v1/bgppeerservice.go | 219 +++++++++++++ .../applyconfiguration/internal/internal.go | 62 ++++ pkg/client/applyconfiguration/utils.go | 39 +++ pkg/client/clientset/versioned/clientset.go | 120 +++++++ .../versioned/fake/clientset_generated.go | 85 +++++ pkg/client/clientset/versioned/fake/doc.go | 20 ++ .../clientset/versioned/fake/register.go | 56 ++++ pkg/client/clientset/versioned/scheme/doc.go | 20 ++ .../clientset/versioned/scheme/register.go | 56 ++++ .../typed/bgppeer/v1/bgppeer_client.go | 107 +++++++ .../typed/bgppeer/v1/bgppeerservice.go | 243 +++++++++++++++ .../versioned/typed/bgppeer/v1/doc.go | 20 ++ .../versioned/typed/bgppeer/v1/fake/doc.go | 20 ++ .../bgppeer/v1/fake/fake_bgppeer_client.go | 40 +++ .../bgppeer/v1/fake/fake_bgppeerservice.go | 178 +++++++++++ .../typed/bgppeer/v1/generated_expansion.go | 21 ++ .../externalversions/bgppeer/interface.go | 46 +++ .../bgppeer/v1/bgppeerservice.go | 89 ++++++ .../externalversions/bgppeer/v1/interface.go | 45 +++ .../informers/externalversions/factory.go | 261 ++++++++++++++++ .../informers/externalversions/generic.go | 62 ++++ .../internalinterfaces/factory_interfaces.go | 40 +++ .../listers/bgppeer/v1/bgppeerservice.go | 68 ++++ .../listers/bgppeer/v1/expansion_generated.go | 23 ++ pkg/crds/bgppeer/v1/doc.go | 4 + pkg/crds/bgppeer/v1/register.go | 31 ++ pkg/crds/bgppeer/v1/types.go | 69 +++++ pkg/crds/bgppeer/v1/zz_generated.deepcopy.go | 156 ++++++++++ pkg/k8s/client.go | 18 +- 36 files changed, 2640 insertions(+), 11 deletions(-) create mode 100644 manifest/crds/bgp-peer-service.yaml create mode 100644 manifest/crds/bgp-peer.yaml create mode 100644 pkg/agent/manager/bgppeer/bgppeer.go create mode 100644 pkg/client/applyconfiguration/bgppeer/v1/bgppeermodel.go create mode 100644 pkg/client/applyconfiguration/bgppeer/v1/bgppeerservice.go create mode 100644 pkg/client/applyconfiguration/internal/internal.go create mode 100644 pkg/client/applyconfiguration/utils.go create mode 100644 pkg/client/clientset/versioned/clientset.go create mode 100644 pkg/client/clientset/versioned/fake/clientset_generated.go create mode 100644 pkg/client/clientset/versioned/fake/doc.go create mode 100644 pkg/client/clientset/versioned/fake/register.go create mode 100644 pkg/client/clientset/versioned/scheme/doc.go create mode 100644 pkg/client/clientset/versioned/scheme/register.go create mode 100644 pkg/client/clientset/versioned/typed/bgppeer/v1/bgppeer_client.go create mode 100644 pkg/client/clientset/versioned/typed/bgppeer/v1/bgppeerservice.go create mode 100644 pkg/client/clientset/versioned/typed/bgppeer/v1/doc.go create mode 100644 pkg/client/clientset/versioned/typed/bgppeer/v1/fake/doc.go create mode 100644 pkg/client/clientset/versioned/typed/bgppeer/v1/fake/fake_bgppeer_client.go create mode 100644 pkg/client/clientset/versioned/typed/bgppeer/v1/fake/fake_bgppeerservice.go create mode 100644 pkg/client/clientset/versioned/typed/bgppeer/v1/generated_expansion.go create mode 100644 pkg/client/informers/externalversions/bgppeer/interface.go create mode 100644 pkg/client/informers/externalversions/bgppeer/v1/bgppeerservice.go create mode 100644 pkg/client/informers/externalversions/bgppeer/v1/interface.go create mode 100644 pkg/client/informers/externalversions/factory.go create mode 100644 pkg/client/informers/externalversions/generic.go create mode 100644 pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go create mode 100644 pkg/client/listers/bgppeer/v1/bgppeerservice.go create mode 100644 pkg/client/listers/bgppeer/v1/expansion_generated.go create mode 100644 pkg/crds/bgppeer/v1/doc.go create mode 100644 pkg/crds/bgppeer/v1/register.go create mode 100644 pkg/crds/bgppeer/v1/types.go create mode 100644 pkg/crds/bgppeer/v1/zz_generated.deepcopy.go diff --git a/cmd/loxilb-agent/agent.go b/cmd/loxilb-agent/agent.go index 1a8a0e4..7685a75 100644 --- a/cmd/loxilb-agent/agent.go +++ b/cmd/loxilb-agent/agent.go @@ -24,8 +24,10 @@ import ( "time" "github.com/loxilb-io/kube-loxilb/pkg/agent/config" + "github.com/loxilb-io/kube-loxilb/pkg/agent/manager/bgppeer" "github.com/loxilb-io/kube-loxilb/pkg/agent/manager/loadbalancer" "github.com/loxilb-io/kube-loxilb/pkg/api" + crdinformers "github.com/loxilb-io/kube-loxilb/pkg/client/informers/externalversions" "github.com/loxilb-io/kube-loxilb/pkg/ippool" "github.com/loxilb-io/kube-loxilb/pkg/k8s" "github.com/loxilb-io/kube-loxilb/pkg/log" @@ -53,12 +55,14 @@ func run(o *Options) error { klog.Infof(" Build: %s", BuildInfo) // create k8s Clientset, CRD Clientset and SharedInformerFactory for the given config. - k8sClient, _, _, err := k8s.CreateClients(o.config.ClientConnection, "") + k8sClient, _, crdClient, _, err := k8s.CreateClients(o.config.ClientConnection, "") if err != nil { return fmt.Errorf("error creating k8s clients: %v", err) } informerFactory := informers.NewSharedInformerFactory(k8sClient, informerDefaultResync) + crdInformerFactory := crdinformers.NewSharedInformerFactory(crdClient, informerDefaultResync) + BGPPeerInformer := crdInformerFactory.Bgppeer().V1().BGPPeerServices() // networkReadyCh is used to notify that the Node's network is ready. // Functions that rely on the Node's network should wait for the channel to close. @@ -181,6 +185,13 @@ func run(o *Options) error { informerFactory, ) + BgpPeerManager := bgppeer.NewBGPPeerManager( + k8sClient, + crdClient, + loxilbClients, + networkConfig, + BGPPeerInformer, + ) go func() { for { select { @@ -192,6 +203,7 @@ func run(o *Options) error { case <-ticker.C: if len(networkConfig.LoxilbURLs) <= 0 { lbManager.DiscoverLoxiLBServices(loxiLBLiveCh, loxiLBDeadCh, loxiLBPurgeCh) + BgpPeerManager.DiscoverLoxiLBServices(loxiLBLiveCh, loxiLBDeadCh, loxiLBPurgeCh) } lbManager.DiscoverLoxiLBPeerServices(loxiLBLiveCh, loxiLBDeadCh, loxiLBPurgeCh) @@ -207,7 +219,7 @@ func run(o *Options) error { informerFactory.Start(stopCh) go lbManager.Run(stopCh, loxiLBLiveCh, loxiLBPurgeCh, loxiLBSelMasterEvent) - + go BgpPeerManager.Run(stopCh, loxiLBLiveCh, loxiLBPurgeCh, loxiLBSelMasterEvent) <-stopCh klog.Info("Stopping loxilb Agent") diff --git a/go.mod b/go.mod index ea7e1c9..88fc16a 100644 --- a/go.mod +++ b/go.mod @@ -14,6 +14,7 @@ require ( k8s.io/component-base v0.26.0 k8s.io/klog/v2 v2.80.1 k8s.io/kube-aggregator v0.26.0 + sigs.k8s.io/structured-merge-diff/v4 v4.2.3 ) require ( @@ -22,6 +23,7 @@ require ( github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/emicklei/go-restful/v3 v3.9.0 // indirect + github.com/evanphx/json-patch v4.12.0+incompatible // indirect github.com/go-logr/logr v1.2.3 // indirect github.com/go-openapi/jsonpointer v0.19.5 // indirect github.com/go-openapi/jsonreference v0.20.0 // indirect @@ -41,6 +43,7 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/pkg/errors v0.9.1 // indirect github.com/prometheus/client_golang v1.14.0 // indirect github.com/prometheus/client_model v0.3.0 // indirect github.com/prometheus/common v0.37.0 // indirect @@ -58,6 +61,5 @@ require ( k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect k8s.io/utils v0.0.0-20221107191617-1a15be271d1d // indirect sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect sigs.k8s.io/yaml v1.3.0 // indirect ) diff --git a/go.sum b/go.sum index c79028d..6cfff9c 100644 --- a/go.sum +++ b/go.sum @@ -65,6 +65,8 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/evanphx/json-patch v4.12.0+incompatible h1:4onqiflcdA9EOZ4RxV643DvftH5pOlLGNtQ5lPWQu84= +github.com/evanphx/json-patch v4.12.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -208,6 +210,7 @@ github.com/onsi/ginkgo/v2 v2.4.0 h1:+Ig9nvqgS5OBSACXNk15PLdp0U9XPYROt9CFzVdFGIs= github.com/onsi/gomega v1.23.0 h1:/oxKu9c2HVap+F3PfKort2Hw5DEU+HGlW8n+tguWsys= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= diff --git a/manifest/crds/bgp-peer-service.yaml b/manifest/crds/bgp-peer-service.yaml new file mode 100644 index 0000000..45c57f5 --- /dev/null +++ b/manifest/crds/bgp-peer-service.yaml @@ -0,0 +1,53 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.13.0 + name: bgppeerservices.bgppeer.loxilb.io +spec: + group: bgppeer.loxilb.io + names: + kind: BGPPeerService + listKind: BGPPeerServiceList + plural: bgppeerservices + singular: bgppeerservice + scope: Cluster + versions: + - name: v1 + served: true + storage: true + additionalPrinterColumns: + - name: Peer + type: string + priority: 0 + jsonPath: .spec.ipAddress + description: BGP Peer IP address + - name: AS + type: string + priority: 0 + jsonPath: .spec.remoteAs + description: BGP Peer Remote AS number + schema: + openAPIV3Schema: + type: object + required: + - spec + properties: + spec: + type: object + x-kubernetes-preserve-unknown-fields: true + properties: + ipAddress: + type: string + remoteAs: + type: integer + remotePort: + type: integer + setMultiHop: + type: boolean + required: + - ipAddress + - remoteAs + status: + type: object + x-kubernetes-preserve-unknown-fields: true \ No newline at end of file diff --git a/manifest/crds/bgp-peer.yaml b/manifest/crds/bgp-peer.yaml new file mode 100644 index 0000000..4f9caf7 --- /dev/null +++ b/manifest/crds/bgp-peer.yaml @@ -0,0 +1,8 @@ +apiVersion: "bgppeer.loxilb.io/v1" +kind: BGPPeerService +metadata: + name: bgp-peer-test +spec: + ipAddress: 123.123.123.2 + remoteAs: 65123 + remotePort: 179 diff --git a/pkg/agent/manager/bgppeer/bgppeer.go b/pkg/agent/manager/bgppeer/bgppeer.go new file mode 100644 index 0000000..0052e37 --- /dev/null +++ b/pkg/agent/manager/bgppeer/bgppeer.go @@ -0,0 +1,292 @@ +/* + * Copyright (c) 2023 NetLOX Inc + * + * 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. + */ + +package bgppeer + +import ( + "context" + "fmt" + "net" + "strings" + "time" + + "github.com/loxilb-io/kube-loxilb/pkg/agent/config" + "github.com/loxilb-io/kube-loxilb/pkg/api" + "github.com/loxilb-io/kube-loxilb/pkg/client/clientset/versioned" + crdInformer "github.com/loxilb-io/kube-loxilb/pkg/client/informers/externalversions/bgppeer/v1" + crdLister "github.com/loxilb-io/kube-loxilb/pkg/client/listers/bgppeer/v1" + crdv1 "github.com/loxilb-io/kube-loxilb/pkg/crds/bgppeer/v1" + "github.com/loxilb-io/kube-loxilb/pkg/k8s" + + //v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/wait" + "k8s.io/client-go/kubernetes" + "k8s.io/client-go/tools/cache" + "k8s.io/client-go/util/workqueue" + "k8s.io/klog/v2" +) + +const ( + mgrName = "BGPPeerServiceManager" + defaultWorkers = 4 + resyncPeriod = 60 * time.Second + minRetryDelay = 2 * time.Second + maxRetryDelay = 120 * time.Second +) + +type Manager struct { + kubeClient kubernetes.Interface + crdClient versioned.Interface + loxiClients []*api.LoxiClient + bgpPeerInformer crdInformer.BGPPeerServiceInformer + bgpPeerLister crdLister.BGPPeerServiceLister + bgpPeerListerSynced cache.InformerSynced + queue workqueue.RateLimitingInterface +} + +// Create and Init Manager. +// Manager is called by kube-loxilb when k8s service is created & updated. +func NewBGPPeerManager( + kubeClient kubernetes.Interface, + crdClient versioned.Interface, + loxiClients []*api.LoxiClient, + networkConfig *config.NetworkConfig, + bgpPeerInformer crdInformer.BGPPeerServiceInformer) *Manager { + + manager := &Manager{ + + kubeClient: kubeClient, + crdClient: crdClient, + loxiClients: loxiClients, + bgpPeerInformer: bgpPeerInformer, + bgpPeerLister: bgpPeerInformer.Lister(), + bgpPeerListerSynced: bgpPeerInformer.Informer().HasSynced, + + queue: workqueue.NewNamedRateLimitingQueue(workqueue.NewItemExponentialFailureRateLimiter(minRetryDelay, maxRetryDelay), "loadbalancer"), + } + + bgpPeerInformer.Informer().AddEventHandlerWithResyncPeriod( + cache.ResourceEventHandlerFuncs{ + AddFunc: func(cur interface{}) { + manager.enqueueService(cur) + }, + UpdateFunc: func(old, cur interface{}) { + manager.enqueueService(cur) + }, + DeleteFunc: func(old interface{}) { + manager.enqueueService(old) + }, + }, + resyncPeriod, + ) + + return manager +} + +func (m *Manager) enqueueService(obj interface{}) { + lb, ok := obj.(*crdv1.BGPPeerService) + if !ok { + deletedState, ok := obj.(cache.DeletedFinalStateUnknown) + if !ok { + klog.Errorf("Received unexpected object: %v", obj) + return + } + lb, ok = deletedState.Obj.(*crdv1.BGPPeerService) + if !ok { + klog.Errorf("DeletedFinalStateUnknown contains non-BGPPeerService object: %v", deletedState.Obj) + } + } + + m.queue.Add(lb) +} + +func (m *Manager) Run(stopCh <-chan struct{}, loxiLBLiveCh chan *api.LoxiClient, loxiLBPurgeCh chan *api.LoxiClient, masterEventCh <-chan bool) { + defer m.queue.ShutDown() + + klog.Infof("Starting %s", mgrName) + defer klog.Infof("Shutting down %s", mgrName) + + if !cache.WaitForNamedCacheSync( + mgrName, + stopCh, + m.bgpPeerListerSynced) { + return + } + + for i := 0; i < defaultWorkers; i++ { + go wait.Until(m.worker, time.Second, stopCh) + } + <-stopCh +} + +func (m *Manager) worker() { + for m.processNextWorkItem() { + } +} + +func (m *Manager) processNextWorkItem() bool { + obj, quit := m.queue.Get() + if quit { + return false + } + + defer m.queue.Done(obj) + + if lb, ok := obj.(*crdv1.BGPPeerService); !ok { + m.queue.Forget(obj) + klog.Errorf("Expected string in work queue but got %#v", obj) + return true + } else if err := m.syncBGPPeerService(lb); err == nil { + m.queue.Forget(obj) + } else { + m.queue.AddRateLimited(obj) + klog.Errorf("Error syncing CRD BGPPeerService %s, requeuing. Error: %v", lb.Name, err) + } + return true +} + +func (m *Manager) syncBGPPeerService(lb *crdv1.BGPPeerService) error { + startTime := time.Now() + defer func() { + klog.V(4).Infof("Finished syncing BGPPeerService %s. (%v)", lb.Name, time.Since(startTime)) + }() + _, err := m.bgpPeerLister.Get(lb.Name) + if err != nil { + return m.deleteBGPPeerService(lb) + } + return m.addBGPPeerService(lb) +} + +func (m *Manager) updateBGPPeerService() error { + bgp := crdv1.BGPPeerService{} + //m.crdClient.BgppeerV1().BGPPeerServices().Update(context.TODO(), &bgp, v1.UpdateOptions{}) + fmt.Println(m.bgpPeerLister.Get(bgp.Name)) + + klog.Infof("IPAddress: %v", bgp.Spec.IPAddress) + klog.Infof("RemoteAs: %v", bgp.Spec.RemoteAs) + klog.Infof("RemotePort: %v", bgp.Spec.RemotePort) + + return nil +} + +func (m *Manager) addBGPPeerService(lb *crdv1.BGPPeerService) error { + // TODO: This code should be made into a function so that it can be reused. + ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) + defer cancel() + + klog.Infof("IPAddress: %v", lb.Spec.IPAddress) + klog.Infof("RemoteAs: %v", lb.Spec.RemoteAs) + klog.Infof("RemotePort: %v", lb.Spec.RemotePort) + + var errChList []chan error + for _, client := range m.loxiClients { + ch := make(chan error) + go func(c *api.LoxiClient, h chan error) { + var err error + if err = c.BGP().CreateNeigh(ctx, &lb.Spec); err != nil { + if !strings.Contains(err.Error(), "exist") { + klog.Errorf("failed to create load-balancer(%s) :%v", c.Url, err) + } else { + err = nil + } + } + h <- err + }(client, ch) + + errChList = append(errChList, ch) + } + + isError := true + for _, errCh := range errChList { + err := <-errCh + if err == nil { + isError = false + } + } + if isError { + klog.Errorf("failed to add load-balancer") + return fmt.Errorf("failed to add loxiLB loadBalancer") + } + + return nil +} + +func (m *Manager) DiscoverLoxiLBServices(loxiLBAliveCh chan *api.LoxiClient, loxiLBDeadCh chan struct{}, loxiLBPurgeCh chan *api.LoxiClient) { + var tmploxilbClients []*api.LoxiClient + ips, err := k8s.GetServiceEndPoints(m.kubeClient, "loxilb-lb-service", "kube-system") + klog.Infof("loxilb-service end-points: %v", ips) + if err != nil { + ips = []net.IP{} + } + + for _, v := range m.loxiClients { + v.Purge = true + for _, ip := range ips { + if v.Host == ip.String() { + v.Purge = false + } + } + } + + for _, ip := range ips { + found := false + for _, v := range m.loxiClients { + if v.Host == ip.String() { + found = true + } + } + if !found { + client, err2 := api.NewLoxiClient("http://"+ip.String()+":11111", loxiLBAliveCh, loxiLBDeadCh, false) + if err2 != nil { + continue + } + tmploxilbClients = append(tmploxilbClients, client) + } + } + if len(tmploxilbClients) > 0 { + m.loxiClients = append(m.loxiClients, tmploxilbClients...) + } + +} + +func (m *Manager) deleteBGPPeerService(lb *crdv1.BGPPeerService) error { + var errChList []chan error + for _, loxiClient := range m.loxiClients { + ch := make(chan error) + errChList = append(errChList, ch) + + go func(client *api.LoxiClient, ch chan error) { + klog.Infof("called loxilb API: delete lb rule %v", lb.Spec) + ch <- client.BGP().DeleteNeigh(context.Background(), lb.Spec.IPAddress, int(lb.Spec.RemoteAs)) + }(loxiClient, ch) + } + + isError := true + errStr := "" + for _, errCh := range errChList { + err := <-errCh + if err == nil { + isError = false + break + } else { + errStr = err.Error() + } + } + if isError { + return fmt.Errorf("failed to delete loxiLB LoadBalancer. Error: %v", errStr) + } + return nil +} diff --git a/pkg/client/applyconfiguration/bgppeer/v1/bgppeermodel.go b/pkg/client/applyconfiguration/bgppeer/v1/bgppeermodel.go new file mode 100644 index 0000000..31b5e19 --- /dev/null +++ b/pkg/client/applyconfiguration/bgppeer/v1/bgppeermodel.go @@ -0,0 +1,57 @@ +/* +Copyright 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 applyconfiguration-gen. DO NOT EDIT. + +package v1 + +// BGPPeerModelApplyConfiguration represents an declarative configuration of the BGPPeerModel type for use +// with apply. +type BGPPeerModelApplyConfiguration struct { + IPAddress *string `json:"ipAddress,omitempty"` + RemoteAs *int64 `json:"remoteAs,omitempty"` + RemotePort *int64 `json:"remotePort,omitempty"` +} + +// BGPPeerModelApplyConfiguration constructs an declarative configuration of the BGPPeerModel type for use with +// apply. +func BGPPeerModel() *BGPPeerModelApplyConfiguration { + return &BGPPeerModelApplyConfiguration{} +} + +// WithIPAddress sets the IPAddress field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the IPAddress field is set to the value of the last call. +func (b *BGPPeerModelApplyConfiguration) WithIPAddress(value string) *BGPPeerModelApplyConfiguration { + b.IPAddress = &value + return b +} + +// WithRemoteAs sets the RemoteAs field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the RemoteAs field is set to the value of the last call. +func (b *BGPPeerModelApplyConfiguration) WithRemoteAs(value int64) *BGPPeerModelApplyConfiguration { + b.RemoteAs = &value + return b +} + +// WithRemotePort sets the RemotePort field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the RemotePort field is set to the value of the last call. +func (b *BGPPeerModelApplyConfiguration) WithRemotePort(value int64) *BGPPeerModelApplyConfiguration { + b.RemotePort = &value + return b +} diff --git a/pkg/client/applyconfiguration/bgppeer/v1/bgppeerservice.go b/pkg/client/applyconfiguration/bgppeer/v1/bgppeerservice.go new file mode 100644 index 0000000..4d07b03 --- /dev/null +++ b/pkg/client/applyconfiguration/bgppeer/v1/bgppeerservice.go @@ -0,0 +1,219 @@ +/* +Copyright 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 applyconfiguration-gen. DO NOT EDIT. + +package v1 + +import ( + crdsbgppeerv1 "github.com/loxilb-io/kube-loxilb/pkg/crds/bgppeer/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + v1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// BGPPeerServiceApplyConfiguration represents an declarative configuration of the BGPPeerService type for use +// with apply. +type BGPPeerServiceApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *BGPPeerModelApplyConfiguration `json:"spec,omitempty"` + Status *crdsbgppeerv1.BGPPeerServiceStatus `json:"status,omitempty"` +} + +// BGPPeerService constructs an declarative configuration of the BGPPeerService type for use with +// apply. +func BGPPeerService(name string) *BGPPeerServiceApplyConfiguration { + b := &BGPPeerServiceApplyConfiguration{} + b.WithName(name) + b.WithKind("BGPPeerService") + b.WithAPIVersion("bgppeer.loxilb.io/v1") + return b +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *BGPPeerServiceApplyConfiguration) WithKind(value string) *BGPPeerServiceApplyConfiguration { + b.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *BGPPeerServiceApplyConfiguration) WithAPIVersion(value string) *BGPPeerServiceApplyConfiguration { + b.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *BGPPeerServiceApplyConfiguration) WithName(value string) *BGPPeerServiceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *BGPPeerServiceApplyConfiguration) WithGenerateName(value string) *BGPPeerServiceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *BGPPeerServiceApplyConfiguration) WithNamespace(value string) *BGPPeerServiceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *BGPPeerServiceApplyConfiguration) WithUID(value types.UID) *BGPPeerServiceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *BGPPeerServiceApplyConfiguration) WithResourceVersion(value string) *BGPPeerServiceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *BGPPeerServiceApplyConfiguration) WithGeneration(value int64) *BGPPeerServiceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *BGPPeerServiceApplyConfiguration) WithCreationTimestamp(value metav1.Time) *BGPPeerServiceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *BGPPeerServiceApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *BGPPeerServiceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *BGPPeerServiceApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *BGPPeerServiceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *BGPPeerServiceApplyConfiguration) WithLabels(entries map[string]string) *BGPPeerServiceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *BGPPeerServiceApplyConfiguration) WithAnnotations(entries map[string]string) *BGPPeerServiceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *BGPPeerServiceApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *BGPPeerServiceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *BGPPeerServiceApplyConfiguration) WithFinalizers(values ...string) *BGPPeerServiceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *BGPPeerServiceApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *BGPPeerServiceApplyConfiguration) WithSpec(value *BGPPeerModelApplyConfiguration) *BGPPeerServiceApplyConfiguration { + b.Spec = value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *BGPPeerServiceApplyConfiguration) WithStatus(value crdsbgppeerv1.BGPPeerServiceStatus) *BGPPeerServiceApplyConfiguration { + b.Status = &value + return b +} diff --git a/pkg/client/applyconfiguration/internal/internal.go b/pkg/client/applyconfiguration/internal/internal.go new file mode 100644 index 0000000..4d7ef13 --- /dev/null +++ b/pkg/client/applyconfiguration/internal/internal.go @@ -0,0 +1,62 @@ +/* +Copyright 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 applyconfiguration-gen. DO NOT EDIT. + +package internal + +import ( + "fmt" + "sync" + + typed "sigs.k8s.io/structured-merge-diff/v4/typed" +) + +func Parser() *typed.Parser { + parserOnce.Do(func() { + var err error + parser, err = typed.NewParser(schemaYAML) + if err != nil { + panic(fmt.Sprintf("Failed to parse schema: %v", err)) + } + }) + return parser +} + +var parserOnce sync.Once +var parser *typed.Parser +var schemaYAML = typed.YAMLObject(`types: +- name: __untyped_atomic_ + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic +- name: __untyped_deduced_ + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_deduced_ + elementRelationship: separable +`) diff --git a/pkg/client/applyconfiguration/utils.go b/pkg/client/applyconfiguration/utils.go new file mode 100644 index 0000000..73c1c08 --- /dev/null +++ b/pkg/client/applyconfiguration/utils.go @@ -0,0 +1,39 @@ +/* +Copyright 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 applyconfiguration-gen. DO NOT EDIT. + +package applyconfiguration + +import ( + bgppeerv1 "github.com/loxilb-io/kube-loxilb/pkg/client/applyconfiguration/bgppeer/v1" + v1 "github.com/loxilb-io/kube-loxilb/pkg/crds/bgppeer/v1" + schema "k8s.io/apimachinery/pkg/runtime/schema" +) + +// ForKind returns an apply configuration type for the given GroupVersionKind, or nil if no +// apply configuration type exists for the given GroupVersionKind. +func ForKind(kind schema.GroupVersionKind) interface{} { + switch kind { + // Group=bgppeer.loxilb.io, Version=v1 + case v1.SchemeGroupVersion.WithKind("BGPPeerModel"): + return &bgppeerv1.BGPPeerModelApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("BGPPeerService"): + return &bgppeerv1.BGPPeerServiceApplyConfiguration{} + + } + return nil +} diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go new file mode 100644 index 0000000..1ed5515 --- /dev/null +++ b/pkg/client/clientset/versioned/clientset.go @@ -0,0 +1,120 @@ +/* +Copyright 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 versioned + +import ( + "fmt" + "net/http" + + bgppeerv1 "github.com/loxilb-io/kube-loxilb/pkg/client/clientset/versioned/typed/bgppeer/v1" + discovery "k8s.io/client-go/discovery" + rest "k8s.io/client-go/rest" + flowcontrol "k8s.io/client-go/util/flowcontrol" +) + +type Interface interface { + Discovery() discovery.DiscoveryInterface + BgppeerV1() bgppeerv1.BgppeerV1Interface +} + +// Clientset contains the clients for groups. +type Clientset struct { + *discovery.DiscoveryClient + bgppeerV1 *bgppeerv1.BgppeerV1Client +} + +// BgppeerV1 retrieves the BgppeerV1Client +func (c *Clientset) BgppeerV1() bgppeerv1.BgppeerV1Interface { + return c.bgppeerV1 +} + +// Discovery retrieves the DiscoveryClient +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + if c == nil { + return nil + } + return c.DiscoveryClient +} + +// NewForConfig creates a new Clientset for the given config. +// If config's RateLimiter is not set and QPS and Burst are acceptable, +// NewForConfig will generate a rate-limiter in configShallowCopy. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*Clientset, error) { + configShallowCopy := *c + + if configShallowCopy.UserAgent == "" { + configShallowCopy.UserAgent = rest.DefaultKubernetesUserAgent() + } + + // share the transport between all clients + httpClient, err := rest.HTTPClientFor(&configShallowCopy) + if err != nil { + return nil, err + } + + return NewForConfigAndClient(&configShallowCopy, httpClient) +} + +// NewForConfigAndClient creates a new Clientset for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +// If config's RateLimiter is not set and QPS and Burst are acceptable, +// NewForConfigAndClient will generate a rate-limiter in configShallowCopy. +func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, error) { + configShallowCopy := *c + if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { + if configShallowCopy.Burst <= 0 { + return nil, fmt.Errorf("burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0") + } + configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) + } + + var cs Clientset + var err error + cs.bgppeerV1, err = bgppeerv1.NewForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } + + cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } + return &cs, nil +} + +// NewForConfigOrDie creates a new Clientset for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *Clientset { + cs, err := NewForConfig(c) + if err != nil { + panic(err) + } + return cs +} + +// New creates a new Clientset for the given RESTClient. +func New(c rest.Interface) *Clientset { + var cs Clientset + cs.bgppeerV1 = bgppeerv1.New(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClient(c) + return &cs +} diff --git a/pkg/client/clientset/versioned/fake/clientset_generated.go b/pkg/client/clientset/versioned/fake/clientset_generated.go new file mode 100644 index 0000000..4b80a1c --- /dev/null +++ b/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -0,0 +1,85 @@ +/* +Copyright 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 fake + +import ( + clientset "github.com/loxilb-io/kube-loxilb/pkg/client/clientset/versioned" + bgppeerv1 "github.com/loxilb-io/kube-loxilb/pkg/client/clientset/versioned/typed/bgppeer/v1" + fakebgppeerv1 "github.com/loxilb-io/kube-loxilb/pkg/client/clientset/versioned/typed/bgppeer/v1/fake" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/discovery" + fakediscovery "k8s.io/client-go/discovery/fake" + "k8s.io/client-go/testing" +) + +// NewSimpleClientset returns a clientset that will respond with the provided objects. +// It's backed by a very simple object tracker that processes creates, updates and deletions as-is, +// without applying any validations and/or defaults. It shouldn't be considered a replacement +// for a real clientset and is mostly useful in simple unit tests. +func NewSimpleClientset(objects ...runtime.Object) *Clientset { + o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) + for _, obj := range objects { + if err := o.Add(obj); err != nil { + panic(err) + } + } + + cs := &Clientset{tracker: o} + cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake} + cs.AddReactor("*", "*", testing.ObjectReaction(o)) + cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) { + gvr := action.GetResource() + ns := action.GetNamespace() + watch, err := o.Watch(gvr, ns) + if err != nil { + return false, nil, err + } + return true, watch, nil + }) + + return cs +} + +// Clientset implements clientset.Interface. Meant to be embedded into a +// struct to get a default implementation. This makes faking out just the method +// you want to test easier. +type Clientset struct { + testing.Fake + discovery *fakediscovery.FakeDiscovery + tracker testing.ObjectTracker +} + +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + return c.discovery +} + +func (c *Clientset) Tracker() testing.ObjectTracker { + return c.tracker +} + +var ( + _ clientset.Interface = &Clientset{} + _ testing.FakeClient = &Clientset{} +) + +// BgppeerV1 retrieves the BgppeerV1Client +func (c *Clientset) BgppeerV1() bgppeerv1.BgppeerV1Interface { + return &fakebgppeerv1.FakeBgppeerV1{Fake: &c.Fake} +} diff --git a/pkg/client/clientset/versioned/fake/doc.go b/pkg/client/clientset/versioned/fake/doc.go new file mode 100644 index 0000000..9b99e71 --- /dev/null +++ b/pkg/client/clientset/versioned/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 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. + +// This package has the automatically generated fake clientset. +package fake diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go new file mode 100644 index 0000000..e4c1f69 --- /dev/null +++ b/pkg/client/clientset/versioned/fake/register.go @@ -0,0 +1,56 @@ +/* +Copyright 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 fake + +import ( + bgppeerv1 "github.com/loxilb-io/kube-loxilb/pkg/crds/bgppeer/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" +) + +var scheme = runtime.NewScheme() +var codecs = serializer.NewCodecFactory(scheme) + +var localSchemeBuilder = runtime.SchemeBuilder{ + bgppeerv1.AddToScheme, +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(AddToScheme(scheme)) +} diff --git a/pkg/client/clientset/versioned/scheme/doc.go b/pkg/client/clientset/versioned/scheme/doc.go new file mode 100644 index 0000000..7dc3756 --- /dev/null +++ b/pkg/client/clientset/versioned/scheme/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 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. + +// This package contains the scheme of the automatically generated clientset. +package scheme diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go new file mode 100644 index 0000000..04106b2 --- /dev/null +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -0,0 +1,56 @@ +/* +Copyright 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 scheme + +import ( + bgppeerv1 "github.com/loxilb-io/kube-loxilb/pkg/crds/bgppeer/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" +) + +var Scheme = runtime.NewScheme() +var Codecs = serializer.NewCodecFactory(Scheme) +var ParameterCodec = runtime.NewParameterCodec(Scheme) +var localSchemeBuilder = runtime.SchemeBuilder{ + bgppeerv1.AddToScheme, +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(AddToScheme(Scheme)) +} diff --git a/pkg/client/clientset/versioned/typed/bgppeer/v1/bgppeer_client.go b/pkg/client/clientset/versioned/typed/bgppeer/v1/bgppeer_client.go new file mode 100644 index 0000000..77d0106 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/bgppeer/v1/bgppeer_client.go @@ -0,0 +1,107 @@ +/* +Copyright 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 v1 + +import ( + "net/http" + + "github.com/loxilb-io/kube-loxilb/pkg/client/clientset/versioned/scheme" + v1 "github.com/loxilb-io/kube-loxilb/pkg/crds/bgppeer/v1" + rest "k8s.io/client-go/rest" +) + +type BgppeerV1Interface interface { + RESTClient() rest.Interface + BGPPeerServicesGetter +} + +// BgppeerV1Client is used to interact with features provided by the bgppeer.loxilb.io group. +type BgppeerV1Client struct { + restClient rest.Interface +} + +func (c *BgppeerV1Client) BGPPeerServices() BGPPeerServiceInterface { + return newBGPPeerServices(c) +} + +// NewForConfig creates a new BgppeerV1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*BgppeerV1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new BgppeerV1Client for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*BgppeerV1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientForConfigAndClient(&config, h) + if err != nil { + return nil, err + } + return &BgppeerV1Client{client}, nil +} + +// NewForConfigOrDie creates a new BgppeerV1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *BgppeerV1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new BgppeerV1Client for the given RESTClient. +func New(c rest.Interface) *BgppeerV1Client { + return &BgppeerV1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *BgppeerV1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/client/clientset/versioned/typed/bgppeer/v1/bgppeerservice.go b/pkg/client/clientset/versioned/typed/bgppeer/v1/bgppeerservice.go new file mode 100644 index 0000000..134b9b5 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/bgppeer/v1/bgppeerservice.go @@ -0,0 +1,243 @@ +/* +Copyright 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 v1 + +import ( + "context" + json "encoding/json" + "fmt" + "time" + + bgppeerv1 "github.com/loxilb-io/kube-loxilb/pkg/client/applyconfiguration/bgppeer/v1" + scheme "github.com/loxilb-io/kube-loxilb/pkg/client/clientset/versioned/scheme" + v1 "github.com/loxilb-io/kube-loxilb/pkg/crds/bgppeer/v1" + metav1 "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" +) + +// BGPPeerServicesGetter has a method to return a BGPPeerServiceInterface. +// A group's client should implement this interface. +type BGPPeerServicesGetter interface { + BGPPeerServices() BGPPeerServiceInterface +} + +// BGPPeerServiceInterface has methods to work with BGPPeerService resources. +type BGPPeerServiceInterface interface { + Create(ctx context.Context, bGPPeerService *v1.BGPPeerService, opts metav1.CreateOptions) (*v1.BGPPeerService, error) + Update(ctx context.Context, bGPPeerService *v1.BGPPeerService, opts metav1.UpdateOptions) (*v1.BGPPeerService, error) + UpdateStatus(ctx context.Context, bGPPeerService *v1.BGPPeerService, opts metav1.UpdateOptions) (*v1.BGPPeerService, error) + Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error + Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1.BGPPeerService, error) + List(ctx context.Context, opts metav1.ListOptions) (*v1.BGPPeerServiceList, error) + Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.BGPPeerService, err error) + Apply(ctx context.Context, bGPPeerService *bgppeerv1.BGPPeerServiceApplyConfiguration, opts metav1.ApplyOptions) (result *v1.BGPPeerService, err error) + ApplyStatus(ctx context.Context, bGPPeerService *bgppeerv1.BGPPeerServiceApplyConfiguration, opts metav1.ApplyOptions) (result *v1.BGPPeerService, err error) + BGPPeerServiceExpansion +} + +// bGPPeerServices implements BGPPeerServiceInterface +type bGPPeerServices struct { + client rest.Interface +} + +// newBGPPeerServices returns a BGPPeerServices +func newBGPPeerServices(c *BgppeerV1Client) *bGPPeerServices { + return &bGPPeerServices{ + client: c.RESTClient(), + } +} + +// Get takes name of the bGPPeerService, and returns the corresponding bGPPeerService object, and an error if there is any. +func (c *bGPPeerServices) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.BGPPeerService, err error) { + result = &v1.BGPPeerService{} + err = c.client.Get(). + Resource("bgppeerservices"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of BGPPeerServices that match those selectors. +func (c *bGPPeerServices) List(ctx context.Context, opts metav1.ListOptions) (result *v1.BGPPeerServiceList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.BGPPeerServiceList{} + err = c.client.Get(). + Resource("bgppeerservices"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested bGPPeerServices. +func (c *bGPPeerServices) Watch(ctx context.Context, opts metav1.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(). + Resource("bgppeerservices"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a bGPPeerService and creates it. Returns the server's representation of the bGPPeerService, and an error, if there is any. +func (c *bGPPeerServices) Create(ctx context.Context, bGPPeerService *v1.BGPPeerService, opts metav1.CreateOptions) (result *v1.BGPPeerService, err error) { + result = &v1.BGPPeerService{} + err = c.client.Post(). + Resource("bgppeerservices"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(bGPPeerService). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a bGPPeerService and updates it. Returns the server's representation of the bGPPeerService, and an error, if there is any. +func (c *bGPPeerServices) Update(ctx context.Context, bGPPeerService *v1.BGPPeerService, opts metav1.UpdateOptions) (result *v1.BGPPeerService, err error) { + result = &v1.BGPPeerService{} + err = c.client.Put(). + Resource("bgppeerservices"). + Name(bGPPeerService.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(bGPPeerService). + 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 *bGPPeerServices) UpdateStatus(ctx context.Context, bGPPeerService *v1.BGPPeerService, opts metav1.UpdateOptions) (result *v1.BGPPeerService, err error) { + result = &v1.BGPPeerService{} + err = c.client.Put(). + Resource("bgppeerservices"). + Name(bGPPeerService.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(bGPPeerService). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the bGPPeerService and deletes it. Returns an error if one occurs. +func (c *bGPPeerServices) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + return c.client.Delete(). + Resource("bgppeerservices"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *bGPPeerServices) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Resource("bgppeerservices"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched bGPPeerService. +func (c *bGPPeerServices) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.BGPPeerService, err error) { + result = &v1.BGPPeerService{} + err = c.client.Patch(pt). + Resource("bgppeerservices"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied bGPPeerService. +func (c *bGPPeerServices) Apply(ctx context.Context, bGPPeerService *bgppeerv1.BGPPeerServiceApplyConfiguration, opts metav1.ApplyOptions) (result *v1.BGPPeerService, err error) { + if bGPPeerService == nil { + return nil, fmt.Errorf("bGPPeerService provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(bGPPeerService) + if err != nil { + return nil, err + } + name := bGPPeerService.Name + if name == nil { + return nil, fmt.Errorf("bGPPeerService.Name must be provided to Apply") + } + result = &v1.BGPPeerService{} + err = c.client.Patch(types.ApplyPatchType). + Resource("bgppeerservices"). + Name(*name). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *bGPPeerServices) ApplyStatus(ctx context.Context, bGPPeerService *bgppeerv1.BGPPeerServiceApplyConfiguration, opts metav1.ApplyOptions) (result *v1.BGPPeerService, err error) { + if bGPPeerService == nil { + return nil, fmt.Errorf("bGPPeerService provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(bGPPeerService) + if err != nil { + return nil, err + } + + name := bGPPeerService.Name + if name == nil { + return nil, fmt.Errorf("bGPPeerService.Name must be provided to Apply") + } + + result = &v1.BGPPeerService{} + err = c.client.Patch(types.ApplyPatchType). + Resource("bgppeerservices"). + Name(*name). + SubResource("status"). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/bgppeer/v1/doc.go b/pkg/client/clientset/versioned/typed/bgppeer/v1/doc.go new file mode 100644 index 0000000..3af5d05 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/bgppeer/v1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 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. + +// This package has the automatically generated typed clients. +package v1 diff --git a/pkg/client/clientset/versioned/typed/bgppeer/v1/fake/doc.go b/pkg/client/clientset/versioned/typed/bgppeer/v1/fake/doc.go new file mode 100644 index 0000000..16f4439 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/bgppeer/v1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 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 fake has the automatically generated clients. +package fake diff --git a/pkg/client/clientset/versioned/typed/bgppeer/v1/fake/fake_bgppeer_client.go b/pkg/client/clientset/versioned/typed/bgppeer/v1/fake/fake_bgppeer_client.go new file mode 100644 index 0000000..d71f8a6 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/bgppeer/v1/fake/fake_bgppeer_client.go @@ -0,0 +1,40 @@ +/* +Copyright 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 fake + +import ( + v1 "github.com/loxilb-io/kube-loxilb/pkg/client/clientset/versioned/typed/bgppeer/v1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeBgppeerV1 struct { + *testing.Fake +} + +func (c *FakeBgppeerV1) BGPPeerServices() v1.BGPPeerServiceInterface { + return &FakeBGPPeerServices{c} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeBgppeerV1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/client/clientset/versioned/typed/bgppeer/v1/fake/fake_bgppeerservice.go b/pkg/client/clientset/versioned/typed/bgppeer/v1/fake/fake_bgppeerservice.go new file mode 100644 index 0000000..00a7297 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/bgppeer/v1/fake/fake_bgppeerservice.go @@ -0,0 +1,178 @@ +/* +Copyright 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 fake + +import ( + "context" + json "encoding/json" + "fmt" + + bgppeerv1 "github.com/loxilb-io/kube-loxilb/pkg/client/applyconfiguration/bgppeer/v1" + v1 "github.com/loxilb-io/kube-loxilb/pkg/crds/bgppeer/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeBGPPeerServices implements BGPPeerServiceInterface +type FakeBGPPeerServices struct { + Fake *FakeBgppeerV1 +} + +var bgppeerservicesResource = v1.SchemeGroupVersion.WithResource("bgppeerservices") + +var bgppeerservicesKind = v1.SchemeGroupVersion.WithKind("BGPPeerService") + +// Get takes name of the bGPPeerService, and returns the corresponding bGPPeerService object, and an error if there is any. +func (c *FakeBGPPeerServices) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.BGPPeerService, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(bgppeerservicesResource, name), &v1.BGPPeerService{}) + if obj == nil { + return nil, err + } + return obj.(*v1.BGPPeerService), err +} + +// List takes label and field selectors, and returns the list of BGPPeerServices that match those selectors. +func (c *FakeBGPPeerServices) List(ctx context.Context, opts metav1.ListOptions) (result *v1.BGPPeerServiceList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(bgppeerservicesResource, bgppeerservicesKind, opts), &v1.BGPPeerServiceList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1.BGPPeerServiceList{ListMeta: obj.(*v1.BGPPeerServiceList).ListMeta} + for _, item := range obj.(*v1.BGPPeerServiceList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested bGPPeerServices. +func (c *FakeBGPPeerServices) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(bgppeerservicesResource, opts)) +} + +// Create takes the representation of a bGPPeerService and creates it. Returns the server's representation of the bGPPeerService, and an error, if there is any. +func (c *FakeBGPPeerServices) Create(ctx context.Context, bGPPeerService *v1.BGPPeerService, opts metav1.CreateOptions) (result *v1.BGPPeerService, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(bgppeerservicesResource, bGPPeerService), &v1.BGPPeerService{}) + if obj == nil { + return nil, err + } + return obj.(*v1.BGPPeerService), err +} + +// Update takes the representation of a bGPPeerService and updates it. Returns the server's representation of the bGPPeerService, and an error, if there is any. +func (c *FakeBGPPeerServices) Update(ctx context.Context, bGPPeerService *v1.BGPPeerService, opts metav1.UpdateOptions) (result *v1.BGPPeerService, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(bgppeerservicesResource, bGPPeerService), &v1.BGPPeerService{}) + if obj == nil { + return nil, err + } + return obj.(*v1.BGPPeerService), 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 *FakeBGPPeerServices) UpdateStatus(ctx context.Context, bGPPeerService *v1.BGPPeerService, opts metav1.UpdateOptions) (*v1.BGPPeerService, error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateSubresourceAction(bgppeerservicesResource, "status", bGPPeerService), &v1.BGPPeerService{}) + if obj == nil { + return nil, err + } + return obj.(*v1.BGPPeerService), err +} + +// Delete takes name of the bGPPeerService and deletes it. Returns an error if one occurs. +func (c *FakeBGPPeerServices) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteActionWithOptions(bgppeerservicesResource, name, opts), &v1.BGPPeerService{}) + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeBGPPeerServices) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(bgppeerservicesResource, listOpts) + + _, err := c.Fake.Invokes(action, &v1.BGPPeerServiceList{}) + return err +} + +// Patch applies the patch and returns the patched bGPPeerService. +func (c *FakeBGPPeerServices) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.BGPPeerService, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(bgppeerservicesResource, name, pt, data, subresources...), &v1.BGPPeerService{}) + if obj == nil { + return nil, err + } + return obj.(*v1.BGPPeerService), err +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied bGPPeerService. +func (c *FakeBGPPeerServices) Apply(ctx context.Context, bGPPeerService *bgppeerv1.BGPPeerServiceApplyConfiguration, opts metav1.ApplyOptions) (result *v1.BGPPeerService, err error) { + if bGPPeerService == nil { + return nil, fmt.Errorf("bGPPeerService provided to Apply must not be nil") + } + data, err := json.Marshal(bGPPeerService) + if err != nil { + return nil, err + } + name := bGPPeerService.Name + if name == nil { + return nil, fmt.Errorf("bGPPeerService.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(bgppeerservicesResource, *name, types.ApplyPatchType, data), &v1.BGPPeerService{}) + if obj == nil { + return nil, err + } + return obj.(*v1.BGPPeerService), err +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *FakeBGPPeerServices) ApplyStatus(ctx context.Context, bGPPeerService *bgppeerv1.BGPPeerServiceApplyConfiguration, opts metav1.ApplyOptions) (result *v1.BGPPeerService, err error) { + if bGPPeerService == nil { + return nil, fmt.Errorf("bGPPeerService provided to Apply must not be nil") + } + data, err := json.Marshal(bGPPeerService) + if err != nil { + return nil, err + } + name := bGPPeerService.Name + if name == nil { + return nil, fmt.Errorf("bGPPeerService.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(bgppeerservicesResource, *name, types.ApplyPatchType, data, "status"), &v1.BGPPeerService{}) + if obj == nil { + return nil, err + } + return obj.(*v1.BGPPeerService), err +} diff --git a/pkg/client/clientset/versioned/typed/bgppeer/v1/generated_expansion.go b/pkg/client/clientset/versioned/typed/bgppeer/v1/generated_expansion.go new file mode 100644 index 0000000..adffc09 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/bgppeer/v1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 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 v1 + +type BGPPeerServiceExpansion interface{} diff --git a/pkg/client/informers/externalversions/bgppeer/interface.go b/pkg/client/informers/externalversions/bgppeer/interface.go new file mode 100644 index 0000000..dc3972c --- /dev/null +++ b/pkg/client/informers/externalversions/bgppeer/interface.go @@ -0,0 +1,46 @@ +/* +Copyright 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 informer-gen. DO NOT EDIT. + +package bgppeer + +import ( + v1 "github.com/loxilb-io/kube-loxilb/pkg/client/informers/externalversions/bgppeer/v1" + internalinterfaces "github.com/loxilb-io/kube-loxilb/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1 provides access to shared informers for resources in V1. + V1() v1.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1 returns a new v1.Interface. +func (g *group) V1() v1.Interface { + return v1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/client/informers/externalversions/bgppeer/v1/bgppeerservice.go b/pkg/client/informers/externalversions/bgppeer/v1/bgppeerservice.go new file mode 100644 index 0000000..ccfa23f --- /dev/null +++ b/pkg/client/informers/externalversions/bgppeer/v1/bgppeerservice.go @@ -0,0 +1,89 @@ +/* +Copyright 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 informer-gen. DO NOT EDIT. + +package v1 + +import ( + "context" + time "time" + + versioned "github.com/loxilb-io/kube-loxilb/pkg/client/clientset/versioned" + internalinterfaces "github.com/loxilb-io/kube-loxilb/pkg/client/informers/externalversions/internalinterfaces" + v1 "github.com/loxilb-io/kube-loxilb/pkg/client/listers/bgppeer/v1" + bgppeerv1 "github.com/loxilb-io/kube-loxilb/pkg/crds/bgppeer/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// BGPPeerServiceInformer provides access to a shared informer and lister for +// BGPPeerServices. +type BGPPeerServiceInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1.BGPPeerServiceLister +} + +type bGPPeerServiceInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewBGPPeerServiceInformer constructs a new informer for BGPPeerService type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewBGPPeerServiceInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredBGPPeerServiceInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredBGPPeerServiceInformer constructs a new informer for BGPPeerService type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredBGPPeerServiceInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.BgppeerV1().BGPPeerServices().List(context.TODO(), options) + }, + WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.BgppeerV1().BGPPeerServices().Watch(context.TODO(), options) + }, + }, + &bgppeerv1.BGPPeerService{}, + resyncPeriod, + indexers, + ) +} + +func (f *bGPPeerServiceInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredBGPPeerServiceInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *bGPPeerServiceInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&bgppeerv1.BGPPeerService{}, f.defaultInformer) +} + +func (f *bGPPeerServiceInformer) Lister() v1.BGPPeerServiceLister { + return v1.NewBGPPeerServiceLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/bgppeer/v1/interface.go b/pkg/client/informers/externalversions/bgppeer/v1/interface.go new file mode 100644 index 0000000..00fb965 --- /dev/null +++ b/pkg/client/informers/externalversions/bgppeer/v1/interface.go @@ -0,0 +1,45 @@ +/* +Copyright 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 informer-gen. DO NOT EDIT. + +package v1 + +import ( + internalinterfaces "github.com/loxilb-io/kube-loxilb/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // BGPPeerServices returns a BGPPeerServiceInformer. + BGPPeerServices() BGPPeerServiceInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// BGPPeerServices returns a BGPPeerServiceInformer. +func (v *version) BGPPeerServices() BGPPeerServiceInformer { + return &bGPPeerServiceInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/client/informers/externalversions/factory.go b/pkg/client/informers/externalversions/factory.go new file mode 100644 index 0000000..cb786f3 --- /dev/null +++ b/pkg/client/informers/externalversions/factory.go @@ -0,0 +1,261 @@ +/* +Copyright 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 informer-gen. DO NOT EDIT. + +package externalversions + +import ( + reflect "reflect" + sync "sync" + time "time" + + versioned "github.com/loxilb-io/kube-loxilb/pkg/client/clientset/versioned" + bgppeer "github.com/loxilb-io/kube-loxilb/pkg/client/informers/externalversions/bgppeer" + internalinterfaces "github.com/loxilb-io/kube-loxilb/pkg/client/informers/externalversions/internalinterfaces" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" +) + +// SharedInformerOption defines the functional option type for SharedInformerFactory. +type SharedInformerOption func(*sharedInformerFactory) *sharedInformerFactory + +type sharedInformerFactory struct { + client versioned.Interface + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc + lock sync.Mutex + defaultResync time.Duration + customResync map[reflect.Type]time.Duration + transform cache.TransformFunc + + informers map[reflect.Type]cache.SharedIndexInformer + // startedInformers is used for tracking which informers have been started. + // This allows Start() to be called multiple times safely. + startedInformers map[reflect.Type]bool + // wg tracks how many goroutines were started. + wg sync.WaitGroup + // shuttingDown is true when Shutdown has been called. It may still be running + // because it needs to wait for goroutines. + shuttingDown bool +} + +// WithCustomResyncConfig sets a custom resync period for the specified informer types. +func WithCustomResyncConfig(resyncConfig map[v1.Object]time.Duration) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + for k, v := range resyncConfig { + factory.customResync[reflect.TypeOf(k)] = v + } + return factory + } +} + +// WithTweakListOptions sets a custom filter on all listers of the configured SharedInformerFactory. +func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.tweakListOptions = tweakListOptions + return factory + } +} + +// WithNamespace limits the SharedInformerFactory to the specified namespace. +func WithNamespace(namespace string) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.namespace = namespace + return factory + } +} + +// WithTransform sets a transform on all informers. +func WithTransform(transform cache.TransformFunc) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.transform = transform + return factory + } +} + +// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces. +func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory { + return NewSharedInformerFactoryWithOptions(client, defaultResync) +} + +// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory. +// Listers obtained via this SharedInformerFactory will be subject to the same filters +// as specified here. +// Deprecated: Please use NewSharedInformerFactoryWithOptions instead +func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory { + return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions)) +} + +// NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options. +func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory { + factory := &sharedInformerFactory{ + client: client, + namespace: v1.NamespaceAll, + defaultResync: defaultResync, + informers: make(map[reflect.Type]cache.SharedIndexInformer), + startedInformers: make(map[reflect.Type]bool), + customResync: make(map[reflect.Type]time.Duration), + } + + // Apply all options + for _, opt := range options { + factory = opt(factory) + } + + return factory +} + +func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) { + f.lock.Lock() + defer f.lock.Unlock() + + if f.shuttingDown { + return + } + + for informerType, informer := range f.informers { + if !f.startedInformers[informerType] { + f.wg.Add(1) + // We need a new variable in each loop iteration, + // otherwise the goroutine would use the loop variable + // and that keeps changing. + informer := informer + go func() { + defer f.wg.Done() + informer.Run(stopCh) + }() + f.startedInformers[informerType] = true + } + } +} + +func (f *sharedInformerFactory) Shutdown() { + f.lock.Lock() + f.shuttingDown = true + f.lock.Unlock() + + // Will return immediately if there is nothing to wait for. + f.wg.Wait() +} + +func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool { + informers := func() map[reflect.Type]cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informers := map[reflect.Type]cache.SharedIndexInformer{} + for informerType, informer := range f.informers { + if f.startedInformers[informerType] { + informers[informerType] = informer + } + } + return informers + }() + + res := map[reflect.Type]bool{} + for informType, informer := range informers { + res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced) + } + return res +} + +// InformerFor returns the SharedIndexInformer for obj using an internal +// client. +func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informerType := reflect.TypeOf(obj) + informer, exists := f.informers[informerType] + if exists { + return informer + } + + resyncPeriod, exists := f.customResync[informerType] + if !exists { + resyncPeriod = f.defaultResync + } + + informer = newFunc(f.client, resyncPeriod) + informer.SetTransform(f.transform) + f.informers[informerType] = informer + + return informer +} + +// SharedInformerFactory provides shared informers for resources in all known +// API group versions. +// +// It is typically used like this: +// +// ctx, cancel := context.Background() +// defer cancel() +// factory := NewSharedInformerFactory(client, resyncPeriod) +// defer factory.WaitForStop() // Returns immediately if nothing was started. +// genericInformer := factory.ForResource(resource) +// typedInformer := factory.SomeAPIGroup().V1().SomeType() +// factory.Start(ctx.Done()) // Start processing these informers. +// synced := factory.WaitForCacheSync(ctx.Done()) +// for v, ok := range synced { +// if !ok { +// fmt.Fprintf(os.Stderr, "caches failed to sync: %v", v) +// return +// } +// } +// +// // Creating informers can also be created after Start, but then +// // Start must be called again: +// anotherGenericInformer := factory.ForResource(resource) +// factory.Start(ctx.Done()) +type SharedInformerFactory interface { + internalinterfaces.SharedInformerFactory + + // Start initializes all requested informers. They are handled in goroutines + // which run until the stop channel gets closed. + Start(stopCh <-chan struct{}) + + // Shutdown marks a factory as shutting down. At that point no new + // informers can be started anymore and Start will return without + // doing anything. + // + // In addition, Shutdown blocks until all goroutines have terminated. For that + // to happen, the close channel(s) that they were started with must be closed, + // either before Shutdown gets called or while it is waiting. + // + // Shutdown may be called multiple times, even concurrently. All such calls will + // block until all goroutines have terminated. + Shutdown() + + // WaitForCacheSync blocks until all started informers' caches were synced + // or the stop channel gets closed. + WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool + + // ForResource gives generic access to a shared informer of the matching type. + ForResource(resource schema.GroupVersionResource) (GenericInformer, error) + + // InformerFor returns the SharedIndexInformer for obj using an internal + // client. + InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer + + Bgppeer() bgppeer.Interface +} + +func (f *sharedInformerFactory) Bgppeer() bgppeer.Interface { + return bgppeer.New(f, f.namespace, f.tweakListOptions) +} diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go new file mode 100644 index 0000000..23dc919 --- /dev/null +++ b/pkg/client/informers/externalversions/generic.go @@ -0,0 +1,62 @@ +/* +Copyright 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 informer-gen. DO NOT EDIT. + +package externalversions + +import ( + "fmt" + + v1 "github.com/loxilb-io/kube-loxilb/pkg/crds/bgppeer/v1" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" +) + +// GenericInformer is type of SharedIndexInformer which will locate and delegate to other +// sharedInformers based on type +type GenericInformer interface { + Informer() cache.SharedIndexInformer + Lister() cache.GenericLister +} + +type genericInformer struct { + informer cache.SharedIndexInformer + resource schema.GroupResource +} + +// Informer returns the SharedIndexInformer. +func (f *genericInformer) Informer() cache.SharedIndexInformer { + return f.informer +} + +// Lister returns the GenericLister. +func (f *genericInformer) Lister() cache.GenericLister { + return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource) +} + +// ForResource gives generic access to a shared informer of the matching type +// TODO extend this to unknown resources with a client pool +func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { + switch resource { + // Group=bgppeer.loxilb.io, Version=v1 + case v1.SchemeGroupVersion.WithResource("bgppeerservices"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Bgppeer().V1().BGPPeerServices().Informer()}, nil + + } + + return nil, fmt.Errorf("no informer found for %v", resource) +} diff --git a/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go b/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go new file mode 100644 index 0000000..bc74a65 --- /dev/null +++ b/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go @@ -0,0 +1,40 @@ +/* +Copyright 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 informer-gen. DO NOT EDIT. + +package internalinterfaces + +import ( + time "time" + + versioned "github.com/loxilb-io/kube-loxilb/pkg/client/clientset/versioned" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + cache "k8s.io/client-go/tools/cache" +) + +// NewInformerFunc takes versioned.Interface and time.Duration to return a SharedIndexInformer. +type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer + +// SharedInformerFactory a small interface to allow for adding an informer without an import cycle +type SharedInformerFactory interface { + Start(stopCh <-chan struct{}) + InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer +} + +// TweakListOptionsFunc is a function that transforms a v1.ListOptions. +type TweakListOptionsFunc func(*v1.ListOptions) diff --git a/pkg/client/listers/bgppeer/v1/bgppeerservice.go b/pkg/client/listers/bgppeer/v1/bgppeerservice.go new file mode 100644 index 0000000..10faaa3 --- /dev/null +++ b/pkg/client/listers/bgppeer/v1/bgppeerservice.go @@ -0,0 +1,68 @@ +/* +Copyright 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 lister-gen. DO NOT EDIT. + +package v1 + +import ( + v1 "github.com/loxilb-io/kube-loxilb/pkg/crds/bgppeer/v1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// BGPPeerServiceLister helps list BGPPeerServices. +// All objects returned here must be treated as read-only. +type BGPPeerServiceLister interface { + // List lists all BGPPeerServices in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1.BGPPeerService, err error) + // Get retrieves the BGPPeerService from the index for a given name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1.BGPPeerService, error) + BGPPeerServiceListerExpansion +} + +// bGPPeerServiceLister implements the BGPPeerServiceLister interface. +type bGPPeerServiceLister struct { + indexer cache.Indexer +} + +// NewBGPPeerServiceLister returns a new BGPPeerServiceLister. +func NewBGPPeerServiceLister(indexer cache.Indexer) BGPPeerServiceLister { + return &bGPPeerServiceLister{indexer: indexer} +} + +// List lists all BGPPeerServices in the indexer. +func (s *bGPPeerServiceLister) List(selector labels.Selector) (ret []*v1.BGPPeerService, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.BGPPeerService)) + }) + return ret, err +} + +// Get retrieves the BGPPeerService from the index for a given name. +func (s *bGPPeerServiceLister) Get(name string) (*v1.BGPPeerService, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("bgppeerservice"), name) + } + return obj.(*v1.BGPPeerService), nil +} diff --git a/pkg/client/listers/bgppeer/v1/expansion_generated.go b/pkg/client/listers/bgppeer/v1/expansion_generated.go new file mode 100644 index 0000000..8ee211d --- /dev/null +++ b/pkg/client/listers/bgppeer/v1/expansion_generated.go @@ -0,0 +1,23 @@ +/* +Copyright 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 lister-gen. DO NOT EDIT. + +package v1 + +// BGPPeerServiceListerExpansion allows custom methods to be added to +// BGPPeerServiceLister. +type BGPPeerServiceListerExpansion interface{} diff --git a/pkg/crds/bgppeer/v1/doc.go b/pkg/crds/bgppeer/v1/doc.go new file mode 100644 index 0000000..d36cf2b --- /dev/null +++ b/pkg/crds/bgppeer/v1/doc.go @@ -0,0 +1,4 @@ +// +k8s:deepcopy-gen=package +// +groupName=bgppeer.loxilb.io + +package v1 diff --git a/pkg/crds/bgppeer/v1/register.go b/pkg/crds/bgppeer/v1/register.go new file mode 100644 index 0000000..3a6b604 --- /dev/null +++ b/pkg/crds/bgppeer/v1/register.go @@ -0,0 +1,31 @@ +package v1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +const GroupName = "bgppeer.loxilb.io" + +var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1"} + +var ( + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme +) + +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes( + SchemeGroupVersion, + &BGPPeerService{}, + &BGPPeerServiceList{}, + ) + + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/pkg/crds/bgppeer/v1/types.go b/pkg/crds/bgppeer/v1/types.go new file mode 100644 index 0000000..0589d1d --- /dev/null +++ b/pkg/crds/bgppeer/v1/types.go @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2022 NetLOX Inc + * + * 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. + */ + +package v1 + +import ( + "github.com/loxilb-io/kube-loxilb/pkg/api" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +type BGPPeerModel BGPNeigh + +// BGPPeerServiceStatus defines the observed state of BGPPeerService +type BGPPeerServiceStatus struct { + // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster + // Important: Run "make" to regenerate code after modifying this file +} + +//+kubebuilder:object:root=true +//+kubebuilder:subresource:status + +// +genclient +// +genclient:nonNamespaced +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type BGPPeerService struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec BGPPeerModel `json:"spec,omitempty"` + Status BGPPeerServiceStatus `json:"status,omitempty"` +} + +// BGPPeerServiceSpec defines the desired state of LBService +type BGPPeerServiceSpec struct { + Model BGPPeerModel `json:"bgpPeer"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type BGPPeerServiceList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []*BGPPeerService `json:"items"` +} + +type BGPNeigh struct { + // BGP Neighbor IP address + IPAddress string `json:"ipAddress,omitempty"` + // Remote AS number + RemoteAs int64 `json:"remoteAs,omitempty"` + // Remote Connect Port (default 179) + RemotePort int64 `json:"remotePort,omitempty"` +} + +func (bpgModel *BGPPeerModel) GetKeyStruct() api.LoxiModel { + return bpgModel +} diff --git a/pkg/crds/bgppeer/v1/zz_generated.deepcopy.go b/pkg/crds/bgppeer/v1/zz_generated.deepcopy.go new file mode 100644 index 0000000..c3ea942 --- /dev/null +++ b/pkg/crds/bgppeer/v1/zz_generated.deepcopy.go @@ -0,0 +1,156 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright 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 deepcopy-gen. DO NOT EDIT. + +package v1 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BGPNeigh) DeepCopyInto(out *BGPNeigh) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BGPNeigh. +func (in *BGPNeigh) DeepCopy() *BGPNeigh { + if in == nil { + return nil + } + out := new(BGPNeigh) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BGPPeerModel) DeepCopyInto(out *BGPPeerModel) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BGPPeerModel. +func (in *BGPPeerModel) DeepCopy() *BGPPeerModel { + if in == nil { + return nil + } + out := new(BGPPeerModel) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BGPPeerService) DeepCopyInto(out *BGPPeerService) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BGPPeerService. +func (in *BGPPeerService) DeepCopy() *BGPPeerService { + if in == nil { + return nil + } + out := new(BGPPeerService) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *BGPPeerService) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BGPPeerServiceList) DeepCopyInto(out *BGPPeerServiceList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]*BGPPeerService, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(BGPPeerService) + (*in).DeepCopyInto(*out) + } + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BGPPeerServiceList. +func (in *BGPPeerServiceList) DeepCopy() *BGPPeerServiceList { + if in == nil { + return nil + } + out := new(BGPPeerServiceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *BGPPeerServiceList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BGPPeerServiceSpec) DeepCopyInto(out *BGPPeerServiceSpec) { + *out = *in + out.Model = in.Model + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BGPPeerServiceSpec. +func (in *BGPPeerServiceSpec) DeepCopy() *BGPPeerServiceSpec { + if in == nil { + return nil + } + out := new(BGPPeerServiceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BGPPeerServiceStatus) DeepCopyInto(out *BGPPeerServiceStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BGPPeerServiceStatus. +func (in *BGPPeerServiceStatus) DeepCopy() *BGPPeerServiceStatus { + if in == nil { + return nil + } + out := new(BGPPeerServiceStatus) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/k8s/client.go b/pkg/k8s/client.go index 0a5e12f..9176d93 100644 --- a/pkg/k8s/client.go +++ b/pkg/k8s/client.go @@ -17,6 +17,7 @@ package k8s import ( + crdclientset "github.com/loxilb-io/kube-loxilb/pkg/client/clientset/versioned" apiextensionclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" clientset "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" @@ -28,7 +29,7 @@ import ( // CreateClients creates kube clients from the given config. func CreateClients(config componentbaseconfig.ClientConnectionConfiguration, kubeAPIServerOverride string) ( - clientset.Interface, aggregatorclientset.Interface, apiextensionclientset.Interface, error) { + clientset.Interface, aggregatorclientset.Interface, crdclientset.Interface, apiextensionclientset.Interface, error) { var kubeConfig *rest.Config var err error @@ -46,7 +47,7 @@ func CreateClients(config componentbaseconfig.ClientConnectionConfiguration, kub } if err != nil { - return nil, nil, nil, err + return nil, nil, nil, nil, err } kubeConfig.AcceptContentTypes = config.AcceptContentTypes @@ -56,22 +57,23 @@ func CreateClients(config componentbaseconfig.ClientConnectionConfiguration, kub client, err := clientset.NewForConfig(kubeConfig) if err != nil { - return nil, nil, nil, err + return nil, nil, nil, nil, err } aggregatorClient, err := aggregatorclientset.NewForConfig(kubeConfig) if err != nil { - return nil, nil, nil, err + return nil, nil, nil, nil, err } // Create client for crd operations - //crdClient, err := crdclientset.NewForConfig(kubeConfig) + crdClient, err := crdclientset.NewForConfig(kubeConfig) if err != nil { - return nil, nil, nil, err + return nil, nil, nil, nil, err } + // Create client for crd manipulations apiExtensionClient, err := apiextensionclientset.NewForConfig(kubeConfig) if err != nil { - return nil, nil, nil, err + return nil, nil, nil, nil, err } - return client, aggregatorClient, apiExtensionClient, nil + return client, aggregatorClient, crdClient, apiExtensionClient, nil } From 320da7039cd6aac0cc6e9d49e67fedf02840f80e Mon Sep 17 00:00:00 2001 From: inho Date: Fri, 29 Mar 2024 17:00:07 +0900 Subject: [PATCH 2/3] Add CRD manual and rules in kube-loxilb.yaml --- README.md | 50 ++++++++++++++++++++++ go.mod | 5 +-- go.sum | 41 ++++++------------ manifest/ext-cluster/kube-loxilb.yaml | 12 ++++++ manifest/ext-peer-cluster/kube-loxilb.yaml | 11 +++++ manifest/gateway-api/kube-loxilb.yaml | 11 +++++ manifest/in-cluster/kube-loxilb.yaml | 11 +++++ manifest/mesh/kube-loxilb.yml | 11 +++++ manifest/zones/kube-loxilb-north.yml | 11 +++++ manifest/zones/kube-loxilb-south.yml | 11 +++++ 10 files changed, 143 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index cfc5d7f..b5ef4c1 100644 --- a/README.md +++ b/README.md @@ -199,3 +199,53 @@ kube-system loxilb-lb-5m85p 1/1 Running ``` Thereafter, the process of service creation remains the same as explained in previous sections. + + +## How to use CRD ? + +Kube-loxilb provides Custom Resource Definition (CRD). The current CRD features include the following and will be updated. +- Add / Delete BGP Peer + +An example of CRD is stored in the manifast folder, and using BGP Peer as an example is as follows. +1. preprocessing + - Apply lbpeercrd.yaml in manifast first +``` +kubectl apply -f manifast/crds/lbpeercrd.yaml +``` +2. CRD definition + +You need to create a yaml file that adds a peer for BGP. The example below is an example of creating a Peer with a RemoteAS number of Peer IP address 65123 at 123.123.2. Create a file named bgp-peer.yaml and add the contents below. +```yaml +apiVersion: "bgppeer.loxilb.io/v1" +kind: BGPPeerService +metadata: + name: bgp-peer-test +spec: + ipAddress: 123.123.123.2 + remoteAs: 65123 + remotePort: 179 +``` + +3. Apply CRD + +It's simple to apply, you can use kubectl the same as the usual k8s settings. +``` +kubectl apply -f bgp-peer.yaml +``` + +4. CRD verification + + +You can check it in two ways. The first one can be checked through loxicmd, and the second one can be checked through kubectl. It is more recommended to check through loxicmd. +``` +# loxicmd +kubectl exec -it {loxilb} -n kube-system -- loxicmd get bgpneigh +| PEER | AS | UP/DOWN | STATE | +|----------------|-------|-------------|-------------| +| 123.123.123.2 | 65123 | never | ACTIVE | + +# kubectl +kubectl get bgppeerservice +NAME PEER AS +bgp-peer-test 123.123.123.2 65123 +``` diff --git a/go.mod b/go.mod index dfbee56..09e280a 100644 --- a/go.mod +++ b/go.mod @@ -14,8 +14,8 @@ require ( k8s.io/component-base v0.28.3 k8s.io/klog/v2 v2.100.1 k8s.io/kube-aggregator v0.26.0 - sigs.k8s.io/structured-merge-diff/v4 v4.2.3 sigs.k8s.io/gateway-api v1.0.0 + sigs.k8s.io/structured-merge-diff/v4 v4.3.0 ) require ( @@ -24,7 +24,7 @@ require ( github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect - github.com/evanphx/json-patch v4.12.0+incompatible // indirect + github.com/evanphx/json-patch v5.7.0+incompatible // indirect github.com/go-logr/logr v1.2.4 // indirect github.com/go-openapi/jsonpointer v0.20.0 // indirect github.com/go-openapi/jsonreference v0.20.2 // indirect @@ -63,6 +63,5 @@ require ( k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.3.0 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/go.sum b/go.sum index 0b29ba7..9d8c170 100644 --- a/go.sum +++ b/go.sum @@ -11,30 +11,13 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= -github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= -github.com/emicklei/go-restful/v3 v3.9.0 h1:XwGDlfxEnQZzuopoqxwSEllNcCOM9DhhFyhFIIGKwxE= -github.com/emicklei/go-restful/v3 v3.9.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/evanphx/json-patch v4.12.0+incompatible h1:4onqiflcdA9EOZ4RxV643DvftH5pOlLGNtQ5lPWQu84= -github.com/evanphx/json-patch v4.12.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= -github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= -github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= -github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= +github.com/evanphx/json-patch v5.7.0+incompatible h1:vgGkfT/9f8zE6tvSCe74nfpAVDQ2tG6yudJd8LBksgI= +github.com/evanphx/json-patch v5.7.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/zapr v1.2.3 h1:a9vnzlIBPQBBkeaR9IuMUfmVOrQlkoC4YfPoFkX3T7A= +github.com/go-logr/zapr v1.2.3/go.mod h1:eIauM6P8qSvTw5o2ez6UEAfGjQKrxQTl5EoK+Qa2oG4= github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= github.com/go-openapi/jsonpointer v0.20.0 h1:ESKJdU9ASRfaPNOPRx12IUyA1vn3R9GiE3KYD14BXdQ= github.com/go-openapi/jsonpointer v0.20.0/go.mod h1:6PGzBjjIIumbLYysB73Klnms1mwnU4G3YHOECG3CedA= @@ -44,6 +27,7 @@ github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+ github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogBU= github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= @@ -60,6 +44,7 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/ github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec= +github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4= @@ -74,6 +59,7 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -94,15 +80,9 @@ github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjY github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/onsi/ginkgo/v2 v2.9.4 h1:xR7vG4IXt5RWx6FfIjyAtsoMAtnc3C/rFXBBd2AjZwE= +github.com/onsi/ginkgo/v2 v2.9.4/go.mod h1:gCQYp2Q+kSoIj7ykSVb9nskRSsR6PUj4AiLywzIhbKM= github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE= -github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/onsi/ginkgo/v2 v2.4.0 h1:+Ig9nvqgS5OBSACXNk15PLdp0U9XPYROt9CFzVdFGIs= -github.com/onsi/gomega v1.23.0 h1:/oxKu9c2HVap+F3PfKort2Hw5DEU+HGlW8n+tguWsys= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -116,6 +96,7 @@ github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGy github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= @@ -129,11 +110,14 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= +go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -182,6 +166,7 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc= +golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/manifest/ext-cluster/kube-loxilb.yaml b/manifest/ext-cluster/kube-loxilb.yaml index c898b8b..ec51501 100644 --- a/manifest/ext-cluster/kube-loxilb.yaml +++ b/manifest/ext-cluster/kube-loxilb.yaml @@ -70,6 +70,18 @@ rules: - subjectaccessreviews verbs: - create + - apiGroups: + - bgppeer.loxilb.io + resources: + - bgppeerservices + verbs: + - get + - watch + - list + - create + - update + - delete + --- kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 diff --git a/manifest/ext-peer-cluster/kube-loxilb.yaml b/manifest/ext-peer-cluster/kube-loxilb.yaml index 435e934..2764aaa 100644 --- a/manifest/ext-peer-cluster/kube-loxilb.yaml +++ b/manifest/ext-peer-cluster/kube-loxilb.yaml @@ -70,6 +70,17 @@ rules: - subjectaccessreviews verbs: - create + - apiGroups: + - bgppeer.loxilb.io + resources: + - bgppeerservices + verbs: + - get + - watch + - list + - create + - update + - delete --- kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 diff --git a/manifest/gateway-api/kube-loxilb.yaml b/manifest/gateway-api/kube-loxilb.yaml index 32be105..d1de5bd 100644 --- a/manifest/gateway-api/kube-loxilb.yaml +++ b/manifest/gateway-api/kube-loxilb.yaml @@ -72,6 +72,17 @@ rules: - subjectaccessreviews verbs: - create + - apiGroups: + - bgppeer.loxilb.io + resources: + - bgppeerservices + verbs: + - get + - watch + - list + - create + - update + - delete --- kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 diff --git a/manifest/in-cluster/kube-loxilb.yaml b/manifest/in-cluster/kube-loxilb.yaml index e723065..781d847 100644 --- a/manifest/in-cluster/kube-loxilb.yaml +++ b/manifest/in-cluster/kube-loxilb.yaml @@ -70,6 +70,17 @@ rules: - subjectaccessreviews verbs: - create + - apiGroups: + - bgppeer.loxilb.io + resources: + - bgppeerservices + verbs: + - get + - watch + - list + - create + - update + - delete --- kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 diff --git a/manifest/mesh/kube-loxilb.yml b/manifest/mesh/kube-loxilb.yml index c50fb4c..9a5aad6 100644 --- a/manifest/mesh/kube-loxilb.yml +++ b/manifest/mesh/kube-loxilb.yml @@ -70,6 +70,17 @@ rules: - subjectaccessreviews verbs: - create + - apiGroups: + - bgppeer.loxilb.io + resources: + - bgppeerservices + verbs: + - get + - watch + - list + - create + - update + - delete --- kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 diff --git a/manifest/zones/kube-loxilb-north.yml b/manifest/zones/kube-loxilb-north.yml index c6558d1..ae816ed 100644 --- a/manifest/zones/kube-loxilb-north.yml +++ b/manifest/zones/kube-loxilb-north.yml @@ -70,6 +70,17 @@ rules: - subjectaccessreviews verbs: - create + - apiGroups: + - bgppeer.loxilb.io + resources: + - bgppeerservices + verbs: + - get + - watch + - list + - create + - update + - delete --- kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 diff --git a/manifest/zones/kube-loxilb-south.yml b/manifest/zones/kube-loxilb-south.yml index e31f4c0..6081ea5 100644 --- a/manifest/zones/kube-loxilb-south.yml +++ b/manifest/zones/kube-loxilb-south.yml @@ -70,6 +70,17 @@ rules: - subjectaccessreviews verbs: - create + - apiGroups: + - bgppeer.loxilb.io + resources: + - bgppeerservices + verbs: + - get + - watch + - list + - create + - update + - delete --- kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 From 575ac149dacab98f2e01721b8f841bf8d520ed58 Mon Sep 17 00:00:00 2001 From: inho Date: Fri, 29 Mar 2024 17:09:27 +0900 Subject: [PATCH 3/3] Add client nil --- pkg/k8s/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/k8s/client.go b/pkg/k8s/client.go index 72d43b6..7da9019 100644 --- a/pkg/k8s/client.go +++ b/pkg/k8s/client.go @@ -75,7 +75,7 @@ func CreateClients(config componentbaseconfig.ClientConnectionConfiguration, kub // Create client for crd manipulations apiExtensionClient, err := apiextensionclientset.NewForConfig(kubeConfig) if err != nil { - return nil, nil, nil, nil, err + return nil, nil, nil, nil, nil, err } sigsClient, err := sigsclientset.NewForConfig(kubeConfig) if err != nil {