Skip to content

Commit b81a8de

Browse files
smarterclaytonironcladlou
authored andcommitted
No PetSet client in client/unversioned
Also add fakes
1 parent bbdbfc8 commit b81a8de

File tree

3 files changed

+101
-0
lines changed

3 files changed

+101
-0
lines changed

pkg/client/unversioned/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ type Interface interface {
4444
PersistentVolumeClaimsNamespacer
4545
ComponentStatusesInterface
4646
ConfigMapsNamespacer
47+
Apps() AppsInterface
4748
Autoscaling() AutoscalingInterface
4849
Batch() BatchInterface
4950
Extensions() ExtensionsInterface
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
Copyright 2016 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package testclient
18+
19+
import (
20+
"k8s.io/kubernetes/pkg/api"
21+
"k8s.io/kubernetes/pkg/apis/apps"
22+
"k8s.io/kubernetes/pkg/watch"
23+
)
24+
25+
// FakePetSets implements PetSetsInterface. Meant to be embedded into a struct to get a default
26+
// implementation. This makes faking out just the method you want to test easier.
27+
type FakePetSets struct {
28+
Fake *FakeApps
29+
Namespace string
30+
}
31+
32+
func (c *FakePetSets) Get(name string) (*apps.PetSet, error) {
33+
obj, err := c.Fake.Invokes(NewGetAction("petsets", c.Namespace, name), &apps.PetSet{})
34+
if obj == nil {
35+
return nil, err
36+
}
37+
38+
return obj.(*apps.PetSet), err
39+
}
40+
41+
func (c *FakePetSets) List(opts api.ListOptions) (*apps.PetSetList, error) {
42+
obj, err := c.Fake.Invokes(NewListAction("petsets", c.Namespace, opts), &apps.PetSetList{})
43+
if obj == nil {
44+
return nil, err
45+
}
46+
return obj.(*apps.PetSetList), err
47+
}
48+
49+
func (c *FakePetSets) Create(rs *apps.PetSet) (*apps.PetSet, error) {
50+
obj, err := c.Fake.Invokes(NewCreateAction("petsets", c.Namespace, rs), rs)
51+
if obj == nil {
52+
return nil, err
53+
}
54+
55+
return obj.(*apps.PetSet), err
56+
}
57+
58+
func (c *FakePetSets) Update(rs *apps.PetSet) (*apps.PetSet, error) {
59+
obj, err := c.Fake.Invokes(NewUpdateAction("petsets", c.Namespace, rs), rs)
60+
if obj == nil {
61+
return nil, err
62+
}
63+
64+
return obj.(*apps.PetSet), err
65+
}
66+
67+
func (c *FakePetSets) Delete(name string, options *api.DeleteOptions) error {
68+
_, err := c.Fake.Invokes(NewDeleteAction("petsets", c.Namespace, name), &apps.PetSet{})
69+
return err
70+
}
71+
72+
func (c *FakePetSets) Watch(opts api.ListOptions) (watch.Interface, error) {
73+
return c.Fake.InvokesWatch(NewWatchAction("petsets", c.Namespace, opts))
74+
}
75+
76+
func (c *FakePetSets) UpdateStatus(rs *apps.PetSet) (result *apps.PetSet, err error) {
77+
obj, err := c.Fake.Invokes(NewUpdateSubresourceAction("petsets", "status", c.Namespace, rs), rs)
78+
if obj == nil {
79+
return nil, err
80+
}
81+
82+
return obj.(*apps.PetSet), err
83+
}

pkg/client/unversioned/testclient/testclient.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,10 @@ func (c *Fake) Namespaces() client.NamespaceInterface {
277277
return &FakeNamespaces{Fake: c}
278278
}
279279

280+
func (c *Fake) Apps() client.AppsInterface {
281+
return &FakeApps{c}
282+
}
283+
280284
func (c *Fake) Autoscaling() client.AutoscalingInterface {
281285
return &FakeAutoscaling{c}
282286
}
@@ -315,6 +319,19 @@ func (c *Fake) SwaggerSchema(version unversioned.GroupVersion) (*swagger.ApiDecl
315319
return &swagger.ApiDeclaration{}, nil
316320
}
317321

322+
// NewSimpleFakeApps returns a client that will respond with the provided objects
323+
func NewSimpleFakeApps(objects ...runtime.Object) *FakeApps {
324+
return &FakeApps{Fake: NewSimpleFake(objects...)}
325+
}
326+
327+
type FakeApps struct {
328+
*Fake
329+
}
330+
331+
func (c *FakeApps) PetSets(namespace string) client.PetSetInterface {
332+
return &FakePetSets{Fake: c, Namespace: namespace}
333+
}
334+
318335
// NewSimpleFakeAutoscaling returns a client that will respond with the provided objects
319336
func NewSimpleFakeAutoscaling(objects ...runtime.Object) *FakeAutoscaling {
320337
return &FakeAutoscaling{Fake: NewSimpleFake(objects...)}

0 commit comments

Comments
 (0)