From d169fa6864c58d4a16a89721d3b1cd939af67e6f Mon Sep 17 00:00:00 2001 From: jianhuiz Date: Tue, 26 Apr 2016 06:10:09 -0700 Subject: [PATCH 1/2] generate v1alpha and unversioned clientset for federation/clusters --- cmd/libs/go2idl/client-gen/main.go | 27 +++- federation/apis/federation/types.go | 2 + federation/apis/federation/v1alpha1/types.go | 2 + .../federation_internalclientset/clientset.go | 86 +++++++++++ .../federation_internalclientset/doc.go | 20 +++ .../fake/clientset_generated.go | 65 ++++++++ .../federation_internalclientset/fake/doc.go | 20 +++ .../typed/federation/unversioned/cluster.go | 140 ++++++++++++++++++ .../typed/federation/unversioned/doc.go | 20 +++ .../typed/federation/unversioned/fake/doc.go | 20 +++ .../unversioned/fake/fake_cluster.go | 108 ++++++++++++++ .../fake/fake_federation_client.go | 30 ++++ .../unversioned/federation_client.go | 90 +++++++++++ .../unversioned/generated_expansion.go | 19 +++ .../federation_release_1_3/clientset.go | 86 +++++++++++ .../federation_release_1_3/doc.go | 20 +++ .../fake/clientset_generated.go | 65 ++++++++ .../federation_release_1_3/fake/doc.go | 20 +++ .../typed/federation/v1alpha1/cluster.go | 140 ++++++++++++++++++ .../typed/federation/v1alpha1/doc.go | 20 +++ .../typed/federation/v1alpha1/fake/doc.go | 20 +++ .../federation/v1alpha1/fake/fake_cluster.go | 108 ++++++++++++++ .../v1alpha1/fake/fake_federation_client.go | 30 ++++ .../federation/v1alpha1/federation_client.go | 96 ++++++++++++ .../v1alpha1/generated_expansion.go | 19 +++ hack/verify-flags/known-flags.txt | 1 + 26 files changed, 1268 insertions(+), 6 deletions(-) create mode 100644 federation/client/clientset_generated/federation_internalclientset/clientset.go create mode 100644 federation/client/clientset_generated/federation_internalclientset/doc.go create mode 100644 federation/client/clientset_generated/federation_internalclientset/fake/clientset_generated.go create mode 100644 federation/client/clientset_generated/federation_internalclientset/fake/doc.go create mode 100644 federation/client/clientset_generated/federation_internalclientset/typed/federation/unversioned/cluster.go create mode 100644 federation/client/clientset_generated/federation_internalclientset/typed/federation/unversioned/doc.go create mode 100644 federation/client/clientset_generated/federation_internalclientset/typed/federation/unversioned/fake/doc.go create mode 100644 federation/client/clientset_generated/federation_internalclientset/typed/federation/unversioned/fake/fake_cluster.go create mode 100644 federation/client/clientset_generated/federation_internalclientset/typed/federation/unversioned/fake/fake_federation_client.go create mode 100644 federation/client/clientset_generated/federation_internalclientset/typed/federation/unversioned/federation_client.go create mode 100644 federation/client/clientset_generated/federation_internalclientset/typed/federation/unversioned/generated_expansion.go create mode 100644 federation/client/clientset_generated/federation_release_1_3/clientset.go create mode 100644 federation/client/clientset_generated/federation_release_1_3/doc.go create mode 100644 federation/client/clientset_generated/federation_release_1_3/fake/clientset_generated.go create mode 100644 federation/client/clientset_generated/federation_release_1_3/fake/doc.go create mode 100644 federation/client/clientset_generated/federation_release_1_3/typed/federation/v1alpha1/cluster.go create mode 100644 federation/client/clientset_generated/federation_release_1_3/typed/federation/v1alpha1/doc.go create mode 100644 federation/client/clientset_generated/federation_release_1_3/typed/federation/v1alpha1/fake/doc.go create mode 100644 federation/client/clientset_generated/federation_release_1_3/typed/federation/v1alpha1/fake/fake_cluster.go create mode 100644 federation/client/clientset_generated/federation_release_1_3/typed/federation/v1alpha1/fake/fake_federation_client.go create mode 100644 federation/client/clientset_generated/federation_release_1_3/typed/federation/v1alpha1/federation_client.go create mode 100644 federation/client/clientset_generated/federation_release_1_3/typed/federation/v1alpha1/generated_expansion.go diff --git a/cmd/libs/go2idl/client-gen/main.go b/cmd/libs/go2idl/client-gen/main.go index 79d8e10190e..29129f9ddf4 100644 --- a/cmd/libs/go2idl/client-gen/main.go +++ b/cmd/libs/go2idl/client-gen/main.go @@ -28,32 +28,45 @@ import ( "github.com/golang/glog" flag "github.com/spf13/pflag" + "strings" ) var ( test = flag.BoolP("test", "t", false, "set this flag to generate the client code for the testdata") inputVersions = flag.StringSlice("input", []string{"api/", "extensions/", "batch/"}, "group/versions that client-gen will generate clients for. At most one version per group is allowed. Specified in the format \"group1/version1,group2/version2...\". Default to \"api/,extensions/,batch/\"") + basePath = flag.String("input-base", "k8s.io/kubernetes/pkg/apis", "base path to look for the api group. Default to \"k8s.io/kubernetes/pkg/apis\"") clientsetName = flag.StringP("clientset-name", "n", "internalclientset", "the name of the generated clientset package.") clientsetPath = flag.String("clientset-path", "k8s.io/kubernetes/pkg/client/clientset_generated/", "the generated clientset will be output to /. Default to \"k8s.io/kubernetes/pkg/client/clientset_generated/\"") clientsetOnly = flag.Bool("clientset-only", false, "when set, client-gen only generates the clientset shell, without generating the individual typed clients") fakeClient = flag.Bool("fake-clientset", true, "when set, client-gen will generate the fake clientset that can be used in tests") ) -func versionToPath(group string, version string) (path string) { - const base = "k8s.io/kubernetes/pkg" +func versionToPath(gvPath string, group string, version string) (path string) { // special case for the core group if group == "api" { - path = filepath.Join(base, "api", version) + path = filepath.Join(*basePath, "../api", version) } else { - path = filepath.Join(base, "apis", group, version) + path = filepath.Join(*basePath, gvPath, group, version) } return } +func parsePathGroupVersion(pgvString string) (gvPath string, gvString string) { + subs := strings.Split(pgvString, "/") + length := len(subs) + switch length { + case 0, 1, 2: + return "", pgvString + default: + return strings.Join(subs[:length-2], "/"), strings.Join(subs[length-2:], "/") + } +} + func parseInputVersions() (paths []string, groupVersions []unversioned.GroupVersion, gvToPath map[unversioned.GroupVersion]string, err error) { var visitedGroups = make(map[string]struct{}) gvToPath = make(map[unversioned.GroupVersion]string) - for _, gvString := range *inputVersions { + for _, input := range *inputVersions { + gvPath, gvString := parsePathGroupVersion(input) gv, err := unversioned.ParseGroupVersion(gvString) if err != nil { return nil, nil, nil, err @@ -64,7 +77,7 @@ func parseInputVersions() (paths []string, groupVersions []unversioned.GroupVers } visitedGroups[gv.Group] = struct{}{} groupVersions = append(groupVersions, gv) - path := versionToPath(gv.Group, gv.Version) + path := versionToPath(gvPath, gv.Group, gv.Version) paths = append(paths, path) gvToPath[gv] = path } @@ -122,6 +135,8 @@ func main() { FakeClient: *fakeClient, CmdArgs: cmdArgs, } + + fmt.Printf("==arguments: %v\n", arguments) } if err := arguments.Execute( diff --git a/federation/apis/federation/types.go b/federation/apis/federation/types.go index 7ccbb9b2855..4de12969ae0 100644 --- a/federation/apis/federation/types.go +++ b/federation/apis/federation/types.go @@ -77,6 +77,8 @@ type ClusterStatus struct { ClusterMeta `json:",inline"` } +// +genclient=true,nonNamespaced=true + // Information about a registered cluster in a federated kubernetes setup. Clusters are not namespaced and have unique names in the federation. type Cluster struct { unversioned.TypeMeta `json:",inline"` diff --git a/federation/apis/federation/v1alpha1/types.go b/federation/apis/federation/v1alpha1/types.go index c1ae4ca25ee..2f3ea9ac7be 100644 --- a/federation/apis/federation/v1alpha1/types.go +++ b/federation/apis/federation/v1alpha1/types.go @@ -77,6 +77,8 @@ type ClusterStatus struct { ClusterMeta `json:",inline" protobuf:"bytes,4,opt,name=clusterMeta"` } +// +genclient=true,nonNamespaced=true + // Information about a registered cluster in a federated kubernetes setup. Clusters are not namespaced and have unique names in the federation. type Cluster struct { unversioned.TypeMeta `json:",inline"` diff --git a/federation/client/clientset_generated/federation_internalclientset/clientset.go b/federation/client/clientset_generated/federation_internalclientset/clientset.go new file mode 100644 index 00000000000..ce038402b6d --- /dev/null +++ b/federation/client/clientset_generated/federation_internalclientset/clientset.go @@ -0,0 +1,86 @@ +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +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. +*/ + +package federation_internalclientset + +import ( + "github.com/golang/glog" + unversionedfederation "k8s.io/kubernetes/federation/client/clientset_generated/federation_internalclientset/typed/federation/unversioned" + restclient "k8s.io/kubernetes/pkg/client/restclient" + discovery "k8s.io/kubernetes/pkg/client/typed/discovery" + "k8s.io/kubernetes/pkg/util/flowcontrol" +) + +type Interface interface { + Discovery() discovery.DiscoveryInterface + Federation() unversionedfederation.FederationInterface +} + +// Clientset contains the clients for groups. Each group has exactly one +// version included in a Clientset. +type Clientset struct { + *discovery.DiscoveryClient + *unversionedfederation.FederationClient +} + +// Federation retrieves the FederationClient +func (c *Clientset) Federation() unversionedfederation.FederationInterface { + return c.FederationClient +} + +// Discovery retrieves the DiscoveryClient +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + return c.DiscoveryClient +} + +// NewForConfig creates a new Clientset for the given config. +func NewForConfig(c *restclient.Config) (*Clientset, error) { + configShallowCopy := *c + if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { + configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) + } + var clientset Clientset + var err error + clientset.FederationClient, err = unversionedfederation.NewForConfig(&configShallowCopy) + if err != nil { + return &clientset, err + } + + clientset.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) + if err != nil { + glog.Errorf("failed to create the DiscoveryClient: %v", err) + } + return &clientset, err +} + +// NewForConfigOrDie creates a new Clientset for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *restclient.Config) *Clientset { + var clientset Clientset + clientset.FederationClient = unversionedfederation.NewForConfigOrDie(c) + + clientset.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) + return &clientset +} + +// New creates a new Clientset for the given RESTClient. +func New(c *restclient.RESTClient) *Clientset { + var clientset Clientset + clientset.FederationClient = unversionedfederation.New(c) + + clientset.DiscoveryClient = discovery.NewDiscoveryClient(c) + return &clientset +} diff --git a/federation/client/clientset_generated/federation_internalclientset/doc.go b/federation/client/clientset_generated/federation_internalclientset/doc.go new file mode 100644 index 00000000000..5906c774317 --- /dev/null +++ b/federation/client/clientset_generated/federation_internalclientset/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +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. +*/ + +// This package is generated by client-gen with arguments: --clientset-name=federation_internalclientset --clientset-path=k8s.io/kubernetes/federation/client/clientset_generated --input=[federation/] --input-base=k8s.io/kubernetes/federation/apis + +// This package has the automatically generated clientset. +package federation_internalclientset diff --git a/federation/client/clientset_generated/federation_internalclientset/fake/clientset_generated.go b/federation/client/clientset_generated/federation_internalclientset/fake/clientset_generated.go new file mode 100644 index 00000000000..064c0e54cf3 --- /dev/null +++ b/federation/client/clientset_generated/federation_internalclientset/fake/clientset_generated.go @@ -0,0 +1,65 @@ +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +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. +*/ + +package fake + +import ( + clientset "k8s.io/kubernetes/federation/client/clientset_generated/federation_internalclientset" + unversionedfederation "k8s.io/kubernetes/federation/client/clientset_generated/federation_internalclientset/typed/federation/unversioned" + fakeunversionedfederation "k8s.io/kubernetes/federation/client/clientset_generated/federation_internalclientset/typed/federation/unversioned/fake" + "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/apimachinery/registered" + "k8s.io/kubernetes/pkg/client/testing/core" + "k8s.io/kubernetes/pkg/client/typed/discovery" + fakediscovery "k8s.io/kubernetes/pkg/client/typed/discovery/fake" + "k8s.io/kubernetes/pkg/runtime" + "k8s.io/kubernetes/pkg/watch" +) + +// Clientset returns a clientset that will respond with the provided objects +func NewSimpleClientset(objects ...runtime.Object) *Clientset { + o := core.NewObjects(api.Scheme, api.Codecs.UniversalDecoder()) + for _, obj := range objects { + if err := o.Add(obj); err != nil { + panic(err) + } + } + + fakePtr := core.Fake{} + fakePtr.AddReactor("*", "*", core.ObjectReaction(o, registered.RESTMapper())) + + fakePtr.AddWatchReactor("*", core.DefaultWatchReactor(watch.NewFake(), nil)) + + return &Clientset{fakePtr} +} + +// 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 { + core.Fake +} + +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + return &fakediscovery.FakeDiscovery{Fake: &c.Fake} +} + +var _ clientset.Interface = &Clientset{} + +// Federation retrieves the FederationClient +func (c *Clientset) Federation() unversionedfederation.FederationInterface { + return &fakeunversionedfederation.FakeFederation{Fake: &c.Fake} +} diff --git a/federation/client/clientset_generated/federation_internalclientset/fake/doc.go b/federation/client/clientset_generated/federation_internalclientset/fake/doc.go new file mode 100644 index 00000000000..95b2b29ba33 --- /dev/null +++ b/federation/client/clientset_generated/federation_internalclientset/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +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. +*/ + +// This package is generated by client-gen with arguments: --clientset-name=federation_internalclientset --clientset-path=k8s.io/kubernetes/federation/client/clientset_generated --input=[federation/] --input-base=k8s.io/kubernetes/federation/apis + +// This package has the automatically generated fake clientset. +package fake diff --git a/federation/client/clientset_generated/federation_internalclientset/typed/federation/unversioned/cluster.go b/federation/client/clientset_generated/federation_internalclientset/typed/federation/unversioned/cluster.go new file mode 100644 index 00000000000..e270951455c --- /dev/null +++ b/federation/client/clientset_generated/federation_internalclientset/typed/federation/unversioned/cluster.go @@ -0,0 +1,140 @@ +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +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. +*/ + +package unversioned + +import ( + federation "k8s.io/kubernetes/federation/apis/federation" + api "k8s.io/kubernetes/pkg/api" + watch "k8s.io/kubernetes/pkg/watch" +) + +// ClustersGetter has a method to return a ClusterInterface. +// A group's client should implement this interface. +type ClustersGetter interface { + Clusters() ClusterInterface +} + +// ClusterInterface has methods to work with Cluster resources. +type ClusterInterface interface { + Create(*federation.Cluster) (*federation.Cluster, error) + Update(*federation.Cluster) (*federation.Cluster, error) + UpdateStatus(*federation.Cluster) (*federation.Cluster, error) + Delete(name string, options *api.DeleteOptions) error + DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error + Get(name string) (*federation.Cluster, error) + List(opts api.ListOptions) (*federation.ClusterList, error) + Watch(opts api.ListOptions) (watch.Interface, error) + ClusterExpansion +} + +// clusters implements ClusterInterface +type clusters struct { + client *FederationClient +} + +// newClusters returns a Clusters +func newClusters(c *FederationClient) *clusters { + return &clusters{ + client: c, + } +} + +// Create takes the representation of a cluster and creates it. Returns the server's representation of the cluster, and an error, if there is any. +func (c *clusters) Create(cluster *federation.Cluster) (result *federation.Cluster, err error) { + result = &federation.Cluster{} + err = c.client.Post(). + Resource("clusters"). + Body(cluster). + Do(). + Into(result) + return +} + +// Update takes the representation of a cluster and updates it. Returns the server's representation of the cluster, and an error, if there is any. +func (c *clusters) Update(cluster *federation.Cluster) (result *federation.Cluster, err error) { + result = &federation.Cluster{} + err = c.client.Put(). + Resource("clusters"). + Name(cluster.Name). + Body(cluster). + Do(). + Into(result) + return +} + +func (c *clusters) UpdateStatus(cluster *federation.Cluster) (result *federation.Cluster, err error) { + result = &federation.Cluster{} + err = c.client.Put(). + Resource("clusters"). + Name(cluster.Name). + SubResource("status"). + Body(cluster). + Do(). + Into(result) + return +} + +// Delete takes name of the cluster and deletes it. Returns an error if one occurs. +func (c *clusters) Delete(name string, options *api.DeleteOptions) error { + return c.client.Delete(). + Resource("clusters"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *clusters) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error { + return c.client.Delete(). + Resource("clusters"). + VersionedParams(&listOptions, api.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Get takes name of the cluster, and returns the corresponding cluster object, and an error if there is any. +func (c *clusters) Get(name string) (result *federation.Cluster, err error) { + result = &federation.Cluster{} + err = c.client.Get(). + Resource("clusters"). + Name(name). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Clusters that match those selectors. +func (c *clusters) List(opts api.ListOptions) (result *federation.ClusterList, err error) { + result = &federation.ClusterList{} + err = c.client.Get(). + Resource("clusters"). + VersionedParams(&opts, api.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested clusters. +func (c *clusters) Watch(opts api.ListOptions) (watch.Interface, error) { + return c.client.Get(). + Prefix("watch"). + Resource("clusters"). + VersionedParams(&opts, api.ParameterCodec). + Watch() +} diff --git a/federation/client/clientset_generated/federation_internalclientset/typed/federation/unversioned/doc.go b/federation/client/clientset_generated/federation_internalclientset/typed/federation/unversioned/doc.go new file mode 100644 index 00000000000..8ebff890648 --- /dev/null +++ b/federation/client/clientset_generated/federation_internalclientset/typed/federation/unversioned/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +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. +*/ + +// This package is generated by client-gen with arguments: --clientset-name=federation_internalclientset --clientset-path=k8s.io/kubernetes/federation/client/clientset_generated --input=[federation/] --input-base=k8s.io/kubernetes/federation/apis + +// This package has the automatically generated typed clients. +package unversioned diff --git a/federation/client/clientset_generated/federation_internalclientset/typed/federation/unversioned/fake/doc.go b/federation/client/clientset_generated/federation_internalclientset/typed/federation/unversioned/fake/doc.go new file mode 100644 index 00000000000..ca9e1fd9d7a --- /dev/null +++ b/federation/client/clientset_generated/federation_internalclientset/typed/federation/unversioned/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +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. +*/ + +// This package is generated by client-gen with arguments: --clientset-name=federation_internalclientset --clientset-path=k8s.io/kubernetes/federation/client/clientset_generated --input=[federation/] --input-base=k8s.io/kubernetes/federation/apis + +// Package fake has the automatically generated clients. +package fake diff --git a/federation/client/clientset_generated/federation_internalclientset/typed/federation/unversioned/fake/fake_cluster.go b/federation/client/clientset_generated/federation_internalclientset/typed/federation/unversioned/fake/fake_cluster.go new file mode 100644 index 00000000000..e5ef0d7bc6e --- /dev/null +++ b/federation/client/clientset_generated/federation_internalclientset/typed/federation/unversioned/fake/fake_cluster.go @@ -0,0 +1,108 @@ +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +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. +*/ + +package fake + +import ( + federation "k8s.io/kubernetes/federation/apis/federation" + api "k8s.io/kubernetes/pkg/api" + unversioned "k8s.io/kubernetes/pkg/api/unversioned" + core "k8s.io/kubernetes/pkg/client/testing/core" + labels "k8s.io/kubernetes/pkg/labels" + watch "k8s.io/kubernetes/pkg/watch" +) + +// FakeClusters implements ClusterInterface +type FakeClusters struct { + Fake *FakeFederation +} + +var clustersResource = unversioned.GroupVersionResource{Group: "federation", Version: "", Resource: "clusters"} + +func (c *FakeClusters) Create(cluster *federation.Cluster) (result *federation.Cluster, err error) { + obj, err := c.Fake. + Invokes(core.NewRootCreateAction(clustersResource, cluster), &federation.Cluster{}) + if obj == nil { + return nil, err + } + return obj.(*federation.Cluster), err +} + +func (c *FakeClusters) Update(cluster *federation.Cluster) (result *federation.Cluster, err error) { + obj, err := c.Fake. + Invokes(core.NewRootUpdateAction(clustersResource, cluster), &federation.Cluster{}) + if obj == nil { + return nil, err + } + return obj.(*federation.Cluster), err +} + +func (c *FakeClusters) UpdateStatus(cluster *federation.Cluster) (*federation.Cluster, error) { + obj, err := c.Fake. + Invokes(core.NewRootUpdateSubresourceAction(clustersResource, "status", cluster), &federation.Cluster{}) + if obj == nil { + return nil, err + } + return obj.(*federation.Cluster), err +} + +func (c *FakeClusters) Delete(name string, options *api.DeleteOptions) error { + _, err := c.Fake. + Invokes(core.NewRootDeleteAction(clustersResource, name), &federation.Cluster{}) + return err +} + +func (c *FakeClusters) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error { + action := core.NewRootDeleteCollectionAction(clustersResource, listOptions) + + _, err := c.Fake.Invokes(action, &federation.ClusterList{}) + return err +} + +func (c *FakeClusters) Get(name string) (result *federation.Cluster, err error) { + obj, err := c.Fake. + Invokes(core.NewRootGetAction(clustersResource, name), &federation.Cluster{}) + if obj == nil { + return nil, err + } + return obj.(*federation.Cluster), err +} + +func (c *FakeClusters) List(opts api.ListOptions) (result *federation.ClusterList, err error) { + obj, err := c.Fake. + Invokes(core.NewRootListAction(clustersResource, opts), &federation.ClusterList{}) + if obj == nil { + return nil, err + } + + label := opts.LabelSelector + if label == nil { + label = labels.Everything() + } + list := &federation.ClusterList{} + for _, item := range obj.(*federation.ClusterList).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 clusters. +func (c *FakeClusters) Watch(opts api.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(core.NewRootWatchAction(clustersResource, opts)) +} diff --git a/federation/client/clientset_generated/federation_internalclientset/typed/federation/unversioned/fake/fake_federation_client.go b/federation/client/clientset_generated/federation_internalclientset/typed/federation/unversioned/fake/fake_federation_client.go new file mode 100644 index 00000000000..9b3687b1224 --- /dev/null +++ b/federation/client/clientset_generated/federation_internalclientset/typed/federation/unversioned/fake/fake_federation_client.go @@ -0,0 +1,30 @@ +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +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. +*/ + +package fake + +import ( + unversioned "k8s.io/kubernetes/federation/client/clientset_generated/federation_internalclientset/typed/federation/unversioned" + core "k8s.io/kubernetes/pkg/client/testing/core" +) + +type FakeFederation struct { + *core.Fake +} + +func (c *FakeFederation) Clusters() unversioned.ClusterInterface { + return &FakeClusters{c} +} diff --git a/federation/client/clientset_generated/federation_internalclientset/typed/federation/unversioned/federation_client.go b/federation/client/clientset_generated/federation_internalclientset/typed/federation/unversioned/federation_client.go new file mode 100644 index 00000000000..b995f0c6e84 --- /dev/null +++ b/federation/client/clientset_generated/federation_internalclientset/typed/federation/unversioned/federation_client.go @@ -0,0 +1,90 @@ +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +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. +*/ + +package unversioned + +import ( + api "k8s.io/kubernetes/pkg/api" + registered "k8s.io/kubernetes/pkg/apimachinery/registered" + restclient "k8s.io/kubernetes/pkg/client/restclient" +) + +type FederationInterface interface { + ClustersGetter +} + +// FederationClient is used to interact with features provided by the Federation group. +type FederationClient struct { + *restclient.RESTClient +} + +func (c *FederationClient) Clusters() ClusterInterface { + return newClusters(c) +} + +// NewForConfig creates a new FederationClient for the given config. +func NewForConfig(c *restclient.Config) (*FederationClient, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := restclient.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &FederationClient{client}, nil +} + +// NewForConfigOrDie creates a new FederationClient for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *restclient.Config) *FederationClient { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new FederationClient for the given RESTClient. +func New(c *restclient.RESTClient) *FederationClient { + return &FederationClient{c} +} + +func setConfigDefaults(config *restclient.Config) error { + // if federation group is not registered, return an error + g, err := registered.Group("federation") + if err != nil { + return err + } + config.APIPath = "/apis" + if config.UserAgent == "" { + config.UserAgent = restclient.DefaultKubernetesUserAgent() + } + // TODO: Unconditionally set the config.Version, until we fix the config. + //if config.Version == "" { + copyGroupVersion := g.GroupVersion + config.GroupVersion = ©GroupVersion + //} + + config.Codec = api.Codecs.LegacyCodec(*config.GroupVersion) + if config.QPS == 0 { + config.QPS = 5 + } + if config.Burst == 0 { + config.Burst = 10 + } + return nil +} diff --git a/federation/client/clientset_generated/federation_internalclientset/typed/federation/unversioned/generated_expansion.go b/federation/client/clientset_generated/federation_internalclientset/typed/federation/unversioned/generated_expansion.go new file mode 100644 index 00000000000..8888bf9bd49 --- /dev/null +++ b/federation/client/clientset_generated/federation_internalclientset/typed/federation/unversioned/generated_expansion.go @@ -0,0 +1,19 @@ +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +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. +*/ + +package unversioned + +type ClusterExpansion interface{} diff --git a/federation/client/clientset_generated/federation_release_1_3/clientset.go b/federation/client/clientset_generated/federation_release_1_3/clientset.go new file mode 100644 index 00000000000..ffb7a96cf96 --- /dev/null +++ b/federation/client/clientset_generated/federation_release_1_3/clientset.go @@ -0,0 +1,86 @@ +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +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. +*/ + +package federation_release_1_3 + +import ( + "github.com/golang/glog" + v1alpha1federation "k8s.io/kubernetes/federation/client/clientset_generated/federation_release_1_3/typed/federation/v1alpha1" + restclient "k8s.io/kubernetes/pkg/client/restclient" + discovery "k8s.io/kubernetes/pkg/client/typed/discovery" + "k8s.io/kubernetes/pkg/util/flowcontrol" +) + +type Interface interface { + Discovery() discovery.DiscoveryInterface + Federation() v1alpha1federation.FederationInterface +} + +// Clientset contains the clients for groups. Each group has exactly one +// version included in a Clientset. +type Clientset struct { + *discovery.DiscoveryClient + *v1alpha1federation.FederationClient +} + +// Federation retrieves the FederationClient +func (c *Clientset) Federation() v1alpha1federation.FederationInterface { + return c.FederationClient +} + +// Discovery retrieves the DiscoveryClient +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + return c.DiscoveryClient +} + +// NewForConfig creates a new Clientset for the given config. +func NewForConfig(c *restclient.Config) (*Clientset, error) { + configShallowCopy := *c + if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { + configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) + } + var clientset Clientset + var err error + clientset.FederationClient, err = v1alpha1federation.NewForConfig(&configShallowCopy) + if err != nil { + return &clientset, err + } + + clientset.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) + if err != nil { + glog.Errorf("failed to create the DiscoveryClient: %v", err) + } + return &clientset, err +} + +// NewForConfigOrDie creates a new Clientset for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *restclient.Config) *Clientset { + var clientset Clientset + clientset.FederationClient = v1alpha1federation.NewForConfigOrDie(c) + + clientset.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) + return &clientset +} + +// New creates a new Clientset for the given RESTClient. +func New(c *restclient.RESTClient) *Clientset { + var clientset Clientset + clientset.FederationClient = v1alpha1federation.New(c) + + clientset.DiscoveryClient = discovery.NewDiscoveryClient(c) + return &clientset +} diff --git a/federation/client/clientset_generated/federation_release_1_3/doc.go b/federation/client/clientset_generated/federation_release_1_3/doc.go new file mode 100644 index 00000000000..1d9f2783070 --- /dev/null +++ b/federation/client/clientset_generated/federation_release_1_3/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +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. +*/ + +// This package is generated by client-gen with arguments: --clientset-name=federation_release_1_3 --clientset-path=k8s.io/kubernetes/federation/client/clientset_generated --input=[federation/v1alpha1] --input-base=k8s.io/kubernetes/federation/apis + +// This package has the automatically generated clientset. +package federation_release_1_3 diff --git a/federation/client/clientset_generated/federation_release_1_3/fake/clientset_generated.go b/federation/client/clientset_generated/federation_release_1_3/fake/clientset_generated.go new file mode 100644 index 00000000000..69439e6b0b1 --- /dev/null +++ b/federation/client/clientset_generated/federation_release_1_3/fake/clientset_generated.go @@ -0,0 +1,65 @@ +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +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. +*/ + +package fake + +import ( + clientset "k8s.io/kubernetes/federation/client/clientset_generated/federation_release_1_3" + v1alpha1federation "k8s.io/kubernetes/federation/client/clientset_generated/federation_release_1_3/typed/federation/v1alpha1" + fakev1alpha1federation "k8s.io/kubernetes/federation/client/clientset_generated/federation_release_1_3/typed/federation/v1alpha1/fake" + "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/apimachinery/registered" + "k8s.io/kubernetes/pkg/client/testing/core" + "k8s.io/kubernetes/pkg/client/typed/discovery" + fakediscovery "k8s.io/kubernetes/pkg/client/typed/discovery/fake" + "k8s.io/kubernetes/pkg/runtime" + "k8s.io/kubernetes/pkg/watch" +) + +// Clientset returns a clientset that will respond with the provided objects +func NewSimpleClientset(objects ...runtime.Object) *Clientset { + o := core.NewObjects(api.Scheme, api.Codecs.UniversalDecoder()) + for _, obj := range objects { + if err := o.Add(obj); err != nil { + panic(err) + } + } + + fakePtr := core.Fake{} + fakePtr.AddReactor("*", "*", core.ObjectReaction(o, registered.RESTMapper())) + + fakePtr.AddWatchReactor("*", core.DefaultWatchReactor(watch.NewFake(), nil)) + + return &Clientset{fakePtr} +} + +// 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 { + core.Fake +} + +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + return &fakediscovery.FakeDiscovery{Fake: &c.Fake} +} + +var _ clientset.Interface = &Clientset{} + +// Federation retrieves the FederationClient +func (c *Clientset) Federation() v1alpha1federation.FederationInterface { + return &fakev1alpha1federation.FakeFederation{Fake: &c.Fake} +} diff --git a/federation/client/clientset_generated/federation_release_1_3/fake/doc.go b/federation/client/clientset_generated/federation_release_1_3/fake/doc.go new file mode 100644 index 00000000000..30f5b44cd12 --- /dev/null +++ b/federation/client/clientset_generated/federation_release_1_3/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +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. +*/ + +// This package is generated by client-gen with arguments: --clientset-name=federation_release_1_3 --clientset-path=k8s.io/kubernetes/federation/client/clientset_generated --input=[federation/v1alpha1] --input-base=k8s.io/kubernetes/federation/apis + +// This package has the automatically generated fake clientset. +package fake diff --git a/federation/client/clientset_generated/federation_release_1_3/typed/federation/v1alpha1/cluster.go b/federation/client/clientset_generated/federation_release_1_3/typed/federation/v1alpha1/cluster.go new file mode 100644 index 00000000000..1a94323e010 --- /dev/null +++ b/federation/client/clientset_generated/federation_release_1_3/typed/federation/v1alpha1/cluster.go @@ -0,0 +1,140 @@ +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +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. +*/ + +package v1alpha1 + +import ( + v1alpha1 "k8s.io/kubernetes/federation/apis/federation/v1alpha1" + api "k8s.io/kubernetes/pkg/api" + watch "k8s.io/kubernetes/pkg/watch" +) + +// ClustersGetter has a method to return a ClusterInterface. +// A group's client should implement this interface. +type ClustersGetter interface { + Clusters() ClusterInterface +} + +// ClusterInterface has methods to work with Cluster resources. +type ClusterInterface interface { + Create(*v1alpha1.Cluster) (*v1alpha1.Cluster, error) + Update(*v1alpha1.Cluster) (*v1alpha1.Cluster, error) + UpdateStatus(*v1alpha1.Cluster) (*v1alpha1.Cluster, error) + Delete(name string, options *api.DeleteOptions) error + DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error + Get(name string) (*v1alpha1.Cluster, error) + List(opts api.ListOptions) (*v1alpha1.ClusterList, error) + Watch(opts api.ListOptions) (watch.Interface, error) + ClusterExpansion +} + +// clusters implements ClusterInterface +type clusters struct { + client *FederationClient +} + +// newClusters returns a Clusters +func newClusters(c *FederationClient) *clusters { + return &clusters{ + client: c, + } +} + +// Create takes the representation of a cluster and creates it. Returns the server's representation of the cluster, and an error, if there is any. +func (c *clusters) Create(cluster *v1alpha1.Cluster) (result *v1alpha1.Cluster, err error) { + result = &v1alpha1.Cluster{} + err = c.client.Post(). + Resource("clusters"). + Body(cluster). + Do(). + Into(result) + return +} + +// Update takes the representation of a cluster and updates it. Returns the server's representation of the cluster, and an error, if there is any. +func (c *clusters) Update(cluster *v1alpha1.Cluster) (result *v1alpha1.Cluster, err error) { + result = &v1alpha1.Cluster{} + err = c.client.Put(). + Resource("clusters"). + Name(cluster.Name). + Body(cluster). + Do(). + Into(result) + return +} + +func (c *clusters) UpdateStatus(cluster *v1alpha1.Cluster) (result *v1alpha1.Cluster, err error) { + result = &v1alpha1.Cluster{} + err = c.client.Put(). + Resource("clusters"). + Name(cluster.Name). + SubResource("status"). + Body(cluster). + Do(). + Into(result) + return +} + +// Delete takes name of the cluster and deletes it. Returns an error if one occurs. +func (c *clusters) Delete(name string, options *api.DeleteOptions) error { + return c.client.Delete(). + Resource("clusters"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *clusters) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error { + return c.client.Delete(). + Resource("clusters"). + VersionedParams(&listOptions, api.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Get takes name of the cluster, and returns the corresponding cluster object, and an error if there is any. +func (c *clusters) Get(name string) (result *v1alpha1.Cluster, err error) { + result = &v1alpha1.Cluster{} + err = c.client.Get(). + Resource("clusters"). + Name(name). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Clusters that match those selectors. +func (c *clusters) List(opts api.ListOptions) (result *v1alpha1.ClusterList, err error) { + result = &v1alpha1.ClusterList{} + err = c.client.Get(). + Resource("clusters"). + VersionedParams(&opts, api.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested clusters. +func (c *clusters) Watch(opts api.ListOptions) (watch.Interface, error) { + return c.client.Get(). + Prefix("watch"). + Resource("clusters"). + VersionedParams(&opts, api.ParameterCodec). + Watch() +} diff --git a/federation/client/clientset_generated/federation_release_1_3/typed/federation/v1alpha1/doc.go b/federation/client/clientset_generated/federation_release_1_3/typed/federation/v1alpha1/doc.go new file mode 100644 index 00000000000..d940668ee68 --- /dev/null +++ b/federation/client/clientset_generated/federation_release_1_3/typed/federation/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +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. +*/ + +// This package is generated by client-gen with arguments: --clientset-name=federation_release_1_3 --clientset-path=k8s.io/kubernetes/federation/client/clientset_generated --input=[federation/v1alpha1] --input-base=k8s.io/kubernetes/federation/apis + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/federation/client/clientset_generated/federation_release_1_3/typed/federation/v1alpha1/fake/doc.go b/federation/client/clientset_generated/federation_release_1_3/typed/federation/v1alpha1/fake/doc.go new file mode 100644 index 00000000000..487a9eafad5 --- /dev/null +++ b/federation/client/clientset_generated/federation_release_1_3/typed/federation/v1alpha1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +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. +*/ + +// This package is generated by client-gen with arguments: --clientset-name=federation_release_1_3 --clientset-path=k8s.io/kubernetes/federation/client/clientset_generated --input=[federation/v1alpha1] --input-base=k8s.io/kubernetes/federation/apis + +// Package fake has the automatically generated clients. +package fake diff --git a/federation/client/clientset_generated/federation_release_1_3/typed/federation/v1alpha1/fake/fake_cluster.go b/federation/client/clientset_generated/federation_release_1_3/typed/federation/v1alpha1/fake/fake_cluster.go new file mode 100644 index 00000000000..a524e9c8e60 --- /dev/null +++ b/federation/client/clientset_generated/federation_release_1_3/typed/federation/v1alpha1/fake/fake_cluster.go @@ -0,0 +1,108 @@ +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +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. +*/ + +package fake + +import ( + v1alpha1 "k8s.io/kubernetes/federation/apis/federation/v1alpha1" + api "k8s.io/kubernetes/pkg/api" + unversioned "k8s.io/kubernetes/pkg/api/unversioned" + core "k8s.io/kubernetes/pkg/client/testing/core" + labels "k8s.io/kubernetes/pkg/labels" + watch "k8s.io/kubernetes/pkg/watch" +) + +// FakeClusters implements ClusterInterface +type FakeClusters struct { + Fake *FakeFederation +} + +var clustersResource = unversioned.GroupVersionResource{Group: "federation", Version: "v1alpha1", Resource: "clusters"} + +func (c *FakeClusters) Create(cluster *v1alpha1.Cluster) (result *v1alpha1.Cluster, err error) { + obj, err := c.Fake. + Invokes(core.NewRootCreateAction(clustersResource, cluster), &v1alpha1.Cluster{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Cluster), err +} + +func (c *FakeClusters) Update(cluster *v1alpha1.Cluster) (result *v1alpha1.Cluster, err error) { + obj, err := c.Fake. + Invokes(core.NewRootUpdateAction(clustersResource, cluster), &v1alpha1.Cluster{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Cluster), err +} + +func (c *FakeClusters) UpdateStatus(cluster *v1alpha1.Cluster) (*v1alpha1.Cluster, error) { + obj, err := c.Fake. + Invokes(core.NewRootUpdateSubresourceAction(clustersResource, "status", cluster), &v1alpha1.Cluster{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Cluster), err +} + +func (c *FakeClusters) Delete(name string, options *api.DeleteOptions) error { + _, err := c.Fake. + Invokes(core.NewRootDeleteAction(clustersResource, name), &v1alpha1.Cluster{}) + return err +} + +func (c *FakeClusters) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error { + action := core.NewRootDeleteCollectionAction(clustersResource, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.ClusterList{}) + return err +} + +func (c *FakeClusters) Get(name string) (result *v1alpha1.Cluster, err error) { + obj, err := c.Fake. + Invokes(core.NewRootGetAction(clustersResource, name), &v1alpha1.Cluster{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Cluster), err +} + +func (c *FakeClusters) List(opts api.ListOptions) (result *v1alpha1.ClusterList, err error) { + obj, err := c.Fake. + Invokes(core.NewRootListAction(clustersResource, opts), &v1alpha1.ClusterList{}) + if obj == nil { + return nil, err + } + + label := opts.LabelSelector + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.ClusterList{} + for _, item := range obj.(*v1alpha1.ClusterList).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 clusters. +func (c *FakeClusters) Watch(opts api.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(core.NewRootWatchAction(clustersResource, opts)) +} diff --git a/federation/client/clientset_generated/federation_release_1_3/typed/federation/v1alpha1/fake/fake_federation_client.go b/federation/client/clientset_generated/federation_release_1_3/typed/federation/v1alpha1/fake/fake_federation_client.go new file mode 100644 index 00000000000..73e72601ab4 --- /dev/null +++ b/federation/client/clientset_generated/federation_release_1_3/typed/federation/v1alpha1/fake/fake_federation_client.go @@ -0,0 +1,30 @@ +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +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. +*/ + +package fake + +import ( + v1alpha1 "k8s.io/kubernetes/federation/client/clientset_generated/federation_release_1_3/typed/federation/v1alpha1" + core "k8s.io/kubernetes/pkg/client/testing/core" +) + +type FakeFederation struct { + *core.Fake +} + +func (c *FakeFederation) Clusters() v1alpha1.ClusterInterface { + return &FakeClusters{c} +} diff --git a/federation/client/clientset_generated/federation_release_1_3/typed/federation/v1alpha1/federation_client.go b/federation/client/clientset_generated/federation_release_1_3/typed/federation/v1alpha1/federation_client.go new file mode 100644 index 00000000000..64689aaad84 --- /dev/null +++ b/federation/client/clientset_generated/federation_release_1_3/typed/federation/v1alpha1/federation_client.go @@ -0,0 +1,96 @@ +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +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. +*/ + +package v1alpha1 + +import ( + fmt "fmt" + api "k8s.io/kubernetes/pkg/api" + registered "k8s.io/kubernetes/pkg/apimachinery/registered" + restclient "k8s.io/kubernetes/pkg/client/restclient" +) + +type FederationInterface interface { + ClustersGetter +} + +// FederationClient is used to interact with features provided by the Federation group. +type FederationClient struct { + *restclient.RESTClient +} + +func (c *FederationClient) Clusters() ClusterInterface { + return newClusters(c) +} + +// NewForConfig creates a new FederationClient for the given config. +func NewForConfig(c *restclient.Config) (*FederationClient, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := restclient.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &FederationClient{client}, nil +} + +// NewForConfigOrDie creates a new FederationClient for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *restclient.Config) *FederationClient { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new FederationClient for the given RESTClient. +func New(c *restclient.RESTClient) *FederationClient { + return &FederationClient{c} +} + +func setConfigDefaults(config *restclient.Config) error { + // if federation group is not registered, return an error + g, err := registered.Group("federation") + if err != nil { + return err + } + config.APIPath = "/apis" + if config.UserAgent == "" { + config.UserAgent = restclient.DefaultKubernetesUserAgent() + } + // TODO: Unconditionally set the config.Version, until we fix the config. + //if config.Version == "" { + copyGroupVersion := g.GroupVersion + config.GroupVersion = ©GroupVersion + //} + + codec, ok := api.Codecs.SerializerForFileExtension("json") + if !ok { + return fmt.Errorf("unable to find serializer for JSON") + } + config.Codec = codec + + if config.QPS == 0 { + config.QPS = 5 + } + if config.Burst == 0 { + config.Burst = 10 + } + return nil +} diff --git a/federation/client/clientset_generated/federation_release_1_3/typed/federation/v1alpha1/generated_expansion.go b/federation/client/clientset_generated/federation_release_1_3/typed/federation/v1alpha1/generated_expansion.go new file mode 100644 index 00000000000..5a05fca2c2e --- /dev/null +++ b/federation/client/clientset_generated/federation_release_1_3/typed/federation/v1alpha1/generated_expansion.go @@ -0,0 +1,19 @@ +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +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. +*/ + +package v1alpha1 + +type ClusterExpansion interface{} diff --git a/hack/verify-flags/known-flags.txt b/hack/verify-flags/known-flags.txt index 4bc5d56cf6d..2893338b630 100644 --- a/hack/verify-flags/known-flags.txt +++ b/hack/verify-flags/known-flags.txt @@ -168,6 +168,7 @@ ignore-not-found image-gc-high-threshold image-gc-low-threshold include-extended-apis +input-base input-dirs insecure-bind-address insecure-port From 09fcfed10a0a22a4c36a94a384cd9a7ee5093b7e Mon Sep 17 00:00:00 2001 From: jianhuiz Date: Thu, 28 Apr 2016 16:29:04 -0700 Subject: [PATCH 2/2] add import_known_version.go for federation clientset --- .../import_known_versions.go | 25 +++++++++++++++++++ .../import_known_versions.go | 25 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 federation/client/clientset_generated/federation_internalclientset/import_known_versions.go create mode 100644 federation/client/clientset_generated/federation_release_1_3/import_known_versions.go diff --git a/federation/client/clientset_generated/federation_internalclientset/import_known_versions.go b/federation/client/clientset_generated/federation_internalclientset/import_known_versions.go new file mode 100644 index 00000000000..af8c2e7436f --- /dev/null +++ b/federation/client/clientset_generated/federation_internalclientset/import_known_versions.go @@ -0,0 +1,25 @@ +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +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. +*/ + +package federation_internalclientset + +// These imports are the API groups the client will support. +import ( + _ "k8s.io/kubernetes/federation/apis/federation/install" +) + +func init() { +} diff --git a/federation/client/clientset_generated/federation_release_1_3/import_known_versions.go b/federation/client/clientset_generated/federation_release_1_3/import_known_versions.go new file mode 100644 index 00000000000..a977647aa0d --- /dev/null +++ b/federation/client/clientset_generated/federation_release_1_3/import_known_versions.go @@ -0,0 +1,25 @@ +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +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. +*/ + +package federation_release_1_3 + +// These imports are the API groups the client will support. +import ( + _ "k8s.io/kubernetes/federation/apis/federation/install" +) + +func init() { +}