Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
b9066392
Commit
b9066392
authored
Aug 04, 2015
by
Alex Mohr
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12146 from deads2k/tweak-testclient
make testclient more precise
parents
366b3829
182885e8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
931 additions
and
324 deletions
+931
-324
actions.go
pkg/client/testclient/actions.go
+279
-0
fake_componentstatuses.go
pkg/client/testclient/fake_componentstatuses.go
+14
-15
fake_endpoints.go
pkg/client/testclient/fake_endpoints.go
+29
-13
fake_events.go
pkg/client/testclient/fake_events.go
+44
-20
fake_limit_ranges.go
pkg/client/testclient/fake_limit_ranges.go
+28
-12
fake_namespaces.go
pkg/client/testclient/fake_namespaces.go
+51
-15
fake_nodes.go
pkg/client/testclient/fake_nodes.go
+39
-13
fake_persistent_volume_claims.go
pkg/client/testclient/fake_persistent_volume_claims.go
+41
-15
fake_persistent_volumes.go
pkg/client/testclient/fake_persistent_volumes.go
+42
-17
fake_pod_templates.go
pkg/client/testclient/fake_pod_templates.go
+28
-12
fake_pods.go
pkg/client/testclient/fake_pods.go
+48
-16
fake_replication_controllers.go
pkg/client/testclient/fake_replication_controllers.go
+25
-18
fake_resource_quotas.go
pkg/client/testclient/fake_resource_quotas.go
+41
-15
fake_secrets.go
pkg/client/testclient/fake_secrets.go
+26
-10
fake_service_accounts.go
pkg/client/testclient/fake_service_accounts.go
+26
-10
fake_services.go
pkg/client/testclient/fake_services.go
+27
-11
fixture.go
pkg/client/testclient/fixture.go
+23
-21
testclient.go
pkg/client/testclient/testclient.go
+19
-16
namespace_controller_test.go
pkg/controller/namespace/namespace_controller_test.go
+17
-19
nodecontroller_test.go
pkg/controller/node/nodecontroller_test.go
+1
-1
replication_controller_test.go
pkg/controller/replication/replication_controller_test.go
+13
-8
resource_quota_controller_test.go
...ontroller/resourcequota/resource_quota_controller_test.go
+3
-3
routecontroller_test.go
pkg/controller/route/routecontroller_test.go
+1
-1
servicecontroller_test.go
pkg/controller/service/servicecontroller_test.go
+1
-1
serviceaccounts_controller_test.go
...troller/serviceaccount/serviceaccounts_controller_test.go
+3
-3
tokens_controller_test.go
pkg/controller/serviceaccount/tokens_controller_test.go
+0
-0
rolling_updater_test.go
pkg/kubectl/rolling_updater_test.go
+3
-3
scale_test.go
pkg/kubectl/scale_test.go
+3
-3
stop_test.go
pkg/kubectl/stop_test.go
+25
-13
kubelet_test.go
pkg/kubelet/kubelet_test.go
+19
-14
status_manager_test.go
pkg/kubelet/status_manager_test.go
+9
-3
admission_test.go
plugin/pkg/admission/exec/denyprivileged/admission_test.go
+2
-2
admission_test.go
...n/pkg/admission/namespace/autoprovision/admission_test.go
+1
-1
No files found.
pkg/client/testclient/actions.go
0 → 100644
View file @
b9066392
/*
Copyright 2015 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
testclient
import
(
"strings"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
)
func
NewRootGetAction
(
resource
,
name
string
)
GetActionImpl
{
action
:=
GetActionImpl
{}
action
.
Verb
=
"get"
action
.
Resource
=
resource
action
.
Name
=
name
return
action
}
func
NewGetAction
(
resource
,
namespace
,
name
string
)
GetActionImpl
{
action
:=
GetActionImpl
{}
action
.
Verb
=
"get"
action
.
Resource
=
resource
action
.
Namespace
=
namespace
action
.
Name
=
name
return
action
}
func
NewRootListAction
(
resource
string
,
label
labels
.
Selector
,
field
fields
.
Selector
)
ListActionImpl
{
action
:=
ListActionImpl
{}
action
.
Verb
=
"list"
action
.
Resource
=
resource
action
.
ListRestrictions
=
ListRestrictions
{
label
,
field
}
return
action
}
func
NewListAction
(
resource
,
namespace
string
,
label
labels
.
Selector
,
field
fields
.
Selector
)
ListActionImpl
{
action
:=
ListActionImpl
{}
action
.
Verb
=
"list"
action
.
Resource
=
resource
action
.
Namespace
=
namespace
action
.
ListRestrictions
=
ListRestrictions
{
label
,
field
}
return
action
}
func
NewRootCreateAction
(
resource
string
,
object
runtime
.
Object
)
CreateActionImpl
{
action
:=
CreateActionImpl
{}
action
.
Verb
=
"create"
action
.
Resource
=
resource
action
.
Object
=
object
return
action
}
func
NewCreateAction
(
resource
,
namespace
string
,
object
runtime
.
Object
)
CreateActionImpl
{
action
:=
CreateActionImpl
{}
action
.
Verb
=
"create"
action
.
Resource
=
resource
action
.
Namespace
=
namespace
action
.
Object
=
object
return
action
}
func
NewRootUpdateAction
(
resource
string
,
object
runtime
.
Object
)
UpdateActionImpl
{
action
:=
UpdateActionImpl
{}
action
.
Verb
=
"update"
action
.
Resource
=
resource
action
.
Object
=
object
return
action
}
func
NewUpdateAction
(
resource
,
namespace
string
,
object
runtime
.
Object
)
UpdateActionImpl
{
action
:=
UpdateActionImpl
{}
action
.
Verb
=
"update"
action
.
Resource
=
resource
action
.
Namespace
=
namespace
action
.
Object
=
object
return
action
}
func
NewRootDeleteAction
(
resource
,
name
string
)
DeleteActionImpl
{
action
:=
DeleteActionImpl
{}
action
.
Verb
=
"delete"
action
.
Resource
=
resource
action
.
Name
=
name
return
action
}
func
NewDeleteAction
(
resource
,
namespace
,
name
string
)
DeleteActionImpl
{
action
:=
DeleteActionImpl
{}
action
.
Verb
=
"delete"
action
.
Resource
=
resource
action
.
Namespace
=
namespace
action
.
Name
=
name
return
action
}
func
NewRootWatchAction
(
resource
string
,
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
WatchActionImpl
{
action
:=
WatchActionImpl
{}
action
.
Verb
=
"watch"
action
.
Resource
=
resource
action
.
WatchRestrictions
=
WatchRestrictions
{
label
,
field
,
resourceVersion
}
return
action
}
func
NewWatchAction
(
resource
,
namespace
string
,
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
WatchActionImpl
{
action
:=
WatchActionImpl
{}
action
.
Verb
=
"watch"
action
.
Resource
=
resource
action
.
Namespace
=
namespace
action
.
WatchRestrictions
=
WatchRestrictions
{
label
,
field
,
resourceVersion
}
return
action
}
type
ListRestrictions
struct
{
Labels
labels
.
Selector
Fields
fields
.
Selector
}
type
WatchRestrictions
struct
{
Labels
labels
.
Selector
Fields
fields
.
Selector
ResourceVersion
string
}
type
Action
interface
{
GetNamespace
()
string
GetVerb
()
string
GetResource
()
string
GetSubresource
()
string
Matches
(
verb
,
resource
string
)
bool
}
type
GenericAction
interface
{
Action
GetValue
()
interface
{}
}
type
GetAction
interface
{
Action
GetName
()
string
}
type
ListAction
interface
{
Action
GetListRestrictions
()
ListRestrictions
}
type
CreateAction
interface
{
Action
GetObject
()
runtime
.
Object
}
type
UpdateAction
interface
{
Action
GetObject
()
runtime
.
Object
}
type
DeleteAction
interface
{
Action
GetName
()
string
}
type
WatchAction
interface
{
Action
GetWatchRestrictions
()
WatchRestrictions
}
type
ActionImpl
struct
{
Namespace
string
Verb
string
Resource
string
Subresource
string
}
func
(
a
ActionImpl
)
GetNamespace
()
string
{
return
a
.
Namespace
}
func
(
a
ActionImpl
)
GetVerb
()
string
{
return
a
.
Verb
}
func
(
a
ActionImpl
)
GetResource
()
string
{
return
a
.
Resource
}
func
(
a
ActionImpl
)
GetSubresource
()
string
{
return
a
.
Subresource
}
func
(
a
ActionImpl
)
Matches
(
verb
,
resource
string
)
bool
{
return
strings
.
ToLower
(
verb
)
==
strings
.
ToLower
(
a
.
Verb
)
&&
strings
.
ToLower
(
resource
)
==
strings
.
ToLower
(
a
.
Resource
)
}
type
GenericActionImpl
struct
{
ActionImpl
Value
interface
{}
}
func
(
a
GenericActionImpl
)
GetValue
()
interface
{}
{
return
a
.
Value
}
type
GetActionImpl
struct
{
ActionImpl
Name
string
}
func
(
a
GetActionImpl
)
GetName
()
string
{
return
a
.
Name
}
type
ListActionImpl
struct
{
ActionImpl
ListRestrictions
ListRestrictions
}
func
(
a
ListActionImpl
)
GetListRestrictions
()
ListRestrictions
{
return
a
.
ListRestrictions
}
type
CreateActionImpl
struct
{
ActionImpl
Object
runtime
.
Object
}
func
(
a
CreateActionImpl
)
GetObject
()
runtime
.
Object
{
return
a
.
Object
}
type
UpdateActionImpl
struct
{
ActionImpl
Object
runtime
.
Object
}
func
(
a
UpdateActionImpl
)
GetObject
()
runtime
.
Object
{
return
a
.
Object
}
type
DeleteActionImpl
struct
{
ActionImpl
Name
string
}
func
(
a
DeleteActionImpl
)
GetName
()
string
{
return
a
.
Name
}
type
WatchActionImpl
struct
{
ActionImpl
WatchRestrictions
WatchRestrictions
}
func
(
a
WatchActionImpl
)
GetWatchRestrictions
()
WatchRestrictions
{
return
a
.
WatchRestrictions
}
pkg/client/testclient/fake_componentstatuses.go
View file @
b9066392
...
@@ -27,21 +27,20 @@ type FakeComponentStatuses struct {
...
@@ -27,21 +27,20 @@ type FakeComponentStatuses struct {
Fake
*
Fake
Fake
*
Fake
}
}
func
(
c
*
FakeComponentStatuses
)
List
(
label
labels
.
Selector
,
field
fields
.
Selector
)
(
result
*
api
.
ComponentStatusList
,
err
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"list-componentstatuses"
},
&
api
.
ComponentStatusList
{})
return
obj
.
(
*
api
.
ComponentStatusList
),
err
}
func
(
c
*
FakeComponentStatuses
)
Get
(
name
string
)
(
*
api
.
ComponentStatus
,
error
)
{
func
(
c
*
FakeComponentStatuses
)
Get
(
name
string
)
(
*
api
.
ComponentStatus
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"get-componentstatus"
,
Value
:
name
},
&
api
.
ComponentStatus
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewRootGetAction
(
"componentstatuses"
,
name
),
&
api
.
ComponentStatus
{})
// c.Actions = append(c.Actions, FakeAction{Action: "get-componentstatuses", Value: nil})
if
obj
==
nil
{
// testStatus := &api.ComponentStatus{
return
nil
,
err
// Name: "test",
}
// Health: "ok",
// HealthCode: int(probe.Success),
// Message: "ok",
// Error: "",
// }
// return &api.ComponentStatusList{Items: []api.ComponentStatus{*testStatus}}, nil
return
obj
.
(
*
api
.
ComponentStatus
),
err
return
obj
.
(
*
api
.
ComponentStatus
),
err
}
}
func
(
c
*
FakeComponentStatuses
)
List
(
label
labels
.
Selector
,
field
fields
.
Selector
)
(
result
*
api
.
ComponentStatusList
,
err
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewRootListAction
(
"componentstatuses"
,
label
,
field
),
&
api
.
ComponentStatusList
{})
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
ComponentStatusList
),
err
}
pkg/client/testclient/fake_endpoints.go
View file @
b9066392
...
@@ -30,32 +30,48 @@ type FakeEndpoints struct {
...
@@ -30,32 +30,48 @@ type FakeEndpoints struct {
Namespace
string
Namespace
string
}
}
func
(
c
*
FakeEndpoints
)
Create
(
endpoints
*
api
.
Endpoints
)
(
*
api
.
Endpoints
,
error
)
{
func
(
c
*
FakeEndpoints
)
Get
(
name
string
)
(
*
api
.
Endpoints
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"create-endpoints"
},
&
api
.
Endpoints
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewGetAction
(
"endpoints"
,
c
.
Namespace
,
name
),
&
api
.
Endpoints
{})
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
Endpoints
),
err
return
obj
.
(
*
api
.
Endpoints
),
err
}
}
func
(
c
*
FakeEndpoints
)
List
(
selector
labels
.
Selector
)
(
*
api
.
EndpointsList
,
error
)
{
func
(
c
*
FakeEndpoints
)
List
(
label
labels
.
Selector
)
(
*
api
.
EndpointsList
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"list-endpoints"
},
&
api
.
EndpointsList
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewListAction
(
"endpoints"
,
c
.
Namespace
,
label
,
nil
),
&
api
.
EndpointsList
{})
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
EndpointsList
),
err
return
obj
.
(
*
api
.
EndpointsList
),
err
}
}
func
(
c
*
FakeEndpoints
)
Get
(
name
string
)
(
*
api
.
Endpoints
,
error
)
{
func
(
c
*
FakeEndpoints
)
Create
(
endpoints
*
api
.
Endpoints
)
(
*
api
.
Endpoints
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"get-endpoints"
,
Value
:
name
},
&
api
.
Endpoints
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewCreateAction
(
"endpoints"
,
c
.
Namespace
,
endpoints
),
endpoints
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
Endpoints
),
err
}
func
(
c
*
FakeEndpoints
)
Update
(
endpoints
*
api
.
Endpoints
)
(
*
api
.
Endpoints
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewUpdateAction
(
"endpoints"
,
c
.
Namespace
,
endpoints
),
endpoints
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
Endpoints
),
err
return
obj
.
(
*
api
.
Endpoints
),
err
}
}
func
(
c
*
FakeEndpoints
)
Delete
(
name
string
)
error
{
func
(
c
*
FakeEndpoints
)
Delete
(
name
string
)
error
{
_
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"delete-endpoints"
,
Value
:
name
}
,
&
api
.
Endpoints
{})
_
,
err
:=
c
.
Fake
.
Invokes
(
NewDeleteAction
(
"endpoints"
,
c
.
Namespace
,
name
)
,
&
api
.
Endpoints
{})
return
err
return
err
}
}
func
(
c
*
FakeEndpoints
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
c
*
FakeEndpoints
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"watch-endpoints"
,
Value
:
resourceVersion
}
,
nil
)
c
.
Fake
.
Invokes
(
NewWatchAction
(
"endpoints"
,
c
.
Namespace
,
label
,
field
,
resourceVersion
)
,
nil
)
return
c
.
Fake
.
Watch
,
c
.
Fake
.
Err
()
return
c
.
Fake
.
Watch
,
c
.
Fake
.
Err
()
}
}
func
(
c
*
FakeEndpoints
)
Update
(
endpoints
*
api
.
Endpoints
)
(
*
api
.
Endpoints
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"update-endpoints"
,
Value
:
endpoints
.
Name
},
&
api
.
Endpoints
{})
return
obj
.
(
*
api
.
Endpoints
),
err
}
pkg/client/testclient/fake_events.go
View file @
b9066392
...
@@ -30,48 +30,72 @@ type FakeEvents struct {
...
@@ -30,48 +30,72 @@ type FakeEvents struct {
Fake
*
Fake
Fake
*
Fake
}
}
// Create makes a new event. Returns the copy of the event the server returns, or an error.
// Get returns the given event, or an error.
func
(
c
*
FakeEvents
)
Create
(
event
*
api
.
Event
)
(
*
api
.
Event
,
error
)
{
func
(
c
*
FakeEvents
)
Get
(
name
string
)
(
*
api
.
Event
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"get-event"
,
Value
:
event
.
Name
},
&
api
.
Event
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewRootGetAction
(
"events"
,
name
),
&
api
.
Event
{})
return
obj
.
(
*
api
.
Event
),
err
if
obj
==
nil
{
}
return
nil
,
err
}
// Update replaces an existing event. Returns the copy of the event the server returns, or an error.
func
(
c
*
FakeEvents
)
Update
(
event
*
api
.
Event
)
(
*
api
.
Event
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"update-event"
,
Value
:
event
.
Name
},
&
api
.
Event
{})
return
obj
.
(
*
api
.
Event
),
err
return
obj
.
(
*
api
.
Event
),
err
}
}
// List returns a list of events matching the selectors.
// List returns a list of events matching the selectors.
func
(
c
*
FakeEvents
)
List
(
label
labels
.
Selector
,
field
fields
.
Selector
)
(
*
api
.
EventList
,
error
)
{
func
(
c
*
FakeEvents
)
List
(
label
labels
.
Selector
,
field
fields
.
Selector
)
(
*
api
.
EventList
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"list-events"
},
&
api
.
EventList
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewRootListAction
(
"events"
,
label
,
field
),
&
api
.
EventList
{})
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
EventList
),
err
return
obj
.
(
*
api
.
EventList
),
err
}
}
// Get returns the given event, or an error.
// Create makes a new event. Returns the copy of the event the server returns, or an error.
func
(
c
*
FakeEvents
)
Get
(
id
string
)
(
*
api
.
Event
,
error
)
{
func
(
c
*
FakeEvents
)
Create
(
event
*
api
.
Event
)
(
*
api
.
Event
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"get-endpoints"
,
Value
:
id
},
&
api
.
Event
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewRootCreateAction
(
"events"
,
event
),
event
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
Event
),
err
}
// Update replaces an existing event. Returns the copy of the event the server returns, or an error.
func
(
c
*
FakeEvents
)
Update
(
event
*
api
.
Event
)
(
*
api
.
Event
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewRootUpdateAction
(
"events"
,
event
),
event
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
Event
),
err
return
obj
.
(
*
api
.
Event
),
err
}
}
func
(
c
*
FakeEvents
)
Delete
(
name
string
)
error
{
_
,
err
:=
c
.
Fake
.
Invokes
(
NewRootDeleteAction
(
"events"
,
name
),
&
api
.
Event
{})
return
err
}
// Watch starts watching for events matching the given selectors.
// Watch starts watching for events matching the given selectors.
func
(
c
*
FakeEvents
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
c
*
FakeEvents
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"watch-events"
,
Value
:
resourceVersion
}
,
nil
)
c
.
Fake
.
Invokes
(
NewRootWatchAction
(
"events"
,
label
,
field
,
resourceVersion
)
,
nil
)
return
c
.
Fake
.
Watch
,
c
.
Fake
.
Err
()
return
c
.
Fake
.
Watch
,
c
.
Fake
.
Err
()
}
}
// Search returns a list of events matching the specified object.
// Search returns a list of events matching the specified object.
func
(
c
*
FakeEvents
)
Search
(
objOrRef
runtime
.
Object
)
(
*
api
.
EventList
,
error
)
{
func
(
c
*
FakeEvents
)
Search
(
objOrRef
runtime
.
Object
)
(
*
api
.
EventList
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"search-events"
},
&
api
.
EventList
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewRootListAction
(
"events"
,
nil
,
nil
),
&
api
.
EventList
{})
return
obj
.
(
*
api
.
EventList
),
err
if
obj
==
nil
{
}
return
nil
,
err
}
func
(
c
*
FakeEvents
)
Delete
(
name
string
)
error
{
return
obj
.
(
*
api
.
EventList
),
err
_
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"delete-event"
,
Value
:
name
},
&
api
.
Event
{})
return
err
}
}
func
(
c
*
FakeEvents
)
GetFieldSelector
(
involvedObjectName
,
involvedObjectNamespace
,
involvedObjectKind
,
involvedObjectUID
*
string
)
fields
.
Selector
{
func
(
c
*
FakeEvents
)
GetFieldSelector
(
involvedObjectName
,
involvedObjectNamespace
,
involvedObjectKind
,
involvedObjectUID
*
string
)
fields
.
Selector
{
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"get-field-selector"
},
nil
)
action
:=
GenericActionImpl
{}
action
.
Verb
=
"get-field-selector"
action
.
Resource
=
"events"
c
.
Fake
.
Invokes
(
action
,
nil
)
return
fields
.
Everything
()
return
fields
.
Everything
()
}
}
pkg/client/testclient/fake_limit_ranges.go
View file @
b9066392
...
@@ -30,32 +30,48 @@ type FakeLimitRanges struct {
...
@@ -30,32 +30,48 @@ type FakeLimitRanges struct {
Namespace
string
Namespace
string
}
}
func
(
c
*
FakeLimitRanges
)
List
(
selector
labels
.
Selector
)
(
*
api
.
LimitRangeList
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"list-limitRanges"
},
&
api
.
LimitRangeList
{})
return
obj
.
(
*
api
.
LimitRangeList
),
err
}
func
(
c
*
FakeLimitRanges
)
Get
(
name
string
)
(
*
api
.
LimitRange
,
error
)
{
func
(
c
*
FakeLimitRanges
)
Get
(
name
string
)
(
*
api
.
LimitRange
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"get-limitRange"
,
Value
:
name
},
&
api
.
LimitRange
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewGetAction
(
"limitranges"
,
c
.
Namespace
,
name
),
&
api
.
LimitRange
{})
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
LimitRange
),
err
return
obj
.
(
*
api
.
LimitRange
),
err
}
}
func
(
c
*
FakeLimitRanges
)
Delete
(
name
string
)
error
{
func
(
c
*
FakeLimitRanges
)
List
(
label
labels
.
Selector
)
(
*
api
.
LimitRangeList
,
error
)
{
_
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"delete-limitRange"
,
Value
:
name
},
&
api
.
LimitRange
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewListAction
(
"limitranges"
,
c
.
Namespace
,
label
,
nil
),
&
api
.
LimitRangeList
{})
return
err
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
LimitRangeList
),
err
}
}
func
(
c
*
FakeLimitRanges
)
Create
(
limitRange
*
api
.
LimitRange
)
(
*
api
.
LimitRange
,
error
)
{
func
(
c
*
FakeLimitRanges
)
Create
(
limitRange
*
api
.
LimitRange
)
(
*
api
.
LimitRange
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"create-limitRange"
},
&
api
.
LimitRange
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewCreateAction
(
"limitranges"
,
c
.
Namespace
,
limitRange
),
limitRange
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
LimitRange
),
err
return
obj
.
(
*
api
.
LimitRange
),
err
}
}
func
(
c
*
FakeLimitRanges
)
Update
(
limitRange
*
api
.
LimitRange
)
(
*
api
.
LimitRange
,
error
)
{
func
(
c
*
FakeLimitRanges
)
Update
(
limitRange
*
api
.
LimitRange
)
(
*
api
.
LimitRange
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"update-limitRange"
,
Value
:
limitRange
.
Name
},
&
api
.
LimitRange
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewUpdateAction
(
"limitranges"
,
c
.
Namespace
,
limitRange
),
limitRange
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
LimitRange
),
err
return
obj
.
(
*
api
.
LimitRange
),
err
}
}
func
(
c
*
FakeLimitRanges
)
Delete
(
name
string
)
error
{
_
,
err
:=
c
.
Fake
.
Invokes
(
NewDeleteAction
(
"limitranges"
,
c
.
Namespace
,
name
),
&
api
.
LimitRange
{})
return
err
}
func
(
c
*
FakeLimitRanges
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
c
*
FakeLimitRanges
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"watch-limitRange"
,
Value
:
resourceVersion
}
,
nil
)
c
.
Fake
.
Invokes
(
NewWatchAction
(
"limitranges"
,
c
.
Namespace
,
label
,
field
,
resourceVersion
)
,
nil
)
return
c
.
Fake
.
Watch
,
nil
return
c
.
Fake
.
Watch
,
nil
}
}
pkg/client/testclient/fake_namespaces.go
View file @
b9066392
...
@@ -29,42 +29,78 @@ type FakeNamespaces struct {
...
@@ -29,42 +29,78 @@ type FakeNamespaces struct {
Fake
*
Fake
Fake
*
Fake
}
}
func
(
c
*
FakeNamespaces
)
List
(
labels
labels
.
Selector
,
field
fields
.
Selector
)
(
*
api
.
NamespaceList
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"list-namespaces"
},
&
api
.
NamespaceList
{})
return
obj
.
(
*
api
.
NamespaceList
),
err
}
func
(
c
*
FakeNamespaces
)
Get
(
name
string
)
(
*
api
.
Namespace
,
error
)
{
func
(
c
*
FakeNamespaces
)
Get
(
name
string
)
(
*
api
.
Namespace
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"get-namespace"
,
Value
:
name
},
&
api
.
Namespace
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewRootGetAction
(
"namespaces"
,
name
),
&
api
.
Namespace
{})
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
Namespace
),
err
return
obj
.
(
*
api
.
Namespace
),
err
}
}
func
(
c
*
FakeNamespaces
)
Delete
(
name
string
)
error
{
func
(
c
*
FakeNamespaces
)
List
(
label
labels
.
Selector
,
field
fields
.
Selector
)
(
*
api
.
NamespaceList
,
error
)
{
_
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"delete-namespace"
,
Value
:
name
},
&
api
.
Namespace
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewRootListAction
(
"namespaces"
,
label
,
field
),
&
api
.
NamespaceList
{})
return
err
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
NamespaceList
),
err
}
}
func
(
c
*
FakeNamespaces
)
Create
(
namespace
*
api
.
Namespace
)
(
*
api
.
Namespace
,
error
)
{
func
(
c
*
FakeNamespaces
)
Create
(
namespace
*
api
.
Namespace
)
(
*
api
.
Namespace
,
error
)
{
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"create-namespace"
},
nil
)
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewRootCreateAction
(
"namespaces"
,
namespace
),
namespace
)
return
&
api
.
Namespace
{},
c
.
Fake
.
Err
()
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
Namespace
),
c
.
Fake
.
Err
()
}
}
func
(
c
*
FakeNamespaces
)
Update
(
namespace
*
api
.
Namespace
)
(
*
api
.
Namespace
,
error
)
{
func
(
c
*
FakeNamespaces
)
Update
(
namespace
*
api
.
Namespace
)
(
*
api
.
Namespace
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"update-namespace"
,
Value
:
namespace
},
&
api
.
Namespace
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewRootUpdateAction
(
"namespaces"
,
namespace
),
namespace
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
Namespace
),
err
return
obj
.
(
*
api
.
Namespace
),
err
}
}
func
(
c
*
FakeNamespaces
)
Delete
(
name
string
)
error
{
_
,
err
:=
c
.
Fake
.
Invokes
(
NewRootDeleteAction
(
"namespaces"
,
name
),
&
api
.
Namespace
{})
return
err
}
func
(
c
*
FakeNamespaces
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
c
*
FakeNamespaces
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"watch-namespaces"
,
Value
:
resourceVersion
}
,
nil
)
c
.
Fake
.
Invokes
(
NewRootWatchAction
(
"namespaces"
,
label
,
field
,
resourceVersion
)
,
nil
)
return
c
.
Fake
.
Watch
,
nil
return
c
.
Fake
.
Watch
,
nil
}
}
func
(
c
*
FakeNamespaces
)
Finalize
(
namespace
*
api
.
Namespace
)
(
*
api
.
Namespace
,
error
)
{
func
(
c
*
FakeNamespaces
)
Finalize
(
namespace
*
api
.
Namespace
)
(
*
api
.
Namespace
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"finalize-namespace"
,
Value
:
namespace
},
&
api
.
Namespace
{})
action
:=
CreateActionImpl
{}
action
.
Verb
=
"create"
action
.
Resource
=
"namespaces"
action
.
Subresource
=
"finalize"
action
.
Object
=
namespace
obj
,
err
:=
c
.
Fake
.
Invokes
(
action
,
namespace
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
Namespace
),
err
return
obj
.
(
*
api
.
Namespace
),
err
}
}
func
(
c
*
FakeNamespaces
)
Status
(
namespace
*
api
.
Namespace
)
(
*
api
.
Namespace
,
error
)
{
func
(
c
*
FakeNamespaces
)
Status
(
namespace
*
api
.
Namespace
)
(
*
api
.
Namespace
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"status-namespace"
,
Value
:
namespace
},
&
api
.
Namespace
{})
action
:=
CreateActionImpl
{}
action
.
Verb
=
"create"
action
.
Resource
=
"namespaces"
action
.
Subresource
=
"status"
action
.
Object
=
namespace
obj
,
err
:=
c
.
Fake
.
Invokes
(
action
,
namespace
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
Namespace
),
err
return
obj
.
(
*
api
.
Namespace
),
err
}
}
pkg/client/testclient/fake_nodes.go
View file @
b9066392
...
@@ -30,36 +30,62 @@ type FakeNodes struct {
...
@@ -30,36 +30,62 @@ type FakeNodes struct {
}
}
func
(
c
*
FakeNodes
)
Get
(
name
string
)
(
*
api
.
Node
,
error
)
{
func
(
c
*
FakeNodes
)
Get
(
name
string
)
(
*
api
.
Node
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"get-node"
,
Value
:
name
},
&
api
.
Node
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewRootGetAction
(
"nodes"
,
name
),
&
api
.
Node
{})
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
Node
),
err
return
obj
.
(
*
api
.
Node
),
err
}
}
func
(
c
*
FakeNodes
)
List
(
label
labels
.
Selector
,
field
fields
.
Selector
)
(
*
api
.
NodeList
,
error
)
{
func
(
c
*
FakeNodes
)
List
(
label
labels
.
Selector
,
field
fields
.
Selector
)
(
*
api
.
NodeList
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"list-nodes"
},
&
api
.
NodeList
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewRootListAction
(
"nodes"
,
label
,
field
),
&
api
.
NodeList
{})
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
NodeList
),
err
return
obj
.
(
*
api
.
NodeList
),
err
}
}
func
(
c
*
FakeNodes
)
Create
(
minion
*
api
.
Node
)
(
*
api
.
Node
,
error
)
{
func
(
c
*
FakeNodes
)
Create
(
minion
*
api
.
Node
)
(
*
api
.
Node
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"create-node"
,
Value
:
minion
},
&
api
.
Node
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewRootCreateAction
(
"nodes"
,
minion
),
minion
)
return
obj
.
(
*
api
.
Node
),
err
if
obj
==
nil
{
}
return
nil
,
err
}
func
(
c
*
FakeNodes
)
Delete
(
name
string
)
error
{
return
obj
.
(
*
api
.
Node
),
err
_
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"delete-node"
,
Value
:
name
},
&
api
.
Node
{})
return
err
}
}
func
(
c
*
FakeNodes
)
Update
(
minion
*
api
.
Node
)
(
*
api
.
Node
,
error
)
{
func
(
c
*
FakeNodes
)
Update
(
minion
*
api
.
Node
)
(
*
api
.
Node
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"update-node"
,
Value
:
minion
},
&
api
.
Node
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewRootUpdateAction
(
"nodes"
,
minion
),
minion
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
Node
),
err
return
obj
.
(
*
api
.
Node
),
err
}
}
func
(
c
*
FakeNodes
)
UpdateStatus
(
minion
*
api
.
Node
)
(
*
api
.
Node
,
error
)
{
func
(
c
*
FakeNodes
)
Delete
(
name
string
)
error
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"update-status-node"
,
Value
:
minion
}
,
&
api
.
Node
{})
_
,
err
:=
c
.
Fake
.
Invokes
(
NewRootDeleteAction
(
"nodes"
,
name
)
,
&
api
.
Node
{})
return
obj
.
(
*
api
.
Node
),
err
return
err
}
}
func
(
c
*
FakeNodes
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
c
*
FakeNodes
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"watch-nodes"
,
Value
:
resourceVersion
}
,
nil
)
c
.
Fake
.
Invokes
(
NewRootWatchAction
(
"nodes"
,
label
,
field
,
resourceVersion
)
,
nil
)
return
c
.
Fake
.
Watch
,
c
.
Fake
.
Err
()
return
c
.
Fake
.
Watch
,
c
.
Fake
.
Err
()
}
}
func
(
c
*
FakeNodes
)
UpdateStatus
(
minion
*
api
.
Node
)
(
*
api
.
Node
,
error
)
{
action
:=
CreateActionImpl
{}
action
.
Verb
=
"update"
action
.
Resource
=
"nodes"
action
.
Subresource
=
"status"
action
.
Object
=
minion
obj
,
err
:=
c
.
Fake
.
Invokes
(
action
,
minion
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
Node
),
err
}
pkg/client/testclient/fake_persistent_volume_claims.go
View file @
b9066392
...
@@ -28,37 +28,63 @@ type FakePersistentVolumeClaims struct {
...
@@ -28,37 +28,63 @@ type FakePersistentVolumeClaims struct {
Namespace
string
Namespace
string
}
}
func
(
c
*
FakePersistentVolumeClaims
)
List
(
label
labels
.
Selector
,
field
fields
.
Selector
)
(
*
api
.
PersistentVolumeClaimList
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"list-persistentVolumeClaims"
},
&
api
.
PersistentVolumeClaimList
{})
return
obj
.
(
*
api
.
PersistentVolumeClaimList
),
err
}
func
(
c
*
FakePersistentVolumeClaims
)
Get
(
name
string
)
(
*
api
.
PersistentVolumeClaim
,
error
)
{
func
(
c
*
FakePersistentVolumeClaims
)
Get
(
name
string
)
(
*
api
.
PersistentVolumeClaim
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"get-persistentVolumeClaims"
,
Value
:
name
},
&
api
.
PersistentVolumeClaim
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewGetAction
(
"persistentvolumeclaims"
,
c
.
Namespace
,
name
),
&
api
.
PersistentVolumeClaim
{})
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
PersistentVolumeClaim
),
err
return
obj
.
(
*
api
.
PersistentVolumeClaim
),
err
}
}
func
(
c
*
FakePersistentVolumeClaims
)
Delete
(
name
string
)
error
{
func
(
c
*
FakePersistentVolumeClaims
)
List
(
label
labels
.
Selector
,
field
fields
.
Selector
)
(
*
api
.
PersistentVolumeClaimList
,
error
)
{
_
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"delete-persistentVolumeClaims"
,
Value
:
name
},
&
api
.
PersistentVolumeClaim
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewListAction
(
"persistentvolumeclaims"
,
c
.
Namespace
,
label
,
field
),
&
api
.
PersistentVolumeClaimList
{})
return
err
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
PersistentVolumeClaimList
),
err
}
}
func
(
c
*
FakePersistentVolumeClaims
)
Create
(
claim
*
api
.
PersistentVolumeClaim
)
(
*
api
.
PersistentVolumeClaim
,
error
)
{
func
(
c
*
FakePersistentVolumeClaims
)
Create
(
claim
*
api
.
PersistentVolumeClaim
)
(
*
api
.
PersistentVolumeClaim
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"create-persistentVolumeClaims"
},
&
api
.
PersistentVolumeClaim
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewCreateAction
(
"persistentvolumeclaims"
,
c
.
Namespace
,
claim
),
claim
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
PersistentVolumeClaim
),
err
return
obj
.
(
*
api
.
PersistentVolumeClaim
),
err
}
}
func
(
c
*
FakePersistentVolumeClaims
)
Update
(
claim
*
api
.
PersistentVolumeClaim
)
(
*
api
.
PersistentVolumeClaim
,
error
)
{
func
(
c
*
FakePersistentVolumeClaims
)
Update
(
claim
*
api
.
PersistentVolumeClaim
)
(
*
api
.
PersistentVolumeClaim
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"update-persistentVolumeClaims"
,
Value
:
claim
.
Name
},
&
api
.
PersistentVolumeClaim
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewUpdateAction
(
"persistentvolumeclaims"
,
c
.
Namespace
,
claim
),
claim
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
PersistentVolumeClaim
),
err
return
obj
.
(
*
api
.
PersistentVolumeClaim
),
err
}
}
func
(
c
*
FakePersistentVolumeClaims
)
UpdateStatus
(
claim
*
api
.
PersistentVolumeClaim
)
(
*
api
.
PersistentVolumeClaim
,
error
)
{
func
(
c
*
FakePersistentVolumeClaims
)
Delete
(
name
string
)
error
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"update-status-persistentVolumeClaims"
,
Value
:
claim
}
,
&
api
.
PersistentVolumeClaim
{})
_
,
err
:=
c
.
Fake
.
Invokes
(
NewDeleteAction
(
"persistentvolumeclaims"
,
c
.
Namespace
,
name
)
,
&
api
.
PersistentVolumeClaim
{})
return
obj
.
(
*
api
.
PersistentVolumeClaim
),
err
return
err
}
}
func
(
c
*
FakePersistentVolumeClaims
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
c
*
FakePersistentVolumeClaims
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"watch-persistentVolumeClaims"
,
Value
:
resourceVersion
}
,
nil
)
c
.
Fake
.
Invokes
(
NewWatchAction
(
"persistentvolumeclaims"
,
c
.
Namespace
,
label
,
field
,
resourceVersion
)
,
nil
)
return
c
.
Fake
.
Watch
,
c
.
Fake
.
Err
()
return
c
.
Fake
.
Watch
,
c
.
Fake
.
Err
()
}
}
func
(
c
*
FakePersistentVolumeClaims
)
UpdateStatus
(
claim
*
api
.
PersistentVolumeClaim
)
(
*
api
.
PersistentVolumeClaim
,
error
)
{
action
:=
UpdateActionImpl
{}
action
.
Verb
=
"update"
action
.
Resource
=
"persistentvolumeclaims"
action
.
Subresource
=
"status"
action
.
Object
=
claim
obj
,
err
:=
c
.
Fake
.
Invokes
(
action
,
claim
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
PersistentVolumeClaim
),
err
}
pkg/client/testclient/fake_persistent_volumes.go
View file @
b9066392
...
@@ -24,41 +24,66 @@ import (
...
@@ -24,41 +24,66 @@ import (
)
)
type
FakePersistentVolumes
struct
{
type
FakePersistentVolumes
struct
{
Fake
*
Fake
Fake
*
Fake
Namespace
string
}
func
(
c
*
FakePersistentVolumes
)
List
(
label
labels
.
Selector
,
field
fields
.
Selector
)
(
*
api
.
PersistentVolumeList
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"list-persistentVolumes"
},
&
api
.
PersistentVolumeList
{})
return
obj
.
(
*
api
.
PersistentVolumeList
),
err
}
}
func
(
c
*
FakePersistentVolumes
)
Get
(
name
string
)
(
*
api
.
PersistentVolume
,
error
)
{
func
(
c
*
FakePersistentVolumes
)
Get
(
name
string
)
(
*
api
.
PersistentVolume
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"get-persistentVolumes"
,
Value
:
name
},
&
api
.
PersistentVolume
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewRootGetAction
(
"persistentvolumes"
,
name
),
&
api
.
PersistentVolume
{})
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
PersistentVolume
),
err
return
obj
.
(
*
api
.
PersistentVolume
),
err
}
}
func
(
c
*
FakePersistentVolumes
)
Delete
(
name
string
)
error
{
func
(
c
*
FakePersistentVolumes
)
List
(
label
labels
.
Selector
,
field
fields
.
Selector
)
(
*
api
.
PersistentVolumeList
,
error
)
{
_
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"delete-persistentVolumes"
,
Value
:
name
},
&
api
.
PersistentVolume
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewRootListAction
(
"persistentvolumes"
,
label
,
field
),
&
api
.
PersistentVolumeList
{})
return
err
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
PersistentVolumeList
),
err
}
}
func
(
c
*
FakePersistentVolumes
)
Create
(
pv
*
api
.
PersistentVolume
)
(
*
api
.
PersistentVolume
,
error
)
{
func
(
c
*
FakePersistentVolumes
)
Create
(
pv
*
api
.
PersistentVolume
)
(
*
api
.
PersistentVolume
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"create-persistentVolumes"
},
&
api
.
PersistentVolume
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewRootCreateAction
(
"persistentvolumes"
,
pv
),
pv
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
PersistentVolume
),
err
return
obj
.
(
*
api
.
PersistentVolume
),
err
}
}
func
(
c
*
FakePersistentVolumes
)
Update
(
pv
*
api
.
PersistentVolume
)
(
*
api
.
PersistentVolume
,
error
)
{
func
(
c
*
FakePersistentVolumes
)
Update
(
pv
*
api
.
PersistentVolume
)
(
*
api
.
PersistentVolume
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"update-persistentVolumes"
,
Value
:
pv
.
Name
},
&
api
.
PersistentVolume
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewRootUpdateAction
(
"persistentvolumes"
,
pv
),
pv
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
PersistentVolume
),
err
return
obj
.
(
*
api
.
PersistentVolume
),
err
}
}
func
(
c
*
FakePersistentVolumes
)
UpdateStatus
(
pv
*
api
.
PersistentVolume
)
(
*
api
.
PersistentVolume
,
error
)
{
func
(
c
*
FakePersistentVolumes
)
Delete
(
name
string
)
error
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"update-status-persistentVolumes"
,
Value
:
pv
}
,
&
api
.
PersistentVolume
{})
_
,
err
:=
c
.
Fake
.
Invokes
(
NewRootDeleteAction
(
"persistentvolumes"
,
name
)
,
&
api
.
PersistentVolume
{})
return
obj
.
(
*
api
.
PersistentVolume
),
err
return
err
}
}
func
(
c
*
FakePersistentVolumes
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
c
*
FakePersistentVolumes
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"watch-persistentVolumes"
,
Value
:
resourceVersion
}
,
nil
)
c
.
Fake
.
Invokes
(
NewRootWatchAction
(
"persistentvolumes"
,
label
,
field
,
resourceVersion
)
,
nil
)
return
c
.
Fake
.
Watch
,
c
.
Fake
.
Err
()
return
c
.
Fake
.
Watch
,
c
.
Fake
.
Err
()
}
}
func
(
c
*
FakePersistentVolumes
)
UpdateStatus
(
pv
*
api
.
PersistentVolume
)
(
*
api
.
PersistentVolume
,
error
)
{
action
:=
UpdateActionImpl
{}
action
.
Verb
=
"update"
action
.
Resource
=
"persistentvolumes"
action
.
Subresource
=
"status"
action
.
Object
=
pv
obj
,
err
:=
c
.
Fake
.
Invokes
(
action
,
pv
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
PersistentVolume
),
err
}
pkg/client/testclient/fake_pod_templates.go
View file @
b9066392
...
@@ -30,32 +30,48 @@ type FakePodTemplates struct {
...
@@ -30,32 +30,48 @@ type FakePodTemplates struct {
Namespace
string
Namespace
string
}
}
func
(
c
*
FakePodTemplates
)
List
(
label
labels
.
Selector
,
field
fields
.
Selector
)
(
*
api
.
PodTemplateList
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"list-podTemplates"
},
&
api
.
PodTemplateList
{})
return
obj
.
(
*
api
.
PodTemplateList
),
err
}
func
(
c
*
FakePodTemplates
)
Get
(
name
string
)
(
*
api
.
PodTemplate
,
error
)
{
func
(
c
*
FakePodTemplates
)
Get
(
name
string
)
(
*
api
.
PodTemplate
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"get-podTemplate"
,
Value
:
name
},
&
api
.
PodTemplate
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewGetAction
(
"podtemplates"
,
c
.
Namespace
,
name
),
&
api
.
PodTemplate
{})
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
PodTemplate
),
err
return
obj
.
(
*
api
.
PodTemplate
),
err
}
}
func
(
c
*
FakePodTemplates
)
Delete
(
name
string
,
options
*
api
.
DeleteOptions
)
error
{
func
(
c
*
FakePodTemplates
)
List
(
label
labels
.
Selector
,
field
fields
.
Selector
)
(
*
api
.
PodTemplateList
,
error
)
{
_
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"delete-podTemplate"
,
Value
:
name
},
&
api
.
PodTemplate
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewListAction
(
"podtemplates"
,
c
.
Namespace
,
label
,
field
),
&
api
.
PodTemplateList
{})
return
err
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
PodTemplateList
),
err
}
}
func
(
c
*
FakePodTemplates
)
Create
(
pod
*
api
.
PodTemplate
)
(
*
api
.
PodTemplate
,
error
)
{
func
(
c
*
FakePodTemplates
)
Create
(
pod
*
api
.
PodTemplate
)
(
*
api
.
PodTemplate
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"create-podTemplate"
},
&
api
.
PodTemplate
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewCreateAction
(
"podtemplates"
,
c
.
Namespace
,
pod
),
pod
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
PodTemplate
),
err
return
obj
.
(
*
api
.
PodTemplate
),
err
}
}
func
(
c
*
FakePodTemplates
)
Update
(
pod
*
api
.
PodTemplate
)
(
*
api
.
PodTemplate
,
error
)
{
func
(
c
*
FakePodTemplates
)
Update
(
pod
*
api
.
PodTemplate
)
(
*
api
.
PodTemplate
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"update-podTemplate"
,
Value
:
pod
.
Name
},
&
api
.
PodTemplate
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewUpdateAction
(
"podtemplates"
,
c
.
Namespace
,
pod
),
pod
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
PodTemplate
),
err
return
obj
.
(
*
api
.
PodTemplate
),
err
}
}
func
(
c
*
FakePodTemplates
)
Delete
(
name
string
,
options
*
api
.
DeleteOptions
)
error
{
_
,
err
:=
c
.
Fake
.
Invokes
(
NewDeleteAction
(
"podtemplates"
,
c
.
Namespace
,
name
),
&
api
.
PodTemplate
{})
return
err
}
func
(
c
*
FakePodTemplates
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
c
*
FakePodTemplates
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"watch-podTemplates"
,
Value
:
resourceVersion
}
,
nil
)
c
.
Fake
.
Invokes
(
NewWatchAction
(
"podtemplates"
,
c
.
Namespace
,
label
,
field
,
resourceVersion
)
,
nil
)
return
c
.
Fake
.
Watch
,
c
.
Fake
.
Err
()
return
c
.
Fake
.
Watch
,
c
.
Fake
.
Err
()
}
}
pkg/client/testclient/fake_pods.go
View file @
b9066392
...
@@ -30,42 +30,74 @@ type FakePods struct {
...
@@ -30,42 +30,74 @@ type FakePods struct {
Namespace
string
Namespace
string
}
}
func
(
c
*
FakePods
)
List
(
label
labels
.
Selector
,
field
fields
.
Selector
)
(
*
api
.
PodList
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"list-pods"
},
&
api
.
PodList
{})
return
obj
.
(
*
api
.
PodList
),
err
}
func
(
c
*
FakePods
)
Get
(
name
string
)
(
*
api
.
Pod
,
error
)
{
func
(
c
*
FakePods
)
Get
(
name
string
)
(
*
api
.
Pod
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"get-pod"
,
Value
:
name
},
&
api
.
Pod
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewGetAction
(
"pods"
,
c
.
Namespace
,
name
),
&
api
.
Pod
{})
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
Pod
),
err
return
obj
.
(
*
api
.
Pod
),
err
}
}
func
(
c
*
FakePods
)
Delete
(
name
string
,
options
*
api
.
DeleteOptions
)
error
{
func
(
c
*
FakePods
)
List
(
label
labels
.
Selector
,
field
fields
.
Selector
)
(
*
api
.
PodList
,
error
)
{
_
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"delete-pod"
,
Value
:
name
},
&
api
.
Pod
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewListAction
(
"pods"
,
c
.
Namespace
,
label
,
field
),
&
api
.
PodList
{})
return
err
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
PodList
),
err
}
}
func
(
c
*
FakePods
)
Create
(
pod
*
api
.
Pod
)
(
*
api
.
Pod
,
error
)
{
func
(
c
*
FakePods
)
Create
(
pod
*
api
.
Pod
)
(
*
api
.
Pod
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"create-pod"
},
&
api
.
Pod
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewCreateAction
(
"pods"
,
c
.
Namespace
,
pod
),
pod
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
Pod
),
err
return
obj
.
(
*
api
.
Pod
),
err
}
}
func
(
c
*
FakePods
)
Update
(
pod
*
api
.
Pod
)
(
*
api
.
Pod
,
error
)
{
func
(
c
*
FakePods
)
Update
(
pod
*
api
.
Pod
)
(
*
api
.
Pod
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"update-pod"
,
Value
:
pod
.
Name
},
&
api
.
Pod
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewUpdateAction
(
"pods"
,
c
.
Namespace
,
pod
),
pod
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
Pod
),
err
return
obj
.
(
*
api
.
Pod
),
err
}
}
func
(
c
*
FakePods
)
Delete
(
name
string
,
options
*
api
.
DeleteOptions
)
error
{
_
,
err
:=
c
.
Fake
.
Invokes
(
NewDeleteAction
(
"pods"
,
c
.
Namespace
,
name
),
&
api
.
Pod
{})
return
err
}
func
(
c
*
FakePods
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
c
*
FakePods
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"watch-pods"
,
Value
:
resourceVersion
}
,
nil
)
c
.
Fake
.
Invokes
(
NewWatchAction
(
"pods"
,
c
.
Namespace
,
label
,
field
,
resourceVersion
)
,
nil
)
return
c
.
Fake
.
Watch
,
c
.
Fake
.
Err
()
return
c
.
Fake
.
Watch
,
c
.
Fake
.
Err
()
}
}
func
(
c
*
FakePods
)
Bind
(
bind
*
api
.
Binding
)
error
{
func
(
c
*
FakePods
)
Bind
(
binding
*
api
.
Binding
)
error
{
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"bind-pod"
,
Value
:
bind
.
Name
},
nil
)
action
:=
CreateActionImpl
{}
return
nil
action
.
Verb
=
"create"
action
.
Resource
=
"pods"
action
.
Subresource
=
"bindings"
action
.
Object
=
binding
_
,
err
:=
c
.
Fake
.
Invokes
(
action
,
binding
)
return
err
}
}
func
(
c
*
FakePods
)
UpdateStatus
(
pod
*
api
.
Pod
)
(
*
api
.
Pod
,
error
)
{
func
(
c
*
FakePods
)
UpdateStatus
(
pod
*
api
.
Pod
)
(
*
api
.
Pod
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"update-status-pod"
,
Value
:
pod
.
Name
},
&
api
.
Pod
{})
action
:=
UpdateActionImpl
{}
action
.
Verb
=
"update"
action
.
Resource
=
"pods"
action
.
Subresource
=
"status"
action
.
Object
=
pod
obj
,
err
:=
c
.
Fake
.
Invokes
(
action
,
pod
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
Pod
),
err
return
obj
.
(
*
api
.
Pod
),
err
}
}
pkg/client/testclient/fake_replication_controllers.go
View file @
b9066392
...
@@ -30,41 +30,48 @@ type FakeReplicationControllers struct {
...
@@ -30,41 +30,48 @@ type FakeReplicationControllers struct {
Namespace
string
Namespace
string
}
}
const
(
func
(
c
*
FakeReplicationControllers
)
Get
(
name
string
)
(
*
api
.
ReplicationController
,
error
)
{
GetControllerAction
=
"get-replicationController"
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewGetAction
(
"replicationcontrollers"
,
c
.
Namespace
,
name
),
&
api
.
ReplicationController
{})
UpdateControllerAction
=
"update-replicationController"
if
obj
==
nil
{
WatchControllerAction
=
"watch-replicationController"
return
nil
,
err
DeleteControllerAction
=
"delete-replicationController"
}
ListControllerAction
=
"list-replicationController"
CreateControllerAction
=
"create-replicationController"
)
func
(
c
*
FakeReplicationControllers
)
List
(
selector
labels
.
Selector
)
(
*
api
.
ReplicationControllerList
,
error
)
{
return
obj
.
(
*
api
.
ReplicationController
),
err
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
ListControllerAction
},
&
api
.
ReplicationControllerList
{})
return
obj
.
(
*
api
.
ReplicationControllerList
),
err
}
}
func
(
c
*
FakeReplicationControllers
)
Get
(
name
string
)
(
*
api
.
ReplicationController
,
error
)
{
func
(
c
*
FakeReplicationControllers
)
List
(
label
labels
.
Selector
)
(
*
api
.
ReplicationControllerList
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
GetControllerAction
,
Value
:
name
},
&
api
.
ReplicationController
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewListAction
(
"replicationcontrollers"
,
c
.
Namespace
,
label
,
nil
),
&
api
.
ReplicationControllerList
{})
return
obj
.
(
*
api
.
ReplicationController
),
err
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
ReplicationControllerList
),
err
}
}
func
(
c
*
FakeReplicationControllers
)
Create
(
controller
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
{
func
(
c
*
FakeReplicationControllers
)
Create
(
controller
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
CreateControllerAction
,
Value
:
controller
},
&
api
.
ReplicationController
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewCreateAction
(
"replicationcontrollers"
,
c
.
Namespace
,
controller
),
controller
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
ReplicationController
),
err
return
obj
.
(
*
api
.
ReplicationController
),
err
}
}
func
(
c
*
FakeReplicationControllers
)
Update
(
controller
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
{
func
(
c
*
FakeReplicationControllers
)
Update
(
controller
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
UpdateControllerAction
,
Value
:
controller
},
&
api
.
ReplicationController
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewUpdateAction
(
"replicationcontrollers"
,
c
.
Namespace
,
controller
),
controller
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
ReplicationController
),
err
return
obj
.
(
*
api
.
ReplicationController
),
err
}
}
func
(
c
*
FakeReplicationControllers
)
Delete
(
name
string
)
error
{
func
(
c
*
FakeReplicationControllers
)
Delete
(
name
string
)
error
{
_
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
DeleteControllerAction
,
Value
:
name
}
,
&
api
.
ReplicationController
{})
_
,
err
:=
c
.
Fake
.
Invokes
(
NewDeleteAction
(
"replicationcontrollers"
,
c
.
Namespace
,
name
)
,
&
api
.
ReplicationController
{})
return
err
return
err
}
}
func
(
c
*
FakeReplicationControllers
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
c
*
FakeReplicationControllers
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
WatchControllerAction
,
Value
:
resourceVersion
}
,
nil
)
c
.
Fake
.
Invokes
(
NewWatchAction
(
"replicationcontrollers"
,
c
.
Namespace
,
label
,
field
,
resourceVersion
)
,
nil
)
return
c
.
Fake
.
Watch
,
nil
return
c
.
Fake
.
Watch
,
nil
}
}
pkg/client/testclient/fake_resource_quotas.go
View file @
b9066392
...
@@ -30,37 +30,63 @@ type FakeResourceQuotas struct {
...
@@ -30,37 +30,63 @@ type FakeResourceQuotas struct {
Namespace
string
Namespace
string
}
}
func
(
c
*
FakeResourceQuotas
)
List
(
selector
labels
.
Selector
)
(
*
api
.
ResourceQuotaList
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"list-resourceQuotas"
},
&
api
.
ResourceQuotaList
{})
return
obj
.
(
*
api
.
ResourceQuotaList
),
err
}
func
(
c
*
FakeResourceQuotas
)
Get
(
name
string
)
(
*
api
.
ResourceQuota
,
error
)
{
func
(
c
*
FakeResourceQuotas
)
Get
(
name
string
)
(
*
api
.
ResourceQuota
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"get-resourceQuota"
,
Value
:
name
},
&
api
.
ResourceQuota
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewGetAction
(
"resourcequotas"
,
c
.
Namespace
,
name
),
&
api
.
ResourceQuota
{})
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
ResourceQuota
),
err
return
obj
.
(
*
api
.
ResourceQuota
),
err
}
}
func
(
c
*
FakeResourceQuotas
)
Delete
(
name
string
)
error
{
func
(
c
*
FakeResourceQuotas
)
List
(
label
labels
.
Selector
)
(
*
api
.
ResourceQuotaList
,
error
)
{
_
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"delete-resourceQuota"
,
Value
:
name
},
&
api
.
ResourceQuota
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewListAction
(
"resourcequotas"
,
c
.
Namespace
,
label
,
nil
),
&
api
.
ResourceQuotaList
{})
return
err
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
ResourceQuotaList
),
err
}
}
func
(
c
*
FakeResourceQuotas
)
Create
(
resourceQuota
*
api
.
ResourceQuota
)
(
*
api
.
ResourceQuota
,
error
)
{
func
(
c
*
FakeResourceQuotas
)
Create
(
resourceQuota
*
api
.
ResourceQuota
)
(
*
api
.
ResourceQuota
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"create-resourceQuota"
,
Value
:
resourceQuota
},
&
api
.
ResourceQuota
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewCreateAction
(
"resourcequotas"
,
c
.
Namespace
,
resourceQuota
),
resourceQuota
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
ResourceQuota
),
err
return
obj
.
(
*
api
.
ResourceQuota
),
err
}
}
func
(
c
*
FakeResourceQuotas
)
Update
(
resourceQuota
*
api
.
ResourceQuota
)
(
*
api
.
ResourceQuota
,
error
)
{
func
(
c
*
FakeResourceQuotas
)
Update
(
resourceQuota
*
api
.
ResourceQuota
)
(
*
api
.
ResourceQuota
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"update-resourceQuota"
,
Value
:
resourceQuota
},
&
api
.
ResourceQuota
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewUpdateAction
(
"resourcequotas"
,
c
.
Namespace
,
resourceQuota
),
resourceQuota
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
ResourceQuota
),
err
return
obj
.
(
*
api
.
ResourceQuota
),
err
}
}
func
(
c
*
FakeResourceQuotas
)
UpdateStatus
(
resourceQuota
*
api
.
ResourceQuota
)
(
*
api
.
ResourceQuota
,
error
)
{
func
(
c
*
FakeResourceQuotas
)
Delete
(
name
string
)
error
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"update-status-resourceQuota"
,
Value
:
resourceQuota
}
,
&
api
.
ResourceQuota
{})
_
,
err
:=
c
.
Fake
.
Invokes
(
NewDeleteAction
(
"resourcequotas"
,
c
.
Namespace
,
name
)
,
&
api
.
ResourceQuota
{})
return
obj
.
(
*
api
.
ResourceQuota
),
err
return
err
}
}
func
(
c
*
FakeResourceQuotas
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
c
*
FakeResourceQuotas
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"watch-resourceQuota"
,
Value
:
resourceVersion
}
,
nil
)
c
.
Fake
.
Invokes
(
NewWatchAction
(
"resourcequotas"
,
c
.
Namespace
,
label
,
field
,
resourceVersion
)
,
nil
)
return
c
.
Fake
.
Watch
,
nil
return
c
.
Fake
.
Watch
,
nil
}
}
func
(
c
*
FakeResourceQuotas
)
UpdateStatus
(
resourceQuota
*
api
.
ResourceQuota
)
(
*
api
.
ResourceQuota
,
error
)
{
action
:=
UpdateActionImpl
{}
action
.
Verb
=
"update"
action
.
Resource
=
"resourcequotas"
action
.
Subresource
=
"status"
action
.
Object
=
resourceQuota
obj
,
err
:=
c
.
Fake
.
Invokes
(
action
,
resourceQuota
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
ResourceQuota
),
err
}
pkg/client/testclient/fake_secrets.go
View file @
b9066392
...
@@ -30,32 +30,48 @@ type FakeSecrets struct {
...
@@ -30,32 +30,48 @@ type FakeSecrets struct {
Namespace
string
Namespace
string
}
}
func
(
c
*
FakeSecrets
)
List
(
labels
labels
.
Selector
,
field
fields
.
Selector
)
(
*
api
.
SecretList
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"list-secrets"
},
&
api
.
SecretList
{})
return
obj
.
(
*
api
.
SecretList
),
err
}
func
(
c
*
FakeSecrets
)
Get
(
name
string
)
(
*
api
.
Secret
,
error
)
{
func
(
c
*
FakeSecrets
)
Get
(
name
string
)
(
*
api
.
Secret
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"get-secret"
,
Value
:
name
},
&
api
.
Secret
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewGetAction
(
"secrets"
,
c
.
Namespace
,
name
),
&
api
.
Secret
{})
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
Secret
),
err
return
obj
.
(
*
api
.
Secret
),
err
}
}
func
(
c
*
FakeSecrets
)
List
(
label
labels
.
Selector
,
field
fields
.
Selector
)
(
*
api
.
SecretList
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewListAction
(
"secrets"
,
c
.
Namespace
,
label
,
field
),
&
api
.
SecretList
{})
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
SecretList
),
err
}
func
(
c
*
FakeSecrets
)
Create
(
secret
*
api
.
Secret
)
(
*
api
.
Secret
,
error
)
{
func
(
c
*
FakeSecrets
)
Create
(
secret
*
api
.
Secret
)
(
*
api
.
Secret
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"create-secret"
,
Value
:
secret
},
&
api
.
Secret
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewCreateAction
(
"secrets"
,
c
.
Namespace
,
secret
),
secret
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
Secret
),
err
return
obj
.
(
*
api
.
Secret
),
err
}
}
func
(
c
*
FakeSecrets
)
Update
(
secret
*
api
.
Secret
)
(
*
api
.
Secret
,
error
)
{
func
(
c
*
FakeSecrets
)
Update
(
secret
*
api
.
Secret
)
(
*
api
.
Secret
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"update-secret"
,
Value
:
secret
},
&
api
.
Secret
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewUpdateAction
(
"secrets"
,
c
.
Namespace
,
secret
),
secret
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
Secret
),
err
return
obj
.
(
*
api
.
Secret
),
err
}
}
func
(
c
*
FakeSecrets
)
Delete
(
name
string
)
error
{
func
(
c
*
FakeSecrets
)
Delete
(
name
string
)
error
{
_
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"delete-secret"
,
Value
:
name
}
,
&
api
.
Secret
{})
_
,
err
:=
c
.
Fake
.
Invokes
(
NewDeleteAction
(
"secrets"
,
c
.
Namespace
,
name
)
,
&
api
.
Secret
{})
return
err
return
err
}
}
func
(
c
*
FakeSecrets
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
c
*
FakeSecrets
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"watch-secrets"
,
Value
:
resourceVersion
}
,
nil
)
c
.
Fake
.
Invokes
(
NewWatchAction
(
"secrets"
,
c
.
Namespace
,
label
,
field
,
resourceVersion
)
,
nil
)
return
c
.
Fake
.
Watch
,
c
.
Fake
.
Err
()
return
c
.
Fake
.
Watch
,
c
.
Fake
.
Err
()
}
}
pkg/client/testclient/fake_service_accounts.go
View file @
b9066392
...
@@ -30,32 +30,48 @@ type FakeServiceAccounts struct {
...
@@ -30,32 +30,48 @@ type FakeServiceAccounts struct {
Namespace
string
Namespace
string
}
}
func
(
c
*
FakeServiceAccounts
)
List
(
labels
labels
.
Selector
,
field
fields
.
Selector
)
(
*
api
.
ServiceAccountList
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"list-serviceaccounts"
},
&
api
.
ServiceAccountList
{})
return
obj
.
(
*
api
.
ServiceAccountList
),
err
}
func
(
c
*
FakeServiceAccounts
)
Get
(
name
string
)
(
*
api
.
ServiceAccount
,
error
)
{
func
(
c
*
FakeServiceAccounts
)
Get
(
name
string
)
(
*
api
.
ServiceAccount
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"get-serviceaccount"
,
Value
:
name
},
&
api
.
ServiceAccount
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewGetAction
(
"serviceaccounts"
,
c
.
Namespace
,
name
),
&
api
.
ServiceAccount
{})
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
ServiceAccount
),
err
return
obj
.
(
*
api
.
ServiceAccount
),
err
}
}
func
(
c
*
FakeServiceAccounts
)
List
(
label
labels
.
Selector
,
field
fields
.
Selector
)
(
*
api
.
ServiceAccountList
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewListAction
(
"serviceaccounts"
,
c
.
Namespace
,
label
,
field
),
&
api
.
ServiceAccountList
{})
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
ServiceAccountList
),
err
}
func
(
c
*
FakeServiceAccounts
)
Create
(
serviceAccount
*
api
.
ServiceAccount
)
(
*
api
.
ServiceAccount
,
error
)
{
func
(
c
*
FakeServiceAccounts
)
Create
(
serviceAccount
*
api
.
ServiceAccount
)
(
*
api
.
ServiceAccount
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"create-serviceaccount"
,
Value
:
serviceAccount
},
&
api
.
ServiceAccount
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewCreateAction
(
"serviceaccounts"
,
c
.
Namespace
,
serviceAccount
),
serviceAccount
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
ServiceAccount
),
err
return
obj
.
(
*
api
.
ServiceAccount
),
err
}
}
func
(
c
*
FakeServiceAccounts
)
Update
(
serviceAccount
*
api
.
ServiceAccount
)
(
*
api
.
ServiceAccount
,
error
)
{
func
(
c
*
FakeServiceAccounts
)
Update
(
serviceAccount
*
api
.
ServiceAccount
)
(
*
api
.
ServiceAccount
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"update-serviceaccount"
,
Value
:
serviceAccount
},
&
api
.
ServiceAccount
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewUpdateAction
(
"serviceaccounts"
,
c
.
Namespace
,
serviceAccount
),
serviceAccount
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
ServiceAccount
),
err
return
obj
.
(
*
api
.
ServiceAccount
),
err
}
}
func
(
c
*
FakeServiceAccounts
)
Delete
(
name
string
)
error
{
func
(
c
*
FakeServiceAccounts
)
Delete
(
name
string
)
error
{
_
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"delete-serviceaccount"
,
Value
:
name
}
,
&
api
.
ServiceAccount
{})
_
,
err
:=
c
.
Fake
.
Invokes
(
NewDeleteAction
(
"serviceaccounts"
,
c
.
Namespace
,
name
)
,
&
api
.
ServiceAccount
{})
return
err
return
err
}
}
func
(
c
*
FakeServiceAccounts
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
c
*
FakeServiceAccounts
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"watch-serviceAccounts"
,
Value
:
resourceVersion
}
,
nil
)
c
.
Fake
.
Invokes
(
NewWatchAction
(
"serviceaccounts"
,
c
.
Namespace
,
label
,
field
,
resourceVersion
)
,
nil
)
return
c
.
Fake
.
Watch
,
c
.
Fake
.
Err
()
return
c
.
Fake
.
Watch
,
c
.
Fake
.
Err
()
}
}
pkg/client/testclient/fake_services.go
View file @
b9066392
...
@@ -30,32 +30,48 @@ type FakeServices struct {
...
@@ -30,32 +30,48 @@ type FakeServices struct {
Namespace
string
Namespace
string
}
}
func
(
c
*
FakeServices
)
List
(
selector
labels
.
Selector
)
(
*
api
.
ServiceList
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"list-services"
},
&
api
.
ServiceList
{})
return
obj
.
(
*
api
.
ServiceList
),
err
}
func
(
c
*
FakeServices
)
Get
(
name
string
)
(
*
api
.
Service
,
error
)
{
func
(
c
*
FakeServices
)
Get
(
name
string
)
(
*
api
.
Service
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"get-service"
,
Value
:
name
},
&
api
.
Service
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewGetAction
(
"services"
,
c
.
Namespace
,
name
),
&
api
.
Service
{})
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
Service
),
err
return
obj
.
(
*
api
.
Service
),
err
}
}
func
(
c
*
FakeServices
)
List
(
label
labels
.
Selector
)
(
*
api
.
ServiceList
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewListAction
(
"services"
,
c
.
Namespace
,
label
,
nil
),
&
api
.
ServiceList
{})
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
ServiceList
),
err
}
func
(
c
*
FakeServices
)
Create
(
service
*
api
.
Service
)
(
*
api
.
Service
,
error
)
{
func
(
c
*
FakeServices
)
Create
(
service
*
api
.
Service
)
(
*
api
.
Service
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"create-service"
,
Value
:
service
},
&
api
.
Service
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewCreateAction
(
"services"
,
c
.
Namespace
,
service
),
service
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
Service
),
err
return
obj
.
(
*
api
.
Service
),
err
}
}
func
(
c
*
FakeServices
)
Update
(
service
*
api
.
Service
)
(
*
api
.
Service
,
error
)
{
func
(
c
*
FakeServices
)
Update
(
service
*
api
.
Service
)
(
*
api
.
Service
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"update-service"
,
Value
:
service
},
&
api
.
Service
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewUpdateAction
(
"services"
,
c
.
Namespace
,
service
),
service
)
if
obj
==
nil
{
return
nil
,
err
}
return
obj
.
(
*
api
.
Service
),
err
return
obj
.
(
*
api
.
Service
),
err
}
}
func
(
c
*
FakeServices
)
Delete
(
name
string
)
error
{
func
(
c
*
FakeServices
)
Delete
(
name
string
)
error
{
_
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"delete-service"
,
Value
:
name
}
,
&
api
.
Service
{})
_
,
err
:=
c
.
Fake
.
Invokes
(
NewDeleteAction
(
"services"
,
c
.
Namespace
,
name
)
,
&
api
.
Service
{})
return
err
return
err
}
}
func
(
c
*
FakeServices
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
c
*
FakeServices
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"watch-services"
,
Value
:
resourceVersion
}
,
nil
)
c
.
Fake
.
Invokes
(
NewWatchAction
(
"services"
,
c
.
Namespace
,
label
,
field
,
resourceVersion
)
,
nil
)
return
c
.
Fake
.
Watch
,
c
.
Fake
.
Err
()
return
c
.
Fake
.
Watch
,
nil
}
}
pkg/client/testclient/fixture.go
View file @
b9066392
...
@@ -47,34 +47,36 @@ type ObjectRetriever interface {
...
@@ -47,34 +47,36 @@ type ObjectRetriever interface {
// ObjectRetriever interface to satisfy retrieval of lists or retrieval of single items.
// ObjectRetriever interface to satisfy retrieval of lists or retrieval of single items.
// TODO: add support for sub resources
// TODO: add support for sub resources
func
ObjectReaction
(
o
ObjectRetriever
,
mapper
meta
.
RESTMapper
)
ReactionFunc
{
func
ObjectReaction
(
o
ObjectRetriever
,
mapper
meta
.
RESTMapper
)
ReactionFunc
{
return
func
(
action
FakeAction
)
(
runtime
.
Object
,
error
)
{
return
func
(
action
Action
)
(
runtime
.
Object
,
error
)
{
segments
:=
strings
.
Split
(
action
.
Action
,
"-"
)
_
,
kind
,
err
:=
mapper
.
VersionAndKindForResource
(
action
.
GetResource
())
var
verb
,
resource
string
switch
len
(
segments
)
{
case
3
:
verb
,
_
,
resource
=
segments
[
0
],
segments
[
1
],
segments
[
2
]
case
2
:
verb
,
resource
=
segments
[
0
],
segments
[
1
]
default
:
return
nil
,
fmt
.
Errorf
(
"unrecognized action, need two or three segments <verb>-<resource> or <verb>-<subresource>-<resource>: %s"
,
action
.
Action
)
}
_
,
kind
,
err
:=
mapper
.
VersionAndKindForResource
(
resource
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"unrecognized action %s: %v"
,
resource
,
err
)
return
nil
,
fmt
.
Errorf
(
"unrecognized action %s: %v"
,
action
.
GetResource
()
,
err
)
}
}
// TODO: have mapper return a Kind for a subresource?
// TODO: have mapper return a Kind for a subresource?
switch
verb
{
switch
castAction
:=
action
.
(
type
)
{
case
"list"
,
"search"
:
case
ListAction
:
return
o
.
Kind
(
kind
+
"List"
,
""
)
return
o
.
Kind
(
kind
+
"List"
,
""
)
case
"get"
,
"create"
,
"update"
,
"delete"
:
case
GetAction
:
// TODO: handle sub resources
return
o
.
Kind
(
kind
,
castAction
.
GetName
())
if
s
,
ok
:=
action
.
Value
.
(
string
);
ok
&&
action
.
Value
!=
nil
{
case
DeleteAction
:
return
o
.
Kind
(
kind
,
s
)
return
o
.
Kind
(
kind
,
castAction
.
GetName
())
case
CreateAction
:
meta
,
err
:=
api
.
ObjectMetaFor
(
castAction
.
GetObject
())
if
err
!=
nil
{
return
nil
,
err
}
}
return
o
.
Kind
(
kind
,
"unknown"
)
return
o
.
Kind
(
kind
,
meta
.
Name
)
case
UpdateAction
:
meta
,
err
:=
api
.
ObjectMetaFor
(
castAction
.
GetObject
())
if
err
!=
nil
{
return
nil
,
err
}
return
o
.
Kind
(
kind
,
meta
.
Name
)
default
:
default
:
return
nil
,
fmt
.
Errorf
(
"no reaction implemented for %s"
,
action
.
Action
)
return
nil
,
fmt
.
Errorf
(
"no reaction implemented for %s"
,
action
)
}
}
return
nil
,
nil
return
nil
,
nil
}
}
}
}
...
...
pkg/client/testclient/testclient.go
View file @
b9066392
...
@@ -39,19 +39,14 @@ func NewSimpleFake(objects ...runtime.Object) *Fake {
...
@@ -39,19 +39,14 @@ func NewSimpleFake(objects ...runtime.Object) *Fake {
return
&
Fake
{
ReactFn
:
ObjectReaction
(
o
,
latest
.
RESTMapper
)}
return
&
Fake
{
ReactFn
:
ObjectReaction
(
o
,
latest
.
RESTMapper
)}
}
}
type
FakeAction
struct
{
Action
string
Value
interface
{}
}
// ReactionFunc is a function that returns an object or error for a given Action
// ReactionFunc is a function that returns an object or error for a given Action
type
ReactionFunc
func
(
Fake
Action
)
(
runtime
.
Object
,
error
)
type
ReactionFunc
func
(
Action
)
(
runtime
.
Object
,
error
)
// Fake implements client.Interface. Meant to be embedded into a struct to get a default
// Fake implements client.Interface. Meant to be embedded into a struct to get a default
// implementation. This makes faking out just the method you want to test easier.
// implementation. This makes faking out just the method you want to test easier.
type
Fake
struct
{
type
Fake
struct
{
sync
.
RWMutex
sync
.
RWMutex
actions
[]
FakeAction
actions
[]
Action
// these may be castable to other types, but "Action" is the minimum
err
error
err
error
Watch
watch
.
Interface
Watch
watch
.
Interface
...
@@ -61,9 +56,9 @@ type Fake struct {
...
@@ -61,9 +56,9 @@ type Fake struct {
ReactFn
ReactionFunc
ReactFn
ReactionFunc
}
}
// Invokes records the provided
Fake
Action and then invokes the ReactFn (if provided).
// Invokes records the provided Action and then invokes the ReactFn (if provided).
//
o
bj is expected to be of the same type a normal call would return.
//
defaultReturnO
bj is expected to be of the same type a normal call would return.
func
(
c
*
Fake
)
Invokes
(
action
FakeAction
,
o
bj
runtime
.
Object
)
(
runtime
.
Object
,
error
)
{
func
(
c
*
Fake
)
Invokes
(
action
Action
,
defaultReturnO
bj
runtime
.
Object
)
(
runtime
.
Object
,
error
)
{
c
.
Lock
()
c
.
Lock
()
defer
c
.
Unlock
()
defer
c
.
Unlock
()
...
@@ -71,7 +66,7 @@ func (c *Fake) Invokes(action FakeAction, obj runtime.Object) (runtime.Object, e
...
@@ -71,7 +66,7 @@ func (c *Fake) Invokes(action FakeAction, obj runtime.Object) (runtime.Object, e
if
c
.
ReactFn
!=
nil
{
if
c
.
ReactFn
!=
nil
{
return
c
.
ReactFn
(
action
)
return
c
.
ReactFn
(
action
)
}
}
return
o
bj
,
c
.
err
return
defaultReturnO
bj
,
c
.
err
}
}
// ClearActions clears the history of actions called on the fake client
// ClearActions clears the history of actions called on the fake client
...
@@ -79,14 +74,14 @@ func (c *Fake) ClearActions() {
...
@@ -79,14 +74,14 @@ func (c *Fake) ClearActions() {
c
.
Lock
()
c
.
Lock
()
c
.
Unlock
()
c
.
Unlock
()
c
.
actions
=
make
([]
Fake
Action
,
0
)
c
.
actions
=
make
([]
Action
,
0
)
}
}
// Actions returns a chronologically ordered slice fake actions called on the fake client
// Actions returns a chronologically ordered slice fake actions called on the fake client
func
(
c
*
Fake
)
Actions
()
[]
Fake
Action
{
func
(
c
*
Fake
)
Actions
()
[]
Action
{
c
.
RLock
()
c
.
RLock
()
defer
c
.
RUnlock
()
defer
c
.
RUnlock
()
fa
:=
make
([]
Fake
Action
,
len
(
c
.
actions
))
fa
:=
make
([]
Action
,
len
(
c
.
actions
))
copy
(
fa
,
c
.
actions
)
copy
(
fa
,
c
.
actions
)
return
fa
return
fa
}
}
...
@@ -164,13 +159,21 @@ func (c *Fake) Namespaces() client.NamespaceInterface {
...
@@ -164,13 +159,21 @@ func (c *Fake) Namespaces() client.NamespaceInterface {
}
}
func
(
c
*
Fake
)
ServerVersion
()
(
*
version
.
Info
,
error
)
{
func
(
c
*
Fake
)
ServerVersion
()
(
*
version
.
Info
,
error
)
{
c
.
Invokes
(
FakeAction
{
Action
:
"get-version"
,
Value
:
nil
},
nil
)
action
:=
ActionImpl
{}
action
.
Verb
=
"get"
action
.
Resource
=
"version"
c
.
Invokes
(
action
,
nil
)
versionInfo
:=
version
.
Get
()
versionInfo
:=
version
.
Get
()
return
&
versionInfo
,
nil
return
&
versionInfo
,
nil
}
}
func
(
c
*
Fake
)
ServerAPIVersions
()
(
*
api
.
APIVersions
,
error
)
{
func
(
c
*
Fake
)
ServerAPIVersions
()
(
*
api
.
APIVersions
,
error
)
{
c
.
Invokes
(
FakeAction
{
Action
:
"get-apiversions"
,
Value
:
nil
},
nil
)
action
:=
ActionImpl
{}
action
.
Verb
=
"get"
action
.
Resource
=
"apiversions"
c
.
Invokes
(
action
,
nil
)
return
&
api
.
APIVersions
{
Versions
:
registered
.
RegisteredVersions
},
nil
return
&
api
.
APIVersions
{
Versions
:
registered
.
RegisteredVersions
},
nil
}
}
...
...
pkg/controller/namespace/namespace_controller_test.go
View file @
b9066392
...
@@ -17,6 +17,7 @@ limitations under the License.
...
@@ -17,6 +17,7 @@ limitations under the License.
package
namespacecontroller
package
namespacecontroller
import
(
import
(
"strings"
"testing"
"testing"
"time"
"time"
...
@@ -56,10 +57,10 @@ func TestFinalize(t *testing.T) {
...
@@ -56,10 +57,10 @@ func TestFinalize(t *testing.T) {
if
len
(
actions
)
!=
1
{
if
len
(
actions
)
!=
1
{
t
.
Errorf
(
"Expected 1 mock client action, but got %v"
,
len
(
actions
))
t
.
Errorf
(
"Expected 1 mock client action, but got %v"
,
len
(
actions
))
}
}
if
actions
[
0
]
.
Action
!=
"finalize-namespac
e"
{
if
!
actions
[
0
]
.
Matches
(
"create"
,
"namespaces"
)
||
actions
[
0
]
.
GetSubresource
()
!=
"finaliz
e"
{
t
.
Errorf
(
"Expected finalize-namespace action %v"
,
actions
[
0
]
.
Action
)
t
.
Errorf
(
"Expected finalize-namespace action %v"
,
actions
[
0
])
}
}
finalizers
:=
actions
[
0
]
.
Value
.
(
*
api
.
Namespace
)
.
Spec
.
Finalizers
finalizers
:=
actions
[
0
]
.
(
testclient
.
CreateAction
)
.
GetObject
()
.
(
*
api
.
Namespace
)
.
Spec
.
Finalizers
if
len
(
finalizers
)
!=
1
{
if
len
(
finalizers
)
!=
1
{
t
.
Errorf
(
"There should be a single finalizer remaining"
)
t
.
Errorf
(
"There should be a single finalizer remaining"
)
}
}
...
@@ -90,18 +91,19 @@ func TestSyncNamespaceThatIsTerminating(t *testing.T) {
...
@@ -90,18 +91,19 @@ func TestSyncNamespaceThatIsTerminating(t *testing.T) {
}
}
// TODO: Reuse the constants for all these strings from testclient
// TODO: Reuse the constants for all these strings from testclient
expectedActionSet
:=
util
.
NewStringSet
(
expectedActionSet
:=
util
.
NewStringSet
(
testclient
.
ListControllerAction
,
strings
.
Join
([]
string
{
"list"
,
"replicationcontrollers"
,
""
},
"-"
),
"list-services"
,
strings
.
Join
([]
string
{
"list"
,
"services"
,
""
},
"-"
),
"list-pods"
,
strings
.
Join
([]
string
{
"list"
,
"pods"
,
""
},
"-"
),
"list-resourceQuotas"
,
strings
.
Join
([]
string
{
"list"
,
"resourcequotas"
,
""
},
"-"
),
"list-secrets"
,
strings
.
Join
([]
string
{
"list"
,
"secrets"
,
""
},
"-"
),
"list-limitRanges"
,
strings
.
Join
([]
string
{
"list"
,
"limitranges"
,
""
},
"-"
),
"list-events"
,
strings
.
Join
([]
string
{
"list"
,
"events"
,
""
},
"-"
),
"finalize-namespace"
,
strings
.
Join
([]
string
{
"create"
,
"namespaces"
,
"finalize"
},
"-"
),
"delete-namespace"
)
strings
.
Join
([]
string
{
"delete"
,
"namespaces"
,
""
},
"-"
),
)
actionSet
:=
util
.
NewStringSet
()
actionSet
:=
util
.
NewStringSet
()
for
_
,
action
:=
range
mockClient
.
Actions
()
{
for
_
,
action
:=
range
mockClient
.
Actions
()
{
actionSet
.
Insert
(
action
.
Action
)
actionSet
.
Insert
(
strings
.
Join
([]
string
{
action
.
GetVerb
(),
action
.
GetResource
(),
action
.
GetSubresource
()},
"-"
)
)
}
}
if
!
actionSet
.
HasAll
(
expectedActionSet
.
List
()
...
)
{
if
!
actionSet
.
HasAll
(
expectedActionSet
.
List
()
...
)
{
t
.
Errorf
(
"Expected actions: %v, but got: %v"
,
expectedActionSet
,
actionSet
)
t
.
Errorf
(
"Expected actions: %v, but got: %v"
,
expectedActionSet
,
actionSet
)
...
@@ -126,12 +128,8 @@ func TestSyncNamespaceThatIsActive(t *testing.T) {
...
@@ -126,12 +128,8 @@ func TestSyncNamespaceThatIsActive(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Unexpected error when synching namespace %v"
,
err
)
t
.
Errorf
(
"Unexpected error when synching namespace %v"
,
err
)
}
}
actionSet
:=
util
.
NewStringSet
()
if
len
(
mockClient
.
Actions
())
!=
0
{
for
_
,
action
:=
range
mockClient
.
Actions
()
{
t
.
Errorf
(
"Expected no action from controller, but got: %v"
,
mockClient
.
Actions
())
actionSet
.
Insert
(
action
.
Action
)
}
if
len
(
actionSet
)
!=
0
{
t
.
Errorf
(
"Expected no action from controller, but got: %v"
,
actionSet
)
}
}
}
}
...
...
pkg/controller/node/nodecontroller_test.go
View file @
b9066392
...
@@ -343,7 +343,7 @@ func TestMonitorNodeStatusEvictPods(t *testing.T) {
...
@@ -343,7 +343,7 @@ func TestMonitorNodeStatusEvictPods(t *testing.T) {
podEvictor
.
TryEvict
(
func
(
nodeName
string
)
{
nodeController
.
deletePods
(
nodeName
)
})
podEvictor
.
TryEvict
(
func
(
nodeName
string
)
{
nodeController
.
deletePods
(
nodeName
)
})
podEvicted
:=
false
podEvicted
:=
false
for
_
,
action
:=
range
item
.
fakeNodeHandler
.
Actions
()
{
for
_
,
action
:=
range
item
.
fakeNodeHandler
.
Actions
()
{
if
action
.
Action
==
"delete-pod
"
{
if
action
.
GetVerb
()
==
"delete"
&&
action
.
GetResource
()
==
"pods
"
{
podEvicted
=
true
podEvicted
=
true
}
}
}
}
...
...
pkg/controller/replication/replication_controller_test.go
View file @
b9066392
...
@@ -682,8 +682,8 @@ func TestControllerUpdateRequeue(t *testing.T) {
...
@@ -682,8 +682,8 @@ func TestControllerUpdateRequeue(t *testing.T) {
func
TestControllerUpdateStatusWithFailure
(
t
*
testing
.
T
)
{
func
TestControllerUpdateStatusWithFailure
(
t
*
testing
.
T
)
{
rc
:=
newReplicationController
(
1
)
rc
:=
newReplicationController
(
1
)
fakeClient
:=
&
testclient
.
Fake
{
fakeClient
:=
&
testclient
.
Fake
{
ReactFn
:
func
(
f
testclient
.
Fake
Action
)
(
runtime
.
Object
,
error
)
{
ReactFn
:
func
(
action
testclient
.
Action
)
(
runtime
.
Object
,
error
)
{
if
f
.
Action
==
testclient
.
GetControllerAction
{
if
action
.
GetVerb
()
==
"get"
&&
action
.
GetResource
()
==
"replicationcontrollers"
{
return
rc
,
nil
return
rc
,
nil
}
}
return
&
api
.
ReplicationController
{},
fmt
.
Errorf
(
"Fake error"
)
return
&
api
.
ReplicationController
{},
fmt
.
Errorf
(
"Fake error"
)
...
@@ -694,18 +694,23 @@ func TestControllerUpdateStatusWithFailure(t *testing.T) {
...
@@ -694,18 +694,23 @@ func TestControllerUpdateStatusWithFailure(t *testing.T) {
updateReplicaCount
(
fakeRCClient
,
*
rc
,
numReplicas
)
updateReplicaCount
(
fakeRCClient
,
*
rc
,
numReplicas
)
updates
,
gets
:=
0
,
0
updates
,
gets
:=
0
,
0
for
_
,
a
:=
range
fakeClient
.
Actions
()
{
for
_
,
a
:=
range
fakeClient
.
Actions
()
{
switch
a
.
Action
{
if
a
.
GetResource
()
!=
"replicationcontrollers"
{
case
testclient
.
GetControllerAction
:
t
.
Errorf
(
"Unexpected action %+v"
,
a
)
continue
}
switch
action
:=
a
.
(
type
)
{
case
testclient
.
GetAction
:
gets
++
gets
++
// Make sure the get is for the right rc even though the update failed.
// Make sure the get is for the right rc even though the update failed.
if
s
,
ok
:=
a
.
Value
.
(
string
);
!
ok
||
s
!=
rc
.
Name
{
if
action
.
GetName
()
!=
rc
.
Name
{
t
.
Errorf
(
"Expected get for rc %v, got %+v instead"
,
rc
.
Name
,
s
)
t
.
Errorf
(
"Expected get for rc %v, got %+v instead"
,
rc
.
Name
,
action
.
GetName
()
)
}
}
case
testclient
.
Update
Controller
Action
:
case
testclient
.
UpdateAction
:
updates
++
updates
++
// Confirm that the update has the right status.Replicas even though the Get
// Confirm that the update has the right status.Replicas even though the Get
// returned an rc with replicas=1.
// returned an rc with replicas=1.
if
c
,
ok
:=
a
.
Value
.
(
*
api
.
ReplicationController
);
!
ok
{
if
c
,
ok
:=
a
ction
.
GetObject
()
.
(
*
api
.
ReplicationController
);
!
ok
{
t
.
Errorf
(
"Expected an rc as the argument to update, got %T"
,
c
)
t
.
Errorf
(
"Expected an rc as the argument to update, got %T"
,
c
)
}
else
if
c
.
Status
.
Replicas
!=
numReplicas
{
}
else
if
c
.
Status
.
Replicas
!=
numReplicas
{
t
.
Errorf
(
"Expected update for rc to contain replicas %v, got %v instead"
,
t
.
Errorf
(
"Expected update for rc to contain replicas %v, got %v instead"
,
...
...
pkg/controller/resourcequota/resource_quota_controller_test.go
View file @
b9066392
...
@@ -158,7 +158,7 @@ func TestSyncResourceQuota(t *testing.T) {
...
@@ -158,7 +158,7 @@ func TestSyncResourceQuota(t *testing.T) {
t
.
Fatalf
(
"Unexpected error %v"
,
err
)
t
.
Fatalf
(
"Unexpected error %v"
,
err
)
}
}
usage
:=
kubeClient
.
Actions
()[
1
]
.
Value
.
(
*
api
.
ResourceQuota
)
usage
:=
kubeClient
.
Actions
()[
1
]
.
(
testclient
.
UpdateAction
)
.
GetObject
()
.
(
*
api
.
ResourceQuota
)
// ensure hard and used limits are what we expected
// ensure hard and used limits are what we expected
for
k
,
v
:=
range
expectedUsage
.
Status
.
Hard
{
for
k
,
v
:=
range
expectedUsage
.
Status
.
Hard
{
...
@@ -216,7 +216,7 @@ func TestSyncResourceQuotaSpecChange(t *testing.T) {
...
@@ -216,7 +216,7 @@ func TestSyncResourceQuotaSpecChange(t *testing.T) {
t
.
Fatalf
(
"Unexpected error %v"
,
err
)
t
.
Fatalf
(
"Unexpected error %v"
,
err
)
}
}
usage
:=
kubeClient
.
Actions
()[
1
]
.
Value
.
(
*
api
.
ResourceQuota
)
usage
:=
kubeClient
.
Actions
()[
1
]
.
(
testclient
.
UpdateAction
)
.
GetObject
()
.
(
*
api
.
ResourceQuota
)
// ensure hard and used limits are what we expected
// ensure hard and used limits are what we expected
for
k
,
v
:=
range
expectedUsage
.
Status
.
Hard
{
for
k
,
v
:=
range
expectedUsage
.
Status
.
Hard
{
...
@@ -264,7 +264,7 @@ func TestSyncResourceQuotaNoChange(t *testing.T) {
...
@@ -264,7 +264,7 @@ func TestSyncResourceQuotaNoChange(t *testing.T) {
}
}
actions
:=
kubeClient
.
Actions
()
actions
:=
kubeClient
.
Actions
()
if
len
(
actions
)
!=
1
&&
actions
[
0
]
.
Action
!=
"list-pods"
{
if
len
(
actions
)
!=
1
&&
!
actions
[
0
]
.
Matches
(
"list"
,
"pods"
)
{
t
.
Errorf
(
"SyncResourceQuota made an unexpected client action when state was not dirty: %v"
,
kubeClient
.
Actions
)
t
.
Errorf
(
"SyncResourceQuota made an unexpected client action when state was not dirty: %v"
,
kubeClient
.
Actions
)
}
}
}
}
...
...
pkg/controller/route/routecontroller_test.go
View file @
b9066392
...
@@ -165,7 +165,7 @@ func TestReconcile(t *testing.T) {
...
@@ -165,7 +165,7 @@ func TestReconcile(t *testing.T) {
}
}
var
finalRoutes
[]
*
cloudprovider
.
Route
var
finalRoutes
[]
*
cloudprovider
.
Route
var
err
error
var
err
error
timeoutChan
:=
time
.
After
(
5
0
*
time
.
Millisecond
)
timeoutChan
:=
time
.
After
(
20
0
*
time
.
Millisecond
)
tick
:=
time
.
NewTicker
(
10
*
time
.
Millisecond
)
tick
:=
time
.
NewTicker
(
10
*
time
.
Millisecond
)
defer
tick
.
Stop
()
defer
tick
.
Stop
()
poll
:
poll
:
...
...
pkg/controller/service/servicecontroller_test.go
View file @
b9066392
...
@@ -119,7 +119,7 @@ func TestCreateExternalLoadBalancer(t *testing.T) {
...
@@ -119,7 +119,7 @@ func TestCreateExternalLoadBalancer(t *testing.T) {
}
}
actionFound
:=
false
actionFound
:=
false
for
_
,
action
:=
range
actions
{
for
_
,
action
:=
range
actions
{
if
action
.
Action
==
"update-service
"
{
if
action
.
GetVerb
()
==
"update"
&&
action
.
GetResource
()
==
"services
"
{
actionFound
=
true
actionFound
=
true
}
}
}
}
...
...
pkg/controller/serviceaccount/serviceaccounts_controller_test.go
View file @
b9066392
...
@@ -199,11 +199,11 @@ func TestServiceAccountCreation(t *testing.T) {
...
@@ -199,11 +199,11 @@ func TestServiceAccountCreation(t *testing.T) {
}
}
for
i
,
expectedName
:=
range
tc
.
ExpectCreatedServiceAccounts
{
for
i
,
expectedName
:=
range
tc
.
ExpectCreatedServiceAccounts
{
action
:=
actions
[
i
]
action
:=
actions
[
i
]
if
action
.
Action
!=
"create-serviceaccount"
{
if
!
action
.
Matches
(
"create"
,
"serviceaccounts"
)
{
t
.
Errorf
(
"%s: Unexpected action %s"
,
k
,
action
.
Action
)
t
.
Errorf
(
"%s: Unexpected action %s"
,
k
,
action
)
break
break
}
}
createdAccount
:=
action
.
Value
.
(
*
api
.
ServiceAccount
)
createdAccount
:=
action
.
(
testclient
.
CreateAction
)
.
GetObject
()
.
(
*
api
.
ServiceAccount
)
if
createdAccount
.
Name
!=
expectedName
{
if
createdAccount
.
Name
!=
expectedName
{
t
.
Errorf
(
"%s: Expected %s to be created, got %s"
,
k
,
expectedName
,
createdAccount
.
Name
)
t
.
Errorf
(
"%s: Expected %s to be created, got %s"
,
k
,
expectedName
,
createdAccount
.
Name
)
}
}
...
...
pkg/controller/serviceaccount/tokens_controller_test.go
View file @
b9066392
This diff is collapsed.
Click to expand it.
pkg/kubectl/rolling_updater_test.go
View file @
b9066392
...
@@ -70,7 +70,7 @@ type fakeRc struct {
...
@@ -70,7 +70,7 @@ type fakeRc struct {
}
}
func
(
c
*
fakeRc
)
Get
(
name
string
)
(
*
api
.
ReplicationController
,
error
)
{
func
(
c
*
fakeRc
)
Get
(
name
string
)
(
*
api
.
ReplicationController
,
error
)
{
action
:=
testclient
.
FakeAction
{
Action
:
"get-controller"
,
Value
:
name
}
action
:=
testclient
.
NewGetAction
(
"replicationcontrollers"
,
""
,
name
)
if
len
(
c
.
responses
)
==
0
{
if
len
(
c
.
responses
)
==
0
{
return
nil
,
fmt
.
Errorf
(
"Unexpected Action: %s"
,
action
)
return
nil
,
fmt
.
Errorf
(
"Unexpected Action: %s"
,
action
)
}
}
...
@@ -81,12 +81,12 @@ func (c *fakeRc) Get(name string) (*api.ReplicationController, error) {
...
@@ -81,12 +81,12 @@ func (c *fakeRc) Get(name string) (*api.ReplicationController, error) {
}
}
func
(
c
*
fakeRc
)
Create
(
controller
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
{
func
(
c
*
fakeRc
)
Create
(
controller
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
{
c
.
Fake
.
Invokes
(
testclient
.
FakeAction
{
Action
:
"create-controller"
,
Value
:
controller
.
ObjectMeta
.
Name
}
,
nil
)
c
.
Fake
.
Invokes
(
testclient
.
NewCreateAction
(
"replicationcontrollers"
,
controller
.
Namespace
,
controller
)
,
nil
)
return
controller
,
nil
return
controller
,
nil
}
}
func
(
c
*
fakeRc
)
Update
(
controller
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
{
func
(
c
*
fakeRc
)
Update
(
controller
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
{
c
.
Fake
.
Invokes
(
testclient
.
FakeAction
{
Action
:
"update-controller"
,
Value
:
controller
.
ObjectMeta
.
Name
}
,
nil
)
c
.
Fake
.
Invokes
(
testclient
.
NewUpdateAction
(
"replicationcontrollers"
,
controller
.
Namespace
,
controller
)
,
nil
)
return
controller
,
nil
return
controller
,
nil
}
}
...
...
pkg/kubectl/scale_test.go
View file @
b9066392
...
@@ -77,10 +77,10 @@ func TestReplicationControllerScale(t *testing.T) {
...
@@ -77,10 +77,10 @@ func TestReplicationControllerScale(t *testing.T) {
if
len
(
actions
)
!=
2
{
if
len
(
actions
)
!=
2
{
t
.
Errorf
(
"unexpected actions: %v, expected 2 actions (get, update)"
,
actions
)
t
.
Errorf
(
"unexpected actions: %v, expected 2 actions (get, update)"
,
actions
)
}
}
if
action
s
[
0
]
.
Action
!=
"get-replicationController"
||
actions
[
0
]
.
Value
!=
name
{
if
action
,
ok
:=
actions
[
0
]
.
(
testclient
.
GetAction
);
!
ok
||
action
.
GetResource
()
!=
"replicationcontrollers"
||
action
.
GetName
()
!=
name
{
t
.
Errorf
(
"unexpected action: %v, expected get-replicationController %s"
,
actions
[
0
],
name
)
t
.
Errorf
(
"unexpected action: %v, expected get-replicationController %s"
,
actions
[
0
],
name
)
}
}
if
action
s
[
1
]
.
Action
!=
"update-replicationController"
||
actions
[
1
]
.
Value
.
(
*
api
.
ReplicationController
)
.
Spec
.
Replicas
!=
int
(
count
)
{
if
action
,
ok
:=
actions
[
1
]
.
(
testclient
.
UpdateAction
);
!
ok
||
action
.
GetResource
()
!=
"replicationcontrollers"
||
action
.
GetObject
()
.
(
*
api
.
ReplicationController
)
.
Spec
.
Replicas
!=
int
(
count
)
{
t
.
Errorf
(
"unexpected action %v, expected update-replicationController with replicas = %d"
,
actions
[
1
],
count
)
t
.
Errorf
(
"unexpected action %v, expected update-replicationController with replicas = %d"
,
actions
[
1
],
count
)
}
}
}
}
...
@@ -101,7 +101,7 @@ func TestReplicationControllerScaleFailsPreconditions(t *testing.T) {
...
@@ -101,7 +101,7 @@ func TestReplicationControllerScaleFailsPreconditions(t *testing.T) {
if
len
(
actions
)
!=
1
{
if
len
(
actions
)
!=
1
{
t
.
Errorf
(
"unexpected actions: %v, expected 2 actions (get, update)"
,
actions
)
t
.
Errorf
(
"unexpected actions: %v, expected 2 actions (get, update)"
,
actions
)
}
}
if
action
s
[
0
]
.
Action
!=
"get-replicationController"
||
actions
[
0
]
.
Value
!=
name
{
if
action
,
ok
:=
actions
[
0
]
.
(
testclient
.
GetAction
);
!
ok
||
action
.
GetResource
()
!=
"replicationcontrollers"
||
action
.
GetName
()
!=
name
{
t
.
Errorf
(
"unexpected action: %v, expected get-replicationController %s"
,
actions
[
0
],
name
)
t
.
Errorf
(
"unexpected action: %v, expected get-replicationController %s"
,
actions
[
0
],
name
)
}
}
}
}
...
...
pkg/kubectl/stop_test.go
View file @
b9066392
...
@@ -51,9 +51,13 @@ func TestReplicationControllerStop(t *testing.T) {
...
@@ -51,9 +51,13 @@ func TestReplicationControllerStop(t *testing.T) {
if
len
(
actions
)
!=
7
{
if
len
(
actions
)
!=
7
{
t
.
Errorf
(
"unexpected actions: %v, expected 6 actions (get, list, get, update, get, get, delete)"
,
fake
.
Actions
)
t
.
Errorf
(
"unexpected actions: %v, expected 6 actions (get, list, get, update, get, get, delete)"
,
fake
.
Actions
)
}
}
for
i
,
action
:=
range
[]
string
{
"get"
,
"list"
,
"get"
,
"update"
,
"get"
,
"get"
,
"delete"
}
{
for
i
,
verb
:=
range
[]
string
{
"get"
,
"list"
,
"get"
,
"update"
,
"get"
,
"get"
,
"delete"
}
{
if
actions
[
i
]
.
Action
!=
action
+
"-replicationController"
{
if
actions
[
i
]
.
GetResource
()
!=
"replicationcontrollers"
{
t
.
Errorf
(
"unexpected action: %+v, expected %s-replicationController"
,
actions
[
i
],
action
)
t
.
Errorf
(
"unexpected action: %+v, expected %s-replicationController"
,
actions
[
i
],
verb
)
continue
}
if
actions
[
i
]
.
GetVerb
()
!=
verb
{
t
.
Errorf
(
"unexpected action: %+v, expected %s-replicationController"
,
actions
[
i
],
verb
)
}
}
}
}
}
}
...
@@ -99,7 +103,7 @@ func TestSimpleStop(t *testing.T) {
...
@@ -99,7 +103,7 @@ func TestSimpleStop(t *testing.T) {
tests
:=
[]
struct
{
tests
:=
[]
struct
{
fake
*
reaperFake
fake
*
reaperFake
kind
string
kind
string
actions
[]
string
actions
[]
testclient
.
Action
expectError
bool
expectError
bool
test
string
test
string
}{
}{
...
@@ -107,8 +111,11 @@ func TestSimpleStop(t *testing.T) {
...
@@ -107,8 +111,11 @@ func TestSimpleStop(t *testing.T) {
fake
:
&
reaperFake
{
fake
:
&
reaperFake
{
Fake
:
&
testclient
.
Fake
{},
Fake
:
&
testclient
.
Fake
{},
},
},
kind
:
"Pod"
,
kind
:
"Pod"
,
actions
:
[]
string
{
"get-pod"
,
"delete-pod"
},
actions
:
[]
testclient
.
Action
{
testclient
.
NewGetAction
(
"pods"
,
api
.
NamespaceDefault
,
"foo"
),
testclient
.
NewDeleteAction
(
"pods"
,
api
.
NamespaceDefault
,
"foo"
),
},
expectError
:
false
,
expectError
:
false
,
test
:
"stop pod succeeds"
,
test
:
"stop pod succeeds"
,
},
},
...
@@ -116,8 +123,11 @@ func TestSimpleStop(t *testing.T) {
...
@@ -116,8 +123,11 @@ func TestSimpleStop(t *testing.T) {
fake
:
&
reaperFake
{
fake
:
&
reaperFake
{
Fake
:
&
testclient
.
Fake
{},
Fake
:
&
testclient
.
Fake
{},
},
},
kind
:
"Service"
,
kind
:
"Service"
,
actions
:
[]
string
{
"get-service"
,
"delete-service"
},
actions
:
[]
testclient
.
Action
{
testclient
.
NewGetAction
(
"services"
,
api
.
NamespaceDefault
,
"foo"
),
testclient
.
NewDeleteAction
(
"services"
,
api
.
NamespaceDefault
,
"foo"
),
},
expectError
:
false
,
expectError
:
false
,
test
:
"stop service succeeds"
,
test
:
"stop service succeeds"
,
},
},
...
@@ -127,7 +137,7 @@ func TestSimpleStop(t *testing.T) {
...
@@ -127,7 +137,7 @@ func TestSimpleStop(t *testing.T) {
noSuchPod
:
true
,
noSuchPod
:
true
,
},
},
kind
:
"Pod"
,
kind
:
"Pod"
,
actions
:
[]
string
{},
actions
:
[]
testclient
.
Action
{},
expectError
:
true
,
expectError
:
true
,
test
:
"stop pod fails, no pod"
,
test
:
"stop pod fails, no pod"
,
},
},
...
@@ -136,8 +146,10 @@ func TestSimpleStop(t *testing.T) {
...
@@ -136,8 +146,10 @@ func TestSimpleStop(t *testing.T) {
Fake
:
&
testclient
.
Fake
{},
Fake
:
&
testclient
.
Fake
{},
noDeleteService
:
true
,
noDeleteService
:
true
,
},
},
kind
:
"Service"
,
kind
:
"Service"
,
actions
:
[]
string
{
"get-service"
},
actions
:
[]
testclient
.
Action
{
testclient
.
NewGetAction
(
"services"
,
api
.
NamespaceDefault
,
"foo"
),
},
expectError
:
true
,
expectError
:
true
,
test
:
"stop service fails, can't delete"
,
test
:
"stop service fails, can't delete"
,
},
},
...
@@ -166,8 +178,8 @@ func TestSimpleStop(t *testing.T) {
...
@@ -166,8 +178,8 @@ func TestSimpleStop(t *testing.T) {
}
}
for
i
,
action
:=
range
actions
{
for
i
,
action
:=
range
actions
{
testAction
:=
test
.
actions
[
i
]
testAction
:=
test
.
actions
[
i
]
if
action
.
Action
!=
testAction
{
if
action
!=
testAction
{
t
.
Errorf
(
"unexpected action: %v; expected %v (%s)"
,
action
,
testAction
,
test
.
test
)
t
.
Errorf
(
"unexpected action: %
#
v; expected %v (%s)"
,
action
,
testAction
,
test
.
test
)
}
}
}
}
}
}
...
...
pkg/kubelet/kubelet_test.go
View file @
b9066392
...
@@ -2323,10 +2323,13 @@ func TestUpdateNewNodeStatus(t *testing.T) {
...
@@ -2323,10 +2323,13 @@ func TestUpdateNewNodeStatus(t *testing.T) {
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
}
actions
:=
kubeClient
.
Actions
()
actions
:=
kubeClient
.
Actions
()
if
len
(
actions
)
!=
2
||
actions
[
1
]
.
Action
!=
"update-status-node"
{
if
len
(
actions
)
!=
2
{
t
.
Fatalf
(
"unexpected actions: %v"
,
actions
)
}
if
!
actions
[
1
]
.
Matches
(
"update"
,
"nodes"
)
||
actions
[
1
]
.
GetSubresource
()
!=
"status"
{
t
.
Fatalf
(
"unexpected actions: %v"
,
actions
)
t
.
Fatalf
(
"unexpected actions: %v"
,
actions
)
}
}
updatedNode
,
ok
:=
actions
[
1
]
.
Value
.
(
*
api
.
Node
)
updatedNode
,
ok
:=
actions
[
1
]
.
(
testclient
.
UpdateAction
)
.
GetObject
()
.
(
*
api
.
Node
)
if
!
ok
{
if
!
ok
{
t
.
Errorf
(
"unexpected object type"
)
t
.
Errorf
(
"unexpected object type"
)
}
}
...
@@ -2424,7 +2427,11 @@ func TestUpdateExistingNodeStatus(t *testing.T) {
...
@@ -2424,7 +2427,11 @@ func TestUpdateExistingNodeStatus(t *testing.T) {
if
len
(
actions
)
!=
2
{
if
len
(
actions
)
!=
2
{
t
.
Errorf
(
"unexpected actions: %v"
,
actions
)
t
.
Errorf
(
"unexpected actions: %v"
,
actions
)
}
}
updatedNode
,
ok
:=
actions
[
1
]
.
Value
.
(
*
api
.
Node
)
updateAction
,
ok
:=
actions
[
1
]
.
(
testclient
.
UpdateAction
)
if
!
ok
{
t
.
Errorf
(
"unexpected action type. expected UpdateAction, got %#v"
,
actions
[
1
])
}
updatedNode
,
ok
:=
updateAction
.
GetObject
()
.
(
*
api
.
Node
)
if
!
ok
{
if
!
ok
{
t
.
Errorf
(
"unexpected object type"
)
t
.
Errorf
(
"unexpected object type"
)
}
}
...
@@ -2509,12 +2516,15 @@ func TestUpdateNodeStatusWithoutContainerRuntime(t *testing.T) {
...
@@ -2509,12 +2516,15 @@ func TestUpdateNodeStatusWithoutContainerRuntime(t *testing.T) {
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
}
actions
:=
kubeClient
.
Actions
()
actions
:=
kubeClient
.
Actions
()
if
len
(
actions
)
!=
2
||
actions
[
1
]
.
Action
!=
"update-status-node"
{
if
len
(
actions
)
!=
2
{
t
.
Fatalf
(
"unexpected actions: %v"
,
actions
)
}
if
!
actions
[
1
]
.
Matches
(
"update"
,
"nodes"
)
||
actions
[
1
]
.
GetSubresource
()
!=
"status"
{
t
.
Fatalf
(
"unexpected actions: %v"
,
actions
)
t
.
Fatalf
(
"unexpected actions: %v"
,
actions
)
}
}
updatedNode
,
ok
:=
actions
[
1
]
.
Value
.
(
*
api
.
Node
)
updatedNode
,
ok
:=
actions
[
1
]
.
(
testclient
.
UpdateAction
)
.
GetObject
()
.
(
*
api
.
Node
)
if
!
ok
{
if
!
ok
{
t
.
Errorf
(
"unexpected
object type"
)
t
.
Errorf
(
"unexpected
action type. expected UpdateAction, got %#v"
,
actions
[
1
]
)
}
}
if
updatedNode
.
Status
.
Conditions
[
0
]
.
LastHeartbeatTime
.
IsZero
()
{
if
updatedNode
.
Status
.
Conditions
[
0
]
.
LastHeartbeatTime
.
IsZero
()
{
...
@@ -2926,13 +2936,8 @@ func TestRegisterExistingNodeWithApiserver(t *testing.T) {
...
@@ -2926,13 +2936,8 @@ func TestRegisterExistingNodeWithApiserver(t *testing.T) {
testKubelet
:=
newTestKubelet
(
t
)
testKubelet
:=
newTestKubelet
(
t
)
kubelet
:=
testKubelet
.
kubelet
kubelet
:=
testKubelet
.
kubelet
kubeClient
:=
testKubelet
.
fakeKubeClient
kubeClient
:=
testKubelet
.
fakeKubeClient
kubeClient
.
ReactFn
=
func
(
action
testclient
.
FakeAction
)
(
runtime
.
Object
,
error
)
{
kubeClient
.
ReactFn
=
func
(
action
testclient
.
Action
)
(
runtime
.
Object
,
error
)
{
segments
:=
strings
.
Split
(
action
.
Action
,
"-"
)
switch
action
.
GetVerb
()
{
if
len
(
segments
)
<
2
{
return
nil
,
fmt
.
Errorf
(
"unrecognized action, need two or three segments <verb>-<resource> or <verb>-<subresource>-<resource>: %s"
,
action
.
Action
)
}
verb
:=
segments
[
0
]
switch
verb
{
case
"create"
:
case
"create"
:
// Return an error on create.
// Return an error on create.
return
&
api
.
Node
{},
&
apierrors
.
StatusError
{
return
&
api
.
Node
{},
&
apierrors
.
StatusError
{
...
@@ -2945,7 +2950,7 @@ func TestRegisterExistingNodeWithApiserver(t *testing.T) {
...
@@ -2945,7 +2950,7 @@ func TestRegisterExistingNodeWithApiserver(t *testing.T) {
Spec
:
api
.
NodeSpec
{
ExternalID
:
testKubeletHostname
},
Spec
:
api
.
NodeSpec
{
ExternalID
:
testKubeletHostname
},
},
nil
},
nil
default
:
default
:
return
nil
,
fmt
.
Errorf
(
"no reaction implemented for %s"
,
action
.
Action
)
return
nil
,
fmt
.
Errorf
(
"no reaction implemented for %s"
,
action
)
}
}
}
}
machineInfo
:=
&
cadvisorApi
.
MachineInfo
{
machineInfo
:=
&
cadvisorApi
.
MachineInfo
{
...
...
pkg/kubelet/status_manager_test.go
View file @
b9066392
...
@@ -52,14 +52,16 @@ func getRandomPodStatus() api.PodStatus {
...
@@ -52,14 +52,16 @@ func getRandomPodStatus() api.PodStatus {
}
}
}
}
func
verifyActions
(
t
*
testing
.
T
,
kubeClient
client
.
Interface
,
expectedActions
[]
string
)
{
func
verifyActions
(
t
*
testing
.
T
,
kubeClient
client
.
Interface
,
expectedActions
[]
testclient
.
Action
)
{
actions
:=
kubeClient
.
(
*
testclient
.
Fake
)
.
Actions
()
actions
:=
kubeClient
.
(
*
testclient
.
Fake
)
.
Actions
()
if
len
(
actions
)
!=
len
(
expectedActions
)
{
if
len
(
actions
)
!=
len
(
expectedActions
)
{
t
.
Errorf
(
"unexpected actions, got: %s expected: %s"
,
actions
,
expectedActions
)
t
.
Errorf
(
"unexpected actions, got: %s expected: %s"
,
actions
,
expectedActions
)
return
return
}
}
for
i
:=
0
;
i
<
len
(
actions
);
i
++
{
for
i
:=
0
;
i
<
len
(
actions
);
i
++
{
if
actions
[
i
]
.
Action
!=
expectedActions
[
i
]
{
e
:=
expectedActions
[
i
]
a
:=
actions
[
i
]
if
!
a
.
Matches
(
e
.
GetVerb
(),
e
.
GetResource
())
||
a
.
GetSubresource
()
!=
e
.
GetSubresource
()
{
t
.
Errorf
(
"unexpected actions, got: %s expected: %s"
,
actions
,
expectedActions
)
t
.
Errorf
(
"unexpected actions, got: %s expected: %s"
,
actions
,
expectedActions
)
}
}
}
}
...
@@ -158,7 +160,11 @@ func TestSyncBatch(t *testing.T) {
...
@@ -158,7 +160,11 @@ func TestSyncBatch(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"unexpected syncing error: %v"
,
err
)
t
.
Errorf
(
"unexpected syncing error: %v"
,
err
)
}
}
verifyActions
(
t
,
syncer
.
kubeClient
,
[]
string
{
"get-pod"
,
"update-status-pod"
})
verifyActions
(
t
,
syncer
.
kubeClient
,
[]
testclient
.
Action
{
testclient
.
GetActionImpl
{
ActionImpl
:
testclient
.
ActionImpl
{
Verb
:
"get"
,
Resource
:
"pods"
}},
testclient
.
UpdateActionImpl
{
ActionImpl
:
testclient
.
ActionImpl
{
Verb
:
"update"
,
Resource
:
"pods"
,
Subresource
:
"status"
}},
},
)
}
}
// shuffle returns a new shuffled list of container statuses.
// shuffle returns a new shuffled list of container statuses.
...
...
plugin/pkg/admission/exec/denyprivileged/admission_test.go
View file @
b9066392
...
@@ -37,8 +37,8 @@ func TestAdmissionDeny(t *testing.T) {
...
@@ -37,8 +37,8 @@ func TestAdmissionDeny(t *testing.T) {
func
testAdmission
(
t
*
testing
.
T
,
pod
*
api
.
Pod
,
shouldAccept
bool
)
{
func
testAdmission
(
t
*
testing
.
T
,
pod
*
api
.
Pod
,
shouldAccept
bool
)
{
mockClient
:=
&
testclient
.
Fake
{
mockClient
:=
&
testclient
.
Fake
{
ReactFn
:
func
(
action
testclient
.
Fake
Action
)
(
runtime
.
Object
,
error
)
{
ReactFn
:
func
(
action
testclient
.
Action
)
(
runtime
.
Object
,
error
)
{
if
action
.
Action
==
"get-pod"
&&
action
.
Value
.
(
string
)
==
pod
.
Name
{
if
action
.
Matches
(
"get"
,
"pods"
)
&&
action
.
(
testclient
.
GetAction
)
.
GetName
(
)
==
pod
.
Name
{
return
pod
,
nil
return
pod
,
nil
}
}
t
.
Errorf
(
"Unexpected API call: %#v"
,
action
)
t
.
Errorf
(
"Unexpected API call: %#v"
,
action
)
...
...
plugin/pkg/admission/namespace/autoprovision/admission_test.go
View file @
b9066392
...
@@ -49,7 +49,7 @@ func TestAdmission(t *testing.T) {
...
@@ -49,7 +49,7 @@ func TestAdmission(t *testing.T) {
if
len
(
actions
)
!=
1
{
if
len
(
actions
)
!=
1
{
t
.
Errorf
(
"Expected a create-namespace request"
)
t
.
Errorf
(
"Expected a create-namespace request"
)
}
}
if
actions
[
0
]
.
Action
!=
"create-namespace"
{
if
!
actions
[
0
]
.
Matches
(
"create"
,
"namespaces"
)
{
t
.
Errorf
(
"Expected a create-namespace request to be made via the client"
)
t
.
Errorf
(
"Expected a create-namespace request to be made via the client"
)
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment