... | ... |
@@ -96,9 +96,9 @@ func fakeUser() user.Info { |
96 | 96 |
func fakeClient(expectedResource string, reviewResponse *authorizationapi.SubjectAccessReviewResponse) client.Interface { |
97 | 97 |
emptyResponse := &authorizationapi.SubjectAccessReviewResponse{} |
98 | 98 |
return &testclient.Fake{ |
99 |
- ReactFn: func(action ktestclient.FakeAction) (runtime.Object, error) { |
|
100 |
- if action.Action == "create-subjectAccessReview" { |
|
101 |
- review, ok := action.Value.(*authorizationapi.SubjectAccessReview) |
|
99 |
+ ReactFn: func(action ktestclient.Action) (runtime.Object, error) { |
|
100 |
+ if action.Matches("create", "subjectaccessreviews") { |
|
101 |
+ review, ok := action.(ktestclient.CreateAction).GetObject().(*authorizationapi.SubjectAccessReview) |
|
102 | 102 |
if !ok { |
103 | 103 |
return emptyResponse, fmt.Errorf("unexpected object received: %#v", review) |
104 | 104 |
} |
... | ... |
@@ -6,26 +6,24 @@ import ( |
6 | 6 |
kapi "k8s.io/kubernetes/pkg/api" |
7 | 7 |
ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
8 | 8 |
"k8s.io/kubernetes/pkg/runtime" |
9 |
+ "k8s.io/kubernetes/pkg/watch" |
|
9 | 10 |
|
10 | 11 |
"github.com/openshift/origin/pkg/api/latest" |
11 | 12 |
"github.com/openshift/origin/pkg/client" |
12 | 13 |
) |
13 | 14 |
|
14 |
-// FakeAction is a wrapper around the Kubernetes FakeAction. |
|
15 |
-// Used for faking various actions on resources. |
|
16 |
-type FakeAction ktestclient.FakeAction |
|
17 |
- |
|
18 | 15 |
// Fake implements Interface. Meant to be embedded into a struct to get a default |
19 | 16 |
// implementation. This makes faking out just the method you want to test easier. |
20 | 17 |
type Fake struct { |
21 |
- // Fake by default keeps a simple list of the methods that have been called. |
|
22 |
- Actions []FakeAction |
|
23 |
- Err error |
|
18 |
+ actions []ktestclient.Action // these may be castable to other types, but "Action" is the minimum |
|
19 |
+ err error |
|
20 |
+ |
|
21 |
+ Watch watch.Interface |
|
24 | 22 |
// ReactFn is an optional function that will be invoked with the provided action |
25 | 23 |
// and return a response. |
26 | 24 |
ReactFn ktestclient.ReactionFunc |
27 | 25 |
|
28 |
- Lock sync.Mutex |
|
26 |
+ Lock sync.RWMutex |
|
29 | 27 |
} |
30 | 28 |
|
31 | 29 |
// NewSimpleFake returns a client that will respond with the provided objects |
... | ... |
@@ -41,15 +39,49 @@ func NewSimpleFake(objects ...runtime.Object) *Fake { |
41 | 41 |
|
42 | 42 |
// Invokes registers the passed fake action and reacts on it if a ReactFn |
43 | 43 |
// has been defined |
44 |
-func (c *Fake) Invokes(action FakeAction, obj runtime.Object) (runtime.Object, error) { |
|
44 |
+func (c *Fake) Invokes(action ktestclient.Action, defaultReturnObj runtime.Object) (runtime.Object, error) { |
|
45 | 45 |
c.Lock.Lock() |
46 | 46 |
defer c.Lock.Unlock() |
47 | 47 |
|
48 |
- c.Actions = append(c.Actions, action) |
|
48 |
+ c.actions = append(c.actions, action) |
|
49 | 49 |
if c.ReactFn != nil { |
50 |
- return c.ReactFn(ktestclient.FakeAction(action)) |
|
50 |
+ return c.ReactFn(action) |
|
51 | 51 |
} |
52 |
- return obj, c.Err |
|
52 |
+ return defaultReturnObj, c.err |
|
53 |
+} |
|
54 |
+ |
|
55 |
+// ClearActions clears the history of actions called on the fake client |
|
56 |
+func (c *Fake) ClearActions() { |
|
57 |
+ c.Lock.Lock() |
|
58 |
+ c.Lock.Unlock() |
|
59 |
+ |
|
60 |
+ c.actions = make([]ktestclient.Action, 0) |
|
61 |
+} |
|
62 |
+ |
|
63 |
+// Actions returns a chronologically ordered slice fake actions called on the fake client |
|
64 |
+func (c *Fake) Actions() []ktestclient.Action { |
|
65 |
+ c.Lock.RLock() |
|
66 |
+ defer c.Lock.RUnlock() |
|
67 |
+ |
|
68 |
+ fa := make([]ktestclient.Action, len(c.actions)) |
|
69 |
+ copy(fa, c.actions) |
|
70 |
+ return fa |
|
71 |
+} |
|
72 |
+ |
|
73 |
+// SetErr sets the error to return for client calls |
|
74 |
+func (c *Fake) SetErr(err error) { |
|
75 |
+ c.Lock.Lock() |
|
76 |
+ defer c.Lock.Unlock() |
|
77 |
+ |
|
78 |
+ c.err = err |
|
79 |
+} |
|
80 |
+ |
|
81 |
+// Err returns any a client error or nil |
|
82 |
+func (c *Fake) Err() error { |
|
83 |
+ c.Lock.RLock() |
|
84 |
+ c.Lock.RUnlock() |
|
85 |
+ |
|
86 |
+ return c.err |
|
53 | 87 |
} |
54 | 88 |
|
55 | 89 |
var _ client.Interface = &Fake{} |
... | ... |
@@ -121,12 +153,12 @@ func (c *Fake) ClusterNetwork() client.ClusterNetworkInterface { |
121 | 121 |
|
122 | 122 |
// Templates provides a fake REST client for Templates |
123 | 123 |
func (c *Fake) Templates(namespace string) client.TemplateInterface { |
124 |
- return &FakeTemplates{Fake: c} |
|
124 |
+ return &FakeTemplates{Fake: c, Namespace: namespace} |
|
125 | 125 |
} |
126 | 126 |
|
127 | 127 |
// TemplateConfigs provides a fake REST client for TemplateConfigs |
128 | 128 |
func (c *Fake) TemplateConfigs(namespace string) client.TemplateConfigInterface { |
129 |
- return &FakeTemplateConfigs{Fake: c} |
|
129 |
+ return &FakeTemplateConfigs{Fake: c, Namespace: namespace} |
|
130 | 130 |
} |
131 | 131 |
|
132 | 132 |
// Identities provides a fake REST client for Identities |
... | ... |
@@ -161,27 +193,27 @@ func (c *Fake) ProjectRequests() client.ProjectRequestInterface { |
161 | 161 |
|
162 | 162 |
// Policies provides a fake REST client for Policies |
163 | 163 |
func (c *Fake) Policies(namespace string) client.PolicyInterface { |
164 |
- return &FakePolicies{Fake: c} |
|
164 |
+ return &FakePolicies{Fake: c, Namespace: namespace} |
|
165 | 165 |
} |
166 | 166 |
|
167 | 167 |
// Roles provides a fake REST client for Roles |
168 | 168 |
func (c *Fake) Roles(namespace string) client.RoleInterface { |
169 |
- return &FakeRoles{Fake: c} |
|
169 |
+ return &FakeRoles{Fake: c, Namespace: namespace} |
|
170 | 170 |
} |
171 | 171 |
|
172 | 172 |
// RoleBindings provides a fake REST client for RoleBindings |
173 | 173 |
func (c *Fake) RoleBindings(namespace string) client.RoleBindingInterface { |
174 |
- return &FakeRoleBindings{Fake: c} |
|
174 |
+ return &FakeRoleBindings{Fake: c, Namespace: namespace} |
|
175 | 175 |
} |
176 | 176 |
|
177 | 177 |
// PolicyBindings provides a fake REST client for PolicyBindings |
178 | 178 |
func (c *Fake) PolicyBindings(namespace string) client.PolicyBindingInterface { |
179 |
- return &FakePolicyBindings{Fake: c} |
|
179 |
+ return &FakePolicyBindings{Fake: c, Namespace: namespace} |
|
180 | 180 |
} |
181 | 181 |
|
182 | 182 |
// ResourceAccessReviews provides a fake REST client for ResourceAccessReviews |
183 | 183 |
func (c *Fake) ResourceAccessReviews(namespace string) client.ResourceAccessReviewInterface { |
184 |
- return &FakeResourceAccessReviews{Fake: c} |
|
184 |
+ return &FakeResourceAccessReviews{Fake: c, Namespace: namespace} |
|
185 | 185 |
} |
186 | 186 |
|
187 | 187 |
// ClusterResourceAccessReviews provides a fake REST client for ClusterResourceAccessReviews |
... | ... |
@@ -191,12 +223,12 @@ func (c *Fake) ClusterResourceAccessReviews() client.ResourceAccessReviewInterfa |
191 | 191 |
|
192 | 192 |
// SubjectAccessReviews provides a fake REST client for SubjectAccessReviews |
193 | 193 |
func (c *Fake) SubjectAccessReviews(namespace string) client.SubjectAccessReviewInterface { |
194 |
- return &FakeSubjectAccessReviews{Fake: c} |
|
194 |
+ return &FakeSubjectAccessReviews{Fake: c, Namespace: namespace} |
|
195 | 195 |
} |
196 | 196 |
|
197 | 197 |
// ImpersonateSubjectAccessReviews provides a fake REST client for SubjectAccessReviews |
198 | 198 |
func (c *Fake) ImpersonateSubjectAccessReviews(token, namespace string) client.SubjectAccessReviewInterface { |
199 |
- return &FakeSubjectAccessReviews{Fake: c} |
|
199 |
+ return &FakeSubjectAccessReviews{Fake: c, Namespace: namespace} |
|
200 | 200 |
} |
201 | 201 |
|
202 | 202 |
// OAuthAccessTokens provides a fake REST client for OAuthAccessTokens |
... | ... |
@@ -4,6 +4,7 @@ import ( |
4 | 4 |
"fmt" |
5 | 5 |
"net/url" |
6 | 6 |
|
7 |
+ ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
|
7 | 8 |
"k8s.io/kubernetes/pkg/fields" |
8 | 9 |
"k8s.io/kubernetes/pkg/labels" |
9 | 10 |
"k8s.io/kubernetes/pkg/watch" |
... | ... |
@@ -19,51 +20,70 @@ type FakeBuildConfigs struct { |
19 | 19 |
Namespace string |
20 | 20 |
} |
21 | 21 |
|
22 |
-func (c *FakeBuildConfigs) List(label labels.Selector, field fields.Selector) (*buildapi.BuildConfigList, error) { |
|
23 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "list-buildconfig"}, &buildapi.BuildConfigList{}) |
|
24 |
- return obj.(*buildapi.BuildConfigList), err |
|
25 |
-} |
|
26 |
- |
|
27 | 22 |
func (c *FakeBuildConfigs) Get(name string) (*buildapi.BuildConfig, error) { |
28 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "get-buildconfig", Value: name}, &buildapi.BuildConfig{}) |
|
23 |
+ obj, err := c.Fake.Invokes(ktestclient.NewGetAction("buildconfigs", c.Namespace, name), &buildapi.BuildConfig{}) |
|
24 |
+ if obj == nil { |
|
25 |
+ return nil, err |
|
26 |
+ } |
|
27 |
+ |
|
29 | 28 |
return obj.(*buildapi.BuildConfig), err |
30 | 29 |
} |
31 | 30 |
|
32 |
-func (c *FakeBuildConfigs) WebHookURL(name string, trigger *buildapi.BuildTriggerPolicy) (*url.URL, error) { |
|
33 |
- switch { |
|
34 |
- case trigger.GenericWebHook != nil: |
|
35 |
- return url.Parse(fmt.Sprintf("http://localhost/buildConfigHooks/%s/%s/generic", name, trigger.GenericWebHook.Secret)) |
|
36 |
- case trigger.GitHubWebHook != nil: |
|
37 |
- return url.Parse(fmt.Sprintf("http://localhost/buildConfigHooks/%s/%s/github", name, trigger.GitHubWebHook.Secret)) |
|
38 |
- default: |
|
39 |
- return nil, client.ErrTriggerIsNotAWebHook |
|
31 |
+func (c *FakeBuildConfigs) List(label labels.Selector, field fields.Selector) (*buildapi.BuildConfigList, error) { |
|
32 |
+ obj, err := c.Fake.Invokes(ktestclient.NewListAction("buildconfigs", c.Namespace, label, field), &buildapi.BuildConfigList{}) |
|
33 |
+ if obj == nil { |
|
34 |
+ return nil, err |
|
40 | 35 |
} |
36 |
+ |
|
37 |
+ return obj.(*buildapi.BuildConfigList), err |
|
41 | 38 |
} |
42 | 39 |
|
43 |
-func (c *FakeBuildConfigs) Create(config *buildapi.BuildConfig) (*buildapi.BuildConfig, error) { |
|
44 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "create-buildconfig"}, &buildapi.BuildConfig{}) |
|
40 |
+func (c *FakeBuildConfigs) Create(inObj *buildapi.BuildConfig) (*buildapi.BuildConfig, error) { |
|
41 |
+ obj, err := c.Fake.Invokes(ktestclient.NewCreateAction("buildconfigs", c.Namespace, inObj), inObj) |
|
42 |
+ if obj == nil { |
|
43 |
+ return nil, err |
|
44 |
+ } |
|
45 |
+ |
|
45 | 46 |
return obj.(*buildapi.BuildConfig), err |
46 | 47 |
} |
47 | 48 |
|
48 |
-func (c *FakeBuildConfigs) Update(config *buildapi.BuildConfig) (*buildapi.BuildConfig, error) { |
|
49 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "update-buildconfig"}, &buildapi.BuildConfig{}) |
|
49 |
+func (c *FakeBuildConfigs) Update(inObj *buildapi.BuildConfig) (*buildapi.BuildConfig, error) { |
|
50 |
+ obj, err := c.Fake.Invokes(ktestclient.NewUpdateAction("buildconfigs", c.Namespace, inObj), inObj) |
|
51 |
+ if obj == nil { |
|
52 |
+ return nil, err |
|
53 |
+ } |
|
54 |
+ |
|
50 | 55 |
return obj.(*buildapi.BuildConfig), err |
51 | 56 |
} |
52 | 57 |
|
53 | 58 |
func (c *FakeBuildConfigs) Delete(name string) error { |
54 |
- _, err := c.Fake.Invokes(FakeAction{Action: "delete-buildconfig", Value: name}, &buildapi.BuildConfig{}) |
|
59 |
+ _, err := c.Fake.Invokes(ktestclient.NewDeleteAction("buildconfigs", c.Namespace, name), &buildapi.BuildConfig{}) |
|
55 | 60 |
return err |
56 | 61 |
} |
57 | 62 |
|
58 | 63 |
func (c *FakeBuildConfigs) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) { |
59 |
- c.Fake.Lock.Lock() |
|
60 |
- defer c.Fake.Lock.Unlock() |
|
64 |
+ c.Fake.Invokes(ktestclient.NewWatchAction("buildconfigs", c.Namespace, label, field, resourceVersion), nil) |
|
65 |
+ return c.Fake.Watch, nil |
|
66 |
+} |
|
61 | 67 |
|
62 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-buildconfigs"}) |
|
63 |
- return nil, nil |
|
68 |
+func (c *FakeBuildConfigs) WebHookURL(name string, trigger *buildapi.BuildTriggerPolicy) (*url.URL, error) { |
|
69 |
+ switch { |
|
70 |
+ case trigger.GenericWebHook != nil: |
|
71 |
+ return url.Parse(fmt.Sprintf("http://localhost/buildConfigHooks/%s/%s/generic", name, trigger.GenericWebHook.Secret)) |
|
72 |
+ case trigger.GitHubWebHook != nil: |
|
73 |
+ return url.Parse(fmt.Sprintf("http://localhost/buildConfigHooks/%s/%s/github", name, trigger.GitHubWebHook.Secret)) |
|
74 |
+ default: |
|
75 |
+ return nil, client.ErrTriggerIsNotAWebHook |
|
76 |
+ } |
|
64 | 77 |
} |
65 | 78 |
|
66 | 79 |
func (c *FakeBuildConfigs) Instantiate(request *buildapi.BuildRequest) (result *buildapi.Build, err error) { |
67 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "instantiate-buildconfig", Value: request}, &buildapi.Build{}) |
|
80 |
+ action := ktestclient.NewCreateAction("buildconfigs", c.Namespace, request) |
|
81 |
+ action.Subresource = "instantiate" |
|
82 |
+ obj, err := c.Fake.Invokes(action, &buildapi.Build{}) |
|
83 |
+ if obj == nil { |
|
84 |
+ return nil, err |
|
85 |
+ } |
|
86 |
+ |
|
68 | 87 |
return obj.(*buildapi.Build), err |
69 | 88 |
} |
... | ... |
@@ -3,7 +3,9 @@ package testclient |
3 | 3 |
import ( |
4 | 4 |
kclient "k8s.io/kubernetes/pkg/client" |
5 | 5 |
|
6 |
- "github.com/openshift/origin/pkg/build/api" |
|
6 |
+ ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
|
7 |
+ |
|
8 |
+ buildapi "github.com/openshift/origin/pkg/build/api" |
|
7 | 9 |
) |
8 | 10 |
|
9 | 11 |
// FakeBuildLogs implements BuildLogsInterface. Meant to be embedded into a struct to get a default |
... | ... |
@@ -13,11 +15,14 @@ type FakeBuildLogs struct { |
13 | 13 |
Namespace string |
14 | 14 |
} |
15 | 15 |
|
16 |
-// Get builds and returns a buildLog request |
|
17 |
-func (c *FakeBuildLogs) Get(name string, opt api.BuildLogOptions) *kclient.Request { |
|
18 |
- c.Fake.Lock.Lock() |
|
19 |
- defer c.Fake.Lock.Unlock() |
|
16 |
+func (c *FakeBuildLogs) Get(name string, opt buildapi.BuildLogOptions) *kclient.Request { |
|
17 |
+ action := ktestclient.GenericActionImpl{} |
|
18 |
+ action.Verb = "get" |
|
19 |
+ action.Namespace = c.Namespace |
|
20 |
+ action.Resource = "builds" |
|
21 |
+ action.Subresource = "logs" |
|
22 |
+ action.Value = opt |
|
20 | 23 |
|
21 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "proxy"}) |
|
24 |
+ _, _ = c.Fake.Invokes(action, &buildapi.BuildConfig{}) |
|
22 | 25 |
return &kclient.Request{} |
23 | 26 |
} |
... | ... |
@@ -1,6 +1,7 @@ |
1 | 1 |
package testclient |
2 | 2 |
|
3 | 3 |
import ( |
4 |
+ ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
|
4 | 5 |
"k8s.io/kubernetes/pkg/fields" |
5 | 6 |
"k8s.io/kubernetes/pkg/labels" |
6 | 7 |
"k8s.io/kubernetes/pkg/watch" |
... | ... |
@@ -15,46 +16,59 @@ type FakeBuilds struct { |
15 | 15 |
Namespace string |
16 | 16 |
} |
17 | 17 |
|
18 |
+func (c *FakeBuilds) Get(name string) (*buildapi.Build, error) { |
|
19 |
+ obj, err := c.Fake.Invokes(ktestclient.NewGetAction("builds", c.Namespace, name), &buildapi.Build{}) |
|
20 |
+ if obj == nil { |
|
21 |
+ return nil, err |
|
22 |
+ } |
|
23 |
+ |
|
24 |
+ return obj.(*buildapi.Build), err |
|
25 |
+} |
|
26 |
+ |
|
18 | 27 |
func (c *FakeBuilds) List(label labels.Selector, field fields.Selector) (*buildapi.BuildList, error) { |
19 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "list-builds"}, &buildapi.BuildList{}) |
|
28 |
+ obj, err := c.Fake.Invokes(ktestclient.NewListAction("builds", c.Namespace, label, field), &buildapi.BuildList{}) |
|
29 |
+ if obj == nil { |
|
30 |
+ return nil, err |
|
31 |
+ } |
|
32 |
+ |
|
20 | 33 |
return obj.(*buildapi.BuildList), err |
21 | 34 |
} |
22 | 35 |
|
23 |
-func (c *FakeBuilds) Get(name string) (*buildapi.Build, error) { |
|
24 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "get-build"}, &buildapi.Build{}) |
|
25 |
- return obj.(*buildapi.Build), err |
|
26 |
-} |
|
36 |
+func (c *FakeBuilds) Create(inObj *buildapi.Build) (*buildapi.Build, error) { |
|
37 |
+ obj, err := c.Fake.Invokes(ktestclient.NewCreateAction("builds", c.Namespace, inObj), inObj) |
|
38 |
+ if obj == nil { |
|
39 |
+ return nil, err |
|
40 |
+ } |
|
27 | 41 |
|
28 |
-func (c *FakeBuilds) Create(build *buildapi.Build) (*buildapi.Build, error) { |
|
29 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "create-build", Value: build}, &buildapi.Build{}) |
|
30 | 42 |
return obj.(*buildapi.Build), err |
31 | 43 |
} |
32 | 44 |
|
33 |
-func (c *FakeBuilds) Update(build *buildapi.Build) (*buildapi.Build, error) { |
|
34 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "update-build"}, &buildapi.Build{}) |
|
45 |
+func (c *FakeBuilds) Update(inObj *buildapi.Build) (*buildapi.Build, error) { |
|
46 |
+ obj, err := c.Fake.Invokes(ktestclient.NewUpdateAction("builds", c.Namespace, inObj), inObj) |
|
47 |
+ if obj == nil { |
|
48 |
+ return nil, err |
|
49 |
+ } |
|
50 |
+ |
|
35 | 51 |
return obj.(*buildapi.Build), err |
36 | 52 |
} |
37 | 53 |
|
38 | 54 |
func (c *FakeBuilds) Delete(name string) error { |
39 |
- c.Fake.Lock.Lock() |
|
40 |
- defer c.Fake.Lock.Unlock() |
|
41 |
- |
|
42 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "delete-build", Value: name}) |
|
43 |
- return nil |
|
55 |
+ _, err := c.Fake.Invokes(ktestclient.NewDeleteAction("builds", c.Namespace, name), &buildapi.Build{}) |
|
56 |
+ return err |
|
44 | 57 |
} |
45 | 58 |
|
46 | 59 |
func (c *FakeBuilds) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) { |
47 |
- c.Fake.Lock.Lock() |
|
48 |
- defer c.Fake.Lock.Unlock() |
|
49 |
- |
|
50 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-builds"}) |
|
51 |
- return nil, nil |
|
60 |
+ c.Fake.Invokes(ktestclient.NewWatchAction("builds", c.Namespace, label, field, resourceVersion), nil) |
|
61 |
+ return c.Fake.Watch, nil |
|
52 | 62 |
} |
53 | 63 |
|
54 | 64 |
func (c *FakeBuilds) Clone(request *buildapi.BuildRequest) (result *buildapi.Build, err error) { |
55 |
- c.Fake.Lock.Lock() |
|
56 |
- defer c.Fake.Lock.Unlock() |
|
65 |
+ action := ktestclient.NewCreateAction("buildconfigs", c.Namespace, request) |
|
66 |
+ action.Subresource = "clone" |
|
67 |
+ obj, err := c.Fake.Invokes(action, &buildapi.Build{}) |
|
68 |
+ if obj == nil { |
|
69 |
+ return nil, err |
|
70 |
+ } |
|
57 | 71 |
|
58 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "clone-build"}) |
|
59 |
- return nil, nil |
|
72 |
+ return obj.(*buildapi.Build), err |
|
60 | 73 |
} |
... | ... |
@@ -1,6 +1,8 @@ |
1 | 1 |
package testclient |
2 | 2 |
|
3 | 3 |
import ( |
4 |
+ ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
|
5 |
+ |
|
4 | 6 |
sdnapi "github.com/openshift/origin/pkg/sdn/api" |
5 | 7 |
) |
6 | 8 |
|
... | ... |
@@ -11,11 +13,19 @@ type FakeClusterNetwork struct { |
11 | 11 |
} |
12 | 12 |
|
13 | 13 |
func (c *FakeClusterNetwork) Get(name string) (*sdnapi.ClusterNetwork, error) { |
14 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "get-network"}, &sdnapi.ClusterNetwork{}) |
|
14 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootGetAction("clusternetworks", name), &sdnapi.ClusterNetwork{}) |
|
15 |
+ if obj == nil { |
|
16 |
+ return nil, err |
|
17 |
+ } |
|
18 |
+ |
|
15 | 19 |
return obj.(*sdnapi.ClusterNetwork), err |
16 | 20 |
} |
17 | 21 |
|
18 |
-func (c *FakeClusterNetwork) Create(sdn *sdnapi.ClusterNetwork) (*sdnapi.ClusterNetwork, error) { |
|
19 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "create-network"}, &sdnapi.ClusterNetwork{}) |
|
22 |
+func (c *FakeClusterNetwork) Create(inObj *sdnapi.ClusterNetwork) (*sdnapi.ClusterNetwork, error) { |
|
23 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootCreateAction("clusternetworks", inObj), inObj) |
|
24 |
+ if obj == nil { |
|
25 |
+ return nil, err |
|
26 |
+ } |
|
27 |
+ |
|
20 | 28 |
return obj.(*sdnapi.ClusterNetwork), err |
21 | 29 |
} |
... | ... |
@@ -1,6 +1,7 @@ |
1 | 1 |
package testclient |
2 | 2 |
|
3 | 3 |
import ( |
4 |
+ ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
|
4 | 5 |
"k8s.io/kubernetes/pkg/fields" |
5 | 6 |
"k8s.io/kubernetes/pkg/labels" |
6 | 7 |
"k8s.io/kubernetes/pkg/watch" |
... | ... |
@@ -14,28 +15,30 @@ type FakeClusterPolicies struct { |
14 | 14 |
Fake *Fake |
15 | 15 |
} |
16 | 16 |
|
17 |
-func (c *FakeClusterPolicies) List(label labels.Selector, field fields.Selector) (*authorizationapi.ClusterPolicyList, error) { |
|
18 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "list-clusterPolicies"}, &authorizationapi.ClusterPolicyList{}) |
|
19 |
- return obj.(*authorizationapi.ClusterPolicyList), err |
|
20 |
-} |
|
21 |
- |
|
22 | 17 |
func (c *FakeClusterPolicies) Get(name string) (*authorizationapi.ClusterPolicy, error) { |
23 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "get-clusterPolicy"}, &authorizationapi.ClusterPolicy{}) |
|
18 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootGetAction("clusterpolicies", name), &authorizationapi.ClusterPolicy{}) |
|
19 |
+ if obj == nil { |
|
20 |
+ return nil, err |
|
21 |
+ } |
|
22 |
+ |
|
24 | 23 |
return obj.(*authorizationapi.ClusterPolicy), err |
25 | 24 |
} |
26 | 25 |
|
27 |
-func (c *FakeClusterPolicies) Delete(name string) error { |
|
28 |
- c.Fake.Lock.Lock() |
|
29 |
- defer c.Fake.Lock.Unlock() |
|
26 |
+func (c *FakeClusterPolicies) List(label labels.Selector, field fields.Selector) (*authorizationapi.ClusterPolicyList, error) { |
|
27 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootListAction("clusterpolicies", label, field), &authorizationapi.ClusterPolicyList{}) |
|
28 |
+ if obj == nil { |
|
29 |
+ return nil, err |
|
30 |
+ } |
|
30 | 31 |
|
31 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "delete-clusterPolicy", Value: name}) |
|
32 |
- return nil |
|
32 |
+ return obj.(*authorizationapi.ClusterPolicyList), err |
|
33 | 33 |
} |
34 | 34 |
|
35 |
-func (c *FakeClusterPolicies) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) { |
|
36 |
- c.Fake.Lock.Lock() |
|
37 |
- defer c.Fake.Lock.Unlock() |
|
35 |
+func (c *FakeClusterPolicies) Delete(name string) error { |
|
36 |
+ _, err := c.Fake.Invokes(ktestclient.NewRootDeleteAction("clusterpolicies", name), &authorizationapi.ClusterPolicy{}) |
|
37 |
+ return err |
|
38 |
+} |
|
38 | 39 |
|
39 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-clusterPolicy"}) |
|
40 |
- return nil, nil |
|
40 |
+func (c *FakeClusterPolicies) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) { |
|
41 |
+ c.Fake.Invokes(ktestclient.NewRootWatchAction("clusterpolicies", label, field, resourceVersion), nil) |
|
42 |
+ return c.Fake.Watch, c.Fake.Err() |
|
41 | 43 |
} |
... | ... |
@@ -1,6 +1,7 @@ |
1 | 1 |
package testclient |
2 | 2 |
|
3 | 3 |
import ( |
4 |
+ ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
|
4 | 5 |
"k8s.io/kubernetes/pkg/fields" |
5 | 6 |
"k8s.io/kubernetes/pkg/labels" |
6 | 7 |
"k8s.io/kubernetes/pkg/watch" |
... | ... |
@@ -14,33 +15,39 @@ type FakeClusterPolicyBindings struct { |
14 | 14 |
Fake *Fake |
15 | 15 |
} |
16 | 16 |
|
17 |
+func (c *FakeClusterPolicyBindings) Get(name string) (*authorizationapi.ClusterPolicyBinding, error) { |
|
18 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootGetAction("clusterpolicybindings", name), &authorizationapi.ClusterPolicyBinding{}) |
|
19 |
+ if obj == nil { |
|
20 |
+ return nil, err |
|
21 |
+ } |
|
22 |
+ |
|
23 |
+ return obj.(*authorizationapi.ClusterPolicyBinding), err |
|
24 |
+} |
|
25 |
+ |
|
17 | 26 |
func (c *FakeClusterPolicyBindings) List(label labels.Selector, field fields.Selector) (*authorizationapi.ClusterPolicyBindingList, error) { |
18 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "list-clusterPolicyBindings"}, &authorizationapi.ClusterPolicyBindingList{}) |
|
27 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootListAction("clusterpolicybindings", label, field), &authorizationapi.ClusterPolicyBindingList{}) |
|
28 |
+ if obj == nil { |
|
29 |
+ return nil, err |
|
30 |
+ } |
|
31 |
+ |
|
19 | 32 |
return obj.(*authorizationapi.ClusterPolicyBindingList), err |
20 | 33 |
} |
21 | 34 |
|
22 |
-func (c *FakeClusterPolicyBindings) Get(name string) (*authorizationapi.ClusterPolicyBinding, error) { |
|
23 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "get-clusterPolicyBinding"}, &authorizationapi.ClusterPolicyBinding{}) |
|
24 |
- return obj.(*authorizationapi.ClusterPolicyBinding), err |
|
25 |
-} |
|
35 |
+func (c *FakeClusterPolicyBindings) Create(inObj *authorizationapi.ClusterPolicyBinding) (*authorizationapi.ClusterPolicyBinding, error) { |
|
36 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootCreateAction("clusterpolicybindings", inObj), inObj) |
|
37 |
+ if obj == nil { |
|
38 |
+ return nil, err |
|
39 |
+ } |
|
26 | 40 |
|
27 |
-func (c *FakeClusterPolicyBindings) Create(policyBinding *authorizationapi.ClusterPolicyBinding) (*authorizationapi.ClusterPolicyBinding, error) { |
|
28 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "create-clusterPolicyBinding", Value: policyBinding}, &authorizationapi.ClusterPolicyBinding{}) |
|
29 | 41 |
return obj.(*authorizationapi.ClusterPolicyBinding), err |
30 | 42 |
} |
31 | 43 |
|
32 | 44 |
func (c *FakeClusterPolicyBindings) Delete(name string) error { |
33 |
- c.Fake.Lock.Lock() |
|
34 |
- defer c.Fake.Lock.Unlock() |
|
35 |
- |
|
36 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "delete-clusterPolicyBinding", Value: name}) |
|
37 |
- return nil |
|
45 |
+ _, err := c.Fake.Invokes(ktestclient.NewRootDeleteAction("clusterpolicybindings", name), &authorizationapi.ClusterPolicyBinding{}) |
|
46 |
+ return err |
|
38 | 47 |
} |
39 | 48 |
|
40 | 49 |
func (c *FakeClusterPolicyBindings) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) { |
41 |
- c.Fake.Lock.Lock() |
|
42 |
- defer c.Fake.Lock.Unlock() |
|
43 |
- |
|
44 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-clusterPolicyBinding"}) |
|
45 |
- return nil, nil |
|
50 |
+ c.Fake.Invokes(ktestclient.NewRootWatchAction("clusterpolicybindings", label, field, resourceVersion), nil) |
|
51 |
+ return c.Fake.Watch, c.Fake.Err() |
|
46 | 52 |
} |
... | ... |
@@ -1,6 +1,7 @@ |
1 | 1 |
package testclient |
2 | 2 |
|
3 | 3 |
import ( |
4 |
+ ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
|
4 | 5 |
"k8s.io/kubernetes/pkg/fields" |
5 | 6 |
"k8s.io/kubernetes/pkg/labels" |
6 | 7 |
|
... | ... |
@@ -13,30 +14,43 @@ type FakeClusterRoleBindings struct { |
13 | 13 |
Fake *Fake |
14 | 14 |
} |
15 | 15 |
|
16 |
+func (c *FakeClusterRoleBindings) Get(name string) (*authorizationapi.ClusterRoleBinding, error) { |
|
17 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootGetAction("clusterrolebindings", name), &authorizationapi.ClusterRoleBinding{}) |
|
18 |
+ if obj == nil { |
|
19 |
+ return nil, err |
|
20 |
+ } |
|
21 |
+ |
|
22 |
+ return obj.(*authorizationapi.ClusterRoleBinding), err |
|
23 |
+} |
|
24 |
+ |
|
16 | 25 |
func (c *FakeClusterRoleBindings) List(label labels.Selector, field fields.Selector) (*authorizationapi.ClusterRoleBindingList, error) { |
17 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "list-clusterRoleBindings"}, &authorizationapi.ClusterRoleBindingList{}) |
|
26 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootListAction("clusterrolebindings", label, field), &authorizationapi.ClusterRoleBindingList{}) |
|
27 |
+ if obj == nil { |
|
28 |
+ return nil, err |
|
29 |
+ } |
|
30 |
+ |
|
18 | 31 |
return obj.(*authorizationapi.ClusterRoleBindingList), err |
19 | 32 |
} |
20 | 33 |
|
21 |
-func (c *FakeClusterRoleBindings) Get(name string) (*authorizationapi.ClusterRoleBinding, error) { |
|
22 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "get-clusterRoleBinding"}, &authorizationapi.ClusterRoleBinding{}) |
|
23 |
- return obj.(*authorizationapi.ClusterRoleBinding), err |
|
24 |
-} |
|
34 |
+func (c *FakeClusterRoleBindings) Create(inObj *authorizationapi.ClusterRoleBinding) (*authorizationapi.ClusterRoleBinding, error) { |
|
35 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootCreateAction("clusterrolebindings", inObj), inObj) |
|
36 |
+ if obj == nil { |
|
37 |
+ return nil, err |
|
38 |
+ } |
|
25 | 39 |
|
26 |
-func (c *FakeClusterRoleBindings) Create(roleBinding *authorizationapi.ClusterRoleBinding) (*authorizationapi.ClusterRoleBinding, error) { |
|
27 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "create-clusterRoleBinding", Value: roleBinding}, &authorizationapi.ClusterRoleBinding{}) |
|
28 | 40 |
return obj.(*authorizationapi.ClusterRoleBinding), err |
29 | 41 |
} |
30 | 42 |
|
31 |
-func (c *FakeClusterRoleBindings) Update(roleBinding *authorizationapi.ClusterRoleBinding) (*authorizationapi.ClusterRoleBinding, error) { |
|
32 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "update-clusterRoleBinding"}, &authorizationapi.ClusterRoleBinding{}) |
|
43 |
+func (c *FakeClusterRoleBindings) Update(inObj *authorizationapi.ClusterRoleBinding) (*authorizationapi.ClusterRoleBinding, error) { |
|
44 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootUpdateAction("clusterrolebindings", inObj), inObj) |
|
45 |
+ if obj == nil { |
|
46 |
+ return nil, err |
|
47 |
+ } |
|
48 |
+ |
|
33 | 49 |
return obj.(*authorizationapi.ClusterRoleBinding), err |
34 | 50 |
} |
35 | 51 |
|
36 | 52 |
func (c *FakeClusterRoleBindings) Delete(name string) error { |
37 |
- c.Fake.Lock.Lock() |
|
38 |
- defer c.Fake.Lock.Unlock() |
|
39 |
- |
|
40 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "delete-clusterRoleBinding", Value: name}) |
|
41 |
- return nil |
|
53 |
+ _, err := c.Fake.Invokes(ktestclient.NewRootDeleteAction("clusterrolebindings", name), &authorizationapi.ClusterRoleBinding{}) |
|
54 |
+ return err |
|
42 | 55 |
} |
... | ... |
@@ -1,6 +1,7 @@ |
1 | 1 |
package testclient |
2 | 2 |
|
3 | 3 |
import ( |
4 |
+ ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
|
4 | 5 |
"k8s.io/kubernetes/pkg/fields" |
5 | 6 |
"k8s.io/kubernetes/pkg/labels" |
6 | 7 |
|
... | ... |
@@ -13,30 +14,43 @@ type FakeClusterRoles struct { |
13 | 13 |
Fake *Fake |
14 | 14 |
} |
15 | 15 |
|
16 |
+func (c *FakeClusterRoles) Get(name string) (*authorizationapi.ClusterRole, error) { |
|
17 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootGetAction("clusterroles", name), &authorizationapi.ClusterRole{}) |
|
18 |
+ if obj == nil { |
|
19 |
+ return nil, err |
|
20 |
+ } |
|
21 |
+ |
|
22 |
+ return obj.(*authorizationapi.ClusterRole), err |
|
23 |
+} |
|
24 |
+ |
|
16 | 25 |
func (c *FakeClusterRoles) List(label labels.Selector, field fields.Selector) (*authorizationapi.ClusterRoleList, error) { |
17 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "list-clusterRoles"}, &authorizationapi.ClusterRoleList{}) |
|
26 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootListAction("clusterroles", label, field), &authorizationapi.ClusterRoleList{}) |
|
27 |
+ if obj == nil { |
|
28 |
+ return nil, err |
|
29 |
+ } |
|
30 |
+ |
|
18 | 31 |
return obj.(*authorizationapi.ClusterRoleList), err |
19 | 32 |
} |
20 | 33 |
|
21 |
-func (c *FakeClusterRoles) Get(name string) (*authorizationapi.ClusterRole, error) { |
|
22 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "get-clusterRole"}, &authorizationapi.ClusterRole{}) |
|
23 |
- return obj.(*authorizationapi.ClusterRole), err |
|
24 |
-} |
|
34 |
+func (c *FakeClusterRoles) Create(inObj *authorizationapi.ClusterRole) (*authorizationapi.ClusterRole, error) { |
|
35 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootCreateAction("clusterroles", inObj), inObj) |
|
36 |
+ if obj == nil { |
|
37 |
+ return nil, err |
|
38 |
+ } |
|
25 | 39 |
|
26 |
-func (c *FakeClusterRoles) Create(role *authorizationapi.ClusterRole) (*authorizationapi.ClusterRole, error) { |
|
27 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "create-clusterRole", Value: role}, &authorizationapi.ClusterRole{}) |
|
28 | 40 |
return obj.(*authorizationapi.ClusterRole), err |
29 | 41 |
} |
30 | 42 |
|
31 |
-func (c *FakeClusterRoles) Update(role *authorizationapi.ClusterRole) (*authorizationapi.ClusterRole, error) { |
|
32 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "update-clusterRole"}, &authorizationapi.ClusterRole{}) |
|
43 |
+func (c *FakeClusterRoles) Update(inObj *authorizationapi.ClusterRole) (*authorizationapi.ClusterRole, error) { |
|
44 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootUpdateAction("clusterroles", inObj), inObj) |
|
45 |
+ if obj == nil { |
|
46 |
+ return nil, err |
|
47 |
+ } |
|
48 |
+ |
|
33 | 49 |
return obj.(*authorizationapi.ClusterRole), err |
34 | 50 |
} |
35 | 51 |
|
36 | 52 |
func (c *FakeClusterRoles) Delete(name string) error { |
37 |
- c.Fake.Lock.Lock() |
|
38 |
- defer c.Fake.Lock.Unlock() |
|
39 |
- |
|
40 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "delete-clusterRole", Value: name}) |
|
41 |
- return nil |
|
53 |
+ _, err := c.Fake.Invokes(ktestclient.NewRootDeleteAction("clusterroles", name), &authorizationapi.ClusterRole{}) |
|
54 |
+ return err |
|
42 | 55 |
} |
... | ... |
@@ -1,6 +1,7 @@ |
1 | 1 |
package testclient |
2 | 2 |
|
3 | 3 |
import ( |
4 |
+ ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
|
4 | 5 |
"k8s.io/kubernetes/pkg/fields" |
5 | 6 |
"k8s.io/kubernetes/pkg/labels" |
6 | 7 |
"k8s.io/kubernetes/pkg/watch" |
... | ... |
@@ -15,51 +16,67 @@ type FakeDeploymentConfigs struct { |
15 | 15 |
Namespace string |
16 | 16 |
} |
17 | 17 |
|
18 |
+func (c *FakeDeploymentConfigs) Get(name string) (*deployapi.DeploymentConfig, error) { |
|
19 |
+ obj, err := c.Fake.Invokes(ktestclient.NewGetAction("deploymentconfigs", c.Namespace, name), &deployapi.DeploymentConfig{}) |
|
20 |
+ if obj == nil { |
|
21 |
+ return nil, err |
|
22 |
+ } |
|
23 |
+ |
|
24 |
+ return obj.(*deployapi.DeploymentConfig), err |
|
25 |
+} |
|
26 |
+ |
|
18 | 27 |
func (c *FakeDeploymentConfigs) List(label labels.Selector, field fields.Selector) (*deployapi.DeploymentConfigList, error) { |
19 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "list-deploymentconfig"}, &deployapi.DeploymentConfigList{}) |
|
28 |
+ obj, err := c.Fake.Invokes(ktestclient.NewListAction("deploymentconfigs", c.Namespace, label, field), &deployapi.DeploymentConfigList{}) |
|
29 |
+ if obj == nil { |
|
30 |
+ return nil, err |
|
31 |
+ } |
|
32 |
+ |
|
20 | 33 |
return obj.(*deployapi.DeploymentConfigList), err |
21 | 34 |
} |
22 | 35 |
|
23 |
-func (c *FakeDeploymentConfigs) Get(name string) (*deployapi.DeploymentConfig, error) { |
|
24 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "get-deploymentconfig"}, &deployapi.DeploymentConfig{}) |
|
25 |
- return obj.(*deployapi.DeploymentConfig), err |
|
26 |
-} |
|
36 |
+func (c *FakeDeploymentConfigs) Create(inObj *deployapi.DeploymentConfig) (*deployapi.DeploymentConfig, error) { |
|
37 |
+ obj, err := c.Fake.Invokes(ktestclient.NewCreateAction("deploymentconfigs", c.Namespace, inObj), inObj) |
|
38 |
+ if obj == nil { |
|
39 |
+ return nil, err |
|
40 |
+ } |
|
27 | 41 |
|
28 |
-func (c *FakeDeploymentConfigs) Create(config *deployapi.DeploymentConfig) (*deployapi.DeploymentConfig, error) { |
|
29 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "create-deploymentconfig"}, &deployapi.DeploymentConfig{}) |
|
30 | 42 |
return obj.(*deployapi.DeploymentConfig), err |
31 | 43 |
} |
32 | 44 |
|
33 |
-func (c *FakeDeploymentConfigs) Update(config *deployapi.DeploymentConfig) (*deployapi.DeploymentConfig, error) { |
|
34 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "update-deploymentconfig"}, &deployapi.DeploymentConfig{}) |
|
45 |
+func (c *FakeDeploymentConfigs) Update(inObj *deployapi.DeploymentConfig) (*deployapi.DeploymentConfig, error) { |
|
46 |
+ obj, err := c.Fake.Invokes(ktestclient.NewUpdateAction("deploymentconfigs", c.Namespace, inObj), inObj) |
|
47 |
+ if obj == nil { |
|
48 |
+ return nil, err |
|
49 |
+ } |
|
50 |
+ |
|
35 | 51 |
return obj.(*deployapi.DeploymentConfig), err |
36 | 52 |
} |
37 | 53 |
|
38 | 54 |
func (c *FakeDeploymentConfigs) Delete(name string) error { |
39 |
- _, err := c.Fake.Invokes(FakeAction{Action: "delete-deploymentconfig"}, nil) |
|
55 |
+ _, err := c.Fake.Invokes(ktestclient.NewDeleteAction("deploymentconfigs", c.Namespace, name), &deployapi.DeploymentConfig{}) |
|
40 | 56 |
return err |
41 | 57 |
} |
42 | 58 |
|
43 | 59 |
func (c *FakeDeploymentConfigs) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) { |
44 |
- c.Fake.Lock.Lock() |
|
45 |
- defer c.Fake.Lock.Unlock() |
|
46 |
- |
|
47 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-deploymentconfig"}) |
|
48 |
- return nil, nil |
|
60 |
+ c.Fake.Invokes(ktestclient.NewWatchAction("deploymentconfigs", c.Namespace, label, field, resourceVersion), nil) |
|
61 |
+ return c.Fake.Watch, nil |
|
49 | 62 |
} |
50 | 63 |
|
51 | 64 |
func (c *FakeDeploymentConfigs) Generate(name string) (*deployapi.DeploymentConfig, error) { |
52 |
- c.Fake.Lock.Lock() |
|
53 |
- defer c.Fake.Lock.Unlock() |
|
65 |
+ obj, err := c.Fake.Invokes(ktestclient.NewGetAction("generatedeploymentconfigs", c.Namespace, name), &deployapi.DeploymentConfig{}) |
|
54 | 66 |
|
55 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "generate-deploymentconfig"}) |
|
56 |
- return nil, nil |
|
67 |
+ if obj == nil { |
|
68 |
+ return nil, err |
|
69 |
+ } |
|
70 |
+ |
|
71 |
+ return obj.(*deployapi.DeploymentConfig), err |
|
57 | 72 |
} |
58 | 73 |
|
59 |
-func (c *FakeDeploymentConfigs) Rollback(config *deployapi.DeploymentConfigRollback) (result *deployapi.DeploymentConfig, err error) { |
|
60 |
- c.Fake.Lock.Lock() |
|
61 |
- defer c.Fake.Lock.Unlock() |
|
74 |
+func (c *FakeDeploymentConfigs) Rollback(inObj *deployapi.DeploymentConfigRollback) (result *deployapi.DeploymentConfig, err error) { |
|
75 |
+ obj, err := c.Fake.Invokes(ktestclient.NewCreateAction("deploymentconfigrollbacks", c.Namespace, inObj), inObj) |
|
76 |
+ if obj == nil { |
|
77 |
+ return nil, err |
|
78 |
+ } |
|
62 | 79 |
|
63 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "rollback"}) |
|
64 |
- return nil, nil |
|
80 |
+ return obj.(*deployapi.DeploymentConfig), err |
|
65 | 81 |
} |
... | ... |
@@ -1,9 +1,11 @@ |
1 | 1 |
package testclient |
2 | 2 |
|
3 | 3 |
import ( |
4 |
- userapi "github.com/openshift/origin/pkg/user/api" |
|
4 |
+ ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
|
5 | 5 |
"k8s.io/kubernetes/pkg/fields" |
6 | 6 |
"k8s.io/kubernetes/pkg/labels" |
7 |
+ |
|
8 |
+ userapi "github.com/openshift/origin/pkg/user/api" |
|
7 | 9 |
) |
8 | 10 |
|
9 | 11 |
// FakeGroups implements GroupsInterface. Meant to be embedded into a struct to get a default |
... | ... |
@@ -12,30 +14,43 @@ type FakeGroups struct { |
12 | 12 |
Fake *Fake |
13 | 13 |
} |
14 | 14 |
|
15 |
+func (c *FakeGroups) Get(name string) (*userapi.Group, error) { |
|
16 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootGetAction("groups", name), &userapi.Group{}) |
|
17 |
+ if obj == nil { |
|
18 |
+ return nil, err |
|
19 |
+ } |
|
20 |
+ |
|
21 |
+ return obj.(*userapi.Group), err |
|
22 |
+} |
|
23 |
+ |
|
15 | 24 |
func (c *FakeGroups) List(label labels.Selector, field fields.Selector) (*userapi.GroupList, error) { |
16 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "list-groups"}, &userapi.GroupList{}) |
|
25 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootListAction("groups", label, field), &userapi.GroupList{}) |
|
26 |
+ if obj == nil { |
|
27 |
+ return nil, err |
|
28 |
+ } |
|
29 |
+ |
|
17 | 30 |
return obj.(*userapi.GroupList), err |
18 | 31 |
} |
19 | 32 |
|
20 |
-func (c *FakeGroups) Get(name string) (*userapi.Group, error) { |
|
21 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "get-group", Value: name}, &userapi.Group{}) |
|
22 |
- return obj.(*userapi.Group), err |
|
23 |
-} |
|
33 |
+func (c *FakeGroups) Create(inObj *userapi.Group) (*userapi.Group, error) { |
|
34 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootCreateAction("groups", inObj), inObj) |
|
35 |
+ if obj == nil { |
|
36 |
+ return nil, err |
|
37 |
+ } |
|
24 | 38 |
|
25 |
-func (c *FakeGroups) Create(group *userapi.Group) (*userapi.Group, error) { |
|
26 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "create-group", Value: group}, &userapi.Group{}) |
|
27 | 39 |
return obj.(*userapi.Group), err |
28 | 40 |
} |
29 | 41 |
|
30 |
-func (c *FakeGroups) Update(group *userapi.Group) (*userapi.Group, error) { |
|
31 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "update-group", Value: group}, &userapi.Group{}) |
|
42 |
+func (c *FakeGroups) Update(inObj *userapi.Group) (*userapi.Group, error) { |
|
43 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootUpdateAction("groups", inObj), inObj) |
|
44 |
+ if obj == nil { |
|
45 |
+ return nil, err |
|
46 |
+ } |
|
47 |
+ |
|
32 | 48 |
return obj.(*userapi.Group), err |
33 | 49 |
} |
34 | 50 |
|
35 | 51 |
func (c *FakeGroups) Delete(name string) error { |
36 |
- c.Fake.Lock.Lock() |
|
37 |
- defer c.Fake.Lock.Unlock() |
|
38 |
- |
|
39 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "delete-group"}) |
|
40 |
- return nil |
|
52 |
+ _, err := c.Fake.Invokes(ktestclient.NewRootDeleteAction("groups", name), &userapi.Group{}) |
|
53 |
+ return err |
|
41 | 54 |
} |
... | ... |
@@ -1,6 +1,7 @@ |
1 | 1 |
package testclient |
2 | 2 |
|
3 | 3 |
import ( |
4 |
+ ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
|
4 | 5 |
"k8s.io/kubernetes/pkg/watch" |
5 | 6 |
|
6 | 7 |
sdnapi "github.com/openshift/origin/pkg/sdn/api" |
... | ... |
@@ -12,33 +13,39 @@ type FakeHostSubnet struct { |
12 | 12 |
Fake *Fake |
13 | 13 |
} |
14 | 14 |
|
15 |
+func (c *FakeHostSubnet) Get(name string) (*sdnapi.HostSubnet, error) { |
|
16 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootGetAction("hostsubnets", name), &sdnapi.HostSubnet{}) |
|
17 |
+ if obj == nil { |
|
18 |
+ return nil, err |
|
19 |
+ } |
|
20 |
+ |
|
21 |
+ return obj.(*sdnapi.HostSubnet), err |
|
22 |
+} |
|
23 |
+ |
|
15 | 24 |
func (c *FakeHostSubnet) List() (*sdnapi.HostSubnetList, error) { |
16 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "list-subnets"}, &sdnapi.HostSubnetList{}) |
|
25 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootListAction("hostsubnets", nil, nil), &sdnapi.HostSubnetList{}) |
|
26 |
+ if obj == nil { |
|
27 |
+ return nil, err |
|
28 |
+ } |
|
29 |
+ |
|
17 | 30 |
return obj.(*sdnapi.HostSubnetList), err |
18 | 31 |
} |
19 | 32 |
|
20 |
-func (c *FakeHostSubnet) Get(name string) (*sdnapi.HostSubnet, error) { |
|
21 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "get-subnets"}, &sdnapi.HostSubnet{}) |
|
22 |
- return obj.(*sdnapi.HostSubnet), err |
|
23 |
-} |
|
33 |
+func (c *FakeHostSubnet) Create(inObj *sdnapi.HostSubnet) (*sdnapi.HostSubnet, error) { |
|
34 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootCreateAction("hostsubnets", inObj), inObj) |
|
35 |
+ if obj == nil { |
|
36 |
+ return nil, err |
|
37 |
+ } |
|
24 | 38 |
|
25 |
-func (c *FakeHostSubnet) Create(sdn *sdnapi.HostSubnet) (*sdnapi.HostSubnet, error) { |
|
26 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "create-subnet"}, &sdnapi.HostSubnet{}) |
|
27 | 39 |
return obj.(*sdnapi.HostSubnet), err |
28 | 40 |
} |
29 | 41 |
|
30 | 42 |
func (c *FakeHostSubnet) Delete(name string) error { |
31 |
- c.Fake.Lock.Lock() |
|
32 |
- defer c.Fake.Lock.Unlock() |
|
33 |
- |
|
34 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "delete-subnet"}) |
|
35 |
- return nil |
|
43 |
+ _, err := c.Fake.Invokes(ktestclient.NewRootDeleteAction("hostsubnets", name), &sdnapi.HostSubnet{}) |
|
44 |
+ return err |
|
36 | 45 |
} |
37 | 46 |
|
38 | 47 |
func (c *FakeHostSubnet) Watch(resourceVersion string) (watch.Interface, error) { |
39 |
- c.Fake.Lock.Lock() |
|
40 |
- defer c.Fake.Lock.Unlock() |
|
41 |
- |
|
42 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-subnets"}) |
|
43 |
- return nil, nil |
|
48 |
+ c.Fake.Invokes(ktestclient.NewRootWatchAction("hostsubnets", nil, nil, resourceVersion), nil) |
|
49 |
+ return c.Fake.Watch, c.Fake.Err() |
|
44 | 50 |
} |
... | ... |
@@ -1,9 +1,11 @@ |
1 | 1 |
package testclient |
2 | 2 |
|
3 | 3 |
import ( |
4 |
- userapi "github.com/openshift/origin/pkg/user/api" |
|
4 |
+ ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
|
5 | 5 |
"k8s.io/kubernetes/pkg/fields" |
6 | 6 |
"k8s.io/kubernetes/pkg/labels" |
7 |
+ |
|
8 |
+ userapi "github.com/openshift/origin/pkg/user/api" |
|
7 | 9 |
) |
8 | 10 |
|
9 | 11 |
// FakeIdentities implements IdentitiesInterface. Meant to be embedded into a struct to get a default |
... | ... |
@@ -12,22 +14,38 @@ type FakeIdentities struct { |
12 | 12 |
Fake *Fake |
13 | 13 |
} |
14 | 14 |
|
15 |
+func (c *FakeIdentities) Get(name string) (*userapi.Identity, error) { |
|
16 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootGetAction("identities", name), &userapi.Identity{}) |
|
17 |
+ if obj == nil { |
|
18 |
+ return nil, err |
|
19 |
+ } |
|
20 |
+ |
|
21 |
+ return obj.(*userapi.Identity), err |
|
22 |
+} |
|
23 |
+ |
|
15 | 24 |
func (c *FakeIdentities) List(label labels.Selector, field fields.Selector) (*userapi.IdentityList, error) { |
16 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "list-identities"}, &userapi.IdentityList{}) |
|
25 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootListAction("identities", label, field), &userapi.IdentityList{}) |
|
26 |
+ if obj == nil { |
|
27 |
+ return nil, err |
|
28 |
+ } |
|
29 |
+ |
|
17 | 30 |
return obj.(*userapi.IdentityList), err |
18 | 31 |
} |
19 | 32 |
|
20 |
-func (c *FakeIdentities) Get(name string) (*userapi.Identity, error) { |
|
21 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "get-identity", Value: name}, &userapi.Identity{}) |
|
22 |
- return obj.(*userapi.Identity), err |
|
23 |
-} |
|
33 |
+func (c *FakeIdentities) Create(inObj *userapi.Identity) (*userapi.Identity, error) { |
|
34 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootCreateAction("identities", inObj), inObj) |
|
35 |
+ if obj == nil { |
|
36 |
+ return nil, err |
|
37 |
+ } |
|
24 | 38 |
|
25 |
-func (c *FakeIdentities) Create(identity *userapi.Identity) (*userapi.Identity, error) { |
|
26 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "create-identity", Value: identity}, &userapi.Identity{}) |
|
27 | 39 |
return obj.(*userapi.Identity), err |
28 | 40 |
} |
29 | 41 |
|
30 |
-func (c *FakeIdentities) Update(identity *userapi.Identity) (*userapi.Identity, error) { |
|
31 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "update-identity", Value: identity}, &userapi.Identity{}) |
|
42 |
+func (c *FakeIdentities) Update(inObj *userapi.Identity) (*userapi.Identity, error) { |
|
43 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootUpdateAction("identities", inObj), inObj) |
|
44 |
+ if obj == nil { |
|
45 |
+ return nil, err |
|
46 |
+ } |
|
47 |
+ |
|
32 | 48 |
return obj.(*userapi.Identity), err |
33 | 49 |
} |
... | ... |
@@ -1,6 +1,7 @@ |
1 | 1 |
package testclient |
2 | 2 |
|
3 | 3 |
import ( |
4 |
+ ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
|
4 | 5 |
"k8s.io/kubernetes/pkg/fields" |
5 | 6 |
"k8s.io/kubernetes/pkg/labels" |
6 | 7 |
|
... | ... |
@@ -17,22 +18,34 @@ type FakeImages struct { |
17 | 17 |
|
18 | 18 |
var _ client.ImageInterface = &FakeImages{} |
19 | 19 |
|
20 |
+func (c *FakeImages) Get(name string) (*imageapi.Image, error) { |
|
21 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootGetAction("images", name), &imageapi.Image{}) |
|
22 |
+ if obj == nil { |
|
23 |
+ return nil, err |
|
24 |
+ } |
|
25 |
+ |
|
26 |
+ return obj.(*imageapi.Image), err |
|
27 |
+} |
|
28 |
+ |
|
20 | 29 |
func (c *FakeImages) List(label labels.Selector, field fields.Selector) (*imageapi.ImageList, error) { |
21 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "list-images"}, &imageapi.ImageList{}) |
|
30 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootListAction("images", label, field), &imageapi.ImageList{}) |
|
31 |
+ if obj == nil { |
|
32 |
+ return nil, err |
|
33 |
+ } |
|
34 |
+ |
|
22 | 35 |
return obj.(*imageapi.ImageList), err |
23 | 36 |
} |
24 | 37 |
|
25 |
-func (c *FakeImages) Get(name string) (*imageapi.Image, error) { |
|
26 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "get-image", Value: name}, &imageapi.Image{}) |
|
27 |
- return obj.(*imageapi.Image), err |
|
28 |
-} |
|
38 |
+func (c *FakeImages) Create(inObj *imageapi.Image) (*imageapi.Image, error) { |
|
39 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootCreateAction("images", inObj), inObj) |
|
40 |
+ if obj == nil { |
|
41 |
+ return nil, err |
|
42 |
+ } |
|
29 | 43 |
|
30 |
-func (c *FakeImages) Create(image *imageapi.Image) (*imageapi.Image, error) { |
|
31 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "create-image"}, &imageapi.Image{}) |
|
32 | 44 |
return obj.(*imageapi.Image), err |
33 | 45 |
} |
34 | 46 |
|
35 | 47 |
func (c *FakeImages) Delete(name string) error { |
36 |
- _, err := c.Fake.Invokes(FakeAction{Action: "delete-image", Value: name}, nil) |
|
48 |
+ _, err := c.Fake.Invokes(ktestclient.NewRootDeleteAction("images", name), &imageapi.Image{}) |
|
37 | 49 |
return err |
38 | 50 |
} |
... | ... |
@@ -3,6 +3,8 @@ package testclient |
3 | 3 |
import ( |
4 | 4 |
"fmt" |
5 | 5 |
|
6 |
+ ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
|
7 |
+ |
|
6 | 8 |
"github.com/openshift/origin/pkg/client" |
7 | 9 |
imageapi "github.com/openshift/origin/pkg/image/api" |
8 | 10 |
) |
... | ... |
@@ -17,7 +19,13 @@ type FakeImageStreamImages struct { |
17 | 17 |
|
18 | 18 |
var _ client.ImageStreamImageInterface = &FakeImageStreamImages{} |
19 | 19 |
|
20 |
-func (c *FakeImageStreamImages) Get(name, id string) (*imageapi.ImageStreamImage, error) { |
|
21 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "get-imagestream-image", Value: fmt.Sprintf("%s@%s", name, id)}, &imageapi.ImageStreamImage{}) |
|
20 |
+func (c *FakeImageStreamImages) Get(repo, imageID string) (*imageapi.ImageStreamImage, error) { |
|
21 |
+ name := fmt.Sprintf("%s@%s", repo, imageID) |
|
22 |
+ |
|
23 |
+ obj, err := c.Fake.Invokes(ktestclient.NewGetAction("imagestreamimages", c.Namespace, name), &imageapi.ImageStreamImage{}) |
|
24 |
+ if obj == nil { |
|
25 |
+ return nil, err |
|
26 |
+ } |
|
27 |
+ |
|
22 | 28 |
return obj.(*imageapi.ImageStreamImage), err |
23 | 29 |
} |
... | ... |
@@ -1,6 +1,8 @@ |
1 | 1 |
package testclient |
2 | 2 |
|
3 | 3 |
import ( |
4 |
+ ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
|
5 |
+ |
|
4 | 6 |
"github.com/openshift/origin/pkg/client" |
5 | 7 |
imageapi "github.com/openshift/origin/pkg/image/api" |
6 | 8 |
) |
... | ... |
@@ -15,10 +17,7 @@ type FakeImageStreamMappings struct { |
15 | 15 |
|
16 | 16 |
var _ client.ImageStreamMappingInterface = &FakeImageStreamMappings{} |
17 | 17 |
|
18 |
-func (c *FakeImageStreamMappings) Create(mapping *imageapi.ImageStreamMapping) error { |
|
19 |
- c.Fake.Lock.Lock() |
|
20 |
- defer c.Fake.Lock.Unlock() |
|
21 |
- |
|
22 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "create-imagestream-mapping"}) |
|
23 |
- return nil |
|
18 |
+func (c *FakeImageStreamMappings) Create(inObj *imageapi.ImageStreamMapping) error { |
|
19 |
+ _, err := c.Fake.Invokes(ktestclient.NewCreateAction("imagestreammappings", c.Namespace, inObj), inObj) |
|
20 |
+ return err |
|
24 | 21 |
} |
... | ... |
@@ -1,6 +1,7 @@ |
1 | 1 |
package testclient |
2 | 2 |
|
3 | 3 |
import ( |
4 |
+ ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
|
4 | 5 |
"k8s.io/kubernetes/pkg/fields" |
5 | 6 |
"k8s.io/kubernetes/pkg/labels" |
6 | 7 |
"k8s.io/kubernetes/pkg/watch" |
... | ... |
@@ -19,43 +20,63 @@ type FakeImageStreams struct { |
19 | 19 |
|
20 | 20 |
var _ client.ImageStreamInterface = &FakeImageStreams{} |
21 | 21 |
|
22 |
+func (c *FakeImageStreams) Get(name string) (*imageapi.ImageStream, error) { |
|
23 |
+ obj, err := c.Fake.Invokes(ktestclient.NewGetAction("imagestreams", c.Namespace, name), &imageapi.ImageStream{}) |
|
24 |
+ if obj == nil { |
|
25 |
+ return nil, err |
|
26 |
+ } |
|
27 |
+ |
|
28 |
+ return obj.(*imageapi.ImageStream), err |
|
29 |
+} |
|
30 |
+ |
|
22 | 31 |
func (c *FakeImageStreams) List(label labels.Selector, field fields.Selector) (*imageapi.ImageStreamList, error) { |
23 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "list-imagestreams"}, &imageapi.ImageStreamList{}) |
|
32 |
+ obj, err := c.Fake.Invokes(ktestclient.NewListAction("imagestreams", c.Namespace, label, field), &imageapi.ImageStreamList{}) |
|
33 |
+ if obj == nil { |
|
34 |
+ return nil, err |
|
35 |
+ } |
|
36 |
+ |
|
24 | 37 |
return obj.(*imageapi.ImageStreamList), err |
25 | 38 |
} |
26 | 39 |
|
27 |
-func (c *FakeImageStreams) Get(name string) (*imageapi.ImageStream, error) { |
|
28 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "get-imagestream", Value: name}, &imageapi.ImageStream{}) |
|
29 |
- return obj.(*imageapi.ImageStream), err |
|
30 |
-} |
|
40 |
+func (c *FakeImageStreams) Create(inObj *imageapi.ImageStream) (*imageapi.ImageStream, error) { |
|
41 |
+ obj, err := c.Fake.Invokes(ktestclient.NewCreateAction("imagestreams", c.Namespace, inObj), inObj) |
|
42 |
+ if obj == nil { |
|
43 |
+ return nil, err |
|
44 |
+ } |
|
31 | 45 |
|
32 |
-func (c *FakeImageStreams) Create(stream *imageapi.ImageStream) (*imageapi.ImageStream, error) { |
|
33 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "create-imagestream"}, &imageapi.ImageStream{}) |
|
34 | 46 |
return obj.(*imageapi.ImageStream), err |
35 | 47 |
} |
36 | 48 |
|
37 |
-func (c *FakeImageStreams) Update(stream *imageapi.ImageStream) (*imageapi.ImageStream, error) { |
|
38 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "update-imagestream", Value: stream}, stream) |
|
49 |
+func (c *FakeImageStreams) Update(inObj *imageapi.ImageStream) (*imageapi.ImageStream, error) { |
|
50 |
+ obj, err := c.Fake.Invokes(ktestclient.NewUpdateAction("imagestreams", c.Namespace, inObj), inObj) |
|
51 |
+ if obj == nil { |
|
52 |
+ return nil, err |
|
53 |
+ } |
|
54 |
+ |
|
39 | 55 |
return obj.(*imageapi.ImageStream), err |
40 | 56 |
} |
41 | 57 |
|
42 | 58 |
func (c *FakeImageStreams) Delete(name string) error { |
43 |
- c.Fake.Lock.Lock() |
|
44 |
- defer c.Fake.Lock.Unlock() |
|
45 |
- |
|
46 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "delete-imagestream", Value: name}) |
|
47 |
- return nil |
|
59 |
+ _, err := c.Fake.Invokes(ktestclient.NewDeleteAction("imagestreams", c.Namespace, name), &imageapi.ImageStream{}) |
|
60 |
+ return err |
|
48 | 61 |
} |
49 | 62 |
|
50 | 63 |
func (c *FakeImageStreams) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) { |
51 |
- c.Fake.Lock.Lock() |
|
52 |
- defer c.Fake.Lock.Unlock() |
|
53 |
- |
|
54 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-imagestreams"}) |
|
55 |
- return nil, nil |
|
64 |
+ c.Fake.Invokes(ktestclient.NewWatchAction("imagestreams", c.Namespace, label, field, resourceVersion), nil) |
|
65 |
+ return c.Fake.Watch, nil |
|
56 | 66 |
} |
57 | 67 |
|
58 |
-func (c *FakeImageStreams) UpdateStatus(stream *imageapi.ImageStream) (result *imageapi.ImageStream, err error) { |
|
59 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "update-status-imagestream", Value: stream}, stream) |
|
68 |
+func (c *FakeImageStreams) UpdateStatus(inObj *imageapi.ImageStream) (result *imageapi.ImageStream, err error) { |
|
69 |
+ action := ktestclient.CreateActionImpl{} |
|
70 |
+ action.Verb = "update" |
|
71 |
+ action.Resource = "imagestreams" |
|
72 |
+ action.Subresource = "status" |
|
73 |
+ action.Object = inObj |
|
74 |
+ |
|
75 |
+ obj, err := c.Fake.Invokes(action, inObj) |
|
76 |
+ if obj == nil { |
|
77 |
+ return nil, err |
|
78 |
+ } |
|
79 |
+ |
|
60 | 80 |
return obj.(*imageapi.ImageStream), err |
61 | 81 |
} |
... | ... |
@@ -1,7 +1,7 @@ |
1 | 1 |
package testclient |
2 | 2 |
|
3 | 3 |
import ( |
4 |
- "fmt" |
|
4 |
+ ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
|
5 | 5 |
|
6 | 6 |
"github.com/openshift/origin/pkg/client" |
7 | 7 |
imageapi "github.com/openshift/origin/pkg/image/api" |
... | ... |
@@ -17,18 +17,16 @@ type FakeImageStreamTags struct { |
17 | 17 |
|
18 | 18 |
var _ client.ImageStreamTagInterface = &FakeImageStreamTags{} |
19 | 19 |
|
20 |
-func (c *FakeImageStreamTags) Get(name, tag string) (result *imageapi.ImageStreamTag, err error) { |
|
21 |
- c.Fake.Lock.Lock() |
|
22 |
- defer c.Fake.Lock.Unlock() |
|
20 |
+func (c *FakeImageStreamTags) Get(name, tag string) (*imageapi.ImageStreamTag, error) { |
|
21 |
+ obj, err := c.Fake.Invokes(ktestclient.NewGetAction("imagestreamtags", c.Namespace, imageapi.JoinImageStreamTag(name, tag)), &imageapi.ImageStreamTag{}) |
|
22 |
+ if obj == nil { |
|
23 |
+ return nil, err |
|
24 |
+ } |
|
23 | 25 |
|
24 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "get-imagestream-tag", Value: fmt.Sprintf("%s:%s", name, tag)}) |
|
25 |
- return &imageapi.ImageStreamTag{}, nil |
|
26 |
+ return obj.(*imageapi.ImageStreamTag), err |
|
26 | 27 |
} |
27 | 28 |
|
28 | 29 |
func (c *FakeImageStreamTags) Delete(name, tag string) error { |
29 |
- c.Fake.Lock.Lock() |
|
30 |
- defer c.Fake.Lock.Unlock() |
|
31 |
- |
|
32 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "delete-imagestream-tag", Value: fmt.Sprintf("%s:%s", name, tag)}) |
|
33 |
- return nil |
|
30 |
+ _, err := c.Fake.Invokes(ktestclient.NewDeleteAction("imagestreamtags", c.Namespace, imageapi.JoinImageStreamTag(name, tag)), &imageapi.ImageStreamTag{}) |
|
31 |
+ return err |
|
34 | 32 |
} |
... | ... |
@@ -1,6 +1,7 @@ |
1 | 1 |
package testclient |
2 | 2 |
|
3 | 3 |
import ( |
4 |
+ ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
|
4 | 5 |
"k8s.io/kubernetes/pkg/watch" |
5 | 6 |
|
6 | 7 |
sdnapi "github.com/openshift/origin/pkg/sdn/api" |
... | ... |
@@ -12,27 +13,39 @@ type FakeNetNamespace struct { |
12 | 12 |
Fake *Fake |
13 | 13 |
} |
14 | 14 |
|
15 |
+func (c *FakeNetNamespace) Get(name string) (*sdnapi.NetNamespace, error) { |
|
16 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootGetAction("netnamespaces", name), &sdnapi.NetNamespace{}) |
|
17 |
+ if obj == nil { |
|
18 |
+ return nil, err |
|
19 |
+ } |
|
20 |
+ |
|
21 |
+ return obj.(*sdnapi.NetNamespace), err |
|
22 |
+} |
|
23 |
+ |
|
15 | 24 |
func (c *FakeNetNamespace) List() (*sdnapi.NetNamespaceList, error) { |
16 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "list-netnamespaces"}, &sdnapi.NetNamespaceList{}) |
|
25 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootListAction("netnamespaces", nil, nil), &sdnapi.NetNamespaceList{}) |
|
26 |
+ if obj == nil { |
|
27 |
+ return nil, err |
|
28 |
+ } |
|
29 |
+ |
|
17 | 30 |
return obj.(*sdnapi.NetNamespaceList), err |
18 | 31 |
} |
19 | 32 |
|
20 |
-func (c *FakeNetNamespace) Get(name string) (*sdnapi.NetNamespace, error) { |
|
21 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "get-netnamespaces"}, &sdnapi.NetNamespace{}) |
|
22 |
- return obj.(*sdnapi.NetNamespace), err |
|
23 |
-} |
|
33 |
+func (c *FakeNetNamespace) Create(inObj *sdnapi.NetNamespace) (*sdnapi.NetNamespace, error) { |
|
34 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootCreateAction("netnamespaces", inObj), inObj) |
|
35 |
+ if obj == nil { |
|
36 |
+ return nil, err |
|
37 |
+ } |
|
24 | 38 |
|
25 |
-func (c *FakeNetNamespace) Create(sdn *sdnapi.NetNamespace) (*sdnapi.NetNamespace, error) { |
|
26 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "create-netnamespace"}, &sdnapi.NetNamespace{}) |
|
27 | 39 |
return obj.(*sdnapi.NetNamespace), err |
28 | 40 |
} |
29 | 41 |
|
30 | 42 |
func (c *FakeNetNamespace) Delete(name string) error { |
31 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "delete-netnamespace"}) |
|
32 |
- return nil |
|
43 |
+ _, err := c.Fake.Invokes(ktestclient.NewRootDeleteAction("netnamespaces", name), &sdnapi.NetNamespace{}) |
|
44 |
+ return err |
|
33 | 45 |
} |
34 | 46 |
|
35 | 47 |
func (c *FakeNetNamespace) Watch(resourceVersion string) (watch.Interface, error) { |
36 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-netnamespaces"}) |
|
37 |
- return nil, nil |
|
48 |
+ c.Fake.Invokes(ktestclient.NewRootWatchAction("netnamespaces", nil, nil, resourceVersion), nil) |
|
49 |
+ return c.Fake.Watch, c.Fake.Err() |
|
38 | 50 |
} |
... | ... |
@@ -1,16 +1,18 @@ |
1 | 1 |
package testclient |
2 | 2 |
|
3 |
+import ( |
|
4 |
+ ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
|
5 |
+ |
|
6 |
+ oauthapi "github.com/openshift/origin/pkg/oauth/api" |
|
7 |
+) |
|
8 |
+ |
|
3 | 9 |
// FakeOAuthAccessTokens implements OAuthAccessTokenInterface. Meant to be embedded into a struct to get a default |
4 | 10 |
// implementation. This makes faking out just the methods you want to test easier. |
5 | 11 |
type FakeOAuthAccessTokens struct { |
6 | 12 |
Fake *Fake |
7 | 13 |
} |
8 | 14 |
|
9 |
-// Delete mocks deleting an OAuthAccessToken |
|
10 | 15 |
func (c *FakeOAuthAccessTokens) Delete(name string) error { |
11 |
- c.Fake.Lock.Lock() |
|
12 |
- defer c.Fake.Lock.Unlock() |
|
13 |
- |
|
14 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "delete-oauthaccesstoken", Value: name}) |
|
15 |
- return nil |
|
16 |
+ _, err := c.Fake.Invokes(ktestclient.NewRootDeleteAction("oauthaccesstokens", name), &oauthapi.OAuthAccessToken{}) |
|
17 |
+ return err |
|
16 | 18 |
} |
... | ... |
@@ -1,6 +1,7 @@ |
1 | 1 |
package testclient |
2 | 2 |
|
3 | 3 |
import ( |
4 |
+ ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
|
4 | 5 |
"k8s.io/kubernetes/pkg/fields" |
5 | 6 |
"k8s.io/kubernetes/pkg/labels" |
6 | 7 |
"k8s.io/kubernetes/pkg/watch" |
... | ... |
@@ -11,31 +12,34 @@ import ( |
11 | 11 |
// FakePolicies implements PolicyInterface. Meant to be embedded into a struct to get a default |
12 | 12 |
// implementation. This makes faking out just the methods you want to test easier. |
13 | 13 |
type FakePolicies struct { |
14 |
- Fake *Fake |
|
15 |
-} |
|
16 |
- |
|
17 |
-func (c *FakePolicies) List(label labels.Selector, field fields.Selector) (*authorizationapi.PolicyList, error) { |
|
18 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "list-policies"}, &authorizationapi.PolicyList{}) |
|
19 |
- return obj.(*authorizationapi.PolicyList), err |
|
14 |
+ Fake *Fake |
|
15 |
+ Namespace string |
|
20 | 16 |
} |
21 | 17 |
|
22 | 18 |
func (c *FakePolicies) Get(name string) (*authorizationapi.Policy, error) { |
23 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "get-policy"}, &authorizationapi.Policy{}) |
|
19 |
+ obj, err := c.Fake.Invokes(ktestclient.NewGetAction("policies", c.Namespace, name), &authorizationapi.Policy{}) |
|
20 |
+ if obj == nil { |
|
21 |
+ return nil, err |
|
22 |
+ } |
|
23 |
+ |
|
24 | 24 |
return obj.(*authorizationapi.Policy), err |
25 | 25 |
} |
26 | 26 |
|
27 |
-func (c *FakePolicies) Delete(name string) error { |
|
28 |
- c.Fake.Lock.Lock() |
|
29 |
- defer c.Fake.Lock.Unlock() |
|
27 |
+func (c *FakePolicies) List(label labels.Selector, field fields.Selector) (*authorizationapi.PolicyList, error) { |
|
28 |
+ obj, err := c.Fake.Invokes(ktestclient.NewListAction("policies", c.Namespace, label, field), &authorizationapi.PolicyList{}) |
|
29 |
+ if obj == nil { |
|
30 |
+ return nil, err |
|
31 |
+ } |
|
30 | 32 |
|
31 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "delete-policy", Value: name}) |
|
32 |
- return nil |
|
33 |
+ return obj.(*authorizationapi.PolicyList), err |
|
33 | 34 |
} |
34 | 35 |
|
35 |
-func (c *FakePolicies) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) { |
|
36 |
- c.Fake.Lock.Lock() |
|
37 |
- defer c.Fake.Lock.Unlock() |
|
36 |
+func (c *FakePolicies) Delete(name string) error { |
|
37 |
+ _, err := c.Fake.Invokes(ktestclient.NewDeleteAction("policies", c.Namespace, name), &authorizationapi.Policy{}) |
|
38 |
+ return err |
|
39 |
+} |
|
38 | 40 |
|
39 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-policy"}) |
|
40 |
- return nil, nil |
|
41 |
+func (c *FakePolicies) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) { |
|
42 |
+ c.Fake.Invokes(ktestclient.NewWatchAction("policies", c.Namespace, label, field, resourceVersion), nil) |
|
43 |
+ return c.Fake.Watch, nil |
|
41 | 44 |
} |
... | ... |
@@ -1,6 +1,7 @@ |
1 | 1 |
package testclient |
2 | 2 |
|
3 | 3 |
import ( |
4 |
+ ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
|
4 | 5 |
"k8s.io/kubernetes/pkg/fields" |
5 | 6 |
"k8s.io/kubernetes/pkg/labels" |
6 | 7 |
"k8s.io/kubernetes/pkg/watch" |
... | ... |
@@ -11,36 +12,43 @@ import ( |
11 | 11 |
// FakePolicyBindings implements PolicyBindingInterface. Meant to be embedded into a struct to get a default |
12 | 12 |
// implementation. This makes faking out just the methods you want to test easier. |
13 | 13 |
type FakePolicyBindings struct { |
14 |
- Fake *Fake |
|
14 |
+ Fake *Fake |
|
15 |
+ Namespace string |
|
16 |
+} |
|
17 |
+ |
|
18 |
+func (c *FakePolicyBindings) Get(name string) (*authorizationapi.PolicyBinding, error) { |
|
19 |
+ obj, err := c.Fake.Invokes(ktestclient.NewGetAction("policybindings", c.Namespace, name), &authorizationapi.PolicyBinding{}) |
|
20 |
+ if obj == nil { |
|
21 |
+ return nil, err |
|
22 |
+ } |
|
23 |
+ |
|
24 |
+ return obj.(*authorizationapi.PolicyBinding), err |
|
15 | 25 |
} |
16 | 26 |
|
17 | 27 |
func (c *FakePolicyBindings) List(label labels.Selector, field fields.Selector) (*authorizationapi.PolicyBindingList, error) { |
18 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "list-policyBindings"}, &authorizationapi.PolicyBindingList{}) |
|
28 |
+ obj, err := c.Fake.Invokes(ktestclient.NewListAction("policybindings", c.Namespace, label, field), &authorizationapi.PolicyBindingList{}) |
|
29 |
+ if obj == nil { |
|
30 |
+ return nil, err |
|
31 |
+ } |
|
32 |
+ |
|
19 | 33 |
return obj.(*authorizationapi.PolicyBindingList), err |
20 | 34 |
} |
21 | 35 |
|
22 |
-func (c *FakePolicyBindings) Get(name string) (*authorizationapi.PolicyBinding, error) { |
|
23 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "get-policyBinding"}, &authorizationapi.PolicyBinding{}) |
|
24 |
- return obj.(*authorizationapi.PolicyBinding), err |
|
25 |
-} |
|
36 |
+func (c *FakePolicyBindings) Create(inObj *authorizationapi.PolicyBinding) (*authorizationapi.PolicyBinding, error) { |
|
37 |
+ obj, err := c.Fake.Invokes(ktestclient.NewCreateAction("policybindings", c.Namespace, inObj), inObj) |
|
38 |
+ if obj == nil { |
|
39 |
+ return nil, err |
|
40 |
+ } |
|
26 | 41 |
|
27 |
-func (c *FakePolicyBindings) Create(policyBinding *authorizationapi.PolicyBinding) (*authorizationapi.PolicyBinding, error) { |
|
28 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "create-policyBinding", Value: policyBinding}, &authorizationapi.PolicyBinding{}) |
|
29 | 42 |
return obj.(*authorizationapi.PolicyBinding), err |
30 | 43 |
} |
31 | 44 |
|
32 | 45 |
func (c *FakePolicyBindings) Delete(name string) error { |
33 |
- c.Fake.Lock.Lock() |
|
34 |
- defer c.Fake.Lock.Unlock() |
|
35 |
- |
|
36 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "delete-policyBinding", Value: name}) |
|
37 |
- return nil |
|
46 |
+ _, err := c.Fake.Invokes(ktestclient.NewDeleteAction("policybindings", c.Namespace, name), &authorizationapi.PolicyBinding{}) |
|
47 |
+ return err |
|
38 | 48 |
} |
39 | 49 |
|
40 | 50 |
func (c *FakePolicyBindings) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) { |
41 |
- c.Fake.Lock.Lock() |
|
42 |
- defer c.Fake.Lock.Unlock() |
|
43 |
- |
|
44 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-policyBinding"}) |
|
45 |
- return nil, nil |
|
51 |
+ c.Fake.Invokes(ktestclient.NewWatchAction("policybindings", c.Namespace, label, field, resourceVersion), nil) |
|
52 |
+ return c.Fake.Watch, nil |
|
46 | 53 |
} |
... | ... |
@@ -2,6 +2,7 @@ package testclient |
2 | 2 |
|
3 | 3 |
import ( |
4 | 4 |
kapi "k8s.io/kubernetes/pkg/api" |
5 |
+ ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
|
5 | 6 |
"k8s.io/kubernetes/pkg/fields" |
6 | 7 |
"k8s.io/kubernetes/pkg/labels" |
7 | 8 |
|
... | ... |
@@ -14,12 +15,20 @@ type FakeProjectRequests struct { |
14 | 14 |
Fake *Fake |
15 | 15 |
} |
16 | 16 |
|
17 |
-func (c *FakeProjectRequests) Create(project *projectapi.ProjectRequest) (*projectapi.Project, error) { |
|
18 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "create-newProject", Value: project}, &projectapi.ProjectRequest{}) |
|
19 |
- return obj.(*projectapi.Project), err |
|
20 |
-} |
|
21 |
- |
|
22 | 17 |
func (c *FakeProjectRequests) List(label labels.Selector, field fields.Selector) (*kapi.Status, error) { |
23 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "list-newProject"}, &kapi.Status{}) |
|
18 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootListAction("newprojects", label, field), &kapi.Status{}) |
|
19 |
+ if obj == nil { |
|
20 |
+ return nil, err |
|
21 |
+ } |
|
22 |
+ |
|
24 | 23 |
return obj.(*kapi.Status), err |
25 | 24 |
} |
25 |
+ |
|
26 |
+func (c *FakeProjectRequests) Create(inObj *projectapi.ProjectRequest) (*projectapi.Project, error) { |
|
27 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootCreateAction("newprojects", inObj), &projectapi.Project{}) |
|
28 |
+ if obj == nil { |
|
29 |
+ return nil, err |
|
30 |
+ } |
|
31 |
+ |
|
32 |
+ return obj.(*projectapi.Project), err |
|
33 |
+} |
... | ... |
@@ -1,6 +1,7 @@ |
1 | 1 |
package testclient |
2 | 2 |
|
3 | 3 |
import ( |
4 |
+ ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
|
4 | 5 |
"k8s.io/kubernetes/pkg/fields" |
5 | 6 |
"k8s.io/kubernetes/pkg/labels" |
6 | 7 |
|
... | ... |
@@ -13,30 +14,43 @@ type FakeProjects struct { |
13 | 13 |
Fake *Fake |
14 | 14 |
} |
15 | 15 |
|
16 |
+func (c *FakeProjects) Get(name string) (*projectapi.Project, error) { |
|
17 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootGetAction("projects", name), &projectapi.Project{}) |
|
18 |
+ if obj == nil { |
|
19 |
+ return nil, err |
|
20 |
+ } |
|
21 |
+ |
|
22 |
+ return obj.(*projectapi.Project), err |
|
23 |
+} |
|
24 |
+ |
|
16 | 25 |
func (c *FakeProjects) List(label labels.Selector, field fields.Selector) (*projectapi.ProjectList, error) { |
17 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "list-projects"}, &projectapi.ProjectList{}) |
|
26 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootListAction("projects", label, field), &projectapi.ProjectList{}) |
|
27 |
+ if obj == nil { |
|
28 |
+ return nil, err |
|
29 |
+ } |
|
30 |
+ |
|
18 | 31 |
return obj.(*projectapi.ProjectList), err |
19 | 32 |
} |
20 | 33 |
|
21 |
-func (c *FakeProjects) Get(name string) (*projectapi.Project, error) { |
|
22 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "get-project"}, &projectapi.Project{}) |
|
23 |
- return obj.(*projectapi.Project), err |
|
24 |
-} |
|
34 |
+func (c *FakeProjects) Create(inObj *projectapi.Project) (*projectapi.Project, error) { |
|
35 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootCreateAction("projects", inObj), inObj) |
|
36 |
+ if obj == nil { |
|
37 |
+ return nil, err |
|
38 |
+ } |
|
25 | 39 |
|
26 |
-func (c *FakeProjects) Create(project *projectapi.Project) (*projectapi.Project, error) { |
|
27 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "create-project", Value: project}, &projectapi.Project{}) |
|
28 | 40 |
return obj.(*projectapi.Project), err |
29 | 41 |
} |
30 | 42 |
|
31 |
-func (c *FakeProjects) Update(project *projectapi.Project) (*projectapi.Project, error) { |
|
32 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "update-project"}, &projectapi.Project{}) |
|
43 |
+func (c *FakeProjects) Update(inObj *projectapi.Project) (*projectapi.Project, error) { |
|
44 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootUpdateAction("projects", inObj), inObj) |
|
45 |
+ if obj == nil { |
|
46 |
+ return nil, err |
|
47 |
+ } |
|
48 |
+ |
|
33 | 49 |
return obj.(*projectapi.Project), err |
34 | 50 |
} |
35 | 51 |
|
36 | 52 |
func (c *FakeProjects) Delete(name string) error { |
37 |
- c.Fake.Lock.Lock() |
|
38 |
- defer c.Fake.Lock.Unlock() |
|
39 |
- |
|
40 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "delete-project", Value: name}) |
|
41 |
- return nil |
|
53 |
+ _, err := c.Fake.Invokes(ktestclient.NewRootDeleteAction("projects", name), &projectapi.Project{}) |
|
54 |
+ return err |
|
42 | 55 |
} |
... | ... |
@@ -1,17 +1,24 @@ |
1 | 1 |
package testclient |
2 | 2 |
|
3 | 3 |
import ( |
4 |
+ ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
|
5 |
+ |
|
4 | 6 |
authorizationapi "github.com/openshift/origin/pkg/authorization/api" |
5 | 7 |
) |
6 | 8 |
|
7 | 9 |
// FakeResourceAccessReviews implements ResourceAccessReviewInterface. Meant to be embedded into a struct to get a default |
8 | 10 |
// implementation. This makes faking out just the methods you want to test easier. |
9 | 11 |
type FakeResourceAccessReviews struct { |
10 |
- Fake *Fake |
|
12 |
+ Fake *Fake |
|
13 |
+ Namespace string |
|
11 | 14 |
} |
12 | 15 |
|
13 |
-func (c *FakeResourceAccessReviews) Create(resourceAccessReview *authorizationapi.ResourceAccessReview) (*authorizationapi.ResourceAccessReviewResponse, error) { |
|
14 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "create-resourceAccessReview", Value: resourceAccessReview}, &authorizationapi.ResourceAccessReviewResponse{}) |
|
16 |
+func (c *FakeResourceAccessReviews) Create(inObj *authorizationapi.ResourceAccessReview) (*authorizationapi.ResourceAccessReviewResponse, error) { |
|
17 |
+ obj, err := c.Fake.Invokes(ktestclient.NewCreateAction("resourceaccessreviews", c.Namespace, inObj), inObj) |
|
18 |
+ if obj == nil { |
|
19 |
+ return nil, err |
|
20 |
+ } |
|
21 |
+ |
|
15 | 22 |
return obj.(*authorizationapi.ResourceAccessReviewResponse), err |
16 | 23 |
} |
17 | 24 |
|
... | ... |
@@ -19,7 +26,11 @@ type FakeClusterResourceAccessReviews struct { |
19 | 19 |
Fake *Fake |
20 | 20 |
} |
21 | 21 |
|
22 |
-func (c *FakeClusterResourceAccessReviews) Create(resourceAccessReview *authorizationapi.ResourceAccessReview) (*authorizationapi.ResourceAccessReviewResponse, error) { |
|
23 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "create-cluster-resourceAccessReview", Value: resourceAccessReview}, &authorizationapi.ResourceAccessReviewResponse{}) |
|
22 |
+func (c *FakeClusterResourceAccessReviews) Create(inObj *authorizationapi.ResourceAccessReview) (*authorizationapi.ResourceAccessReviewResponse, error) { |
|
23 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootCreateAction("resourceaccessreviews", inObj), inObj) |
|
24 |
+ if obj == nil { |
|
25 |
+ return nil, err |
|
26 |
+ } |
|
27 |
+ |
|
24 | 28 |
return obj.(*authorizationapi.ResourceAccessReviewResponse), err |
25 | 29 |
} |
... | ... |
@@ -1,6 +1,7 @@ |
1 | 1 |
package testclient |
2 | 2 |
|
3 | 3 |
import ( |
4 |
+ ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
|
4 | 5 |
"k8s.io/kubernetes/pkg/fields" |
5 | 6 |
"k8s.io/kubernetes/pkg/labels" |
6 | 7 |
|
... | ... |
@@ -10,33 +11,47 @@ import ( |
10 | 10 |
// FakeRoleBindings implements RoleBindingInterface. Meant to be embedded into a struct to get a default |
11 | 11 |
// implementation. This makes faking out just the methods you want to test easier. |
12 | 12 |
type FakeRoleBindings struct { |
13 |
- Fake *Fake |
|
13 |
+ Fake *Fake |
|
14 |
+ Namespace string |
|
15 |
+} |
|
16 |
+ |
|
17 |
+func (c *FakeRoleBindings) Get(name string) (*authorizationapi.RoleBinding, error) { |
|
18 |
+ obj, err := c.Fake.Invokes(ktestclient.NewGetAction("rolebindings", c.Namespace, name), &authorizationapi.RoleBinding{}) |
|
19 |
+ if obj == nil { |
|
20 |
+ return nil, err |
|
21 |
+ } |
|
22 |
+ |
|
23 |
+ return obj.(*authorizationapi.RoleBinding), err |
|
14 | 24 |
} |
15 | 25 |
|
16 | 26 |
func (c *FakeRoleBindings) List(label labels.Selector, field fields.Selector) (*authorizationapi.RoleBindingList, error) { |
17 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "list-roleBinding"}, &authorizationapi.RoleBindingList{}) |
|
27 |
+ obj, err := c.Fake.Invokes(ktestclient.NewListAction("rolebindings", c.Namespace, label, field), &authorizationapi.RoleBindingList{}) |
|
28 |
+ if obj == nil { |
|
29 |
+ return nil, err |
|
30 |
+ } |
|
31 |
+ |
|
18 | 32 |
return obj.(*authorizationapi.RoleBindingList), err |
19 | 33 |
} |
20 | 34 |
|
21 |
-func (c *FakeRoleBindings) Get(name string) (*authorizationapi.RoleBinding, error) { |
|
22 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "get-roleBinding"}, &authorizationapi.RoleBinding{}) |
|
23 |
- return obj.(*authorizationapi.RoleBinding), err |
|
24 |
-} |
|
35 |
+func (c *FakeRoleBindings) Create(inObj *authorizationapi.RoleBinding) (*authorizationapi.RoleBinding, error) { |
|
36 |
+ obj, err := c.Fake.Invokes(ktestclient.NewCreateAction("rolebindings", c.Namespace, inObj), inObj) |
|
37 |
+ if obj == nil { |
|
38 |
+ return nil, err |
|
39 |
+ } |
|
25 | 40 |
|
26 |
-func (c *FakeRoleBindings) Create(roleBinding *authorizationapi.RoleBinding) (*authorizationapi.RoleBinding, error) { |
|
27 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "create-roleBinding", Value: roleBinding}, &authorizationapi.RoleBinding{}) |
|
28 | 41 |
return obj.(*authorizationapi.RoleBinding), err |
29 | 42 |
} |
30 | 43 |
|
31 |
-func (c *FakeRoleBindings) Update(roleBinding *authorizationapi.RoleBinding) (*authorizationapi.RoleBinding, error) { |
|
32 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "update-roleBinding"}, &authorizationapi.RoleBinding{}) |
|
44 |
+func (c *FakeRoleBindings) Update(inObj *authorizationapi.RoleBinding) (*authorizationapi.RoleBinding, error) { |
|
45 |
+ obj, err := c.Fake.Invokes(ktestclient.NewUpdateAction("rolebindings", c.Namespace, inObj), inObj) |
|
46 |
+ if obj == nil { |
|
47 |
+ return nil, err |
|
48 |
+ } |
|
49 |
+ |
|
33 | 50 |
return obj.(*authorizationapi.RoleBinding), err |
34 | 51 |
} |
35 | 52 |
|
36 | 53 |
func (c *FakeRoleBindings) Delete(name string) error { |
37 |
- c.Fake.Lock.Lock() |
|
38 |
- defer c.Fake.Lock.Unlock() |
|
39 |
- |
|
40 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "delete-roleBinding", Value: name}) |
|
41 |
- return nil |
|
54 |
+ _, err := c.Fake.Invokes(ktestclient.NewDeleteAction("rolebindings", c.Namespace, name), &authorizationapi.RoleBinding{}) |
|
55 |
+ return err |
|
42 | 56 |
} |
... | ... |
@@ -1,6 +1,7 @@ |
1 | 1 |
package testclient |
2 | 2 |
|
3 | 3 |
import ( |
4 |
+ ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
|
4 | 5 |
"k8s.io/kubernetes/pkg/fields" |
5 | 6 |
"k8s.io/kubernetes/pkg/labels" |
6 | 7 |
|
... | ... |
@@ -10,33 +11,47 @@ import ( |
10 | 10 |
// FakeRoles implements RoleInterface. Meant to be embedded into a struct to get a default |
11 | 11 |
// implementation. This makes faking out just the methods you want to test easier. |
12 | 12 |
type FakeRoles struct { |
13 |
- Fake *Fake |
|
13 |
+ Fake *Fake |
|
14 |
+ Namespace string |
|
15 |
+} |
|
16 |
+ |
|
17 |
+func (c *FakeRoles) Get(name string) (*authorizationapi.Role, error) { |
|
18 |
+ obj, err := c.Fake.Invokes(ktestclient.NewGetAction("roles", c.Namespace, name), &authorizationapi.Role{}) |
|
19 |
+ if obj == nil { |
|
20 |
+ return nil, err |
|
21 |
+ } |
|
22 |
+ |
|
23 |
+ return obj.(*authorizationapi.Role), err |
|
14 | 24 |
} |
15 | 25 |
|
16 | 26 |
func (c *FakeRoles) List(label labels.Selector, field fields.Selector) (*authorizationapi.RoleList, error) { |
17 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "list-role"}, &authorizationapi.RoleList{}) |
|
27 |
+ obj, err := c.Fake.Invokes(ktestclient.NewListAction("roles", c.Namespace, label, field), &authorizationapi.RoleList{}) |
|
28 |
+ if obj == nil { |
|
29 |
+ return nil, err |
|
30 |
+ } |
|
31 |
+ |
|
18 | 32 |
return obj.(*authorizationapi.RoleList), err |
19 | 33 |
} |
20 | 34 |
|
21 |
-func (c *FakeRoles) Get(name string) (*authorizationapi.Role, error) { |
|
22 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "get-role"}, &authorizationapi.Role{}) |
|
23 |
- return obj.(*authorizationapi.Role), err |
|
24 |
-} |
|
35 |
+func (c *FakeRoles) Create(inObj *authorizationapi.Role) (*authorizationapi.Role, error) { |
|
36 |
+ obj, err := c.Fake.Invokes(ktestclient.NewCreateAction("roles", c.Namespace, inObj), inObj) |
|
37 |
+ if obj == nil { |
|
38 |
+ return nil, err |
|
39 |
+ } |
|
25 | 40 |
|
26 |
-func (c *FakeRoles) Create(role *authorizationapi.Role) (*authorizationapi.Role, error) { |
|
27 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "create-role", Value: role}, &authorizationapi.Role{}) |
|
28 | 41 |
return obj.(*authorizationapi.Role), err |
29 | 42 |
} |
30 | 43 |
|
31 |
-func (c *FakeRoles) Update(role *authorizationapi.Role) (*authorizationapi.Role, error) { |
|
32 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "update-role"}, &authorizationapi.Role{}) |
|
44 |
+func (c *FakeRoles) Update(inObj *authorizationapi.Role) (*authorizationapi.Role, error) { |
|
45 |
+ obj, err := c.Fake.Invokes(ktestclient.NewUpdateAction("roles", c.Namespace, inObj), inObj) |
|
46 |
+ if obj == nil { |
|
47 |
+ return nil, err |
|
48 |
+ } |
|
49 |
+ |
|
33 | 50 |
return obj.(*authorizationapi.Role), err |
34 | 51 |
} |
35 | 52 |
|
36 | 53 |
func (c *FakeRoles) Delete(name string) error { |
37 |
- c.Fake.Lock.Lock() |
|
38 |
- defer c.Fake.Lock.Unlock() |
|
39 |
- |
|
40 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "delete-role", Value: name}) |
|
41 |
- return nil |
|
54 |
+ _, err := c.Fake.Invokes(ktestclient.NewDeleteAction("roles", c.Namespace, name), &authorizationapi.Role{}) |
|
55 |
+ return err |
|
42 | 56 |
} |
... | ... |
@@ -1,6 +1,7 @@ |
1 | 1 |
package testclient |
2 | 2 |
|
3 | 3 |
import ( |
4 |
+ ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
|
4 | 5 |
"k8s.io/kubernetes/pkg/fields" |
5 | 6 |
"k8s.io/kubernetes/pkg/labels" |
6 | 7 |
"k8s.io/kubernetes/pkg/watch" |
... | ... |
@@ -15,38 +16,48 @@ type FakeRoutes struct { |
15 | 15 |
Namespace string |
16 | 16 |
} |
17 | 17 |
|
18 |
+func (c *FakeRoutes) Get(name string) (*routeapi.Route, error) { |
|
19 |
+ obj, err := c.Fake.Invokes(ktestclient.NewGetAction("routes", c.Namespace, name), &routeapi.Route{}) |
|
20 |
+ if obj == nil { |
|
21 |
+ return nil, err |
|
22 |
+ } |
|
23 |
+ |
|
24 |
+ return obj.(*routeapi.Route), err |
|
25 |
+} |
|
26 |
+ |
|
18 | 27 |
func (c *FakeRoutes) List(label labels.Selector, field fields.Selector) (*routeapi.RouteList, error) { |
19 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "list-routes"}, &routeapi.RouteList{}) |
|
28 |
+ obj, err := c.Fake.Invokes(ktestclient.NewListAction("routes", c.Namespace, label, field), &routeapi.RouteList{}) |
|
29 |
+ if obj == nil { |
|
30 |
+ return nil, err |
|
31 |
+ } |
|
32 |
+ |
|
20 | 33 |
return obj.(*routeapi.RouteList), err |
21 | 34 |
} |
22 | 35 |
|
23 |
-func (c *FakeRoutes) Get(name string) (*routeapi.Route, error) { |
|
24 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "get-route"}, &routeapi.Route{}) |
|
25 |
- return obj.(*routeapi.Route), err |
|
26 |
-} |
|
36 |
+func (c *FakeRoutes) Create(inObj *routeapi.Route) (*routeapi.Route, error) { |
|
37 |
+ obj, err := c.Fake.Invokes(ktestclient.NewCreateAction("routes", c.Namespace, inObj), inObj) |
|
38 |
+ if obj == nil { |
|
39 |
+ return nil, err |
|
40 |
+ } |
|
27 | 41 |
|
28 |
-func (c *FakeRoutes) Create(route *routeapi.Route) (*routeapi.Route, error) { |
|
29 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "create-route"}, &routeapi.Route{}) |
|
30 | 42 |
return obj.(*routeapi.Route), err |
31 | 43 |
} |
32 | 44 |
|
33 |
-func (c *FakeRoutes) Update(route *routeapi.Route) (*routeapi.Route, error) { |
|
34 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "update-route"}, &routeapi.Route{}) |
|
45 |
+func (c *FakeRoutes) Update(inObj *routeapi.Route) (*routeapi.Route, error) { |
|
46 |
+ obj, err := c.Fake.Invokes(ktestclient.NewUpdateAction("routes", c.Namespace, inObj), inObj) |
|
47 |
+ if obj == nil { |
|
48 |
+ return nil, err |
|
49 |
+ } |
|
50 |
+ |
|
35 | 51 |
return obj.(*routeapi.Route), err |
36 | 52 |
} |
37 | 53 |
|
38 | 54 |
func (c *FakeRoutes) Delete(name string) error { |
39 |
- c.Fake.Lock.Lock() |
|
40 |
- defer c.Fake.Lock.Unlock() |
|
41 |
- |
|
42 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "delete-route"}) |
|
43 |
- return nil |
|
55 |
+ _, err := c.Fake.Invokes(ktestclient.NewDeleteAction("routes", c.Namespace, name), &routeapi.Route{}) |
|
56 |
+ return err |
|
44 | 57 |
} |
45 | 58 |
|
46 | 59 |
func (c *FakeRoutes) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) { |
47 |
- c.Fake.Lock.Lock() |
|
48 |
- defer c.Fake.Lock.Unlock() |
|
49 |
- |
|
50 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-routes"}) |
|
51 |
- return nil, nil |
|
60 |
+ c.Fake.Invokes(ktestclient.NewWatchAction("routes", c.Namespace, label, field, resourceVersion), nil) |
|
61 |
+ return c.Fake.Watch, nil |
|
52 | 62 |
} |
... | ... |
@@ -1,17 +1,24 @@ |
1 | 1 |
package testclient |
2 | 2 |
|
3 | 3 |
import ( |
4 |
+ ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
|
5 |
+ |
|
4 | 6 |
authorizationapi "github.com/openshift/origin/pkg/authorization/api" |
5 | 7 |
) |
6 | 8 |
|
7 | 9 |
// FakeSubjectAccessReviews implements SubjectAccessReviewInterface. Meant to be embedded into a struct to get a default |
8 | 10 |
// implementation. This makes faking out just the methods you want to test easier. |
9 | 11 |
type FakeSubjectAccessReviews struct { |
10 |
- Fake *Fake |
|
12 |
+ Fake *Fake |
|
13 |
+ Namespace string |
|
11 | 14 |
} |
12 | 15 |
|
13 |
-func (c *FakeSubjectAccessReviews) Create(subjectAccessReview *authorizationapi.SubjectAccessReview) (*authorizationapi.SubjectAccessReviewResponse, error) { |
|
14 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "create-subjectAccessReview", Value: subjectAccessReview}, &authorizationapi.SubjectAccessReviewResponse{}) |
|
16 |
+func (c *FakeSubjectAccessReviews) Create(inObj *authorizationapi.SubjectAccessReview) (*authorizationapi.SubjectAccessReviewResponse, error) { |
|
17 |
+ obj, err := c.Fake.Invokes(ktestclient.NewCreateAction("subjectaccessreviews", c.Namespace, inObj), inObj) |
|
18 |
+ if obj == nil { |
|
19 |
+ return nil, err |
|
20 |
+ } |
|
21 |
+ |
|
15 | 22 |
return obj.(*authorizationapi.SubjectAccessReviewResponse), err |
16 | 23 |
} |
17 | 24 |
|
... | ... |
@@ -22,7 +29,11 @@ type FakeClusterSubjectAccessReviews struct { |
22 | 22 |
Fake *Fake |
23 | 23 |
} |
24 | 24 |
|
25 |
-func (c *FakeClusterSubjectAccessReviews) Create(resourceAccessReview *authorizationapi.SubjectAccessReview) (*authorizationapi.SubjectAccessReviewResponse, error) { |
|
26 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "create-cluster-subjectAccessReview", Value: resourceAccessReview}, &authorizationapi.SubjectAccessReviewResponse{}) |
|
25 |
+func (c *FakeClusterSubjectAccessReviews) Create(inObj *authorizationapi.SubjectAccessReview) (*authorizationapi.SubjectAccessReviewResponse, error) { |
|
26 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootCreateAction("subjectaccessreviews", inObj), inObj) |
|
27 |
+ if obj == nil { |
|
28 |
+ return nil, err |
|
29 |
+ } |
|
30 |
+ |
|
27 | 31 |
return obj.(*authorizationapi.SubjectAccessReviewResponse), err |
28 | 32 |
} |
... | ... |
@@ -1,6 +1,8 @@ |
1 | 1 |
package testclient |
2 | 2 |
|
3 | 3 |
import ( |
4 |
+ ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
|
5 |
+ |
|
4 | 6 |
templateapi "github.com/openshift/origin/pkg/template/api" |
5 | 7 |
) |
6 | 8 |
|
... | ... |
@@ -11,7 +13,11 @@ type FakeTemplateConfigs struct { |
11 | 11 |
Namespace string |
12 | 12 |
} |
13 | 13 |
|
14 |
-func (c *FakeTemplateConfigs) Create(template *templateapi.Template) (*templateapi.Template, error) { |
|
15 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "create-template-config", Value: template}, &templateapi.Template{}) |
|
14 |
+func (c *FakeTemplateConfigs) Create(inObj *templateapi.Template) (*templateapi.Template, error) { |
|
15 |
+ obj, err := c.Fake.Invokes(ktestclient.NewCreateAction("templateconfigs", c.Namespace, inObj), inObj) |
|
16 |
+ if obj == nil { |
|
17 |
+ return nil, err |
|
18 |
+ } |
|
19 |
+ |
|
16 | 20 |
return obj.(*templateapi.Template), err |
17 | 21 |
} |
... | ... |
@@ -1,6 +1,7 @@ |
1 | 1 |
package testclient |
2 | 2 |
|
3 | 3 |
import ( |
4 |
+ ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
|
4 | 5 |
"k8s.io/kubernetes/pkg/fields" |
5 | 6 |
"k8s.io/kubernetes/pkg/labels" |
6 | 7 |
"k8s.io/kubernetes/pkg/watch" |
... | ... |
@@ -15,38 +16,48 @@ type FakeTemplates struct { |
15 | 15 |
Namespace string |
16 | 16 |
} |
17 | 17 |
|
18 |
+func (c *FakeTemplates) Get(name string) (*templateapi.Template, error) { |
|
19 |
+ obj, err := c.Fake.Invokes(ktestclient.NewGetAction("templates", c.Namespace, name), &templateapi.Template{}) |
|
20 |
+ if obj == nil { |
|
21 |
+ return nil, err |
|
22 |
+ } |
|
23 |
+ |
|
24 |
+ return obj.(*templateapi.Template), err |
|
25 |
+} |
|
26 |
+ |
|
18 | 27 |
func (c *FakeTemplates) List(label labels.Selector, field fields.Selector) (*templateapi.TemplateList, error) { |
19 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "list-templates"}, &templateapi.TemplateList{}) |
|
28 |
+ obj, err := c.Fake.Invokes(ktestclient.NewListAction("templates", c.Namespace, label, field), &templateapi.TemplateList{}) |
|
29 |
+ if obj == nil { |
|
30 |
+ return nil, err |
|
31 |
+ } |
|
32 |
+ |
|
20 | 33 |
return obj.(*templateapi.TemplateList), err |
21 | 34 |
} |
22 | 35 |
|
23 |
-func (c *FakeTemplates) Get(name string) (*templateapi.Template, error) { |
|
24 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "get-template"}, &templateapi.Template{}) |
|
25 |
- return obj.(*templateapi.Template), err |
|
26 |
-} |
|
36 |
+func (c *FakeTemplates) Create(inObj *templateapi.Template) (*templateapi.Template, error) { |
|
37 |
+ obj, err := c.Fake.Invokes(ktestclient.NewCreateAction("templates", c.Namespace, inObj), inObj) |
|
38 |
+ if obj == nil { |
|
39 |
+ return nil, err |
|
40 |
+ } |
|
27 | 41 |
|
28 |
-func (c *FakeTemplates) Create(template *templateapi.Template) (*templateapi.Template, error) { |
|
29 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "create-template", Value: template}, &templateapi.Template{}) |
|
30 | 42 |
return obj.(*templateapi.Template), err |
31 | 43 |
} |
32 | 44 |
|
33 |
-func (c *FakeTemplates) Update(template *templateapi.Template) (*templateapi.Template, error) { |
|
34 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "update-template"}, &templateapi.Template{}) |
|
45 |
+func (c *FakeTemplates) Update(inObj *templateapi.Template) (*templateapi.Template, error) { |
|
46 |
+ obj, err := c.Fake.Invokes(ktestclient.NewUpdateAction("templates", c.Namespace, inObj), inObj) |
|
47 |
+ if obj == nil { |
|
48 |
+ return nil, err |
|
49 |
+ } |
|
50 |
+ |
|
35 | 51 |
return obj.(*templateapi.Template), err |
36 | 52 |
} |
37 | 53 |
|
38 | 54 |
func (c *FakeTemplates) Delete(name string) error { |
39 |
- c.Fake.Lock.Lock() |
|
40 |
- defer c.Fake.Lock.Unlock() |
|
41 |
- |
|
42 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "delete-template", Value: name}) |
|
43 |
- return nil |
|
55 |
+ _, err := c.Fake.Invokes(ktestclient.NewDeleteAction("templates", c.Namespace, name), &templateapi.Template{}) |
|
56 |
+ return err |
|
44 | 57 |
} |
45 | 58 |
|
46 | 59 |
func (c *FakeTemplates) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) { |
47 |
- c.Fake.Lock.Lock() |
|
48 |
- defer c.Fake.Lock.Unlock() |
|
49 |
- |
|
50 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-templates"}) |
|
51 |
- return nil, nil |
|
60 |
+ c.Fake.Invokes(ktestclient.NewWatchAction("templates", c.Namespace, label, field, resourceVersion), nil) |
|
61 |
+ return c.Fake.Watch, nil |
|
52 | 62 |
} |
... | ... |
@@ -1,6 +1,8 @@ |
1 | 1 |
package testclient |
2 | 2 |
|
3 | 3 |
import ( |
4 |
+ ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
|
5 |
+ |
|
4 | 6 |
userapi "github.com/openshift/origin/pkg/user/api" |
5 | 7 |
) |
6 | 8 |
|
... | ... |
@@ -11,24 +13,33 @@ type FakeUserIdentityMappings struct { |
11 | 11 |
} |
12 | 12 |
|
13 | 13 |
func (c *FakeUserIdentityMappings) Get(name string) (*userapi.UserIdentityMapping, error) { |
14 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "get-useridentitymapping", Value: name}, &userapi.UserIdentityMapping{}) |
|
14 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootGetAction("useridentitymappings", name), &userapi.UserIdentityMapping{}) |
|
15 |
+ if obj == nil { |
|
16 |
+ return nil, err |
|
17 |
+ } |
|
18 |
+ |
|
15 | 19 |
return obj.(*userapi.UserIdentityMapping), err |
16 | 20 |
} |
17 | 21 |
|
18 |
-func (c *FakeUserIdentityMappings) Create(mapping *userapi.UserIdentityMapping) (*userapi.UserIdentityMapping, error) { |
|
19 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "create-useridentitymapping", Value: mapping}, &userapi.UserIdentityMapping{}) |
|
22 |
+func (c *FakeUserIdentityMappings) Create(inObj *userapi.UserIdentityMapping) (*userapi.UserIdentityMapping, error) { |
|
23 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootCreateAction("useridentitymappings", inObj), inObj) |
|
24 |
+ if obj == nil { |
|
25 |
+ return nil, err |
|
26 |
+ } |
|
27 |
+ |
|
20 | 28 |
return obj.(*userapi.UserIdentityMapping), err |
21 | 29 |
} |
22 | 30 |
|
23 |
-func (c *FakeUserIdentityMappings) Update(mapping *userapi.UserIdentityMapping) (*userapi.UserIdentityMapping, error) { |
|
24 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "update-useridentitymapping", Value: mapping}, &userapi.UserIdentityMapping{}) |
|
31 |
+func (c *FakeUserIdentityMappings) Update(inObj *userapi.UserIdentityMapping) (*userapi.UserIdentityMapping, error) { |
|
32 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootUpdateAction("useridentitymappings", inObj), inObj) |
|
33 |
+ if obj == nil { |
|
34 |
+ return nil, err |
|
35 |
+ } |
|
36 |
+ |
|
25 | 37 |
return obj.(*userapi.UserIdentityMapping), err |
26 | 38 |
} |
27 | 39 |
|
28 | 40 |
func (c *FakeUserIdentityMappings) Delete(name string) error { |
29 |
- c.Fake.Lock.Lock() |
|
30 |
- defer c.Fake.Lock.Unlock() |
|
31 |
- |
|
32 |
- c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "delete-useridentitymapping", Value: name}) |
|
33 |
- return nil |
|
41 |
+ _, err := c.Fake.Invokes(ktestclient.NewRootDeleteAction("useridentitymappings", name), &userapi.UserIdentityMapping{}) |
|
42 |
+ return err |
|
34 | 43 |
} |
... | ... |
@@ -1,9 +1,11 @@ |
1 | 1 |
package testclient |
2 | 2 |
|
3 | 3 |
import ( |
4 |
- userapi "github.com/openshift/origin/pkg/user/api" |
|
4 |
+ ktestclient "k8s.io/kubernetes/pkg/client/testclient" |
|
5 | 5 |
"k8s.io/kubernetes/pkg/fields" |
6 | 6 |
"k8s.io/kubernetes/pkg/labels" |
7 |
+ |
|
8 |
+ userapi "github.com/openshift/origin/pkg/user/api" |
|
7 | 9 |
) |
8 | 10 |
|
9 | 11 |
// FakeUsers implements UsersInterface. Meant to be embedded into a struct to get a default |
... | ... |
@@ -12,22 +14,38 @@ type FakeUsers struct { |
12 | 12 |
Fake *Fake |
13 | 13 |
} |
14 | 14 |
|
15 |
+func (c *FakeUsers) Get(name string) (*userapi.User, error) { |
|
16 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootGetAction("users", name), &userapi.User{}) |
|
17 |
+ if obj == nil { |
|
18 |
+ return nil, err |
|
19 |
+ } |
|
20 |
+ |
|
21 |
+ return obj.(*userapi.User), err |
|
22 |
+} |
|
23 |
+ |
|
15 | 24 |
func (c *FakeUsers) List(label labels.Selector, field fields.Selector) (*userapi.UserList, error) { |
16 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "list-users"}, &userapi.UserList{}) |
|
25 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootListAction("users", label, field), &userapi.UserList{}) |
|
26 |
+ if obj == nil { |
|
27 |
+ return nil, err |
|
28 |
+ } |
|
29 |
+ |
|
17 | 30 |
return obj.(*userapi.UserList), err |
18 | 31 |
} |
19 | 32 |
|
20 |
-func (c *FakeUsers) Get(name string) (*userapi.User, error) { |
|
21 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "get-user", Value: name}, &userapi.User{}) |
|
22 |
- return obj.(*userapi.User), err |
|
23 |
-} |
|
33 |
+func (c *FakeUsers) Create(inObj *userapi.User) (*userapi.User, error) { |
|
34 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootCreateAction("users", inObj), inObj) |
|
35 |
+ if obj == nil { |
|
36 |
+ return nil, err |
|
37 |
+ } |
|
24 | 38 |
|
25 |
-func (c *FakeUsers) Create(user *userapi.User) (*userapi.User, error) { |
|
26 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "create-user", Value: user}, &userapi.User{}) |
|
27 | 39 |
return obj.(*userapi.User), err |
28 | 40 |
} |
29 | 41 |
|
30 |
-func (c *FakeUsers) Update(user *userapi.User) (*userapi.User, error) { |
|
31 |
- obj, err := c.Fake.Invokes(FakeAction{Action: "update-user", Value: user}, &userapi.User{}) |
|
42 |
+func (c *FakeUsers) Update(inObj *userapi.User) (*userapi.User, error) { |
|
43 |
+ obj, err := c.Fake.Invokes(ktestclient.NewRootUpdateAction("users", inObj), inObj) |
|
44 |
+ if obj == nil { |
|
45 |
+ return nil, err |
|
46 |
+ } |
|
47 |
+ |
|
32 | 48 |
return obj.(*userapi.User), err |
33 | 49 |
} |
... | ... |
@@ -1,6 +1,7 @@ |
1 | 1 |
package reaper |
2 | 2 |
|
3 | 3 |
import ( |
4 |
+ "reflect" |
|
4 | 5 |
"testing" |
5 | 6 |
"time" |
6 | 7 |
|
... | ... |
@@ -38,8 +39,8 @@ func TestStop(t *testing.T) { |
38 | 38 |
name string |
39 | 39 |
oc *testclient.Fake |
40 | 40 |
kc *ktestclient.Fake |
41 |
- expected []string |
|
42 |
- kexpected []string |
|
41 |
+ expected []ktestclient.Action |
|
42 |
+ kexpected []ktestclient.Action |
|
43 | 43 |
output string |
44 | 44 |
err bool |
45 | 45 |
}{ |
... | ... |
@@ -49,18 +50,18 @@ func TestStop(t *testing.T) { |
49 | 49 |
name: "config", |
50 | 50 |
oc: testclient.NewSimpleFake(deploytest.OkDeploymentConfig(1)), |
51 | 51 |
kc: ktestclient.NewSimpleFake(mkdeploymentlist(1)), |
52 |
- expected: []string{ |
|
53 |
- "delete-deploymentconfig", |
|
52 |
+ expected: []ktestclient.Action{ |
|
53 |
+ ktestclient.NewDeleteAction("deploymentconfigs", "default", "config"), |
|
54 | 54 |
}, |
55 |
- kexpected: []string{ |
|
56 |
- "list-replicationController", |
|
57 |
- "get-replicationController", |
|
58 |
- "list-replicationController", |
|
59 |
- "get-replicationController", |
|
60 |
- "update-replicationController", |
|
61 |
- "get-replicationController", |
|
62 |
- "get-replicationController", |
|
63 |
- "delete-replicationController", |
|
55 |
+ kexpected: []ktestclient.Action{ |
|
56 |
+ ktestclient.NewListAction("replicationcontrollers", "default", nil, nil), |
|
57 |
+ ktestclient.NewGetAction("replicationcontrollers", "", "config-1"), |
|
58 |
+ ktestclient.NewListAction("replicationcontrollers", "", nil, nil), |
|
59 |
+ ktestclient.NewGetAction("replicationcontrollers", "", "config-1"), |
|
60 |
+ ktestclient.NewUpdateAction("replicationcontrollers", "", nil), |
|
61 |
+ ktestclient.NewGetAction("replicationcontrollers", "", "config-1"), |
|
62 |
+ ktestclient.NewGetAction("replicationcontrollers", "", "config-1"), |
|
63 |
+ ktestclient.NewDeleteAction("replicationcontrollers", "", "config-1"), |
|
64 | 64 |
}, |
65 | 65 |
output: "config stopped", |
66 | 66 |
err: false, |
... | ... |
@@ -71,46 +72,46 @@ func TestStop(t *testing.T) { |
71 | 71 |
name: "config", |
72 | 72 |
oc: testclient.NewSimpleFake(deploytest.OkDeploymentConfig(5)), |
73 | 73 |
kc: ktestclient.NewSimpleFake(mkdeploymentlist(1, 2, 3, 4, 5)), |
74 |
- expected: []string{ |
|
75 |
- "delete-deploymentconfig", |
|
74 |
+ expected: []ktestclient.Action{ |
|
75 |
+ ktestclient.NewDeleteAction("deploymentconfigs", "default", "config"), |
|
76 | 76 |
}, |
77 |
- kexpected: []string{ |
|
78 |
- "list-replicationController", |
|
79 |
- "get-replicationController", |
|
80 |
- "list-replicationController", |
|
81 |
- "get-replicationController", |
|
82 |
- "update-replicationController", |
|
83 |
- "get-replicationController", |
|
84 |
- "get-replicationController", |
|
85 |
- "delete-replicationController", |
|
86 |
- "get-replicationController", |
|
87 |
- "list-replicationController", |
|
88 |
- "get-replicationController", |
|
89 |
- "update-replicationController", |
|
90 |
- "get-replicationController", |
|
91 |
- "get-replicationController", |
|
92 |
- "delete-replicationController", |
|
93 |
- "get-replicationController", |
|
94 |
- "list-replicationController", |
|
95 |
- "get-replicationController", |
|
96 |
- "update-replicationController", |
|
97 |
- "get-replicationController", |
|
98 |
- "get-replicationController", |
|
99 |
- "delete-replicationController", |
|
100 |
- "get-replicationController", |
|
101 |
- "list-replicationController", |
|
102 |
- "get-replicationController", |
|
103 |
- "update-replicationController", |
|
104 |
- "get-replicationController", |
|
105 |
- "get-replicationController", |
|
106 |
- "delete-replicationController", |
|
107 |
- "get-replicationController", |
|
108 |
- "list-replicationController", |
|
109 |
- "get-replicationController", |
|
110 |
- "update-replicationController", |
|
111 |
- "get-replicationController", |
|
112 |
- "get-replicationController", |
|
113 |
- "delete-replicationController", |
|
77 |
+ kexpected: []ktestclient.Action{ |
|
78 |
+ ktestclient.NewListAction("replicationcontrollers", "default", nil, nil), |
|
79 |
+ ktestclient.NewGetAction("replicationcontrollers", "", "config-1"), |
|
80 |
+ ktestclient.NewListAction("replicationcontrollers", "", nil, nil), |
|
81 |
+ ktestclient.NewGetAction("replicationcontrollers", "", "config-1"), |
|
82 |
+ ktestclient.NewUpdateAction("replicationcontrollers", "", nil), |
|
83 |
+ ktestclient.NewGetAction("replicationcontrollers", "", "config-1"), |
|
84 |
+ ktestclient.NewGetAction("replicationcontrollers", "", "config-4"), |
|
85 |
+ ktestclient.NewDeleteAction("replicationcontrollers", "", "config-1"), |
|
86 |
+ ktestclient.NewGetAction("replicationcontrollers", "", "config-2"), |
|
87 |
+ ktestclient.NewListAction("replicationcontrollers", "", nil, nil), |
|
88 |
+ ktestclient.NewGetAction("replicationcontrollers", "", "config-2"), |
|
89 |
+ ktestclient.NewUpdateAction("replicationcontrollers", "", nil), |
|
90 |
+ ktestclient.NewGetAction("replicationcontrollers", "", "config-2"), |
|
91 |
+ ktestclient.NewGetAction("replicationcontrollers", "", "config-5"), |
|
92 |
+ ktestclient.NewDeleteAction("replicationcontrollers", "", "config-2"), |
|
93 |
+ ktestclient.NewGetAction("replicationcontrollers", "", "config-3"), |
|
94 |
+ ktestclient.NewListAction("replicationcontrollers", "", nil, nil), |
|
95 |
+ ktestclient.NewGetAction("replicationcontrollers", "", "config-3"), |
|
96 |
+ ktestclient.NewUpdateAction("replicationcontrollers", "", nil), |
|
97 |
+ ktestclient.NewGetAction("replicationcontrollers", "", "config-3"), |
|
98 |
+ ktestclient.NewGetAction("replicationcontrollers", "", "config-5"), |
|
99 |
+ ktestclient.NewDeleteAction("replicationcontrollers", "", "config-3"), |
|
100 |
+ ktestclient.NewGetAction("replicationcontrollers", "", "config-4"), |
|
101 |
+ ktestclient.NewListAction("replicationcontrollers", "", nil, nil), |
|
102 |
+ ktestclient.NewGetAction("replicationcontrollers", "", "config-4"), |
|
103 |
+ ktestclient.NewUpdateAction("replicationcontrollers", "", nil), |
|
104 |
+ ktestclient.NewGetAction("replicationcontrollers", "", "config-4"), |
|
105 |
+ ktestclient.NewGetAction("replicationcontrollers", "", "config-5"), |
|
106 |
+ ktestclient.NewDeleteAction("replicationcontrollers", "", "config-4"), |
|
107 |
+ ktestclient.NewGetAction("replicationcontrollers", "", "config-5"), |
|
108 |
+ ktestclient.NewListAction("replicationcontrollers", "", nil, nil), |
|
109 |
+ ktestclient.NewGetAction("replicationcontrollers", "", "config-5"), |
|
110 |
+ ktestclient.NewUpdateAction("replicationcontrollers", "", nil), |
|
111 |
+ ktestclient.NewGetAction("replicationcontrollers", "", "config-5"), |
|
112 |
+ ktestclient.NewGetAction("replicationcontrollers", "", "config-5"), |
|
113 |
+ ktestclient.NewDeleteAction("replicationcontrollers", "", "config-5"), |
|
114 | 114 |
}, |
115 | 115 |
output: "config stopped", |
116 | 116 |
err: false, |
... | ... |
@@ -121,18 +122,18 @@ func TestStop(t *testing.T) { |
121 | 121 |
name: "config", |
122 | 122 |
oc: testclient.NewSimpleFake(notfound()), |
123 | 123 |
kc: ktestclient.NewSimpleFake(mkdeploymentlist(1)), |
124 |
- expected: []string{ |
|
125 |
- "delete-deploymentconfig", |
|
124 |
+ expected: []ktestclient.Action{ |
|
125 |
+ ktestclient.NewDeleteAction("deploymentconfigs", "default", "config"), |
|
126 | 126 |
}, |
127 |
- kexpected: []string{ |
|
128 |
- "list-replicationController", |
|
129 |
- "get-replicationController", |
|
130 |
- "list-replicationController", |
|
131 |
- "get-replicationController", |
|
132 |
- "update-replicationController", |
|
133 |
- "get-replicationController", |
|
134 |
- "get-replicationController", |
|
135 |
- "delete-replicationController", |
|
127 |
+ kexpected: []ktestclient.Action{ |
|
128 |
+ ktestclient.NewListAction("replicationcontrollers", "default", nil, nil), |
|
129 |
+ ktestclient.NewGetAction("replicationcontrollers", "", "config-1"), |
|
130 |
+ ktestclient.NewListAction("replicationcontrollers", "", nil, nil), |
|
131 |
+ ktestclient.NewGetAction("replicationcontrollers", "", "config-1"), |
|
132 |
+ ktestclient.NewUpdateAction("replicationcontrollers", "", nil), |
|
133 |
+ ktestclient.NewGetAction("replicationcontrollers", "", "config-1"), |
|
134 |
+ ktestclient.NewGetAction("replicationcontrollers", "", "config-1"), |
|
135 |
+ ktestclient.NewDeleteAction("replicationcontrollers", "", "config-1"), |
|
136 | 136 |
}, |
137 | 137 |
output: "config stopped", |
138 | 138 |
err: false, |
... | ... |
@@ -143,11 +144,11 @@ func TestStop(t *testing.T) { |
143 | 143 |
name: "config", |
144 | 144 |
oc: testclient.NewSimpleFake(notfound()), |
145 | 145 |
kc: ktestclient.NewSimpleFake(&kapi.ReplicationControllerList{}), |
146 |
- expected: []string{ |
|
147 |
- "delete-deploymentconfig", |
|
146 |
+ expected: []ktestclient.Action{ |
|
147 |
+ ktestclient.NewDeleteAction("deploymentconfigs", "default", "config"), |
|
148 | 148 |
}, |
149 |
- kexpected: []string{ |
|
150 |
- "list-replicationController", |
|
149 |
+ kexpected: []ktestclient.Action{ |
|
150 |
+ ktestclient.NewListAction("replicationcontrollers", "default", nil, nil), |
|
151 | 151 |
}, |
152 | 152 |
output: "", |
153 | 153 |
err: true, |
... | ... |
@@ -158,11 +159,11 @@ func TestStop(t *testing.T) { |
158 | 158 |
name: "config", |
159 | 159 |
oc: testclient.NewSimpleFake(deploytest.OkDeploymentConfig(5)), |
160 | 160 |
kc: ktestclient.NewSimpleFake(&kapi.ReplicationControllerList{}), |
161 |
- expected: []string{ |
|
162 |
- "delete-deploymentconfig", |
|
161 |
+ expected: []ktestclient.Action{ |
|
162 |
+ ktestclient.NewDeleteAction("deploymentconfigs", "default", "config"), |
|
163 | 163 |
}, |
164 |
- kexpected: []string{ |
|
165 |
- "list-replicationController", |
|
164 |
+ kexpected: []ktestclient.Action{ |
|
165 |
+ ktestclient.NewListAction("replicationcontrollers", "default", nil, nil), |
|
166 | 166 |
}, |
167 | 167 |
output: "config stopped", |
168 | 168 |
err: false, |
... | ... |
@@ -179,20 +180,31 @@ func TestStop(t *testing.T) { |
179 | 179 |
if test.err && err == nil { |
180 | 180 |
t.Errorf("%s: expected an error", test.testName) |
181 | 181 |
} |
182 |
- if len(test.oc.Actions) != len(test.expected) { |
|
182 |
+ if len(test.oc.Actions()) != len(test.expected) { |
|
183 | 183 |
t.Fatalf("%s: unexpected actions: %v, expected %v", test.testName, test.oc.Actions, test.expected) |
184 | 184 |
} |
185 |
- for j, fake := range test.oc.Actions { |
|
186 |
- if fake.Action != test.expected[j] { |
|
187 |
- t.Errorf("%s: unexpected action: %s, expected %s", test.testName, fake.Action, test.expected[j]) |
|
185 |
+ for j, actualAction := range test.oc.Actions() { |
|
186 |
+ if !reflect.DeepEqual(actualAction, test.expected[j]) { |
|
187 |
+ t.Errorf("%s: unexpected action: %s, expected %s", test.testName, actualAction, test.expected[j]) |
|
188 | 188 |
} |
189 | 189 |
} |
190 | 190 |
if len(test.kc.Actions()) != len(test.kexpected) { |
191 | 191 |
t.Fatalf("%s: unexpected actions: %v, expected %v", test.testName, test.kc.Actions(), test.kexpected) |
192 | 192 |
} |
193 |
- for j, fake := range test.kc.Actions() { |
|
194 |
- if fake.Action != test.kexpected[j] { |
|
195 |
- t.Errorf("%s: unexpected action: %s, expected %s", test.testName, fake.Action, test.kexpected[j]) |
|
193 |
+ for j, actualAction := range test.kc.Actions() { |
|
194 |
+ e, a := test.kexpected[j], actualAction |
|
195 |
+ if e.GetVerb() != a.GetVerb() || |
|
196 |
+ e.GetNamespace() != a.GetNamespace() || |
|
197 |
+ e.GetResource() != a.GetResource() || |
|
198 |
+ e.GetSubresource() != a.GetSubresource() { |
|
199 |
+ t.Errorf("%s: unexpected action[%d]: %s, expected %s", test.testName, j, a, e) |
|
200 |
+ } |
|
201 |
+ |
|
202 |
+ switch a.(type) { |
|
203 |
+ case ktestclient.GetAction, ktestclient.DeleteAction: |
|
204 |
+ if !reflect.DeepEqual(e, a) { |
|
205 |
+ t.Errorf("%s: unexpected action[%d]: %s, expected %s", test.testName, j, a, e) |
|
206 |
+ } |
|
196 | 207 |
} |
197 | 208 |
} |
198 | 209 |
if out != test.output { |
... | ... |
@@ -1,6 +1,7 @@ |
1 | 1 |
package scaler |
2 | 2 |
|
3 | 3 |
import ( |
4 |
+ "reflect" |
|
4 | 5 |
"testing" |
5 | 6 |
"time" |
6 | 7 |
|
... | ... |
@@ -36,8 +37,8 @@ func TestScale(t *testing.T) { |
36 | 36 |
retry, waitForReplicas *kubectl.RetryParams |
37 | 37 |
oc *testclient.Fake |
38 | 38 |
kc *ktestclient.Fake |
39 |
- expected []string |
|
40 |
- kexpected []string |
|
39 |
+ expected []ktestclient.Action |
|
40 |
+ kexpected []ktestclient.Action |
|
41 | 41 |
expectedErr error |
42 | 42 |
}{ |
43 | 43 |
{ |
... | ... |
@@ -47,12 +48,12 @@ func TestScale(t *testing.T) { |
47 | 47 |
count: uint(3), |
48 | 48 |
oc: testclient.NewSimpleFake(deploytest.OkDeploymentConfig(1)), |
49 | 49 |
kc: ktestclient.NewSimpleFake(mkDeploymentList(1)), |
50 |
- expected: []string{ |
|
51 |
- "get-deploymentconfig", |
|
50 |
+ expected: []ktestclient.Action{ |
|
51 |
+ ktestclient.NewGetAction("deploymentconfigs", "default", "foo"), |
|
52 | 52 |
}, |
53 |
- kexpected: []string{ |
|
54 |
- "get-replicationController", |
|
55 |
- "update-replicationController", |
|
53 |
+ kexpected: []ktestclient.Action{ |
|
54 |
+ ktestclient.NewGetAction("replicationcontrollers", "default", "config-1"), |
|
55 |
+ ktestclient.NewUpdateAction("replicationcontrollers", "default", nil), |
|
56 | 56 |
}, |
57 | 57 |
expectedErr: nil, |
58 | 58 |
}, |
... | ... |
@@ -64,15 +65,15 @@ func TestScale(t *testing.T) { |
64 | 64 |
waitForReplicas: &kubectl.RetryParams{Interval: time.Millisecond, Timeout: time.Millisecond}, |
65 | 65 |
oc: testclient.NewSimpleFake(deploytest.OkDeploymentConfig(1)), |
66 | 66 |
kc: ktestclient.NewSimpleFake(mkDeploymentList(1)), |
67 |
- expected: []string{ |
|
68 |
- "get-deploymentconfig", |
|
69 |
- "get-deploymentconfig", |
|
67 |
+ expected: []ktestclient.Action{ |
|
68 |
+ ktestclient.NewGetAction("deploymentconfigs", "default", "foo"), |
|
69 |
+ ktestclient.NewGetAction("deploymentconfigs", "default", "foo"), |
|
70 | 70 |
}, |
71 |
- kexpected: []string{ |
|
72 |
- "get-replicationController", |
|
73 |
- "update-replicationController", |
|
74 |
- "get-replicationController", |
|
75 |
- "get-replicationController", |
|
71 |
+ kexpected: []ktestclient.Action{ |
|
72 |
+ ktestclient.NewGetAction("replicationcontrollers", "default", "config-1"), |
|
73 |
+ ktestclient.NewUpdateAction("replicationcontrollers", "default", nil), |
|
74 |
+ ktestclient.NewGetAction("replicationcontrollers", "default", "config-1"), |
|
75 |
+ ktestclient.NewGetAction("replicationcontrollers", "", "config-1"), |
|
76 | 76 |
}, |
77 | 77 |
expectedErr: nil, |
78 | 78 |
}, |
... | ... |
@@ -84,20 +85,31 @@ func TestScale(t *testing.T) { |
84 | 84 |
if got != test.expectedErr { |
85 | 85 |
t.Errorf("%s: error mismatch: expected %v, got %v", test.expectedErr, got) |
86 | 86 |
} |
87 |
- if len(test.oc.Actions) != len(test.expected) { |
|
88 |
- t.Fatalf("%s: unexpected actions: %v, expected %v", test.testName, test.oc.Actions, test.expected) |
|
87 |
+ if len(test.oc.Actions()) != len(test.expected) { |
|
88 |
+ t.Fatalf("%s: unexpected actions: %v, expected %v", test.testName, test.oc.Actions(), test.expected) |
|
89 | 89 |
} |
90 |
- for j, fake := range test.oc.Actions { |
|
91 |
- if fake.Action != test.expected[j] { |
|
92 |
- t.Errorf("%s: unexpected action: %s, expected %s", test.testName, fake.Action, test.expected[j]) |
|
90 |
+ for j, actualAction := range test.oc.Actions() { |
|
91 |
+ if actualAction != test.expected[j] { |
|
92 |
+ t.Errorf("%s: unexpected action: %s, expected %s", test.testName, actualAction, test.expected[j]) |
|
93 | 93 |
} |
94 | 94 |
} |
95 | 95 |
if len(test.kc.Actions()) != len(test.kexpected) { |
96 |
- t.Fatalf("%s: unexpected actions: %v, expected %v", test.testName, test.kc.Actions, test.kexpected) |
|
96 |
+ t.Fatalf("%s: unexpected actions: %v, expected %v", test.testName, test.kc.Actions(), test.kexpected) |
|
97 | 97 |
} |
98 |
- for j, fake := range test.kc.Actions() { |
|
99 |
- if fake.Action != test.kexpected[j] { |
|
100 |
- t.Errorf("%s: unexpected action: %s, expected %s", test.testName, fake.Action, test.kexpected[j]) |
|
98 |
+ for j, actualAction := range test.kc.Actions() { |
|
99 |
+ e, a := test.kexpected[j], actualAction |
|
100 |
+ if e.GetVerb() != a.GetVerb() || |
|
101 |
+ e.GetNamespace() != a.GetNamespace() || |
|
102 |
+ e.GetResource() != a.GetResource() || |
|
103 |
+ e.GetSubresource() != a.GetSubresource() { |
|
104 |
+ t.Errorf("%s: unexpected action[%d]: %s, expected %s", test.testName, j, a, e) |
|
105 |
+ } |
|
106 |
+ |
|
107 |
+ switch a.(type) { |
|
108 |
+ case ktestclient.GetAction, ktestclient.DeleteAction: |
|
109 |
+ if !reflect.DeepEqual(e, a) { |
|
110 |
+ t.Errorf("%s: unexpected action[%d]: %s, expected %s", test.testName, j, a, e) |
|
111 |
+ } |
|
101 | 112 |
} |
102 | 113 |
} |
103 | 114 |
} |
... | ... |
@@ -1159,13 +1159,14 @@ func dockerBuilderImage() *docker.Image { |
1159 | 1159 |
|
1160 | 1160 |
func fakeImageStreamSearcher() app.Searcher { |
1161 | 1161 |
client := &client.Fake{ |
1162 |
- ReactFn: func(action testclient.FakeAction) (runtime.Object, error) { |
|
1163 |
- switch action.Action { |
|
1164 |
- case "get-imagestream": |
|
1162 |
+ ReactFn: func(action testclient.Action) (runtime.Object, error) { |
|
1163 |
+ if action.Matches("get", "imagestreams") { |
|
1165 | 1164 |
return builderImageStream(), nil |
1166 |
- case "list-imagestreams": |
|
1165 |
+ } |
|
1166 |
+ if action.Matches("list", "imagestreams") { |
|
1167 | 1167 |
return builderImageStreams(), nil |
1168 |
- case "get-imagestream-image": |
|
1168 |
+ } |
|
1169 |
+ if action.Matches("get", "imagestreamimages") { |
|
1169 | 1170 |
return builderImage(), nil |
1170 | 1171 |
} |
1171 | 1172 |
return nil, nil |
... | ... |
@@ -1180,9 +1181,8 @@ func fakeImageStreamSearcher() app.Searcher { |
1180 | 1180 |
|
1181 | 1181 |
func fakeTemplateSearcher() app.Searcher { |
1182 | 1182 |
client := &client.Fake{ |
1183 |
- ReactFn: func(action testclient.FakeAction) (runtime.Object, error) { |
|
1184 |
- switch action.Action { |
|
1185 |
- case "list-templates": |
|
1183 |
+ ReactFn: func(action testclient.Action) (runtime.Object, error) { |
|
1184 |
+ if action.Matches("list", "templates") { |
|
1186 | 1185 |
return &templateapi.TemplateList{ |
1187 | 1186 |
Items: []templateapi.Template{ |
1188 | 1187 |
{ |
... | ... |
@@ -15,12 +15,12 @@ import ( |
15 | 15 |
|
16 | 16 |
func testImageStreamClient(imageStreams *imageapi.ImageStreamList, images map[string]*imageapi.ImageStreamImage) client.Interface { |
17 | 17 |
return &testclient.Fake{ |
18 |
- ReactFn: func(action ktestclient.FakeAction) (runtime.Object, error) { |
|
19 |
- switch action.Action { |
|
20 |
- case "list-imagestreams": |
|
18 |
+ ReactFn: func(action ktestclient.Action) (runtime.Object, error) { |
|
19 |
+ if action.Matches("list", "imagestreams") { |
|
21 | 20 |
return imageStreams, nil |
22 |
- case "get-imagestream-image": |
|
23 |
- return images[action.Value.(string)], nil |
|
21 |
+ } |
|
22 |
+ if action.Matches("get", "imagestreamimages") { |
|
23 |
+ return images[action.(ktestclient.GetAction).GetName()], nil |
|
24 | 24 |
} |
25 | 25 |
return nil, nil |
26 | 26 |
}, |
... | ... |
@@ -104,7 +104,7 @@ func TestControllerRepoHandled(t *testing.T) { |
104 | 104 |
if len(stream.Annotations["openshift.io/image.dockerRepositoryCheck"]) == 0 { |
105 | 105 |
t.Errorf("did not set annotation: %#v", stream) |
106 | 106 |
} |
107 |
- if len(fake.Actions) != 1 { |
|
107 |
+ if len(fake.Actions()) != 1 { |
|
108 | 108 |
t.Errorf("expected an update action: %#v", fake.Actions) |
109 | 109 |
} |
110 | 110 |
} |
... | ... |
@@ -125,7 +125,7 @@ func TestControllerTagRetrievalFails(t *testing.T) { |
125 | 125 |
if len(stream.Annotations["openshift.io/image.dockerRepositoryCheck"]) != 0 { |
126 | 126 |
t.Errorf("should not set annotation: %#v", stream) |
127 | 127 |
} |
128 |
- if len(fake.Actions) != 0 { |
|
128 |
+ if len(fake.Actions()) != 0 { |
|
129 | 129 |
t.Error("expected no actions on fake client") |
130 | 130 |
} |
131 | 131 |
} |
... | ... |
@@ -155,7 +155,7 @@ func TestControllerRetrievesInsecure(t *testing.T) { |
155 | 155 |
if len(stream.Annotations["openshift.io/image.dockerRepositoryCheck"]) != 0 { |
156 | 156 |
t.Errorf("should not set annotation: %#v", stream) |
157 | 157 |
} |
158 |
- if len(fake.Actions) != 0 { |
|
158 |
+ if len(fake.Actions()) != 0 { |
|
159 | 159 |
t.Error("expected no actions on fake client") |
160 | 160 |
} |
161 | 161 |
} |
... | ... |
@@ -175,8 +175,8 @@ func TestControllerImageNotFoundError(t *testing.T) { |
175 | 175 |
if len(stream.Annotations["openshift.io/image.dockerRepositoryCheck"]) == 0 { |
176 | 176 |
t.Errorf("did not set annotation: %#v", stream) |
177 | 177 |
} |
178 |
- if len(fake.Actions) != 1 { |
|
179 |
- t.Errorf("expected an update action: %#v", fake.Actions) |
|
178 |
+ if len(fake.Actions()) != 1 { |
|
179 |
+ t.Errorf("expected an update action: %#v", fake.Actions()) |
|
180 | 180 |
} |
181 | 181 |
} |
182 | 182 |
|
... | ... |
@@ -203,8 +203,8 @@ func TestControllerImageWithGenericError(t *testing.T) { |
203 | 203 |
if len(stream.Annotations["openshift.io/image.dockerRepositoryCheck"]) != 0 { |
204 | 204 |
t.Errorf("did not expect annotation: %#v", stream) |
205 | 205 |
} |
206 |
- if len(fake.Actions) != 0 { |
|
207 |
- t.Errorf("expected no update action: %#v", fake.Actions) |
|
206 |
+ if len(fake.Actions()) != 0 { |
|
207 |
+ t.Errorf("expected no update action: %#v", fake.Actions()) |
|
208 | 208 |
} |
209 | 209 |
} |
210 | 210 |
|
... | ... |
@@ -234,8 +234,8 @@ func TestControllerWithImage(t *testing.T) { |
234 | 234 |
if !isRFC3339(stream.Annotations["openshift.io/image.dockerRepositoryCheck"]) { |
235 | 235 |
t.Fatalf("did not set annotation: %#v", stream) |
236 | 236 |
} |
237 |
- if len(fake.Actions) != 2 { |
|
238 |
- t.Errorf("expected an update action: %#v", fake.Actions) |
|
237 |
+ if len(fake.Actions()) != 2 { |
|
238 |
+ t.Errorf("expected an update action: %#v", fake.Actions()) |
|
239 | 239 |
} |
240 | 240 |
} |
241 | 241 |
|
... | ... |
@@ -303,21 +303,21 @@ func TestControllerWithSpecTags(t *testing.T) { |
303 | 303 |
t.Fatalf("%s: did not set annotation: %#v", name, stream) |
304 | 304 |
} |
305 | 305 |
if test.expectUpdate { |
306 |
- if len(fake.Actions) != 2 { |
|
307 |
- t.Errorf("%s: expected an update action: %#v", name, fake.Actions) |
|
306 |
+ if len(fake.Actions()) != 2 { |
|
307 |
+ t.Errorf("%s: expected an update action: %#v", name, fake.Actions()) |
|
308 | 308 |
} |
309 |
- if e, a := "create-imagestream-mapping", fake.Actions[0].Action; e != a { |
|
310 |
- t.Errorf("%s: expected %s, got %s", name, e, a) |
|
309 |
+ if !fake.Actions()[0].Matches("create", "imagestreammappings") { |
|
310 |
+ t.Errorf("%s: expected %s, got %v", name, "create-imagestreammappings", fake.Actions()[0]) |
|
311 | 311 |
} |
312 |
- if e, a := "update-imagestream", fake.Actions[1].Action; e != a { |
|
313 |
- t.Errorf("%s: expected %s, got %s", name, e, a) |
|
312 |
+ if !fake.Actions()[1].Matches("update", "imagestreams") { |
|
313 |
+ t.Errorf("%s: expected %s, got %v", name, "update-imagestreams", fake.Actions()[1]) |
|
314 | 314 |
} |
315 | 315 |
} else { |
316 |
- if len(fake.Actions) != 1 { |
|
317 |
- t.Errorf("%s: expected no update action: %#v", name, fake.Actions) |
|
316 |
+ if len(fake.Actions()) != 1 { |
|
317 |
+ t.Errorf("%s: expected no update action: %#v", name, fake.Actions()) |
|
318 | 318 |
} |
319 |
- if e, a := "update-imagestream", fake.Actions[0].Action; e != a { |
|
320 |
- t.Errorf("%s: expected %s, got %s", name, e, a) |
|
319 |
+ if !fake.Actions()[0].Matches("update", "imagestreams") { |
|
320 |
+ t.Errorf("%s: expected %s, got %v", name, "update-imagestreams", fake.Actions()[0]) |
|
321 | 321 |
} |
322 | 322 |
} |
323 | 323 |
} |
... | ... |
@@ -713,9 +713,8 @@ func TestDeletingImagePruner(t *testing.T) { |
713 | 713 |
} |
714 | 714 |
|
715 | 715 |
for name, test := range tests { |
716 |
- imageClient := testclient.Fake{ |
|
717 |
- Err: test.imageDeletionError, |
|
718 |
- } |
|
716 |
+ imageClient := testclient.Fake{} |
|
717 |
+ imageClient.SetErr(test.imageDeletionError) |
|
719 | 718 |
imagePruner := NewDeletingImagePruner(imageClient.Images()) |
720 | 719 |
err := imagePruner.PruneImage(&imageapi.Image{ObjectMeta: kapi.ObjectMeta{Name: "id2"}}) |
721 | 720 |
if test.imageDeletionError != nil { |
... | ... |
@@ -725,13 +724,13 @@ func TestDeletingImagePruner(t *testing.T) { |
725 | 725 |
continue |
726 | 726 |
} |
727 | 727 |
|
728 |
- if e, a := 1, len(imageClient.Actions); e != a { |
|
729 |
- t.Errorf("%s: expected %d actions, got %d: %#v", name, e, a, imageClient.Actions) |
|
728 |
+ if e, a := 1, len(imageClient.Actions()); e != a { |
|
729 |
+ t.Errorf("%s: expected %d actions, got %d: %#v", name, e, a, imageClient.Actions()) |
|
730 | 730 |
continue |
731 | 731 |
} |
732 | 732 |
|
733 |
- if e, a := "delete-image", imageClient.Actions[0].Action; e != a { |
|
734 |
- t.Errorf("%s: expected action %q, got %q", name, e, a) |
|
733 |
+ if !imageClient.Actions()[0].Matches("delete", "images") { |
|
734 |
+ t.Errorf("%s: expected action %s, got %v", name, "delete-images", imageClient.Actions()[0]) |
|
735 | 735 |
} |
736 | 736 |
} |
737 | 737 |
} |
... | ... |
@@ -37,7 +37,7 @@ func TestIgnoreThatWhichCannotBeKnown(t *testing.T) { |
37 | 37 |
// TestAdmissionExists verifies you cannot create Origin content if namespace is not known |
38 | 38 |
func TestAdmissionExists(t *testing.T) { |
39 | 39 |
mockClient := &testclient.Fake{ |
40 |
- ReactFn: func(f testclient.FakeAction) (runtime.Object, error) { |
|
40 |
+ ReactFn: func(f testclient.Action) (runtime.Object, error) { |
|
41 | 41 |
return &kapi.Namespace{}, fmt.Errorf("DOES NOT EXIST") |
42 | 42 |
}, |
43 | 43 |
} |
... | ... |
@@ -37,27 +37,28 @@ func TestSyncNamespaceThatIsTerminating(t *testing.T) { |
37 | 37 |
} |
38 | 38 |
|
39 | 39 |
// TODO: we will expect a finalize namespace call after rebase |
40 |
- expectedActionSet := util.NewStringSet( |
|
41 |
- "list-buildconfig", |
|
42 |
- "list-policies", |
|
43 |
- "list-imagestreams", |
|
44 |
- "list-policyBindings", |
|
45 |
- "list-roleBinding", |
|
46 |
- "list-role", |
|
47 |
- "list-routes", |
|
48 |
- "list-templates", |
|
49 |
- "list-builds", |
|
50 |
- "finalize-namespace", |
|
51 |
- "list-deploymentconfig", |
|
52 |
- ) |
|
53 |
- actionSet := util.NewStringSet() |
|
40 |
+ expectedActionSet := []ktestclient.Action{ |
|
41 |
+ ktestclient.NewListAction("buildconfigs", "", nil, nil), |
|
42 |
+ ktestclient.NewListAction("policies", "", nil, nil), |
|
43 |
+ ktestclient.NewListAction("imagestreams", "", nil, nil), |
|
44 |
+ ktestclient.NewListAction("policybindings", "", nil, nil), |
|
45 |
+ ktestclient.NewListAction("rolebindings", "", nil, nil), |
|
46 |
+ ktestclient.NewListAction("roles", "", nil, nil), |
|
47 |
+ ktestclient.NewListAction("routes", "", nil, nil), |
|
48 |
+ ktestclient.NewListAction("templates", "", nil, nil), |
|
49 |
+ ktestclient.NewListAction("builds", "", nil, nil), |
|
50 |
+ ktestclient.NewListAction("namespace", "", nil, nil), |
|
51 |
+ ktestclient.NewListAction("deploymentconfig", "", nil, nil), |
|
52 |
+ } |
|
53 |
+ actionSet := []ktestclient.Action{} |
|
54 | 54 |
for i := range mockKubeClient.Actions() { |
55 |
- actionSet.Insert(mockKubeClient.Actions()[i].Action) |
|
55 |
+ actionSet = append(actionSet, mockKubeClient.Actions()[i]) |
|
56 | 56 |
} |
57 |
- for i := range mockOriginClient.Actions { |
|
58 |
- actionSet.Insert(mockOriginClient.Actions[i].Action) |
|
57 |
+ for i := range mockOriginClient.Actions() { |
|
58 |
+ actionSet = append(actionSet, mockOriginClient.Actions()[i]) |
|
59 | 59 |
} |
60 |
- if !(actionSet.HasAll(expectedActionSet.List()...) && (len(actionSet) == len(expectedActionSet))) { |
|
60 |
+ |
|
61 |
+ if len(actionSet) != len(expectedActionSet) { |
|
61 | 62 |
t.Errorf("Expected actions: %v, but got: %v", expectedActionSet, actionSet) |
62 | 63 |
} |
63 | 64 |
} |
... | ... |
@@ -85,13 +86,14 @@ func TestSyncNamespaceThatIsActive(t *testing.T) { |
85 | 85 |
if err != nil { |
86 | 86 |
t.Errorf("Unexpected error when handling namespace %v", err) |
87 | 87 |
} |
88 |
- actionSet := util.NewStringSet() |
|
88 |
+ actionSet := []ktestclient.Action{} |
|
89 | 89 |
for i := range mockKubeClient.Actions() { |
90 |
- actionSet.Insert(mockKubeClient.Actions()[i].Action) |
|
90 |
+ actionSet = append(actionSet, mockKubeClient.Actions()[i]) |
|
91 | 91 |
} |
92 |
- for i := range mockOriginClient.Actions { |
|
93 |
- actionSet.Insert(mockOriginClient.Actions[i].Action) |
|
92 |
+ for i := range mockOriginClient.Actions() { |
|
93 |
+ actionSet = append(actionSet, mockOriginClient.Actions()[i]) |
|
94 | 94 |
} |
95 |
+ |
|
95 | 96 |
if len(actionSet) != 0 { |
96 | 97 |
t.Errorf("Expected no action from controller, but got: %v", actionSet) |
97 | 98 |
} |
... | ... |
@@ -94,7 +94,7 @@ func TestCreateProjectOK(t *testing.T) { |
94 | 94 |
if len(mockClient.Actions()) != 1 { |
95 | 95 |
t.Errorf("Expected client action for create") |
96 | 96 |
} |
97 |
- if mockClient.Actions()[0].Action != "create-namespace" { |
|
97 |
+ if !mockClient.Actions()[0].Matches("create", "namespaces") { |
|
98 | 98 |
t.Errorf("Expected call to create-namespace") |
99 | 99 |
} |
100 | 100 |
} |
... | ... |
@@ -136,7 +136,7 @@ func TestDeleteProject(t *testing.T) { |
136 | 136 |
if len(mockClient.Actions()) != 1 { |
137 | 137 |
t.Errorf("Expected client action for delete") |
138 | 138 |
} |
139 |
- if mockClient.Actions()[0].Action != "delete-namespace" { |
|
139 |
+ if !mockClient.Actions()[0].Matches("delete", "namespaces") { |
|
140 | 140 |
t.Errorf("Expected call to delete-namespace") |
141 | 141 |
} |
142 | 142 |
} |
... | ... |
@@ -17,9 +17,9 @@ import ( |
17 | 17 |
) |
18 | 18 |
|
19 | 19 |
func TestController(t *testing.T) { |
20 |
- var action testclient.FakeAction |
|
20 |
+ var action testclient.Action |
|
21 | 21 |
client := &testclient.Fake{ |
22 |
- ReactFn: func(a testclient.FakeAction) (runtime.Object, error) { |
|
22 |
+ ReactFn: func(a testclient.Action) (runtime.Object, error) { |
|
23 | 23 |
action = a |
24 | 24 |
return (*kapi.Namespace)(nil), nil |
25 | 25 |
}, |
... | ... |
@@ -38,7 +38,7 @@ func TestController(t *testing.T) { |
38 | 38 |
t.Fatal(err) |
39 | 39 |
} |
40 | 40 |
|
41 |
- got := action.Value.(*kapi.Namespace) |
|
41 |
+ got := action.(testclient.CreateAction).GetObject().(*kapi.Namespace) |
|
42 | 42 |
if got.Annotations[security.UIDRangeAnnotation] != "10/2" { |
43 | 43 |
t.Errorf("unexpected annotation: %#v", got) |
44 | 44 |
} |
... | ... |
@@ -69,8 +69,8 @@ func TestControllerError(t *testing.T) { |
69 | 69 |
}, |
70 | 70 |
"conflict": { |
71 | 71 |
actions: 4, |
72 |
- reactFn: func(a testclient.FakeAction) (runtime.Object, error) { |
|
73 |
- if a.Action == "get-namespace" { |
|
72 |
+ reactFn: func(a testclient.Action) (runtime.Object, error) { |
|
73 |
+ if a.Matches("get", "namespaces") { |
|
74 | 74 |
return &kapi.Namespace{ObjectMeta: kapi.ObjectMeta{Name: "test"}}, nil |
75 | 75 |
} |
76 | 76 |
return (*kapi.Namespace)(nil), errors.NewConflict("namespace", "test", fmt.Errorf("test conflict")) |
... | ... |
@@ -84,7 +84,7 @@ func TestControllerError(t *testing.T) { |
84 | 84 |
for s, testCase := range testCases { |
85 | 85 |
client := &testclient.Fake{ReactFn: testCase.reactFn} |
86 | 86 |
if client.ReactFn == nil { |
87 |
- client.ReactFn = func(a testclient.FakeAction) (runtime.Object, error) { |
|
87 |
+ client.ReactFn = func(a testclient.Action) (runtime.Object, error) { |
|
88 | 88 |
return (*kapi.Namespace)(nil), testCase.err() |
89 | 89 |
} |
90 | 90 |
} |
... | ... |
@@ -28,10 +28,8 @@ func (r *fakeRange) CreateOrUpdate(update *kapi.RangeAllocation) error { |
28 | 28 |
} |
29 | 29 |
|
30 | 30 |
func TestRepair(t *testing.T) { |
31 |
- var action testclient.FakeAction |
|
32 | 31 |
client := &testclient.Fake{ |
33 |
- ReactFn: func(a testclient.FakeAction) (runtime.Object, error) { |
|
34 |
- action = a |
|
32 |
+ ReactFn: func(a testclient.Action) (runtime.Object, error) { |
|
35 | 33 |
list := &kapi.NamespaceList{ |
36 | 34 |
Items: []kapi.Namespace{ |
37 | 35 |
{ObjectMeta: kapi.ObjectMeta{Name: "default"}}, |
... | ... |
@@ -16,34 +16,34 @@ func TestDockercfgDeletion(t *testing.T) { |
16 | 16 |
|
17 | 17 |
DeletedSecret *api.Secret |
18 | 18 |
|
19 |
- ExpectedActions []testclient.FakeAction |
|
19 |
+ ExpectedActions []testclient.Action |
|
20 | 20 |
}{ |
21 | 21 |
"deleted dockercfg secret without serviceaccount": { |
22 | 22 |
DeletedSecret: createdDockercfgSecret(), |
23 | 23 |
|
24 |
- ExpectedActions: []testclient.FakeAction{ |
|
25 |
- {Action: "get-serviceaccount", Value: "default"}, |
|
26 |
- {Action: "delete-secret", Value: "token-secret-1"}, |
|
24 |
+ ExpectedActions: []testclient.Action{ |
|
25 |
+ testclient.NewGetAction("serviceaccounts", "default", "default"), |
|
26 |
+ testclient.NewDeleteAction("secrets", "default", "token-secret-1"), |
|
27 | 27 |
}, |
28 | 28 |
}, |
29 | 29 |
"deleted dockercfg secret with serviceaccount with reference": { |
30 | 30 |
ClientObjects: []runtime.Object{serviceAccount(addTokenSecretReference(tokenSecretReferences()), imagePullSecretReferences()), createdDockercfgSecret()}, |
31 | 31 |
|
32 | 32 |
DeletedSecret: createdDockercfgSecret(), |
33 |
- ExpectedActions: []testclient.FakeAction{ |
|
34 |
- {Action: "get-serviceaccount", Value: "default"}, |
|
35 |
- {Action: "update-serviceaccount", Value: serviceAccount(tokenSecretReferences(), emptyImagePullSecretReferences())}, |
|
36 |
- {Action: "delete-secret", Value: "token-secret-1"}, |
|
33 |
+ ExpectedActions: []testclient.Action{ |
|
34 |
+ testclient.NewGetAction("serviceaccounts", "default", "default"), |
|
35 |
+ testclient.NewUpdateAction("serviceaccounts", "default", serviceAccount(tokenSecretReferences(), emptyImagePullSecretReferences())), |
|
36 |
+ testclient.NewDeleteAction("secrets", "default", "token-secret-1"), |
|
37 | 37 |
}, |
38 | 38 |
}, |
39 | 39 |
"deleted dockercfg secret with serviceaccount without reference": { |
40 | 40 |
ClientObjects: []runtime.Object{serviceAccount(addTokenSecretReference(tokenSecretReferences()), imagePullSecretReferences()), createdDockercfgSecret()}, |
41 | 41 |
|
42 | 42 |
DeletedSecret: createdDockercfgSecret(), |
43 |
- ExpectedActions: []testclient.FakeAction{ |
|
44 |
- {Action: "get-serviceaccount", Value: "default"}, |
|
45 |
- {Action: "update-serviceaccount", Value: serviceAccount(tokenSecretReferences(), emptyImagePullSecretReferences())}, |
|
46 |
- {Action: "delete-secret", Value: "token-secret-1"}, |
|
43 |
+ ExpectedActions: []testclient.Action{ |
|
44 |
+ testclient.NewGetAction("serviceaccounts", "default", "default"), |
|
45 |
+ testclient.NewUpdateAction("serviceaccounts", "default", serviceAccount(tokenSecretReferences(), emptyImagePullSecretReferences())), |
|
46 |
+ testclient.NewDeleteAction("secrets", "default", "token-secret-1"), |
|
47 | 47 |
}, |
48 | 48 |
}, |
49 | 49 |
} |
... | ... |
@@ -67,12 +67,8 @@ func TestDockercfgDeletion(t *testing.T) { |
67 | 67 |
} |
68 | 68 |
|
69 | 69 |
expectedAction := tc.ExpectedActions[i] |
70 |
- if expectedAction.Action != action.Action { |
|
71 |
- t.Errorf("%s: Expected %s, got %s", k, expectedAction.Action, action.Action) |
|
72 |
- continue |
|
73 |
- } |
|
74 |
- if !reflect.DeepEqual(expectedAction.Value, action.Value) { |
|
75 |
- t.Errorf("%s: Expected\n\t%#v\ngot\n\t%#v", k, expectedAction.Value, action.Value) |
|
70 |
+ if !reflect.DeepEqual(expectedAction, action) { |
|
71 |
+ t.Errorf("%s: Expected %v, got %v", k, expectedAction, action) |
|
76 | 72 |
continue |
77 | 73 |
} |
78 | 74 |
} |
... | ... |
@@ -6,7 +6,10 @@ import ( |
6 | 6 |
"testing" |
7 | 7 |
|
8 | 8 |
"k8s.io/kubernetes/pkg/api" |
9 |
+ "k8s.io/kubernetes/pkg/client" |
|
9 | 10 |
"k8s.io/kubernetes/pkg/client/testclient" |
11 |
+ "k8s.io/kubernetes/pkg/fields" |
|
12 |
+ "k8s.io/kubernetes/pkg/labels" |
|
10 | 13 |
"k8s.io/kubernetes/pkg/runtime" |
11 | 14 |
) |
12 | 15 |
|
... | ... |
@@ -121,38 +124,40 @@ func serviceAccountTokenSecretWithoutTokenData() *api.Secret { |
121 | 121 |
} |
122 | 122 |
|
123 | 123 |
func TestTokenDeletion(t *testing.T) { |
124 |
+ dockercfgSecretFieldSelector := fields.OneTermEqualSelector(client.SecretType, string(api.SecretTypeDockercfg)) |
|
125 |
+ |
|
124 | 126 |
testcases := map[string]struct { |
125 | 127 |
ClientObjects []runtime.Object |
126 | 128 |
|
127 | 129 |
DeletedSecret *api.Secret |
128 | 130 |
|
129 |
- ExpectedActions []testclient.FakeAction |
|
131 |
+ ExpectedActions []testclient.Action |
|
130 | 132 |
}{ |
131 | 133 |
"deleted token secret without serviceaccount": { |
132 | 134 |
ClientObjects: []runtime.Object{serviceAccount(addTokenSecretReference(tokenSecretReferences()), imagePullSecretReferences()), createdDockercfgSecret()}, |
133 | 135 |
DeletedSecret: serviceAccountTokenSecret(), |
134 | 136 |
|
135 |
- ExpectedActions: []testclient.FakeAction{ |
|
136 |
- {Action: "list-secrets"}, |
|
137 |
- {Action: "delete-secret", Value: "default-dockercfg-fplln"}, |
|
137 |
+ ExpectedActions: []testclient.Action{ |
|
138 |
+ testclient.NewListAction("secrets", "default", labels.Everything(), dockercfgSecretFieldSelector), |
|
139 |
+ testclient.NewDeleteAction("secrets", "default", "default-dockercfg-fplln"), |
|
138 | 140 |
}, |
139 | 141 |
}, |
140 | 142 |
"deleted token secret with serviceaccount with reference": { |
141 | 143 |
ClientObjects: []runtime.Object{serviceAccount(addTokenSecretReference(tokenSecretReferences()), imagePullSecretReferences()), createdDockercfgSecret()}, |
142 | 144 |
|
143 | 145 |
DeletedSecret: serviceAccountTokenSecret(), |
144 |
- ExpectedActions: []testclient.FakeAction{ |
|
145 |
- {Action: "list-secrets"}, |
|
146 |
- {Action: "delete-secret", Value: "default-dockercfg-fplln"}, |
|
146 |
+ ExpectedActions: []testclient.Action{ |
|
147 |
+ testclient.NewListAction("secrets", "default", labels.Everything(), dockercfgSecretFieldSelector), |
|
148 |
+ testclient.NewDeleteAction("secrets", "default", "default-dockercfg-fplln"), |
|
147 | 149 |
}, |
148 | 150 |
}, |
149 | 151 |
"deleted token secret with serviceaccount without reference": { |
150 | 152 |
ClientObjects: []runtime.Object{serviceAccount(addTokenSecretReference(tokenSecretReferences()), imagePullSecretReferences()), createdDockercfgSecret()}, |
151 | 153 |
|
152 | 154 |
DeletedSecret: serviceAccountTokenSecret(), |
153 |
- ExpectedActions: []testclient.FakeAction{ |
|
154 |
- {Action: "list-secrets"}, |
|
155 |
- {Action: "delete-secret", Value: "default-dockercfg-fplln"}, |
|
155 |
+ ExpectedActions: []testclient.Action{ |
|
156 |
+ testclient.NewListAction("secrets", "default", labels.Everything(), dockercfgSecretFieldSelector), |
|
157 |
+ testclient.NewDeleteAction("secrets", "default", "default-dockercfg-fplln"), |
|
156 | 158 |
}, |
157 | 159 |
}, |
158 | 160 |
} |
... | ... |
@@ -176,12 +181,8 @@ func TestTokenDeletion(t *testing.T) { |
176 | 176 |
} |
177 | 177 |
|
178 | 178 |
expectedAction := tc.ExpectedActions[i] |
179 |
- if expectedAction.Action != action.Action { |
|
180 |
- t.Errorf("%s: Expected %s, got %s", k, expectedAction.Action, action.Action) |
|
181 |
- continue |
|
182 |
- } |
|
183 |
- if !reflect.DeepEqual(expectedAction.Value, action.Value) { |
|
184 |
- t.Errorf("%s: Expected\n\t%#v\ngot\n\t%#v", k, expectedAction.Value, action.Value) |
|
179 |
+ if !reflect.DeepEqual(expectedAction, action) { |
|
180 |
+ t.Errorf("%s: Expected %v, got %v", k, expectedAction, action) |
|
185 | 181 |
continue |
186 | 182 |
} |
187 | 183 |
} |