Merge pull request #12146 from deads2k/tweak-testclient
make testclient more precise
This commit is contained in:
commit
b90663924b
279
pkg/client/testclient/actions.go
Normal file
279
pkg/client/testclient/actions.go
Normal file
@ -0,0 +1,279 @@
|
|||||||
|
/*
|
||||||
|
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
|
||||||
|
}
|
@ -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
|
||||||
|
}
|
||||||
|
@ -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
|
|
||||||
}
|
|
||||||
|
@ -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
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
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{})
|
||||||
|
if obj == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return obj.(*api.EventList), err
|
return obj.(*api.EventList), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FakeEvents) Delete(name string) error {
|
|
||||||
_, 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()
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
@ -29,42 +29,78 @@ type FakeNamespaces struct {
|
|||||||
Fake *Fake
|
Fake *Fake
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FakeNamespaces) List(labels labels.Selector, field fields.Selector) (*api.NamespaceList, error) {
|
func (c *FakeNamespaces) Get(name string) (*api.Namespace, error) {
|
||||||
obj, err := c.Fake.Invokes(FakeAction{Action: "list-namespaces"}, &api.NamespaceList{})
|
obj, err := c.Fake.Invokes(NewRootGetAction("namespaces", name), &api.Namespace{})
|
||||||
|
if obj == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return obj.(*api.Namespace), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *FakeNamespaces) List(label labels.Selector, field fields.Selector) (*api.NamespaceList, error) {
|
||||||
|
obj, err := c.Fake.Invokes(NewRootListAction("namespaces", label, field), &api.NamespaceList{})
|
||||||
|
if obj == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return obj.(*api.NamespaceList), err
|
return obj.(*api.NamespaceList), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FakeNamespaces) Get(name string) (*api.Namespace, error) {
|
func (c *FakeNamespaces) Create(namespace *api.Namespace) (*api.Namespace, error) {
|
||||||
obj, err := c.Fake.Invokes(FakeAction{Action: "get-namespace", Value: name}, &api.Namespace{})
|
obj, err := c.Fake.Invokes(NewRootCreateAction("namespaces", namespace), namespace)
|
||||||
|
if obj == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return obj.(*api.Namespace), c.Fake.Err()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *FakeNamespaces) Update(namespace *api.Namespace) (*api.Namespace, error) {
|
||||||
|
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 {
|
func (c *FakeNamespaces) Delete(name string) error {
|
||||||
_, err := c.Fake.Invokes(FakeAction{Action: "delete-namespace", Value: name}, &api.Namespace{})
|
_, err := c.Fake.Invokes(NewRootDeleteAction("namespaces", name), &api.Namespace{})
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FakeNamespaces) Create(namespace *api.Namespace) (*api.Namespace, error) {
|
|
||||||
c.Fake.Invokes(FakeAction{Action: "create-namespace"}, nil)
|
|
||||||
return &api.Namespace{}, c.Fake.Err()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *FakeNamespaces) Update(namespace *api.Namespace) (*api.Namespace, error) {
|
|
||||||
obj, err := c.Fake.Invokes(FakeAction{Action: "update-namespace", Value: namespace}, &api.Namespace{})
|
|
||||||
return obj.(*api.Namespace), 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
|
||||||
}
|
}
|
||||||
|
@ -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)
|
||||||
|
if obj == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return obj.(*api.Node), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *FakeNodes) Update(minion *api.Node) (*api.Node, error) {
|
||||||
|
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) Delete(name string) error {
|
func (c *FakeNodes) Delete(name string) error {
|
||||||
_, err := c.Fake.Invokes(FakeAction{Action: "delete-node", Value: name}, &api.Node{})
|
_, err := c.Fake.Invokes(NewRootDeleteAction("nodes", name), &api.Node{})
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FakeNodes) Update(minion *api.Node) (*api.Node, error) {
|
func (c *FakeNodes) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
|
||||||
obj, err := c.Fake.Invokes(FakeAction{Action: "update-node", Value: minion}, &api.Node{})
|
c.Fake.Invokes(NewRootWatchAction("nodes", label, field, resourceVersion), nil)
|
||||||
return obj.(*api.Node), err
|
return c.Fake.Watch, c.Fake.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FakeNodes) UpdateStatus(minion *api.Node) (*api.Node, error) {
|
func (c *FakeNodes) UpdateStatus(minion *api.Node) (*api.Node, error) {
|
||||||
obj, err := c.Fake.Invokes(FakeAction{Action: "update-status-node", Value: minion}, &api.Node{})
|
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
|
return obj.(*api.Node), err
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
|
||||||
return c.Fake.Watch, c.Fake.Err()
|
|
||||||
}
|
|
||||||
|
@ -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
|
||||||
|
}
|
||||||
|
@ -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
|
||||||
|
}
|
||||||
|
@ -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()
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
@ -30,41 +30,48 @@ type FakeReplicationControllers struct {
|
|||||||
Namespace string
|
Namespace string
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
|
||||||
GetControllerAction = "get-replicationController"
|
|
||||||
UpdateControllerAction = "update-replicationController"
|
|
||||||
WatchControllerAction = "watch-replicationController"
|
|
||||||
DeleteControllerAction = "delete-replicationController"
|
|
||||||
ListControllerAction = "list-replicationController"
|
|
||||||
CreateControllerAction = "create-replicationController"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (c *FakeReplicationControllers) List(selector labels.Selector) (*api.ReplicationControllerList, error) {
|
|
||||||
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) Get(name string) (*api.ReplicationController, error) {
|
||||||
obj, err := c.Fake.Invokes(FakeAction{Action: GetControllerAction, Value: name}, &api.ReplicationController{})
|
obj, err := c.Fake.Invokes(NewGetAction("replicationcontrollers", c.Namespace, name), &api.ReplicationController{})
|
||||||
|
if obj == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return obj.(*api.ReplicationController), err
|
return obj.(*api.ReplicationController), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *FakeReplicationControllers) List(label labels.Selector) (*api.ReplicationControllerList, error) {
|
||||||
|
obj, err := c.Fake.Invokes(NewListAction("replicationcontrollers", c.Namespace, label, nil), &api.ReplicationControllerList{})
|
||||||
|
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
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
}
|
||||||
|
@ -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()
|
||||||
}
|
}
|
||||||
|
@ -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()
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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(FakeAction) (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 {
|
|||||||
ReactFn ReactionFunc
|
ReactFn ReactionFunc
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invokes records the provided FakeAction and then invokes the ReactFn (if provided).
|
// Invokes records the provided Action and then invokes the ReactFn (if provided).
|
||||||
// obj is expected to be of the same type a normal call would return.
|
// defaultReturnObj is expected to be of the same type a normal call would return.
|
||||||
func (c *Fake) Invokes(action FakeAction, obj runtime.Object) (runtime.Object, error) {
|
func (c *Fake) Invokes(action Action, defaultReturnObj 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
|
|||||||
if c.ReactFn != nil {
|
if c.ReactFn != nil {
|
||||||
return c.ReactFn(action)
|
return c.ReactFn(action)
|
||||||
}
|
}
|
||||||
return obj, c.err
|
return defaultReturnObj, 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() {
|
|||||||
c.Lock()
|
c.Lock()
|
||||||
c.Unlock()
|
c.Unlock()
|
||||||
|
|
||||||
c.actions = make([]FakeAction, 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() []FakeAction {
|
func (c *Fake) Actions() []Action {
|
||||||
c.RLock()
|
c.RLock()
|
||||||
defer c.RUnlock()
|
defer c.RUnlock()
|
||||||
fa := make([]FakeAction, 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 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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) {
|
|||||||
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-namespace" {
|
if !actions[0].Matches("create", "namespaces") || actions[0].GetSubresource() != "finalize" {
|
||||||
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) {
|
|||||||
}
|
}
|
||||||
// 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) {
|
|||||||
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)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.FakeAction) (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) {
|
|||||||
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.UpdateControllerAction:
|
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 := action.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",
|
||||||
|
@ -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) {
|
|||||||
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) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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(50 * time.Millisecond)
|
timeoutChan := time.After(200 * time.Millisecond)
|
||||||
tick := time.NewTicker(10 * time.Millisecond)
|
tick := time.NewTicker(10 * time.Millisecond)
|
||||||
defer tick.Stop()
|
defer tick.Stop()
|
||||||
poll:
|
poll:
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
|
@ -172,16 +172,16 @@ func TestTokenCreation(t *testing.T) {
|
|||||||
UpdatedSecret *api.Secret
|
UpdatedSecret *api.Secret
|
||||||
DeletedSecret *api.Secret
|
DeletedSecret *api.Secret
|
||||||
|
|
||||||
ExpectedActions []testclient.FakeAction
|
ExpectedActions []testclient.Action
|
||||||
}{
|
}{
|
||||||
"new serviceaccount with no secrets": {
|
"new serviceaccount with no secrets": {
|
||||||
ClientObjects: []runtime.Object{serviceAccount(emptySecretReferences()), createdTokenSecret()},
|
ClientObjects: []runtime.Object{serviceAccount(emptySecretReferences()), createdTokenSecret()},
|
||||||
|
|
||||||
AddedServiceAccount: serviceAccount(emptySecretReferences()),
|
AddedServiceAccount: serviceAccount(emptySecretReferences()),
|
||||||
ExpectedActions: []testclient.FakeAction{
|
ExpectedActions: []testclient.Action{
|
||||||
{Action: "create-secret", Value: createdTokenSecret()},
|
testclient.NewCreateAction("secrets", api.NamespaceDefault, createdTokenSecret()),
|
||||||
{Action: "get-serviceaccount", Value: "default"},
|
testclient.NewGetAction("serviceaccounts", api.NamespaceDefault, "default"),
|
||||||
{Action: "update-serviceaccount", Value: serviceAccount(addTokenSecretReference(emptySecretReferences()))},
|
testclient.NewUpdateAction("serviceaccounts", api.NamespaceDefault, serviceAccount(addTokenSecretReference(emptySecretReferences()))),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"new serviceaccount with no secrets with unsynced secret store": {
|
"new serviceaccount with no secrets with unsynced secret store": {
|
||||||
@ -190,20 +190,20 @@ func TestTokenCreation(t *testing.T) {
|
|||||||
SecretsSyncPending: true,
|
SecretsSyncPending: true,
|
||||||
|
|
||||||
AddedServiceAccount: serviceAccount(emptySecretReferences()),
|
AddedServiceAccount: serviceAccount(emptySecretReferences()),
|
||||||
ExpectedActions: []testclient.FakeAction{
|
ExpectedActions: []testclient.Action{
|
||||||
{Action: "create-secret", Value: createdTokenSecret()},
|
testclient.NewCreateAction("secrets", api.NamespaceDefault, createdTokenSecret()),
|
||||||
{Action: "get-serviceaccount", Value: "default"},
|
testclient.NewGetAction("serviceaccounts", api.NamespaceDefault, "default"),
|
||||||
{Action: "update-serviceaccount", Value: serviceAccount(addTokenSecretReference(emptySecretReferences()))},
|
testclient.NewUpdateAction("serviceaccounts", api.NamespaceDefault, serviceAccount(addTokenSecretReference(emptySecretReferences()))),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"new serviceaccount with missing secrets": {
|
"new serviceaccount with missing secrets": {
|
||||||
ClientObjects: []runtime.Object{serviceAccount(missingSecretReferences()), createdTokenSecret()},
|
ClientObjects: []runtime.Object{serviceAccount(missingSecretReferences()), createdTokenSecret()},
|
||||||
|
|
||||||
AddedServiceAccount: serviceAccount(missingSecretReferences()),
|
AddedServiceAccount: serviceAccount(missingSecretReferences()),
|
||||||
ExpectedActions: []testclient.FakeAction{
|
ExpectedActions: []testclient.Action{
|
||||||
{Action: "create-secret", Value: createdTokenSecret()},
|
testclient.NewCreateAction("secrets", api.NamespaceDefault, createdTokenSecret()),
|
||||||
{Action: "get-serviceaccount", Value: "default"},
|
testclient.NewGetAction("serviceaccounts", api.NamespaceDefault, "default"),
|
||||||
{Action: "update-serviceaccount", Value: serviceAccount(addTokenSecretReference(missingSecretReferences()))},
|
testclient.NewUpdateAction("serviceaccounts", api.NamespaceDefault, serviceAccount(addTokenSecretReference(missingSecretReferences()))),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"new serviceaccount with missing secrets with unsynced secret store": {
|
"new serviceaccount with missing secrets with unsynced secret store": {
|
||||||
@ -212,16 +212,16 @@ func TestTokenCreation(t *testing.T) {
|
|||||||
SecretsSyncPending: true,
|
SecretsSyncPending: true,
|
||||||
|
|
||||||
AddedServiceAccount: serviceAccount(missingSecretReferences()),
|
AddedServiceAccount: serviceAccount(missingSecretReferences()),
|
||||||
ExpectedActions: []testclient.FakeAction{},
|
ExpectedActions: []testclient.Action{},
|
||||||
},
|
},
|
||||||
"new serviceaccount with non-token secrets": {
|
"new serviceaccount with non-token secrets": {
|
||||||
ClientObjects: []runtime.Object{serviceAccount(regularSecretReferences()), createdTokenSecret(), opaqueSecret()},
|
ClientObjects: []runtime.Object{serviceAccount(regularSecretReferences()), createdTokenSecret(), opaqueSecret()},
|
||||||
|
|
||||||
AddedServiceAccount: serviceAccount(regularSecretReferences()),
|
AddedServiceAccount: serviceAccount(regularSecretReferences()),
|
||||||
ExpectedActions: []testclient.FakeAction{
|
ExpectedActions: []testclient.Action{
|
||||||
{Action: "create-secret", Value: createdTokenSecret()},
|
testclient.NewCreateAction("secrets", api.NamespaceDefault, createdTokenSecret()),
|
||||||
{Action: "get-serviceaccount", Value: "default"},
|
testclient.NewGetAction("serviceaccounts", api.NamespaceDefault, "default"),
|
||||||
{Action: "update-serviceaccount", Value: serviceAccount(addTokenSecretReference(regularSecretReferences()))},
|
testclient.NewUpdateAction("serviceaccounts", api.NamespaceDefault, serviceAccount(addTokenSecretReference(regularSecretReferences()))),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"new serviceaccount with token secrets": {
|
"new serviceaccount with token secrets": {
|
||||||
@ -229,17 +229,17 @@ func TestTokenCreation(t *testing.T) {
|
|||||||
ExistingSecrets: []*api.Secret{serviceAccountTokenSecret()},
|
ExistingSecrets: []*api.Secret{serviceAccountTokenSecret()},
|
||||||
|
|
||||||
AddedServiceAccount: serviceAccount(tokenSecretReferences()),
|
AddedServiceAccount: serviceAccount(tokenSecretReferences()),
|
||||||
ExpectedActions: []testclient.FakeAction{},
|
ExpectedActions: []testclient.Action{},
|
||||||
},
|
},
|
||||||
|
|
||||||
"updated serviceaccount with no secrets": {
|
"updated serviceaccount with no secrets": {
|
||||||
ClientObjects: []runtime.Object{serviceAccount(emptySecretReferences()), createdTokenSecret()},
|
ClientObjects: []runtime.Object{serviceAccount(emptySecretReferences()), createdTokenSecret()},
|
||||||
|
|
||||||
UpdatedServiceAccount: serviceAccount(emptySecretReferences()),
|
UpdatedServiceAccount: serviceAccount(emptySecretReferences()),
|
||||||
ExpectedActions: []testclient.FakeAction{
|
ExpectedActions: []testclient.Action{
|
||||||
{Action: "create-secret", Value: createdTokenSecret()},
|
testclient.NewCreateAction("secrets", api.NamespaceDefault, createdTokenSecret()),
|
||||||
{Action: "get-serviceaccount", Value: "default"},
|
testclient.NewGetAction("serviceaccounts", api.NamespaceDefault, "default"),
|
||||||
{Action: "update-serviceaccount", Value: serviceAccount(addTokenSecretReference(emptySecretReferences()))},
|
testclient.NewUpdateAction("serviceaccounts", api.NamespaceDefault, serviceAccount(addTokenSecretReference(emptySecretReferences()))),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"updated serviceaccount with no secrets with unsynced secret store": {
|
"updated serviceaccount with no secrets with unsynced secret store": {
|
||||||
@ -248,20 +248,20 @@ func TestTokenCreation(t *testing.T) {
|
|||||||
SecretsSyncPending: true,
|
SecretsSyncPending: true,
|
||||||
|
|
||||||
UpdatedServiceAccount: serviceAccount(emptySecretReferences()),
|
UpdatedServiceAccount: serviceAccount(emptySecretReferences()),
|
||||||
ExpectedActions: []testclient.FakeAction{
|
ExpectedActions: []testclient.Action{
|
||||||
{Action: "create-secret", Value: createdTokenSecret()},
|
testclient.NewCreateAction("secrets", api.NamespaceDefault, createdTokenSecret()),
|
||||||
{Action: "get-serviceaccount", Value: "default"},
|
testclient.NewGetAction("serviceaccounts", api.NamespaceDefault, "default"),
|
||||||
{Action: "update-serviceaccount", Value: serviceAccount(addTokenSecretReference(emptySecretReferences()))},
|
testclient.NewUpdateAction("serviceaccounts", api.NamespaceDefault, serviceAccount(addTokenSecretReference(emptySecretReferences()))),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"updated serviceaccount with missing secrets": {
|
"updated serviceaccount with missing secrets": {
|
||||||
ClientObjects: []runtime.Object{serviceAccount(missingSecretReferences()), createdTokenSecret()},
|
ClientObjects: []runtime.Object{serviceAccount(missingSecretReferences()), createdTokenSecret()},
|
||||||
|
|
||||||
UpdatedServiceAccount: serviceAccount(missingSecretReferences()),
|
UpdatedServiceAccount: serviceAccount(missingSecretReferences()),
|
||||||
ExpectedActions: []testclient.FakeAction{
|
ExpectedActions: []testclient.Action{
|
||||||
{Action: "create-secret", Value: createdTokenSecret()},
|
testclient.NewCreateAction("secrets", api.NamespaceDefault, createdTokenSecret()),
|
||||||
{Action: "get-serviceaccount", Value: "default"},
|
testclient.NewGetAction("serviceaccounts", api.NamespaceDefault, "default"),
|
||||||
{Action: "update-serviceaccount", Value: serviceAccount(addTokenSecretReference(missingSecretReferences()))},
|
testclient.NewUpdateAction("serviceaccounts", api.NamespaceDefault, serviceAccount(addTokenSecretReference(missingSecretReferences()))),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"updated serviceaccount with missing secrets with unsynced secret store": {
|
"updated serviceaccount with missing secrets with unsynced secret store": {
|
||||||
@ -270,46 +270,46 @@ func TestTokenCreation(t *testing.T) {
|
|||||||
SecretsSyncPending: true,
|
SecretsSyncPending: true,
|
||||||
|
|
||||||
UpdatedServiceAccount: serviceAccount(missingSecretReferences()),
|
UpdatedServiceAccount: serviceAccount(missingSecretReferences()),
|
||||||
ExpectedActions: []testclient.FakeAction{},
|
ExpectedActions: []testclient.Action{},
|
||||||
},
|
},
|
||||||
"updated serviceaccount with non-token secrets": {
|
"updated serviceaccount with non-token secrets": {
|
||||||
ClientObjects: []runtime.Object{serviceAccount(regularSecretReferences()), createdTokenSecret(), opaqueSecret()},
|
ClientObjects: []runtime.Object{serviceAccount(regularSecretReferences()), createdTokenSecret(), opaqueSecret()},
|
||||||
|
|
||||||
UpdatedServiceAccount: serviceAccount(regularSecretReferences()),
|
UpdatedServiceAccount: serviceAccount(regularSecretReferences()),
|
||||||
ExpectedActions: []testclient.FakeAction{
|
ExpectedActions: []testclient.Action{
|
||||||
{Action: "create-secret", Value: createdTokenSecret()},
|
testclient.NewCreateAction("secrets", api.NamespaceDefault, createdTokenSecret()),
|
||||||
{Action: "get-serviceaccount", Value: "default"},
|
testclient.NewGetAction("serviceaccounts", api.NamespaceDefault, "default"),
|
||||||
{Action: "update-serviceaccount", Value: serviceAccount(addTokenSecretReference(regularSecretReferences()))},
|
testclient.NewUpdateAction("serviceaccounts", api.NamespaceDefault, serviceAccount(addTokenSecretReference(regularSecretReferences()))),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"updated serviceaccount with token secrets": {
|
"updated serviceaccount with token secrets": {
|
||||||
ExistingSecrets: []*api.Secret{serviceAccountTokenSecret()},
|
ExistingSecrets: []*api.Secret{serviceAccountTokenSecret()},
|
||||||
|
|
||||||
UpdatedServiceAccount: serviceAccount(tokenSecretReferences()),
|
UpdatedServiceAccount: serviceAccount(tokenSecretReferences()),
|
||||||
ExpectedActions: []testclient.FakeAction{},
|
ExpectedActions: []testclient.Action{},
|
||||||
},
|
},
|
||||||
|
|
||||||
"deleted serviceaccount with no secrets": {
|
"deleted serviceaccount with no secrets": {
|
||||||
DeletedServiceAccount: serviceAccount(emptySecretReferences()),
|
DeletedServiceAccount: serviceAccount(emptySecretReferences()),
|
||||||
ExpectedActions: []testclient.FakeAction{},
|
ExpectedActions: []testclient.Action{},
|
||||||
},
|
},
|
||||||
"deleted serviceaccount with missing secrets": {
|
"deleted serviceaccount with missing secrets": {
|
||||||
DeletedServiceAccount: serviceAccount(missingSecretReferences()),
|
DeletedServiceAccount: serviceAccount(missingSecretReferences()),
|
||||||
ExpectedActions: []testclient.FakeAction{},
|
ExpectedActions: []testclient.Action{},
|
||||||
},
|
},
|
||||||
"deleted serviceaccount with non-token secrets": {
|
"deleted serviceaccount with non-token secrets": {
|
||||||
ClientObjects: []runtime.Object{opaqueSecret()},
|
ClientObjects: []runtime.Object{opaqueSecret()},
|
||||||
|
|
||||||
DeletedServiceAccount: serviceAccount(regularSecretReferences()),
|
DeletedServiceAccount: serviceAccount(regularSecretReferences()),
|
||||||
ExpectedActions: []testclient.FakeAction{},
|
ExpectedActions: []testclient.Action{},
|
||||||
},
|
},
|
||||||
"deleted serviceaccount with token secrets": {
|
"deleted serviceaccount with token secrets": {
|
||||||
ClientObjects: []runtime.Object{serviceAccountTokenSecret()},
|
ClientObjects: []runtime.Object{serviceAccountTokenSecret()},
|
||||||
ExistingSecrets: []*api.Secret{serviceAccountTokenSecret()},
|
ExistingSecrets: []*api.Secret{serviceAccountTokenSecret()},
|
||||||
|
|
||||||
DeletedServiceAccount: serviceAccount(tokenSecretReferences()),
|
DeletedServiceAccount: serviceAccount(tokenSecretReferences()),
|
||||||
ExpectedActions: []testclient.FakeAction{
|
ExpectedActions: []testclient.Action{
|
||||||
{Action: "delete-secret", Value: "token-secret-1"},
|
testclient.NewDeleteAction("secrets", api.NamespaceDefault, "token-secret-1"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -317,24 +317,24 @@ func TestTokenCreation(t *testing.T) {
|
|||||||
ClientObjects: []runtime.Object{serviceAccountTokenSecret()},
|
ClientObjects: []runtime.Object{serviceAccountTokenSecret()},
|
||||||
|
|
||||||
AddedSecret: serviceAccountTokenSecret(),
|
AddedSecret: serviceAccountTokenSecret(),
|
||||||
ExpectedActions: []testclient.FakeAction{
|
ExpectedActions: []testclient.Action{
|
||||||
{Action: "get-serviceaccount", Value: "default"},
|
testclient.NewGetAction("serviceaccounts", api.NamespaceDefault, "default"),
|
||||||
{Action: "delete-secret", Value: "token-secret-1"},
|
testclient.NewDeleteAction("secrets", api.NamespaceDefault, "token-secret-1"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"added secret with serviceaccount": {
|
"added secret with serviceaccount": {
|
||||||
ExistingServiceAccount: serviceAccount(tokenSecretReferences()),
|
ExistingServiceAccount: serviceAccount(tokenSecretReferences()),
|
||||||
|
|
||||||
AddedSecret: serviceAccountTokenSecret(),
|
AddedSecret: serviceAccountTokenSecret(),
|
||||||
ExpectedActions: []testclient.FakeAction{},
|
ExpectedActions: []testclient.Action{},
|
||||||
},
|
},
|
||||||
"added token secret without token data": {
|
"added token secret without token data": {
|
||||||
ClientObjects: []runtime.Object{serviceAccountTokenSecretWithoutTokenData()},
|
ClientObjects: []runtime.Object{serviceAccountTokenSecretWithoutTokenData()},
|
||||||
ExistingServiceAccount: serviceAccount(tokenSecretReferences()),
|
ExistingServiceAccount: serviceAccount(tokenSecretReferences()),
|
||||||
|
|
||||||
AddedSecret: serviceAccountTokenSecretWithoutTokenData(),
|
AddedSecret: serviceAccountTokenSecretWithoutTokenData(),
|
||||||
ExpectedActions: []testclient.FakeAction{
|
ExpectedActions: []testclient.Action{
|
||||||
{Action: "update-secret", Value: serviceAccountTokenSecret()},
|
testclient.NewUpdateAction("secrets", api.NamespaceDefault, serviceAccountTokenSecret()),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"added token secret without ca data": {
|
"added token secret without ca data": {
|
||||||
@ -342,8 +342,8 @@ func TestTokenCreation(t *testing.T) {
|
|||||||
ExistingServiceAccount: serviceAccount(tokenSecretReferences()),
|
ExistingServiceAccount: serviceAccount(tokenSecretReferences()),
|
||||||
|
|
||||||
AddedSecret: serviceAccountTokenSecretWithoutCAData(),
|
AddedSecret: serviceAccountTokenSecretWithoutCAData(),
|
||||||
ExpectedActions: []testclient.FakeAction{
|
ExpectedActions: []testclient.Action{
|
||||||
{Action: "update-secret", Value: serviceAccountTokenSecret()},
|
testclient.NewUpdateAction("secrets", api.NamespaceDefault, serviceAccountTokenSecret()),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"added token secret with mismatched ca data": {
|
"added token secret with mismatched ca data": {
|
||||||
@ -351,8 +351,8 @@ func TestTokenCreation(t *testing.T) {
|
|||||||
ExistingServiceAccount: serviceAccount(tokenSecretReferences()),
|
ExistingServiceAccount: serviceAccount(tokenSecretReferences()),
|
||||||
|
|
||||||
AddedSecret: serviceAccountTokenSecretWithCAData([]byte("mismatched")),
|
AddedSecret: serviceAccountTokenSecretWithCAData([]byte("mismatched")),
|
||||||
ExpectedActions: []testclient.FakeAction{
|
ExpectedActions: []testclient.Action{
|
||||||
{Action: "update-secret", Value: serviceAccountTokenSecret()},
|
testclient.NewUpdateAction("secrets", api.NamespaceDefault, serviceAccountTokenSecret()),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -360,24 +360,24 @@ func TestTokenCreation(t *testing.T) {
|
|||||||
ClientObjects: []runtime.Object{serviceAccountTokenSecret()},
|
ClientObjects: []runtime.Object{serviceAccountTokenSecret()},
|
||||||
|
|
||||||
UpdatedSecret: serviceAccountTokenSecret(),
|
UpdatedSecret: serviceAccountTokenSecret(),
|
||||||
ExpectedActions: []testclient.FakeAction{
|
ExpectedActions: []testclient.Action{
|
||||||
{Action: "get-serviceaccount", Value: "default"},
|
testclient.NewGetAction("serviceaccounts", api.NamespaceDefault, "default"),
|
||||||
{Action: "delete-secret", Value: "token-secret-1"},
|
testclient.NewDeleteAction("secrets", api.NamespaceDefault, "token-secret-1"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"updated secret with serviceaccount": {
|
"updated secret with serviceaccount": {
|
||||||
ExistingServiceAccount: serviceAccount(tokenSecretReferences()),
|
ExistingServiceAccount: serviceAccount(tokenSecretReferences()),
|
||||||
|
|
||||||
UpdatedSecret: serviceAccountTokenSecret(),
|
UpdatedSecret: serviceAccountTokenSecret(),
|
||||||
ExpectedActions: []testclient.FakeAction{},
|
ExpectedActions: []testclient.Action{},
|
||||||
},
|
},
|
||||||
"updated token secret without token data": {
|
"updated token secret without token data": {
|
||||||
ClientObjects: []runtime.Object{serviceAccountTokenSecretWithoutTokenData()},
|
ClientObjects: []runtime.Object{serviceAccountTokenSecretWithoutTokenData()},
|
||||||
ExistingServiceAccount: serviceAccount(tokenSecretReferences()),
|
ExistingServiceAccount: serviceAccount(tokenSecretReferences()),
|
||||||
|
|
||||||
UpdatedSecret: serviceAccountTokenSecretWithoutTokenData(),
|
UpdatedSecret: serviceAccountTokenSecretWithoutTokenData(),
|
||||||
ExpectedActions: []testclient.FakeAction{
|
ExpectedActions: []testclient.Action{
|
||||||
{Action: "update-secret", Value: serviceAccountTokenSecret()},
|
testclient.NewUpdateAction("secrets", api.NamespaceDefault, serviceAccountTokenSecret()),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"updated token secret without ca data": {
|
"updated token secret without ca data": {
|
||||||
@ -385,8 +385,8 @@ func TestTokenCreation(t *testing.T) {
|
|||||||
ExistingServiceAccount: serviceAccount(tokenSecretReferences()),
|
ExistingServiceAccount: serviceAccount(tokenSecretReferences()),
|
||||||
|
|
||||||
UpdatedSecret: serviceAccountTokenSecretWithoutCAData(),
|
UpdatedSecret: serviceAccountTokenSecretWithoutCAData(),
|
||||||
ExpectedActions: []testclient.FakeAction{
|
ExpectedActions: []testclient.Action{
|
||||||
{Action: "update-secret", Value: serviceAccountTokenSecret()},
|
testclient.NewUpdateAction("secrets", api.NamespaceDefault, serviceAccountTokenSecret()),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"updated token secret with mismatched ca data": {
|
"updated token secret with mismatched ca data": {
|
||||||
@ -394,30 +394,30 @@ func TestTokenCreation(t *testing.T) {
|
|||||||
ExistingServiceAccount: serviceAccount(tokenSecretReferences()),
|
ExistingServiceAccount: serviceAccount(tokenSecretReferences()),
|
||||||
|
|
||||||
UpdatedSecret: serviceAccountTokenSecretWithCAData([]byte("mismatched")),
|
UpdatedSecret: serviceAccountTokenSecretWithCAData([]byte("mismatched")),
|
||||||
ExpectedActions: []testclient.FakeAction{
|
ExpectedActions: []testclient.Action{
|
||||||
{Action: "update-secret", Value: serviceAccountTokenSecret()},
|
testclient.NewUpdateAction("secrets", api.NamespaceDefault, serviceAccountTokenSecret()),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
"deleted secret without serviceaccount": {
|
"deleted secret without serviceaccount": {
|
||||||
DeletedSecret: serviceAccountTokenSecret(),
|
DeletedSecret: serviceAccountTokenSecret(),
|
||||||
ExpectedActions: []testclient.FakeAction{},
|
ExpectedActions: []testclient.Action{},
|
||||||
},
|
},
|
||||||
"deleted secret with serviceaccount with reference": {
|
"deleted secret with serviceaccount with reference": {
|
||||||
ClientObjects: []runtime.Object{serviceAccount(tokenSecretReferences())},
|
ClientObjects: []runtime.Object{serviceAccount(tokenSecretReferences())},
|
||||||
ExistingServiceAccount: serviceAccount(tokenSecretReferences()),
|
ExistingServiceAccount: serviceAccount(tokenSecretReferences()),
|
||||||
|
|
||||||
DeletedSecret: serviceAccountTokenSecret(),
|
DeletedSecret: serviceAccountTokenSecret(),
|
||||||
ExpectedActions: []testclient.FakeAction{
|
ExpectedActions: []testclient.Action{
|
||||||
{Action: "get-serviceaccount", Value: "default"},
|
testclient.NewGetAction("serviceaccounts", api.NamespaceDefault, "default"),
|
||||||
{Action: "update-serviceaccount", Value: serviceAccount(emptySecretReferences())},
|
testclient.NewUpdateAction("serviceaccounts", api.NamespaceDefault, serviceAccount(emptySecretReferences())),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"deleted secret with serviceaccount without reference": {
|
"deleted secret with serviceaccount without reference": {
|
||||||
ExistingServiceAccount: serviceAccount(emptySecretReferences()),
|
ExistingServiceAccount: serviceAccount(emptySecretReferences()),
|
||||||
|
|
||||||
DeletedSecret: serviceAccountTokenSecret(),
|
DeletedSecret: serviceAccountTokenSecret(),
|
||||||
ExpectedActions: []testclient.FakeAction{},
|
ExpectedActions: []testclient.Action{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -470,12 +470,8 @@ func TestTokenCreation(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
expectedAction := tc.ExpectedActions[i]
|
expectedAction := tc.ExpectedActions[i]
|
||||||
if expectedAction.Action != action.Action {
|
if !reflect.DeepEqual(expectedAction, action) {
|
||||||
t.Errorf("%s: Expected %s, got %s", k, expectedAction.Action, action.Action)
|
t.Errorf("%s: Expected\n\t%#v\ngot\n\t%#v", k, expectedAction, action)
|
||||||
continue
|
|
||||||
}
|
|
||||||
if !reflect.DeepEqual(expectedAction.Value, action.Value) {
|
|
||||||
t.Errorf("%s: Expected\n\t%#v\ngot\n\t%#v", k, expectedAction.Value, action.Value)
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 actions[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 actions[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) {
|
|||||||
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 actions[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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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) {
|
|||||||
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) {
|
|||||||
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) {
|
|||||||
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) {
|
|||||||
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) {
|
|||||||
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) {
|
|||||||
}
|
}
|
||||||
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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)
|
t.Fatalf("unexpected actions: %v", actions)
|
||||||
}
|
}
|
||||||
updatedNode, ok := actions[1].Value.(*api.Node)
|
if !actions[1].Matches("update", "nodes") || actions[1].GetSubresource() != "status" {
|
||||||
|
t.Fatalf("unexpected actions: %v", actions)
|
||||||
|
}
|
||||||
|
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) {
|
|||||||
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) {
|
|||||||
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)
|
t.Fatalf("unexpected actions: %v", actions)
|
||||||
}
|
}
|
||||||
updatedNode, ok := actions[1].Value.(*api.Node)
|
if !actions[1].Matches("update", "nodes") || actions[1].GetSubresource() != "status" {
|
||||||
|
t.Fatalf("unexpected actions: %v", actions)
|
||||||
|
}
|
||||||
|
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) {
|
|||||||
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) {
|
|||||||
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{
|
||||||
|
@ -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) {
|
|||||||
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.
|
||||||
|
@ -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.FakeAction) (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)
|
||||||
|
@ -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")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user