diff --git a/generated/client/clientset/versioned/clientset.go b/generated/client/clientset/versioned/clientset.go index b6c343f..3e71ce3 100644 --- a/generated/client/clientset/versioned/clientset.go +++ b/generated/client/clientset/versioned/clientset.go @@ -4,12 +4,12 @@ package versioned import ( "fmt" + "net/http" + prescalingv1 "github.com/BedrockStreaming/prescaling-exporter/generated/client/clientset/versioned/typed/prescaling.bedrock.tech/v1" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" - - prescalingv1 "github.com/BedrockStreaming/prescaling-exporter/generated/client/clientset/versioned/typed/prescaling.bedrock.tech/v1" ) type Interface interface { @@ -17,8 +17,7 @@ type Interface interface { PrescalingV1() prescalingv1.PrescalingV1Interface } -// Clientset contains the clients for groups. Each group has exactly one -// version included in a Clientset. +// Clientset contains the clients for groups. type Clientset struct { *discovery.DiscoveryClient prescalingV1 *prescalingv1.PrescalingV1Client @@ -40,22 +39,45 @@ func (c *Clientset) Discovery() discovery.DiscoveryInterface { // 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.prescalingV1, err = prescalingv1.NewForConfig(&configShallowCopy) + cs.prescalingV1, err = prescalingv1.NewForConfigAndClient(&configShallowCopy, httpClient) if err != nil { return nil, err } - cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) + cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient) if err != nil { return nil, err } @@ -65,11 +87,11 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { // 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 { - var cs Clientset - cs.prescalingV1 = prescalingv1.NewForConfigOrDie(c) - - cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) - return &cs + cs, err := NewForConfig(c) + if err != nil { + panic(err) + } + return cs } // New creates a new Clientset for the given RESTClient. diff --git a/generated/client/clientset/versioned/fake/clientset_generated.go b/generated/client/clientset/versioned/fake/clientset_generated.go index 13479eb..6f9fa7b 100644 --- a/generated/client/clientset/versioned/fake/clientset_generated.go +++ b/generated/client/clientset/versioned/fake/clientset_generated.go @@ -3,15 +3,14 @@ package fake import ( + clientset "github.com/BedrockStreaming/prescaling-exporter/generated/client/clientset/versioned" + prescalingv1 "github.com/BedrockStreaming/prescaling-exporter/generated/client/clientset/versioned/typed/prescaling.bedrock.tech/v1" + fakeprescalingv1 "github.com/BedrockStreaming/prescaling-exporter/generated/client/clientset/versioned/typed/prescaling.bedrock.tech/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" - - clientset "github.com/BedrockStreaming/prescaling-exporter/generated/client/clientset/versioned" - prescalingv1 "github.com/BedrockStreaming/prescaling-exporter/generated/client/clientset/versioned/typed/prescaling.bedrock.tech/v1" - fakeprescalingv1 "github.com/BedrockStreaming/prescaling-exporter/generated/client/clientset/versioned/typed/prescaling.bedrock.tech/v1/fake" ) // NewSimpleClientset returns a clientset that will respond with the provided objects. @@ -59,7 +58,10 @@ func (c *Clientset) Tracker() testing.ObjectTracker { return c.tracker } -var _ clientset.Interface = &Clientset{} +var ( + _ clientset.Interface = &Clientset{} + _ testing.FakeClient = &Clientset{} +) // PrescalingV1 retrieves the PrescalingV1Client func (c *Clientset) PrescalingV1() prescalingv1.PrescalingV1Interface { diff --git a/generated/client/clientset/versioned/fake/register.go b/generated/client/clientset/versioned/fake/register.go index a30027c..ed11ba6 100644 --- a/generated/client/clientset/versioned/fake/register.go +++ b/generated/client/clientset/versioned/fake/register.go @@ -3,13 +3,12 @@ package fake import ( + prescalingv1 "github.com/BedrockStreaming/prescaling-exporter/pkg/apis/prescaling.bedrock.tech/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" - - prescalingv1 "github.com/BedrockStreaming/prescaling-exporter/pkg/apis/prescaling.bedrock.tech/v1" ) var scheme = runtime.NewScheme() diff --git a/generated/client/clientset/versioned/scheme/register.go b/generated/client/clientset/versioned/scheme/register.go index 2407116..64c4794 100644 --- a/generated/client/clientset/versioned/scheme/register.go +++ b/generated/client/clientset/versioned/scheme/register.go @@ -3,13 +3,12 @@ package scheme import ( + prescalingv1 "github.com/BedrockStreaming/prescaling-exporter/pkg/apis/prescaling.bedrock.tech/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" - - prescalingv1 "github.com/BedrockStreaming/prescaling-exporter/pkg/apis/prescaling.bedrock.tech/v1" ) var Scheme = runtime.NewScheme() diff --git a/generated/client/clientset/versioned/typed/prescaling.bedrock.tech/v1/fake/fake_prescaling.bedrock.tech_client.go b/generated/client/clientset/versioned/typed/prescaling.bedrock.tech/v1/fake/fake_prescaling.bedrock.tech_client.go index 6dbe253..d80a4f4 100644 --- a/generated/client/clientset/versioned/typed/prescaling.bedrock.tech/v1/fake/fake_prescaling.bedrock.tech_client.go +++ b/generated/client/clientset/versioned/typed/prescaling.bedrock.tech/v1/fake/fake_prescaling.bedrock.tech_client.go @@ -3,10 +3,9 @@ package fake import ( + v1 "github.com/BedrockStreaming/prescaling-exporter/generated/client/clientset/versioned/typed/prescaling.bedrock.tech/v1" rest "k8s.io/client-go/rest" testing "k8s.io/client-go/testing" - - v1 "github.com/BedrockStreaming/prescaling-exporter/generated/client/clientset/versioned/typed/prescaling.bedrock.tech/v1" ) type FakePrescalingV1 struct { diff --git a/generated/client/clientset/versioned/typed/prescaling.bedrock.tech/v1/fake/fake_prescalingevent.go b/generated/client/clientset/versioned/typed/prescaling.bedrock.tech/v1/fake/fake_prescalingevent.go index de705cd..de8d59b 100644 --- a/generated/client/clientset/versioned/typed/prescaling.bedrock.tech/v1/fake/fake_prescalingevent.go +++ b/generated/client/clientset/versioned/typed/prescaling.bedrock.tech/v1/fake/fake_prescalingevent.go @@ -5,14 +5,13 @@ package fake import ( "context" + prescalingbedrocktechv1 "github.com/BedrockStreaming/prescaling-exporter/pkg/apis/prescaling.bedrock.tech/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" - - prescalingbedrocktechv1 "github.com/BedrockStreaming/prescaling-exporter/pkg/apis/prescaling.bedrock.tech/v1" ) // FakePrescalingEvents implements PrescalingEventInterface @@ -90,7 +89,7 @@ func (c *FakePrescalingEvents) Update(ctx context.Context, prescalingEvent *pres // Delete takes name of the prescalingEvent and deletes it. Returns an error if one occurs. func (c *FakePrescalingEvents) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewDeleteAction(prescalingeventsResource, c.ns, name), &prescalingbedrocktechv1.PrescalingEvent{}) + Invokes(testing.NewDeleteActionWithOptions(prescalingeventsResource, c.ns, name, opts), &prescalingbedrocktechv1.PrescalingEvent{}) return err } diff --git a/generated/client/clientset/versioned/typed/prescaling.bedrock.tech/v1/prescaling.bedrock.tech_client.go b/generated/client/clientset/versioned/typed/prescaling.bedrock.tech/v1/prescaling.bedrock.tech_client.go index 30304b9..c0c25b2 100644 --- a/generated/client/clientset/versioned/typed/prescaling.bedrock.tech/v1/prescaling.bedrock.tech_client.go +++ b/generated/client/clientset/versioned/typed/prescaling.bedrock.tech/v1/prescaling.bedrock.tech_client.go @@ -3,10 +3,11 @@ package v1 import ( - rest "k8s.io/client-go/rest" + "net/http" "github.com/BedrockStreaming/prescaling-exporter/generated/client/clientset/versioned/scheme" v1 "github.com/BedrockStreaming/prescaling-exporter/pkg/apis/prescaling.bedrock.tech/v1" + rest "k8s.io/client-go/rest" ) type PrescalingV1Interface interface { @@ -24,12 +25,28 @@ func (c *PrescalingV1Client) PrescalingEvents(namespace string) PrescalingEventI } // NewForConfig creates a new PrescalingV1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*PrescalingV1Client, error) { config := *c if err := setConfigDefaults(&config); err != nil { return nil, err } - client, err := rest.RESTClientFor(&config) + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new PrescalingV1Client 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) (*PrescalingV1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientForConfigAndClient(&config, h) if err != nil { return nil, err } diff --git a/generated/client/clientset/versioned/typed/prescaling.bedrock.tech/v1/prescalingevent.go b/generated/client/clientset/versioned/typed/prescaling.bedrock.tech/v1/prescalingevent.go index d0b26d3..11063fd 100644 --- a/generated/client/clientset/versioned/typed/prescaling.bedrock.tech/v1/prescalingevent.go +++ b/generated/client/clientset/versioned/typed/prescaling.bedrock.tech/v1/prescalingevent.go @@ -6,13 +6,12 @@ import ( "context" "time" + scheme "github.com/BedrockStreaming/prescaling-exporter/generated/client/clientset/versioned/scheme" + v1 "github.com/BedrockStreaming/prescaling-exporter/pkg/apis/prescaling.bedrock.tech/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" - - scheme "github.com/BedrockStreaming/prescaling-exporter/generated/client/clientset/versioned/scheme" - v1 "github.com/BedrockStreaming/prescaling-exporter/pkg/apis/prescaling.bedrock.tech/v1" ) // PrescalingEventsGetter has a method to return a PrescalingEventInterface. diff --git a/go.mod b/go.mod index 2f3a56d..34cb14f 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( k8s.io/api v0.25.4 k8s.io/apimachinery v0.26.2 k8s.io/client-go v0.25.4 - k8s.io/code-generator v0.26.2 + k8s.io/code-generator v0.26.3 k8s.io/utils v0.0.0-20221107191617-1a15be271d1d ) diff --git a/go.sum b/go.sum index 2aaf2ee..1a8eea2 100644 --- a/go.sum +++ b/go.sum @@ -628,8 +628,8 @@ k8s.io/apimachinery v0.26.2 h1:da1u3D5wfR5u2RpLhE/ZtZS2P7QvDgLZTi9wrNZl/tQ= k8s.io/apimachinery v0.26.2/go.mod h1:ats7nN1LExKHvJ9TmwootT00Yz05MuYqPXEXaVeOy5I= k8s.io/client-go v0.25.4 h1:3RNRDffAkNU56M/a7gUfXaEzdhZlYhoW8dgViGy5fn8= k8s.io/client-go v0.25.4/go.mod h1:8trHCAC83XKY0wsBIpbirZU4NTUpbuhc2JnI7OruGZw= -k8s.io/code-generator v0.26.2 h1:QMgN5oXUgQe27uMaqpbT0hg6ti+rvgCWaHEDMHVhox8= -k8s.io/code-generator v0.26.2/go.mod h1:ryaiIKwfxEJEaywEzx3dhWOydpVctKYbqLajJf0O8dI= +k8s.io/code-generator v0.26.3 h1:DNYPsWoeFwmg4qFg97Z1cHSSv7KSG10mAEIFoZGTQM8= +k8s.io/code-generator v0.26.3/go.mod h1:ryaiIKwfxEJEaywEzx3dhWOydpVctKYbqLajJf0O8dI= k8s.io/gengo v0.0.0-20220902162205-c0856e24416d h1:U9tB195lKdzwqicbJvyJeOXV7Klv+wNAWENRnXEGi08= k8s.io/gengo v0.0.0-20220902162205-c0856e24416d/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=