diff --git a/Makefile b/Makefile index 774b697b08c4..5e695652aa65 100644 --- a/Makefile +++ b/Makefile @@ -134,7 +134,7 @@ pkg/apis/%/.controller-gen.stamp: .k0sbuild.docker-image.k0s hack/tools/boilerpl object:headerFile=hack/tools/boilerplate.go.txt touch -- '$@' -clientset_input_dirs := pkg/apis/autopilot/v1beta2 pkg/apis/k0s/v1beta1 +clientset_input_dirs := pkg/apis/autopilot/v1beta2 pkg/apis/k0s/v1beta1 pkg/apis/helm/v1beta1 codegen_targets += pkg/client/clientset/.client-gen.stamp pkg/client/clientset/.client-gen.stamp: $(shell find $(clientset_input_dirs) -type f -name \*.go -not -name \*_test.go -not -name zz_\*) pkg/client/clientset/.client-gen.stamp: .k0sbuild.docker-image.k0s hack/tools/boilerplate.go.txt embedded-bins/Makefile.variables diff --git a/pkg/apis/helm/v1beta1/chart_types.go b/pkg/apis/helm/v1beta1/chart_types.go index 8f2b9814e18f..b94004bc5993 100644 --- a/pkg/apis/helm/v1beta1/chart_types.go +++ b/pkg/apis/helm/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/v1beta1/groupversion_info.go b/pkg/apis/helm/v1beta1/groupversion_info.go index d33dad9513af..3e74dd98341d 100644 --- a/pkg/apis/helm/v1beta1/groupversion_info.go +++ b/pkg/apis/helm/v1beta1/groupversion_info.go @@ -27,6 +27,9 @@ var ( // GroupVersion is group version used to register these objects GroupVersion = schema.GroupVersion{Group: helm.GroupName, Version: Version} + // SchemeGroupVersion is group version used to register these objects + SchemeGroupVersion = schema.GroupVersion{Group: helm.GroupName, Version: Version} + // SchemeBuilder is used to add go types to the GroupVersionKind scheme SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} diff --git a/pkg/client/clientset/clientset.go b/pkg/client/clientset/clientset.go index 9fc93d83be8e..beb51fece218 100644 --- a/pkg/client/clientset/clientset.go +++ b/pkg/client/clientset/clientset.go @@ -23,6 +23,7 @@ import ( "net/http" autopilotv1beta2 "github.com/k0sproject/k0s/pkg/client/clientset/typed/autopilot/v1beta2" + helmv1beta1 "github.com/k0sproject/k0s/pkg/client/clientset/typed/helm/v1beta1" k0sv1beta1 "github.com/k0sproject/k0s/pkg/client/clientset/typed/k0s/v1beta1" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" @@ -32,6 +33,7 @@ import ( type Interface interface { Discovery() discovery.DiscoveryInterface AutopilotV1beta2() autopilotv1beta2.AutopilotV1beta2Interface + HelmV1beta1() helmv1beta1.HelmV1beta1Interface K0sV1beta1() k0sv1beta1.K0sV1beta1Interface } @@ -39,6 +41,7 @@ type Interface interface { type Clientset struct { *discovery.DiscoveryClient autopilotV1beta2 *autopilotv1beta2.AutopilotV1beta2Client + helmV1beta1 *helmv1beta1.HelmV1beta1Client k0sV1beta1 *k0sv1beta1.K0sV1beta1Client } @@ -47,6 +50,11 @@ func (c *Clientset) AutopilotV1beta2() autopilotv1beta2.AutopilotV1beta2Interfac return c.autopilotV1beta2 } +// HelmV1beta1 retrieves the HelmV1beta1Client +func (c *Clientset) HelmV1beta1() helmv1beta1.HelmV1beta1Interface { + return c.helmV1beta1 +} + // K0sV1beta1 retrieves the K0sV1beta1Client func (c *Clientset) K0sV1beta1() k0sv1beta1.K0sV1beta1Interface { return c.k0sV1beta1 @@ -100,6 +108,10 @@ func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, if err != nil { return nil, err } + cs.helmV1beta1, err = helmv1beta1.NewForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } cs.k0sV1beta1, err = k0sv1beta1.NewForConfigAndClient(&configShallowCopy, httpClient) if err != nil { return nil, err @@ -126,6 +138,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { func New(c rest.Interface) *Clientset { var cs Clientset cs.autopilotV1beta2 = autopilotv1beta2.New(c) + cs.helmV1beta1 = helmv1beta1.New(c) cs.k0sV1beta1 = k0sv1beta1.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) diff --git a/pkg/client/clientset/fake/clientset_generated.go b/pkg/client/clientset/fake/clientset_generated.go index c3c679a595c5..d7006bde0172 100644 --- a/pkg/client/clientset/fake/clientset_generated.go +++ b/pkg/client/clientset/fake/clientset_generated.go @@ -22,6 +22,8 @@ import ( clientset "github.com/k0sproject/k0s/pkg/client/clientset" autopilotv1beta2 "github.com/k0sproject/k0s/pkg/client/clientset/typed/autopilot/v1beta2" fakeautopilotv1beta2 "github.com/k0sproject/k0s/pkg/client/clientset/typed/autopilot/v1beta2/fake" + helmv1beta1 "github.com/k0sproject/k0s/pkg/client/clientset/typed/helm/v1beta1" + fakehelmv1beta1 "github.com/k0sproject/k0s/pkg/client/clientset/typed/helm/v1beta1/fake" k0sv1beta1 "github.com/k0sproject/k0s/pkg/client/clientset/typed/k0s/v1beta1" fakek0sv1beta1 "github.com/k0sproject/k0s/pkg/client/clientset/typed/k0s/v1beta1/fake" "k8s.io/apimachinery/pkg/runtime" @@ -86,6 +88,11 @@ func (c *Clientset) AutopilotV1beta2() autopilotv1beta2.AutopilotV1beta2Interfac return &fakeautopilotv1beta2.FakeAutopilotV1beta2{Fake: &c.Fake} } +// HelmV1beta1 retrieves the HelmV1beta1Client +func (c *Clientset) HelmV1beta1() helmv1beta1.HelmV1beta1Interface { + return &fakehelmv1beta1.FakeHelmV1beta1{Fake: &c.Fake} +} + // K0sV1beta1 retrieves the K0sV1beta1Client func (c *Clientset) K0sV1beta1() k0sv1beta1.K0sV1beta1Interface { return &fakek0sv1beta1.FakeK0sV1beta1{Fake: &c.Fake} diff --git a/pkg/client/clientset/fake/register.go b/pkg/client/clientset/fake/register.go index c8c806e50682..6a20e119b37f 100644 --- a/pkg/client/clientset/fake/register.go +++ b/pkg/client/clientset/fake/register.go @@ -20,6 +20,7 @@ package fake import ( autopilotv1beta2 "github.com/k0sproject/k0s/pkg/apis/autopilot/v1beta2" + helmv1beta1 "github.com/k0sproject/k0s/pkg/apis/helm/v1beta1" k0sv1beta1 "github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" @@ -33,6 +34,7 @@ var codecs = serializer.NewCodecFactory(scheme) var localSchemeBuilder = runtime.SchemeBuilder{ autopilotv1beta2.AddToScheme, + helmv1beta1.AddToScheme, k0sv1beta1.AddToScheme, } diff --git a/pkg/client/clientset/scheme/register.go b/pkg/client/clientset/scheme/register.go index 905a4c5a426e..48310aaf7f30 100644 --- a/pkg/client/clientset/scheme/register.go +++ b/pkg/client/clientset/scheme/register.go @@ -20,6 +20,7 @@ package scheme import ( autopilotv1beta2 "github.com/k0sproject/k0s/pkg/apis/autopilot/v1beta2" + helmv1beta1 "github.com/k0sproject/k0s/pkg/apis/helm/v1beta1" k0sv1beta1 "github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" @@ -33,6 +34,7 @@ var Codecs = serializer.NewCodecFactory(Scheme) var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ autopilotv1beta2.AddToScheme, + helmv1beta1.AddToScheme, k0sv1beta1.AddToScheme, } diff --git a/pkg/client/clientset/typed/helm/v1beta1/chart.go b/pkg/client/clientset/typed/helm/v1beta1/chart.go new file mode 100644 index 000000000000..fd42e40a8478 --- /dev/null +++ b/pkg/client/clientset/typed/helm/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/v1beta1" + scheme "github.com/k0sproject/k0s/pkg/client/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/client/clientset/typed/helm/v1beta1/doc.go b/pkg/client/clientset/typed/helm/v1beta1/doc.go new file mode 100644 index 000000000000..f6d3c8a5f3fc --- /dev/null +++ b/pkg/client/clientset/typed/helm/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/client/clientset/typed/helm/v1beta1/fake/doc.go b/pkg/client/clientset/typed/helm/v1beta1/fake/doc.go new file mode 100644 index 000000000000..f7926ec7323e --- /dev/null +++ b/pkg/client/clientset/typed/helm/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/client/clientset/typed/helm/v1beta1/fake/fake_chart.go b/pkg/client/clientset/typed/helm/v1beta1/fake/fake_chart.go new file mode 100644 index 000000000000..04a9a2d08bb3 --- /dev/null +++ b/pkg/client/clientset/typed/helm/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/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/client/clientset/typed/helm/v1beta1/fake/fake_helm_client.go b/pkg/client/clientset/typed/helm/v1beta1/fake/fake_helm_client.go new file mode 100644 index 000000000000..e666ba463d8c --- /dev/null +++ b/pkg/client/clientset/typed/helm/v1beta1/fake/fake_helm_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/client/clientset/typed/helm/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/client/clientset/typed/helm/v1beta1/generated_expansion.go b/pkg/client/clientset/typed/helm/v1beta1/generated_expansion.go new file mode 100644 index 000000000000..2af6a91299bd --- /dev/null +++ b/pkg/client/clientset/typed/helm/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/client/clientset/typed/helm/v1beta1/helm_client.go b/pkg/client/clientset/typed/helm/v1beta1/helm_client.go new file mode 100644 index 000000000000..e72993bbb8fd --- /dev/null +++ b/pkg/client/clientset/typed/helm/v1beta1/helm_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/v1beta1" + "github.com/k0sproject/k0s/pkg/client/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 +}