From 56c74272bb6a60609d20c359e4df9cb195e3cf65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Edouard=20Br=C3=A9t=C3=A9ch=C3=A9?= Date: Wed, 28 Sep 2022 11:31:06 +0200 Subject: [PATCH] chore: update client code generator (#4711) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: update client code generator Signed-off-by: Charles-Edouard Brétéché * fix inconsistency on my mac Signed-off-by: Charles-Edouard Brétéché Signed-off-by: Charles-Edouard Brétéché --- Makefile | 6 +-- pkg/client/clientset/versioned/clientset.go | 47 ++++++++++++++----- .../versioned/fake/clientset_generated.go | 5 +- .../clientset/versioned/fake/register.go | 14 +++--- .../clientset/versioned/scheme/register.go | 14 +++--- .../kyverno/v1/fake/fake_clusterpolicy.go | 2 +- .../kyverno/v1/fake/fake_generaterequest.go | 2 +- .../typed/kyverno/v1/fake/fake_policy.go | 2 +- .../typed/kyverno/v1/kyverno_client.go | 20 +++++++- .../fake/fake_clusterreportchangerequest.go | 2 +- .../v1alpha2/fake/fake_reportchangerequest.go | 2 +- .../typed/kyverno/v1alpha2/kyverno_client.go | 20 +++++++- .../v1beta1/fake/fake_updaterequest.go | 2 +- .../typed/kyverno/v1beta1/kyverno_client.go | 20 +++++++- .../v1alpha2/fake/fake_clusterpolicyreport.go | 2 +- .../v1alpha2/fake/fake_policyreport.go | 2 +- .../v1alpha2/policyreport_client.go | 20 +++++++- 17 files changed, 139 insertions(+), 43 deletions(-) diff --git a/Makefile b/Makefile index 4e6ff26093..ab2db3b8e5 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ CONTROLLER_GEN_VERSION := v0.9.1-0.20220629131006-1878064c4cdf CLIENT_GEN := $(TOOLS_DIR)/client-gen LISTER_GEN := $(TOOLS_DIR)/lister-gen INFORMER_GEN := $(TOOLS_DIR)/informer-gen -CODE_GEN_VERSION := v0.19.0 +CODE_GEN_VERSION := v0.25.2 GEN_CRD_API_REFERENCE_DOCS := $(TOOLS_DIR)/gen-crd-api-reference-docs GEN_CRD_API_REFERENCE_DOCS_VERSION := latest GO_ACC := $(TOOLS_DIR)/go-acc @@ -458,10 +458,10 @@ verify-crds: codegen-crds-all ## Check CRDs are up to date .PHONY: verify-client verify-client: codegen-client-all ## Check client is up to date - @git --no-pager diff pkg/client + @git --no-pager diff --ignore-space-change pkg/client @echo 'If this test fails, it is because the git diff is non-empty after running "make codegen-client-all".' @echo 'To correct this, locally run "make codegen-client-all", commit the changes, and re-run tests.' - @git diff --quiet --exit-code pkg/client + @git diff --ignore-space-change --quiet --exit-code pkg/client .PHONY: verify-deepcopy verify-deepcopy: codegen-deepcopy-all ## Check deepcopy functions are up to date diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go index 5752ca53ba..8672c2b1b5 100644 --- a/pkg/client/clientset/versioned/clientset.go +++ b/pkg/client/clientset/versioned/clientset.go @@ -20,6 +20,7 @@ package versioned import ( "fmt" + "net/http" kyvernov1 "github.com/kyverno/kyverno/pkg/client/clientset/versioned/typed/kyverno/v1" kyvernov1alpha2 "github.com/kyverno/kyverno/pkg/client/clientset/versioned/typed/kyverno/v1alpha2" @@ -79,34 +80,57 @@ 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.kyvernoV1, err = kyvernov1.NewForConfig(&configShallowCopy) + cs.kyvernoV1, err = kyvernov1.NewForConfigAndClient(&configShallowCopy, httpClient) if err != nil { return nil, err } - cs.kyvernoV1beta1, err = kyvernov1beta1.NewForConfig(&configShallowCopy) + cs.kyvernoV1beta1, err = kyvernov1beta1.NewForConfigAndClient(&configShallowCopy, httpClient) if err != nil { return nil, err } - cs.kyvernoV1alpha2, err = kyvernov1alpha2.NewForConfig(&configShallowCopy) + cs.kyvernoV1alpha2, err = kyvernov1alpha2.NewForConfigAndClient(&configShallowCopy, httpClient) if err != nil { return nil, err } - cs.wgpolicyk8sV1alpha2, err = wgpolicyk8sv1alpha2.NewForConfig(&configShallowCopy) + cs.wgpolicyk8sV1alpha2, err = wgpolicyk8sv1alpha2.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 } @@ -116,14 +140,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.kyvernoV1 = kyvernov1.NewForConfigOrDie(c) - cs.kyvernoV1beta1 = kyvernov1beta1.NewForConfigOrDie(c) - cs.kyvernoV1alpha2 = kyvernov1alpha2.NewForConfigOrDie(c) - cs.wgpolicyk8sV1alpha2 = wgpolicyk8sv1alpha2.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/pkg/client/clientset/versioned/fake/clientset_generated.go b/pkg/client/clientset/versioned/fake/clientset_generated.go index 170bc2042d..74cc2268ca 100644 --- a/pkg/client/clientset/versioned/fake/clientset_generated.go +++ b/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -80,7 +80,10 @@ func (c *Clientset) Tracker() testing.ObjectTracker { return c.tracker } -var _ clientset.Interface = &Clientset{} +var ( + _ clientset.Interface = &Clientset{} + _ testing.FakeClient = &Clientset{} +) // KyvernoV1 retrieves the KyvernoV1Client func (c *Clientset) KyvernoV1() kyvernov1.KyvernoV1Interface { diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go index a93604b6d1..cf3c1a08f4 100644 --- a/pkg/client/clientset/versioned/fake/register.go +++ b/pkg/client/clientset/versioned/fake/register.go @@ -43,14 +43,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // 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" -// ) +// 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) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go index 9fbeaa98f0..776190e352 100644 --- a/pkg/client/clientset/versioned/scheme/register.go +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -43,14 +43,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // 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" -// ) +// 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) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/pkg/client/clientset/versioned/typed/kyverno/v1/fake/fake_clusterpolicy.go b/pkg/client/clientset/versioned/typed/kyverno/v1/fake/fake_clusterpolicy.go index 0750a0a6e3..51f0139518 100644 --- a/pkg/client/clientset/versioned/typed/kyverno/v1/fake/fake_clusterpolicy.go +++ b/pkg/client/clientset/versioned/typed/kyverno/v1/fake/fake_clusterpolicy.go @@ -110,7 +110,7 @@ func (c *FakeClusterPolicies) UpdateStatus(ctx context.Context, clusterPolicy *k // Delete takes name of the clusterPolicy and deletes it. Returns an error if one occurs. func (c *FakeClusterPolicies) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewRootDeleteAction(clusterpoliciesResource, name), &kyvernov1.ClusterPolicy{}) + Invokes(testing.NewRootDeleteActionWithOptions(clusterpoliciesResource, name, opts), &kyvernov1.ClusterPolicy{}) return err } diff --git a/pkg/client/clientset/versioned/typed/kyverno/v1/fake/fake_generaterequest.go b/pkg/client/clientset/versioned/typed/kyverno/v1/fake/fake_generaterequest.go index 7c2c185a60..f1ca3d585d 100644 --- a/pkg/client/clientset/versioned/typed/kyverno/v1/fake/fake_generaterequest.go +++ b/pkg/client/clientset/versioned/typed/kyverno/v1/fake/fake_generaterequest.go @@ -117,7 +117,7 @@ func (c *FakeGenerateRequests) UpdateStatus(ctx context.Context, generateRequest // Delete takes name of the generateRequest and deletes it. Returns an error if one occurs. func (c *FakeGenerateRequests) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewDeleteAction(generaterequestsResource, c.ns, name), &kyvernov1.GenerateRequest{}) + Invokes(testing.NewDeleteActionWithOptions(generaterequestsResource, c.ns, name, opts), &kyvernov1.GenerateRequest{}) return err } diff --git a/pkg/client/clientset/versioned/typed/kyverno/v1/fake/fake_policy.go b/pkg/client/clientset/versioned/typed/kyverno/v1/fake/fake_policy.go index 6844d4f44b..e8fd570cf2 100644 --- a/pkg/client/clientset/versioned/typed/kyverno/v1/fake/fake_policy.go +++ b/pkg/client/clientset/versioned/typed/kyverno/v1/fake/fake_policy.go @@ -117,7 +117,7 @@ func (c *FakePolicies) UpdateStatus(ctx context.Context, policy *kyvernov1.Polic // Delete takes name of the policy and deletes it. Returns an error if one occurs. func (c *FakePolicies) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewDeleteAction(policiesResource, c.ns, name), &kyvernov1.Policy{}) + Invokes(testing.NewDeleteActionWithOptions(policiesResource, c.ns, name, opts), &kyvernov1.Policy{}) return err } diff --git a/pkg/client/clientset/versioned/typed/kyverno/v1/kyverno_client.go b/pkg/client/clientset/versioned/typed/kyverno/v1/kyverno_client.go index 3d8cecb03f..82a38ce1dd 100644 --- a/pkg/client/clientset/versioned/typed/kyverno/v1/kyverno_client.go +++ b/pkg/client/clientset/versioned/typed/kyverno/v1/kyverno_client.go @@ -19,6 +19,8 @@ limitations under the License. package v1 import ( + "net/http" + v1 "github.com/kyverno/kyverno/api/kyverno/v1" "github.com/kyverno/kyverno/pkg/client/clientset/versioned/scheme" rest "k8s.io/client-go/rest" @@ -49,12 +51,28 @@ func (c *KyvernoV1Client) Policies(namespace string) PolicyInterface { } // NewForConfig creates a new KyvernoV1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*KyvernoV1Client, 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 KyvernoV1Client 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) (*KyvernoV1Client, 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/pkg/client/clientset/versioned/typed/kyverno/v1alpha2/fake/fake_clusterreportchangerequest.go b/pkg/client/clientset/versioned/typed/kyverno/v1alpha2/fake/fake_clusterreportchangerequest.go index f97dcafb03..fc731789e1 100644 --- a/pkg/client/clientset/versioned/typed/kyverno/v1alpha2/fake/fake_clusterreportchangerequest.go +++ b/pkg/client/clientset/versioned/typed/kyverno/v1alpha2/fake/fake_clusterreportchangerequest.go @@ -99,7 +99,7 @@ func (c *FakeClusterReportChangeRequests) Update(ctx context.Context, clusterRep // Delete takes name of the clusterReportChangeRequest and deletes it. Returns an error if one occurs. func (c *FakeClusterReportChangeRequests) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewRootDeleteAction(clusterreportchangerequestsResource, name), &v1alpha2.ClusterReportChangeRequest{}) + Invokes(testing.NewRootDeleteActionWithOptions(clusterreportchangerequestsResource, name, opts), &v1alpha2.ClusterReportChangeRequest{}) return err } diff --git a/pkg/client/clientset/versioned/typed/kyverno/v1alpha2/fake/fake_reportchangerequest.go b/pkg/client/clientset/versioned/typed/kyverno/v1alpha2/fake/fake_reportchangerequest.go index 4737fc39d9..91ad2542f6 100644 --- a/pkg/client/clientset/versioned/typed/kyverno/v1alpha2/fake/fake_reportchangerequest.go +++ b/pkg/client/clientset/versioned/typed/kyverno/v1alpha2/fake/fake_reportchangerequest.go @@ -105,7 +105,7 @@ func (c *FakeReportChangeRequests) Update(ctx context.Context, reportChangeReque // Delete takes name of the reportChangeRequest and deletes it. Returns an error if one occurs. func (c *FakeReportChangeRequests) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewDeleteAction(reportchangerequestsResource, c.ns, name), &v1alpha2.ReportChangeRequest{}) + Invokes(testing.NewDeleteActionWithOptions(reportchangerequestsResource, c.ns, name, opts), &v1alpha2.ReportChangeRequest{}) return err } diff --git a/pkg/client/clientset/versioned/typed/kyverno/v1alpha2/kyverno_client.go b/pkg/client/clientset/versioned/typed/kyverno/v1alpha2/kyverno_client.go index 919d513344..0ab8a9d3e2 100644 --- a/pkg/client/clientset/versioned/typed/kyverno/v1alpha2/kyverno_client.go +++ b/pkg/client/clientset/versioned/typed/kyverno/v1alpha2/kyverno_client.go @@ -19,6 +19,8 @@ limitations under the License. package v1alpha2 import ( + "net/http" + v1alpha2 "github.com/kyverno/kyverno/api/kyverno/v1alpha2" "github.com/kyverno/kyverno/pkg/client/clientset/versioned/scheme" rest "k8s.io/client-go/rest" @@ -44,12 +46,28 @@ func (c *KyvernoV1alpha2Client) ReportChangeRequests(namespace string) ReportCha } // NewForConfig creates a new KyvernoV1alpha2Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*KyvernoV1alpha2Client, 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 KyvernoV1alpha2Client 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) (*KyvernoV1alpha2Client, 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/pkg/client/clientset/versioned/typed/kyverno/v1beta1/fake/fake_updaterequest.go b/pkg/client/clientset/versioned/typed/kyverno/v1beta1/fake/fake_updaterequest.go index 876b320b33..4ce72c55d9 100644 --- a/pkg/client/clientset/versioned/typed/kyverno/v1beta1/fake/fake_updaterequest.go +++ b/pkg/client/clientset/versioned/typed/kyverno/v1beta1/fake/fake_updaterequest.go @@ -117,7 +117,7 @@ func (c *FakeUpdateRequests) UpdateStatus(ctx context.Context, updateRequest *v1 // Delete takes name of the updateRequest and deletes it. Returns an error if one occurs. func (c *FakeUpdateRequests) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewDeleteAction(updaterequestsResource, c.ns, name), &v1beta1.UpdateRequest{}) + Invokes(testing.NewDeleteActionWithOptions(updaterequestsResource, c.ns, name, opts), &v1beta1.UpdateRequest{}) return err } diff --git a/pkg/client/clientset/versioned/typed/kyverno/v1beta1/kyverno_client.go b/pkg/client/clientset/versioned/typed/kyverno/v1beta1/kyverno_client.go index 679b734c5c..0cacaa4bcb 100644 --- a/pkg/client/clientset/versioned/typed/kyverno/v1beta1/kyverno_client.go +++ b/pkg/client/clientset/versioned/typed/kyverno/v1beta1/kyverno_client.go @@ -19,6 +19,8 @@ limitations under the License. package v1beta1 import ( + "net/http" + v1beta1 "github.com/kyverno/kyverno/api/kyverno/v1beta1" "github.com/kyverno/kyverno/pkg/client/clientset/versioned/scheme" rest "k8s.io/client-go/rest" @@ -39,12 +41,28 @@ func (c *KyvernoV1beta1Client) UpdateRequests(namespace string) UpdateRequestInt } // NewForConfig creates a new KyvernoV1beta1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*KyvernoV1beta1Client, 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 KyvernoV1beta1Client 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) (*KyvernoV1beta1Client, 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/pkg/client/clientset/versioned/typed/policyreport/v1alpha2/fake/fake_clusterpolicyreport.go b/pkg/client/clientset/versioned/typed/policyreport/v1alpha2/fake/fake_clusterpolicyreport.go index e68fa4ca00..879a30de96 100644 --- a/pkg/client/clientset/versioned/typed/policyreport/v1alpha2/fake/fake_clusterpolicyreport.go +++ b/pkg/client/clientset/versioned/typed/policyreport/v1alpha2/fake/fake_clusterpolicyreport.go @@ -99,7 +99,7 @@ func (c *FakeClusterPolicyReports) Update(ctx context.Context, clusterPolicyRepo // Delete takes name of the clusterPolicyReport and deletes it. Returns an error if one occurs. func (c *FakeClusterPolicyReports) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewRootDeleteAction(clusterpolicyreportsResource, name), &v1alpha2.ClusterPolicyReport{}) + Invokes(testing.NewRootDeleteActionWithOptions(clusterpolicyreportsResource, name, opts), &v1alpha2.ClusterPolicyReport{}) return err } diff --git a/pkg/client/clientset/versioned/typed/policyreport/v1alpha2/fake/fake_policyreport.go b/pkg/client/clientset/versioned/typed/policyreport/v1alpha2/fake/fake_policyreport.go index 956ee3cb7f..1f9bc38774 100644 --- a/pkg/client/clientset/versioned/typed/policyreport/v1alpha2/fake/fake_policyreport.go +++ b/pkg/client/clientset/versioned/typed/policyreport/v1alpha2/fake/fake_policyreport.go @@ -105,7 +105,7 @@ func (c *FakePolicyReports) Update(ctx context.Context, policyReport *v1alpha2.P // Delete takes name of the policyReport and deletes it. Returns an error if one occurs. func (c *FakePolicyReports) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewDeleteAction(policyreportsResource, c.ns, name), &v1alpha2.PolicyReport{}) + Invokes(testing.NewDeleteActionWithOptions(policyreportsResource, c.ns, name, opts), &v1alpha2.PolicyReport{}) return err } diff --git a/pkg/client/clientset/versioned/typed/policyreport/v1alpha2/policyreport_client.go b/pkg/client/clientset/versioned/typed/policyreport/v1alpha2/policyreport_client.go index 5682cba525..1ee6925d84 100644 --- a/pkg/client/clientset/versioned/typed/policyreport/v1alpha2/policyreport_client.go +++ b/pkg/client/clientset/versioned/typed/policyreport/v1alpha2/policyreport_client.go @@ -19,6 +19,8 @@ limitations under the License. package v1alpha2 import ( + "net/http" + v1alpha2 "github.com/kyverno/kyverno/api/policyreport/v1alpha2" "github.com/kyverno/kyverno/pkg/client/clientset/versioned/scheme" rest "k8s.io/client-go/rest" @@ -44,12 +46,28 @@ func (c *Wgpolicyk8sV1alpha2Client) PolicyReports(namespace string) PolicyReport } // NewForConfig creates a new Wgpolicyk8sV1alpha2Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*Wgpolicyk8sV1alpha2Client, 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 Wgpolicyk8sV1alpha2Client 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) (*Wgpolicyk8sV1alpha2Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientForConfigAndClient(&config, h) if err != nil { return nil, err }