From e880de0e638e7f29b2e2298dbbeec572ea93cd5d Mon Sep 17 00:00:00 2001 From: Klaus Ma Date: Wed, 16 Jan 2019 15:10:29 +0800 Subject: [PATCH] Added clients --- pkg/client/clientset/versioned/clientset.go | 22 +++ .../versioned/fake/clientset_generated.go | 12 ++ .../clientset/versioned/fake/register.go | 2 + .../clientset/versioned/scheme/register.go | 2 + .../typed/batch/v1alpha1/fake/fake_job.go | 2 +- .../versioned/typed/batch/v1alpha1/job.go | 17 ++ .../typed/bus/v1alpha1/bus_client.go | 90 +++++++++ .../versioned/typed/bus/v1alpha1/command.go | 174 ++++++++++++++++++ .../versioned/typed/bus/v1alpha1/doc.go | 20 ++ .../versioned/typed/bus/v1alpha1/fake/doc.go | 20 ++ .../bus/v1alpha1/fake/fake_bus_client.go | 40 ++++ .../typed/bus/v1alpha1/fake/fake_command.go | 128 +++++++++++++ .../typed/bus/v1alpha1/generated_expansion.go | 21 +++ .../externalversions/bus/interface.go | 46 +++++ .../externalversions/bus/v1alpha1/command.go | 89 +++++++++ .../bus/v1alpha1/interface.go | 45 +++++ .../informers/externalversions/factory.go | 6 + .../informers/externalversions/generic.go | 5 + .../internalinterfaces/factory_interfaces.go | 2 + pkg/client/listers/bus/v1alpha1/command.go | 94 ++++++++++ .../bus/v1alpha1/expansion_generated.go | 27 +++ 21 files changed, 863 insertions(+), 1 deletion(-) create mode 100644 pkg/client/clientset/versioned/typed/bus/v1alpha1/bus_client.go create mode 100644 pkg/client/clientset/versioned/typed/bus/v1alpha1/command.go create mode 100644 pkg/client/clientset/versioned/typed/bus/v1alpha1/doc.go create mode 100644 pkg/client/clientset/versioned/typed/bus/v1alpha1/fake/doc.go create mode 100644 pkg/client/clientset/versioned/typed/bus/v1alpha1/fake/fake_bus_client.go create mode 100644 pkg/client/clientset/versioned/typed/bus/v1alpha1/fake/fake_command.go create mode 100644 pkg/client/clientset/versioned/typed/bus/v1alpha1/generated_expansion.go create mode 100644 pkg/client/informers/externalversions/bus/interface.go create mode 100644 pkg/client/informers/externalversions/bus/v1alpha1/command.go create mode 100644 pkg/client/informers/externalversions/bus/v1alpha1/interface.go create mode 100644 pkg/client/listers/bus/v1alpha1/command.go create mode 100644 pkg/client/listers/bus/v1alpha1/expansion_generated.go diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go index 4944cc2ef4..a5bd3a96a7 100644 --- a/pkg/client/clientset/versioned/clientset.go +++ b/pkg/client/clientset/versioned/clientset.go @@ -20,6 +20,7 @@ package versioned import ( batchv1alpha1 "hpw.cloud/volcano/pkg/client/clientset/versioned/typed/batch/v1alpha1" + busv1alpha1 "hpw.cloud/volcano/pkg/client/clientset/versioned/typed/bus/v1alpha1" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" @@ -30,6 +31,9 @@ type Interface interface { BatchV1alpha1() batchv1alpha1.BatchV1alpha1Interface // Deprecated: please explicitly pick a version if possible. Batch() batchv1alpha1.BatchV1alpha1Interface + BusV1alpha1() busv1alpha1.BusV1alpha1Interface + // Deprecated: please explicitly pick a version if possible. + Bus() busv1alpha1.BusV1alpha1Interface } // Clientset contains the clients for groups. Each group has exactly one @@ -37,6 +41,7 @@ type Interface interface { type Clientset struct { *discovery.DiscoveryClient batchV1alpha1 *batchv1alpha1.BatchV1alpha1Client + busV1alpha1 *busv1alpha1.BusV1alpha1Client } // BatchV1alpha1 retrieves the BatchV1alpha1Client @@ -50,6 +55,17 @@ func (c *Clientset) Batch() batchv1alpha1.BatchV1alpha1Interface { return c.batchV1alpha1 } +// BusV1alpha1 retrieves the BusV1alpha1Client +func (c *Clientset) BusV1alpha1() busv1alpha1.BusV1alpha1Interface { + return c.busV1alpha1 +} + +// Deprecated: Bus retrieves the default version of BusClient. +// Please explicitly pick a version. +func (c *Clientset) Bus() busv1alpha1.BusV1alpha1Interface { + return c.busV1alpha1 +} + // Discovery retrieves the DiscoveryClient func (c *Clientset) Discovery() discovery.DiscoveryInterface { if c == nil { @@ -70,6 +86,10 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { if err != nil { return nil, err } + cs.busV1alpha1, err = busv1alpha1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) if err != nil { @@ -83,6 +103,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { func NewForConfigOrDie(c *rest.Config) *Clientset { var cs Clientset cs.batchV1alpha1 = batchv1alpha1.NewForConfigOrDie(c) + cs.busV1alpha1 = busv1alpha1.NewForConfigOrDie(c) cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) return &cs @@ -92,6 +113,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { func New(c rest.Interface) *Clientset { var cs Clientset cs.batchV1alpha1 = batchv1alpha1.New(c) + cs.busV1alpha1 = busv1alpha1.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) return &cs diff --git a/pkg/client/clientset/versioned/fake/clientset_generated.go b/pkg/client/clientset/versioned/fake/clientset_generated.go index 3f071210fa..200ff4b499 100644 --- a/pkg/client/clientset/versioned/fake/clientset_generated.go +++ b/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -22,6 +22,8 @@ import ( clientset "hpw.cloud/volcano/pkg/client/clientset/versioned" batchv1alpha1 "hpw.cloud/volcano/pkg/client/clientset/versioned/typed/batch/v1alpha1" fakebatchv1alpha1 "hpw.cloud/volcano/pkg/client/clientset/versioned/typed/batch/v1alpha1/fake" + busv1alpha1 "hpw.cloud/volcano/pkg/client/clientset/versioned/typed/bus/v1alpha1" + fakebusv1alpha1 "hpw.cloud/volcano/pkg/client/clientset/versioned/typed/bus/v1alpha1/fake" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/discovery" @@ -80,3 +82,13 @@ func (c *Clientset) BatchV1alpha1() batchv1alpha1.BatchV1alpha1Interface { func (c *Clientset) Batch() batchv1alpha1.BatchV1alpha1Interface { return &fakebatchv1alpha1.FakeBatchV1alpha1{Fake: &c.Fake} } + +// BusV1alpha1 retrieves the BusV1alpha1Client +func (c *Clientset) BusV1alpha1() busv1alpha1.BusV1alpha1Interface { + return &fakebusv1alpha1.FakeBusV1alpha1{Fake: &c.Fake} +} + +// Bus retrieves the BusV1alpha1Client +func (c *Clientset) Bus() busv1alpha1.BusV1alpha1Interface { + return &fakebusv1alpha1.FakeBusV1alpha1{Fake: &c.Fake} +} diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go index 6a18f48a0b..042fc724f3 100644 --- a/pkg/client/clientset/versioned/fake/register.go +++ b/pkg/client/clientset/versioned/fake/register.go @@ -20,6 +20,7 @@ package fake import ( batchv1alpha1 "hpw.cloud/volcano/pkg/apis/batch/v1alpha1" + busv1alpha1 "hpw.cloud/volcano/pkg/apis/bus/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -32,6 +33,7 @@ var codecs = serializer.NewCodecFactory(scheme) var parameterCodec = runtime.NewParameterCodec(scheme) var localSchemeBuilder = runtime.SchemeBuilder{ batchv1alpha1.AddToScheme, + busv1alpha1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go index 12752b8d32..cf319718be 100644 --- a/pkg/client/clientset/versioned/scheme/register.go +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -20,6 +20,7 @@ package scheme import ( batchv1alpha1 "hpw.cloud/volcano/pkg/apis/batch/v1alpha1" + busv1alpha1 "hpw.cloud/volcano/pkg/apis/bus/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -32,6 +33,7 @@ var Codecs = serializer.NewCodecFactory(Scheme) var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ batchv1alpha1.AddToScheme, + busv1alpha1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/client/clientset/versioned/typed/batch/v1alpha1/fake/fake_job.go b/pkg/client/clientset/versioned/typed/batch/v1alpha1/fake/fake_job.go index 789814cf60..d02c37149e 100644 --- a/pkg/client/clientset/versioned/typed/batch/v1alpha1/fake/fake_job.go +++ b/pkg/client/clientset/versioned/typed/batch/v1alpha1/fake/fake_job.go @@ -131,7 +131,7 @@ func (c *FakeJobs) DeleteCollection(options *v1.DeleteOptions, listOptions v1.Li // Patch applies the patch and returns the patched job. func (c *FakeJobs) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Job, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(jobsResource, c.ns, name, data, subresources...), &v1alpha1.Job{}) + Invokes(testing.NewPatchSubresourceAction(jobsResource, c.ns, name, pt, data, subresources...), &v1alpha1.Job{}) if obj == nil { return nil, err diff --git a/pkg/client/clientset/versioned/typed/batch/v1alpha1/job.go b/pkg/client/clientset/versioned/typed/batch/v1alpha1/job.go index 7306e378ed..2e962e278a 100644 --- a/pkg/client/clientset/versioned/typed/batch/v1alpha1/job.go +++ b/pkg/client/clientset/versioned/typed/batch/v1alpha1/job.go @@ -19,6 +19,8 @@ limitations under the License. package v1alpha1 import ( + "time" + v1alpha1 "hpw.cloud/volcano/pkg/apis/batch/v1alpha1" scheme "hpw.cloud/volcano/pkg/client/clientset/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -76,11 +78,16 @@ func (c *jobs) Get(name string, options v1.GetOptions) (result *v1alpha1.Job, er // List takes label and field selectors, and returns the list of Jobs that match those selectors. func (c *jobs) List(opts v1.ListOptions) (result *v1alpha1.JobList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } result = &v1alpha1.JobList{} err = c.client.Get(). Namespace(c.ns). Resource("jobs"). VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). Do(). Into(result) return @@ -88,11 +95,16 @@ func (c *jobs) List(opts v1.ListOptions) (result *v1alpha1.JobList, err error) { // Watch returns a watch.Interface that watches the requested jobs. func (c *jobs) Watch(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("jobs"). VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). Watch() } @@ -150,10 +162,15 @@ func (c *jobs) Delete(name string, options *v1.DeleteOptions) error { // DeleteCollection deletes a collection of objects. func (c *jobs) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + var timeout time.Duration + if listOptions.TimeoutSeconds != nil { + timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second + } return c.client.Delete(). Namespace(c.ns). Resource("jobs"). VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). Body(options). Do(). Error() diff --git a/pkg/client/clientset/versioned/typed/bus/v1alpha1/bus_client.go b/pkg/client/clientset/versioned/typed/bus/v1alpha1/bus_client.go new file mode 100644 index 0000000000..73e36f5bd8 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/bus/v1alpha1/bus_client.go @@ -0,0 +1,90 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "hpw.cloud/volcano/pkg/apis/bus/v1alpha1" + "hpw.cloud/volcano/pkg/client/clientset/versioned/scheme" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + rest "k8s.io/client-go/rest" +) + +type BusV1alpha1Interface interface { + RESTClient() rest.Interface + CommandsGetter +} + +// BusV1alpha1Client is used to interact with features provided by the bus group. +type BusV1alpha1Client struct { + restClient rest.Interface +} + +func (c *BusV1alpha1Client) Commands(namespace string) CommandInterface { + return newCommands(c, namespace) +} + +// NewForConfig creates a new BusV1alpha1Client for the given config. +func NewForConfig(c *rest.Config) (*BusV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &BusV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new BusV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *BusV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new BusV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *BusV1alpha1Client { + return &BusV1alpha1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs} + + 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 *BusV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/client/clientset/versioned/typed/bus/v1alpha1/command.go b/pkg/client/clientset/versioned/typed/bus/v1alpha1/command.go new file mode 100644 index 0000000000..9f9a1a3045 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/bus/v1alpha1/command.go @@ -0,0 +1,174 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "time" + + v1alpha1 "hpw.cloud/volcano/pkg/apis/bus/v1alpha1" + scheme "hpw.cloud/volcano/pkg/client/clientset/versioned/scheme" + v1 "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" +) + +// CommandsGetter has a method to return a CommandInterface. +// A group's client should implement this interface. +type CommandsGetter interface { + Commands(namespace string) CommandInterface +} + +// CommandInterface has methods to work with Command resources. +type CommandInterface interface { + Create(*v1alpha1.Command) (*v1alpha1.Command, error) + Update(*v1alpha1.Command) (*v1alpha1.Command, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.Command, error) + List(opts v1.ListOptions) (*v1alpha1.CommandList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Command, err error) + CommandExpansion +} + +// commands implements CommandInterface +type commands struct { + client rest.Interface + ns string +} + +// newCommands returns a Commands +func newCommands(c *BusV1alpha1Client, namespace string) *commands { + return &commands{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the command, and returns the corresponding command object, and an error if there is any. +func (c *commands) Get(name string, options v1.GetOptions) (result *v1alpha1.Command, err error) { + result = &v1alpha1.Command{} + err = c.client.Get(). + Namespace(c.ns). + Resource("commands"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Commands that match those selectors. +func (c *commands) List(opts v1.ListOptions) (result *v1alpha1.CommandList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.CommandList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("commands"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested commands. +func (c *commands) Watch(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("commands"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a command and creates it. Returns the server's representation of the command, and an error, if there is any. +func (c *commands) Create(command *v1alpha1.Command) (result *v1alpha1.Command, err error) { + result = &v1alpha1.Command{} + err = c.client.Post(). + Namespace(c.ns). + Resource("commands"). + Body(command). + Do(). + Into(result) + return +} + +// Update takes the representation of a command and updates it. Returns the server's representation of the command, and an error, if there is any. +func (c *commands) Update(command *v1alpha1.Command) (result *v1alpha1.Command, err error) { + result = &v1alpha1.Command{} + err = c.client.Put(). + Namespace(c.ns). + Resource("commands"). + Name(command.Name). + Body(command). + Do(). + Into(result) + return +} + +// Delete takes name of the command and deletes it. Returns an error if one occurs. +func (c *commands) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("commands"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *commands) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + var timeout time.Duration + if listOptions.TimeoutSeconds != nil { + timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("commands"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched command. +func (c *commands) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Command, err error) { + result = &v1alpha1.Command{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("commands"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/bus/v1alpha1/doc.go b/pkg/client/clientset/versioned/typed/bus/v1alpha1/doc.go new file mode 100644 index 0000000000..df51baa4d4 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/bus/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/pkg/client/clientset/versioned/typed/bus/v1alpha1/fake/doc.go b/pkg/client/clientset/versioned/typed/bus/v1alpha1/fake/doc.go new file mode 100644 index 0000000000..16f4439906 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/bus/v1alpha1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/pkg/client/clientset/versioned/typed/bus/v1alpha1/fake/fake_bus_client.go b/pkg/client/clientset/versioned/typed/bus/v1alpha1/fake/fake_bus_client.go new file mode 100644 index 0000000000..9fc41d974f --- /dev/null +++ b/pkg/client/clientset/versioned/typed/bus/v1alpha1/fake/fake_bus_client.go @@ -0,0 +1,40 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha1 "hpw.cloud/volcano/pkg/client/clientset/versioned/typed/bus/v1alpha1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeBusV1alpha1 struct { + *testing.Fake +} + +func (c *FakeBusV1alpha1) Commands(namespace string) v1alpha1.CommandInterface { + return &FakeCommands{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeBusV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/client/clientset/versioned/typed/bus/v1alpha1/fake/fake_command.go b/pkg/client/clientset/versioned/typed/bus/v1alpha1/fake/fake_command.go new file mode 100644 index 0000000000..9ca688ee07 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/bus/v1alpha1/fake/fake_command.go @@ -0,0 +1,128 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha1 "hpw.cloud/volcano/pkg/apis/bus/v1alpha1" + 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" +) + +// FakeCommands implements CommandInterface +type FakeCommands struct { + Fake *FakeBusV1alpha1 + ns string +} + +var commandsResource = schema.GroupVersionResource{Group: "bus", Version: "v1alpha1", Resource: "commands"} + +var commandsKind = schema.GroupVersionKind{Group: "bus", Version: "v1alpha1", Kind: "Command"} + +// Get takes name of the command, and returns the corresponding command object, and an error if there is any. +func (c *FakeCommands) Get(name string, options v1.GetOptions) (result *v1alpha1.Command, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(commandsResource, c.ns, name), &v1alpha1.Command{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Command), err +} + +// List takes label and field selectors, and returns the list of Commands that match those selectors. +func (c *FakeCommands) List(opts v1.ListOptions) (result *v1alpha1.CommandList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(commandsResource, commandsKind, c.ns, opts), &v1alpha1.CommandList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.CommandList{ListMeta: obj.(*v1alpha1.CommandList).ListMeta} + for _, item := range obj.(*v1alpha1.CommandList).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 commands. +func (c *FakeCommands) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(commandsResource, c.ns, opts)) + +} + +// Create takes the representation of a command and creates it. Returns the server's representation of the command, and an error, if there is any. +func (c *FakeCommands) Create(command *v1alpha1.Command) (result *v1alpha1.Command, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(commandsResource, c.ns, command), &v1alpha1.Command{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Command), err +} + +// Update takes the representation of a command and updates it. Returns the server's representation of the command, and an error, if there is any. +func (c *FakeCommands) Update(command *v1alpha1.Command) (result *v1alpha1.Command, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(commandsResource, c.ns, command), &v1alpha1.Command{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Command), err +} + +// Delete takes name of the command and deletes it. Returns an error if one occurs. +func (c *FakeCommands) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(commandsResource, c.ns, name), &v1alpha1.Command{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeCommands) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(commandsResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.CommandList{}) + return err +} + +// Patch applies the patch and returns the patched command. +func (c *FakeCommands) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Command, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(commandsResource, c.ns, name, pt, data, subresources...), &v1alpha1.Command{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Command), err +} diff --git a/pkg/client/clientset/versioned/typed/bus/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/bus/v1alpha1/generated_expansion.go new file mode 100644 index 0000000000..55e8cd3bf5 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/bus/v1alpha1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +type CommandExpansion interface{} diff --git a/pkg/client/informers/externalversions/bus/interface.go b/pkg/client/informers/externalversions/bus/interface.go new file mode 100644 index 0000000000..15f65c76d6 --- /dev/null +++ b/pkg/client/informers/externalversions/bus/interface.go @@ -0,0 +1,46 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package bus + +import ( + v1alpha1 "hpw.cloud/volcano/pkg/client/informers/externalversions/bus/v1alpha1" + internalinterfaces "hpw.cloud/volcano/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() v1alpha1.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1alpha1 returns a new v1alpha1.Interface. +func (g *group) V1alpha1() v1alpha1.Interface { + return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/client/informers/externalversions/bus/v1alpha1/command.go b/pkg/client/informers/externalversions/bus/v1alpha1/command.go new file mode 100644 index 0000000000..8940112bc1 --- /dev/null +++ b/pkg/client/informers/externalversions/bus/v1alpha1/command.go @@ -0,0 +1,89 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + time "time" + + busv1alpha1 "hpw.cloud/volcano/pkg/apis/bus/v1alpha1" + versioned "hpw.cloud/volcano/pkg/client/clientset/versioned" + internalinterfaces "hpw.cloud/volcano/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "hpw.cloud/volcano/pkg/client/listers/bus/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// CommandInformer provides access to a shared informer and lister for +// Commands. +type CommandInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.CommandLister +} + +type commandInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewCommandInformer constructs a new informer for Command type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewCommandInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredCommandInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredCommandInformer constructs a new informer for Command type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredCommandInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.BusV1alpha1().Commands(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.BusV1alpha1().Commands(namespace).Watch(options) + }, + }, + &busv1alpha1.Command{}, + resyncPeriod, + indexers, + ) +} + +func (f *commandInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredCommandInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *commandInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&busv1alpha1.Command{}, f.defaultInformer) +} + +func (f *commandInformer) Lister() v1alpha1.CommandLister { + return v1alpha1.NewCommandLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/bus/v1alpha1/interface.go b/pkg/client/informers/externalversions/bus/v1alpha1/interface.go new file mode 100644 index 0000000000..0d7a883808 --- /dev/null +++ b/pkg/client/informers/externalversions/bus/v1alpha1/interface.go @@ -0,0 +1,45 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + internalinterfaces "hpw.cloud/volcano/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // Commands returns a CommandInformer. + Commands() CommandInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// Commands returns a CommandInformer. +func (v *version) Commands() CommandInformer { + return &commandInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/client/informers/externalversions/factory.go b/pkg/client/informers/externalversions/factory.go index 48a38c2e0a..ffd4fe18d1 100644 --- a/pkg/client/informers/externalversions/factory.go +++ b/pkg/client/informers/externalversions/factory.go @@ -25,6 +25,7 @@ import ( versioned "hpw.cloud/volcano/pkg/client/clientset/versioned" batch "hpw.cloud/volcano/pkg/client/informers/externalversions/batch" + bus "hpw.cloud/volcano/pkg/client/informers/externalversions/bus" internalinterfaces "hpw.cloud/volcano/pkg/client/informers/externalversions/internalinterfaces" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" @@ -173,8 +174,13 @@ type SharedInformerFactory interface { WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool Batch() batch.Interface + Bus() bus.Interface } func (f *sharedInformerFactory) Batch() batch.Interface { return batch.New(f, f.namespace, f.tweakListOptions) } + +func (f *sharedInformerFactory) Bus() bus.Interface { + return bus.New(f, f.namespace, f.tweakListOptions) +} diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index d4e09a8ff1..b447ff6063 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -22,6 +22,7 @@ import ( "fmt" v1alpha1 "hpw.cloud/volcano/pkg/apis/batch/v1alpha1" + busv1alpha1 "hpw.cloud/volcano/pkg/apis/bus/v1alpha1" schema "k8s.io/apimachinery/pkg/runtime/schema" cache "k8s.io/client-go/tools/cache" ) @@ -56,6 +57,10 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource case v1alpha1.SchemeGroupVersion.WithResource("jobs"): return &genericInformer{resource: resource.GroupResource(), informer: f.Batch().V1alpha1().Jobs().Informer()}, nil + // Group=bus, Version=v1alpha1 + case busv1alpha1.SchemeGroupVersion.WithResource("commands"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Bus().V1alpha1().Commands().Informer()}, nil + } return nil, fmt.Errorf("no informer found for %v", resource) diff --git a/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go b/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go index 4fc16ec606..174b92767d 100644 --- a/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go +++ b/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go @@ -27,6 +27,7 @@ import ( cache "k8s.io/client-go/tools/cache" ) +// NewInformerFunc takes versioned.Interface and time.Duration to return a SharedIndexInformer. type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer // SharedInformerFactory a small interface to allow for adding an informer without an import cycle @@ -35,4 +36,5 @@ type SharedInformerFactory interface { InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer } +// TweakListOptionsFunc is a function that transforms a v1.ListOptions. type TweakListOptionsFunc func(*v1.ListOptions) diff --git a/pkg/client/listers/bus/v1alpha1/command.go b/pkg/client/listers/bus/v1alpha1/command.go new file mode 100644 index 0000000000..3c1e1f4044 --- /dev/null +++ b/pkg/client/listers/bus/v1alpha1/command.go @@ -0,0 +1,94 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "hpw.cloud/volcano/pkg/apis/bus/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// CommandLister helps list Commands. +type CommandLister interface { + // List lists all Commands in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.Command, err error) + // Commands returns an object that can list and get Commands. + Commands(namespace string) CommandNamespaceLister + CommandListerExpansion +} + +// commandLister implements the CommandLister interface. +type commandLister struct { + indexer cache.Indexer +} + +// NewCommandLister returns a new CommandLister. +func NewCommandLister(indexer cache.Indexer) CommandLister { + return &commandLister{indexer: indexer} +} + +// List lists all Commands in the indexer. +func (s *commandLister) List(selector labels.Selector) (ret []*v1alpha1.Command, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Command)) + }) + return ret, err +} + +// Commands returns an object that can list and get Commands. +func (s *commandLister) Commands(namespace string) CommandNamespaceLister { + return commandNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// CommandNamespaceLister helps list and get Commands. +type CommandNamespaceLister interface { + // List lists all Commands in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.Command, err error) + // Get retrieves the Command from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.Command, error) + CommandNamespaceListerExpansion +} + +// commandNamespaceLister implements the CommandNamespaceLister +// interface. +type commandNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Commands in the indexer for a given namespace. +func (s commandNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Command, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Command)) + }) + return ret, err +} + +// Get retrieves the Command from the indexer for a given namespace and name. +func (s commandNamespaceLister) Get(name string) (*v1alpha1.Command, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("command"), name) + } + return obj.(*v1alpha1.Command), nil +} diff --git a/pkg/client/listers/bus/v1alpha1/expansion_generated.go b/pkg/client/listers/bus/v1alpha1/expansion_generated.go new file mode 100644 index 0000000000..f0a2fa2164 --- /dev/null +++ b/pkg/client/listers/bus/v1alpha1/expansion_generated.go @@ -0,0 +1,27 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +// CommandListerExpansion allows custom methods to be added to +// CommandLister. +type CommandListerExpansion interface{} + +// CommandNamespaceListerExpansion allows custom methods to be added to +// CommandNamespaceLister. +type CommandNamespaceListerExpansion interface{}