From 3d9a80b958092c2fedc424ad64433fe0d5d190c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan-Luis=20de=20Sousa-Valadas=20Casta=C3=B1o?= Date: Thu, 11 Jan 2024 23:12:15 +0100 Subject: [PATCH] Generate helm clienset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Juan-Luis de Sousa-Valadas CastaƱo (cherry picked from commit 687a1030d3bd70ec9175672b3106a6b0c60bd17e) (cherry picked from commit 1e3bd4d5cecd6715af0698c9eff073588ffc41b8) --- Makefile | 5 + .../helm.k0sproject.io/v1beta1/chart_types.go | 3 + .../v1beta1/clientset/clientset.go | 120 +++++++++++++++ .../clientset/fake/clientset_generated.go | 85 +++++++++++ .../v1beta1/clientset/fake/doc.go | 20 +++ .../v1beta1/clientset/fake/register.go | 56 +++++++ .../v1beta1/clientset/scheme/doc.go | 20 +++ .../v1beta1/clientset/scheme/register.go | 56 +++++++ .../typed/helm.k0sproject.io/v1beta1/chart.go | 144 ++++++++++++++++++ .../typed/helm.k0sproject.io/v1beta1/doc.go | 20 +++ .../helm.k0sproject.io/v1beta1/fake/doc.go | 20 +++ .../v1beta1/fake/fake_chart.go | 109 +++++++++++++ .../fake/fake_helm.k0sproject.io_client.go | 40 +++++ .../v1beta1/generated_expansion.go | 21 +++ .../v1beta1/helm.k0sproject.io_client.go | 107 +++++++++++++ .../v1beta1/groupversion_info.go | 6 +- .../controller/extensions_controller.go | 2 +- 17 files changed, 830 insertions(+), 4 deletions(-) create mode 100644 pkg/apis/helm.k0sproject.io/v1beta1/clientset/clientset.go create mode 100644 pkg/apis/helm.k0sproject.io/v1beta1/clientset/fake/clientset_generated.go create mode 100644 pkg/apis/helm.k0sproject.io/v1beta1/clientset/fake/doc.go create mode 100644 pkg/apis/helm.k0sproject.io/v1beta1/clientset/fake/register.go create mode 100644 pkg/apis/helm.k0sproject.io/v1beta1/clientset/scheme/doc.go create mode 100644 pkg/apis/helm.k0sproject.io/v1beta1/clientset/scheme/register.go create mode 100644 pkg/apis/helm.k0sproject.io/v1beta1/clientset/typed/helm.k0sproject.io/v1beta1/chart.go create mode 100644 pkg/apis/helm.k0sproject.io/v1beta1/clientset/typed/helm.k0sproject.io/v1beta1/doc.go create mode 100644 pkg/apis/helm.k0sproject.io/v1beta1/clientset/typed/helm.k0sproject.io/v1beta1/fake/doc.go create mode 100644 pkg/apis/helm.k0sproject.io/v1beta1/clientset/typed/helm.k0sproject.io/v1beta1/fake/fake_chart.go create mode 100644 pkg/apis/helm.k0sproject.io/v1beta1/clientset/typed/helm.k0sproject.io/v1beta1/fake/fake_helm.k0sproject.io_client.go create mode 100644 pkg/apis/helm.k0sproject.io/v1beta1/clientset/typed/helm.k0sproject.io/v1beta1/generated_expansion.go create mode 100644 pkg/apis/helm.k0sproject.io/v1beta1/clientset/typed/helm.k0sproject.io/v1beta1/helm.k0sproject.io_client.go diff --git a/Makefile b/Makefile index 6ce61b3bb462..e6b99de31336 100644 --- a/Makefile +++ b/Makefile @@ -142,6 +142,11 @@ pkg/apis/autopilot.k0sproject.io/v1beta2/.client-gen.stamp: $(shell find pkg/api pkg/apis/autopilot.k0sproject.io/v1beta2/.client-gen.stamp: groupver = autopilot.k0sproject.io/v1beta2 pkg/apis/autopilot.k0sproject.io/v1beta2/.client-gen.stamp: gen_output_dir = $(groupver) +codegen_targets += pkg/apis/helm.k0sproject.io/v1beta1/.client-gen.stamp +pkg/apis/helm.k0sproject.io/v1beta1/.client-gen.stamp: $(shell find pkg/apis/helm.k0sproject.io/v1beta1/ -maxdepth 1 -type f -name \*.go -not -name zz_\*.go) +pkg/apis/helm.k0sproject.io/v1beta1/.client-gen.stamp: groupver = helm.k0sproject.io/v1beta1 +pkg/apis/helm.k0sproject.io/v1beta1/.client-gen.stamp: gen_output_dir = $(groupver) + pkg/apis/%/.client-gen.stamp: .k0sbuild.docker-image.k0s hack/tools/boilerplate.go.txt embedded-bins/Makefile.variables rm -rf 'pkg/apis/$(gen_output_dir)/clientset/' CGO_ENABLED=0 $(GO) install k8s.io/code-generator/cmd/client-gen@v$(patsubst 1.%,0.%,$(kubernetes_version)) diff --git a/pkg/apis/helm.k0sproject.io/v1beta1/chart_types.go b/pkg/apis/helm.k0sproject.io/v1beta1/chart_types.go index 8f2b9814e18f..b94004bc5993 100644 --- a/pkg/apis/helm.k0sproject.io/v1beta1/chart_types.go +++ b/pkg/apis/helm.k0sproject.io/v1beta1/chart_types.go @@ -70,6 +70,9 @@ type ChartStatus struct { // +kubebuilder:object:root=true // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +kubebuilder:subresource:status +// +genclient +// +genclient:onlyVerbs=create,delete,list,get,watch,update +// +groupName=helm.k0sproject.io // Chart is the Schema for the charts API type Chart struct { metav1.TypeMeta `json:",inline"` diff --git a/pkg/apis/helm.k0sproject.io/v1beta1/clientset/clientset.go b/pkg/apis/helm.k0sproject.io/v1beta1/clientset/clientset.go new file mode 100644 index 000000000000..d9995d515c9c --- /dev/null +++ b/pkg/apis/helm.k0sproject.io/v1beta1/clientset/clientset.go @@ -0,0 +1,120 @@ +/* +Copyright k0s 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 clientset + +import ( + "fmt" + "net/http" + + helmv1beta1 "github.com/k0sproject/k0s/pkg/apis/helm.k0sproject.io/v1beta1/clientset/typed/helm.k0sproject.io/v1beta1" + 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 + HelmV1beta1() helmv1beta1.HelmV1beta1Interface +} + +// Clientset contains the clients for groups. +type Clientset struct { + *discovery.DiscoveryClient + helmV1beta1 *helmv1beta1.HelmV1beta1Client +} + +// HelmV1beta1 retrieves the HelmV1beta1Client +func (c *Clientset) HelmV1beta1() helmv1beta1.HelmV1beta1Interface { + return c.helmV1beta1 +} + +// 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.helmV1beta1, err = helmv1beta1.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.helmV1beta1 = helmv1beta1.New(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClient(c) + return &cs +} diff --git a/pkg/apis/helm.k0sproject.io/v1beta1/clientset/fake/clientset_generated.go b/pkg/apis/helm.k0sproject.io/v1beta1/clientset/fake/clientset_generated.go new file mode 100644 index 000000000000..d795d6a0f4ac --- /dev/null +++ b/pkg/apis/helm.k0sproject.io/v1beta1/clientset/fake/clientset_generated.go @@ -0,0 +1,85 @@ +/* +Copyright k0s 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/k0sproject/k0s/pkg/apis/helm.k0sproject.io/v1beta1/clientset" + helmv1beta1 "github.com/k0sproject/k0s/pkg/apis/helm.k0sproject.io/v1beta1/clientset/typed/helm.k0sproject.io/v1beta1" + fakehelmv1beta1 "github.com/k0sproject/k0s/pkg/apis/helm.k0sproject.io/v1beta1/clientset/typed/helm.k0sproject.io/v1beta1/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{} +) + +// HelmV1beta1 retrieves the HelmV1beta1Client +func (c *Clientset) HelmV1beta1() helmv1beta1.HelmV1beta1Interface { + return &fakehelmv1beta1.FakeHelmV1beta1{Fake: &c.Fake} +} diff --git a/pkg/apis/helm.k0sproject.io/v1beta1/clientset/fake/doc.go b/pkg/apis/helm.k0sproject.io/v1beta1/clientset/fake/doc.go new file mode 100644 index 000000000000..f28234f2f8f2 --- /dev/null +++ b/pkg/apis/helm.k0sproject.io/v1beta1/clientset/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright k0s 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/apis/helm.k0sproject.io/v1beta1/clientset/fake/register.go b/pkg/apis/helm.k0sproject.io/v1beta1/clientset/fake/register.go new file mode 100644 index 000000000000..2f476ce279f8 --- /dev/null +++ b/pkg/apis/helm.k0sproject.io/v1beta1/clientset/fake/register.go @@ -0,0 +1,56 @@ +/* +Copyright k0s 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 ( + helmv1beta1 "github.com/k0sproject/k0s/pkg/apis/helm.k0sproject.io/v1beta1" + 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{ + helmv1beta1.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/apis/helm.k0sproject.io/v1beta1/clientset/scheme/doc.go b/pkg/apis/helm.k0sproject.io/v1beta1/clientset/scheme/doc.go new file mode 100644 index 000000000000..0e79b44aa90b --- /dev/null +++ b/pkg/apis/helm.k0sproject.io/v1beta1/clientset/scheme/doc.go @@ -0,0 +1,20 @@ +/* +Copyright k0s 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/apis/helm.k0sproject.io/v1beta1/clientset/scheme/register.go b/pkg/apis/helm.k0sproject.io/v1beta1/clientset/scheme/register.go new file mode 100644 index 000000000000..fa8e517d022f --- /dev/null +++ b/pkg/apis/helm.k0sproject.io/v1beta1/clientset/scheme/register.go @@ -0,0 +1,56 @@ +/* +Copyright k0s 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 ( + helmv1beta1 "github.com/k0sproject/k0s/pkg/apis/helm.k0sproject.io/v1beta1" + 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{ + helmv1beta1.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/apis/helm.k0sproject.io/v1beta1/clientset/typed/helm.k0sproject.io/v1beta1/chart.go b/pkg/apis/helm.k0sproject.io/v1beta1/clientset/typed/helm.k0sproject.io/v1beta1/chart.go new file mode 100644 index 000000000000..e68e7b6a8d4a --- /dev/null +++ b/pkg/apis/helm.k0sproject.io/v1beta1/clientset/typed/helm.k0sproject.io/v1beta1/chart.go @@ -0,0 +1,144 @@ +/* +Copyright k0s 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 v1beta1 + +import ( + "context" + "time" + + v1beta1 "github.com/k0sproject/k0s/pkg/apis/helm.k0sproject.io/v1beta1" + scheme "github.com/k0sproject/k0s/pkg/apis/helm.k0sproject.io/v1beta1/clientset/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// ChartsGetter has a method to return a ChartInterface. +// A group's client should implement this interface. +type ChartsGetter interface { + Charts(namespace string) ChartInterface +} + +// ChartInterface has methods to work with Chart resources. +type ChartInterface interface { + Create(ctx context.Context, chart *v1beta1.Chart, opts v1.CreateOptions) (*v1beta1.Chart, error) + Update(ctx context.Context, chart *v1beta1.Chart, opts v1.UpdateOptions) (*v1beta1.Chart, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.Chart, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta1.ChartList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + ChartExpansion +} + +// charts implements ChartInterface +type charts struct { + client rest.Interface + ns string +} + +// newCharts returns a Charts +func newCharts(c *HelmV1beta1Client, namespace string) *charts { + return &charts{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the chart, and returns the corresponding chart object, and an error if there is any. +func (c *charts) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.Chart, err error) { + result = &v1beta1.Chart{} + err = c.client.Get(). + Namespace(c.ns). + Resource("charts"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Charts that match those selectors. +func (c *charts) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.ChartList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.ChartList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("charts"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested charts. +func (c *charts) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("charts"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a chart and creates it. Returns the server's representation of the chart, and an error, if there is any. +func (c *charts) Create(ctx context.Context, chart *v1beta1.Chart, opts v1.CreateOptions) (result *v1beta1.Chart, err error) { + result = &v1beta1.Chart{} + err = c.client.Post(). + Namespace(c.ns). + Resource("charts"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(chart). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a chart and updates it. Returns the server's representation of the chart, and an error, if there is any. +func (c *charts) Update(ctx context.Context, chart *v1beta1.Chart, opts v1.UpdateOptions) (result *v1beta1.Chart, err error) { + result = &v1beta1.Chart{} + err = c.client.Put(). + Namespace(c.ns). + Resource("charts"). + Name(chart.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(chart). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the chart and deletes it. Returns an error if one occurs. +func (c *charts) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("charts"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} diff --git a/pkg/apis/helm.k0sproject.io/v1beta1/clientset/typed/helm.k0sproject.io/v1beta1/doc.go b/pkg/apis/helm.k0sproject.io/v1beta1/clientset/typed/helm.k0sproject.io/v1beta1/doc.go new file mode 100644 index 000000000000..f6d3c8a5f3fc --- /dev/null +++ b/pkg/apis/helm.k0sproject.io/v1beta1/clientset/typed/helm.k0sproject.io/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright k0s 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 v1beta1 diff --git a/pkg/apis/helm.k0sproject.io/v1beta1/clientset/typed/helm.k0sproject.io/v1beta1/fake/doc.go b/pkg/apis/helm.k0sproject.io/v1beta1/clientset/typed/helm.k0sproject.io/v1beta1/fake/doc.go new file mode 100644 index 000000000000..f7926ec7323e --- /dev/null +++ b/pkg/apis/helm.k0sproject.io/v1beta1/clientset/typed/helm.k0sproject.io/v1beta1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright k0s 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/apis/helm.k0sproject.io/v1beta1/clientset/typed/helm.k0sproject.io/v1beta1/fake/fake_chart.go b/pkg/apis/helm.k0sproject.io/v1beta1/clientset/typed/helm.k0sproject.io/v1beta1/fake/fake_chart.go new file mode 100644 index 000000000000..e73022be5be1 --- /dev/null +++ b/pkg/apis/helm.k0sproject.io/v1beta1/clientset/typed/helm.k0sproject.io/v1beta1/fake/fake_chart.go @@ -0,0 +1,109 @@ +/* +Copyright k0s 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" + + v1beta1 "github.com/k0sproject/k0s/pkg/apis/helm.k0sproject.io/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeCharts implements ChartInterface +type FakeCharts struct { + Fake *FakeHelmV1beta1 + ns string +} + +var chartsResource = v1beta1.SchemeGroupVersion.WithResource("charts") + +var chartsKind = v1beta1.SchemeGroupVersion.WithKind("Chart") + +// Get takes name of the chart, and returns the corresponding chart object, and an error if there is any. +func (c *FakeCharts) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.Chart, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(chartsResource, c.ns, name), &v1beta1.Chart{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Chart), err +} + +// List takes label and field selectors, and returns the list of Charts that match those selectors. +func (c *FakeCharts) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.ChartList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(chartsResource, chartsKind, c.ns, opts), &v1beta1.ChartList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta1.ChartList{ListMeta: obj.(*v1beta1.ChartList).ListMeta} + for _, item := range obj.(*v1beta1.ChartList).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 charts. +func (c *FakeCharts) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(chartsResource, c.ns, opts)) + +} + +// Create takes the representation of a chart and creates it. Returns the server's representation of the chart, and an error, if there is any. +func (c *FakeCharts) Create(ctx context.Context, chart *v1beta1.Chart, opts v1.CreateOptions) (result *v1beta1.Chart, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(chartsResource, c.ns, chart), &v1beta1.Chart{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Chart), err +} + +// Update takes the representation of a chart and updates it. Returns the server's representation of the chart, and an error, if there is any. +func (c *FakeCharts) Update(ctx context.Context, chart *v1beta1.Chart, opts v1.UpdateOptions) (result *v1beta1.Chart, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(chartsResource, c.ns, chart), &v1beta1.Chart{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Chart), err +} + +// Delete takes name of the chart and deletes it. Returns an error if one occurs. +func (c *FakeCharts) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(chartsResource, c.ns, name, opts), &v1beta1.Chart{}) + + return err +} diff --git a/pkg/apis/helm.k0sproject.io/v1beta1/clientset/typed/helm.k0sproject.io/v1beta1/fake/fake_helm.k0sproject.io_client.go b/pkg/apis/helm.k0sproject.io/v1beta1/clientset/typed/helm.k0sproject.io/v1beta1/fake/fake_helm.k0sproject.io_client.go new file mode 100644 index 000000000000..f9f2a159fd15 --- /dev/null +++ b/pkg/apis/helm.k0sproject.io/v1beta1/clientset/typed/helm.k0sproject.io/v1beta1/fake/fake_helm.k0sproject.io_client.go @@ -0,0 +1,40 @@ +/* +Copyright k0s 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 ( + v1beta1 "github.com/k0sproject/k0s/pkg/apis/helm.k0sproject.io/v1beta1/clientset/typed/helm.k0sproject.io/v1beta1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeHelmV1beta1 struct { + *testing.Fake +} + +func (c *FakeHelmV1beta1) Charts(namespace string) v1beta1.ChartInterface { + return &FakeCharts{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeHelmV1beta1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/apis/helm.k0sproject.io/v1beta1/clientset/typed/helm.k0sproject.io/v1beta1/generated_expansion.go b/pkg/apis/helm.k0sproject.io/v1beta1/clientset/typed/helm.k0sproject.io/v1beta1/generated_expansion.go new file mode 100644 index 000000000000..2af6a91299bd --- /dev/null +++ b/pkg/apis/helm.k0sproject.io/v1beta1/clientset/typed/helm.k0sproject.io/v1beta1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright k0s 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 v1beta1 + +type ChartExpansion interface{} diff --git a/pkg/apis/helm.k0sproject.io/v1beta1/clientset/typed/helm.k0sproject.io/v1beta1/helm.k0sproject.io_client.go b/pkg/apis/helm.k0sproject.io/v1beta1/clientset/typed/helm.k0sproject.io/v1beta1/helm.k0sproject.io_client.go new file mode 100644 index 000000000000..d2de4dc14422 --- /dev/null +++ b/pkg/apis/helm.k0sproject.io/v1beta1/clientset/typed/helm.k0sproject.io/v1beta1/helm.k0sproject.io_client.go @@ -0,0 +1,107 @@ +/* +Copyright k0s 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 v1beta1 + +import ( + "net/http" + + v1beta1 "github.com/k0sproject/k0s/pkg/apis/helm.k0sproject.io/v1beta1" + "github.com/k0sproject/k0s/pkg/apis/helm.k0sproject.io/v1beta1/clientset/scheme" + rest "k8s.io/client-go/rest" +) + +type HelmV1beta1Interface interface { + RESTClient() rest.Interface + ChartsGetter +} + +// HelmV1beta1Client is used to interact with features provided by the helm.k0sproject.io group. +type HelmV1beta1Client struct { + restClient rest.Interface +} + +func (c *HelmV1beta1Client) Charts(namespace string) ChartInterface { + return newCharts(c, namespace) +} + +// NewForConfig creates a new HelmV1beta1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*HelmV1beta1Client, 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 HelmV1beta1Client 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) (*HelmV1beta1Client, 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 &HelmV1beta1Client{client}, nil +} + +// NewForConfigOrDie creates a new HelmV1beta1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *HelmV1beta1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new HelmV1beta1Client for the given RESTClient. +func New(c rest.Interface) *HelmV1beta1Client { + return &HelmV1beta1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1beta1.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 *HelmV1beta1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/apis/helm.k0sproject.io/v1beta1/groupversion_info.go b/pkg/apis/helm.k0sproject.io/v1beta1/groupversion_info.go index 5d0fb11e8595..1a4153945212 100644 --- a/pkg/apis/helm.k0sproject.io/v1beta1/groupversion_info.go +++ b/pkg/apis/helm.k0sproject.io/v1beta1/groupversion_info.go @@ -25,11 +25,11 @@ import ( ) var ( - // GroupVersion is group version used to register these objects - GroupVersion = schema.GroupVersion{Group: "helm.k0sproject.io", Version: "v1beta1"} + // SchemeGroupVersion is group version used to register these objects + SchemeGroupVersion = schema.GroupVersion{Group: "helm.k0sproject.io", Version: "v1beta1"} // SchemeBuilder is used to add go types to the GroupVersionKind scheme - SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} + SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion} // AddToScheme adds the types in this group-version to the given scheme. AddToScheme = SchemeBuilder.AddToScheme diff --git a/pkg/component/controller/extensions_controller.go b/pkg/component/controller/extensions_controller.go index a04a1fab9618..93a24db18818 100644 --- a/pkg/component/controller/extensions_controller.go +++ b/pkg/component/controller/extensions_controller.go @@ -368,7 +368,7 @@ func (ec *ExtensionsController) Start(ctx context.Context) error { return fmt.Errorf("can't build controller-runtime controller for helm extensions: %w", err) } gk := schema.GroupKind{ - Group: v1beta1.GroupVersion.Group, + Group: v1beta1.SchemeGroupVersion.Group, Kind: "Chart", }