forked from kubernetes/kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
generate fake client for release_1_2
- Loading branch information
Chao Xu
committed
Feb 18, 2016
1 parent
9e9574c
commit ad46715
Showing
84 changed files
with
3,159 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
Copyright 2015 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 args | ||
|
||
import "k8s.io/kubernetes/pkg/api/unversioned" | ||
|
||
// ClientGenArgs is a wrapper for arguments to client-gen. | ||
type Args struct { | ||
// TODO: we should make another type declaration of GroupVersion out of the | ||
// unversioned package, which is part of our API. Tools like client-gen | ||
// shouldn't depend on an API. | ||
GroupVersions []unversioned.GroupVersion | ||
|
||
// GroupVersionToInputPath is a map between GroupVersion and the path to | ||
// the respective types.go. We still need GroupVersions in the struct because | ||
// we need an order. | ||
GroupVersionToInputPath map[unversioned.GroupVersion]string | ||
// ClientsetName is the name of the clientset to be generated. It's | ||
// populated from command-line arguments. | ||
ClientsetName string | ||
// ClientsetOutputPath is the path the clientset will be generated at. It's | ||
// populated from command-line arguments. | ||
ClientsetOutputPath string | ||
// ClientsetOnly determines if we should generate the clients for groups and | ||
// types along with the clientset. It's populated from command-line | ||
// arguments. | ||
ClientsetOnly bool | ||
// FakeClient determines if client-gen generates the fake clients. | ||
FakeClient bool | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
pkg/client/clientset_generated/release_1_2/fake/clientset_generated.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
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 ( | ||
"k8s.io/kubernetes/pkg/api" | ||
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_2" | ||
"k8s.io/kubernetes/pkg/client/testing/core" | ||
v1core "k8s.io/kubernetes/pkg/client/typed/generated/core/v1" | ||
fakev1core "k8s.io/kubernetes/pkg/client/typed/generated/core/v1/fake" | ||
v1beta1extensions "k8s.io/kubernetes/pkg/client/typed/generated/extensions/v1beta1" | ||
fakev1beta1extensions "k8s.io/kubernetes/pkg/client/typed/generated/extensions/v1beta1/fake" | ||
"k8s.io/kubernetes/pkg/client/unversioned" | ||
"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, api.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() unversioned.DiscoveryInterface { | ||
return &FakeDiscovery{&c.Fake} | ||
} | ||
|
||
var _ clientset.Interface = &Clientset{} | ||
|
||
// Core retrieves the CoreClient | ||
func (c *Clientset) Core() v1core.CoreInterface { | ||
return &fakev1core.FakeCore{&c.Fake} | ||
} | ||
|
||
// Extensions retrieves the ExtensionsClient | ||
func (c *Clientset) Extensions() v1beta1extensions.ExtensionsInterface { | ||
return &fakev1beta1extensions.FakeExtensions{&c.Fake} | ||
} |
Oops, something went wrong.