Embed mock service interface from client-go
We use the default implementation by embedding fake.FakeServices which implements ServiceInterface.pull/1075/head
parent
4746cdbc88
commit
b638b101a2
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"ImportPath": "k8s.io/minikube",
|
||||
"GoVersion": "go1.7",
|
||||
"GodepVersion": "v77",
|
||||
"GodepVersion": "v74",
|
||||
"Packages": [
|
||||
"./..."
|
||||
],
|
||||
|
@ -2361,6 +2361,11 @@
|
|||
"Comment": "v1.5.0",
|
||||
"Rev": "843f7c4f28b1f647f664f883697107d5c02c5acc"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake",
|
||||
"Comment": "v1.5.0",
|
||||
"Rev": "843f7c4f28b1f647f664f883697107d5c02c5acc"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/client-go/1.5/kubernetes/typed/extensions/v1beta1",
|
||||
"Comment": "v1.5.0",
|
||||
|
@ -2816,6 +2821,11 @@
|
|||
"Comment": "v1.5.0",
|
||||
"Rev": "843f7c4f28b1f647f664f883697107d5c02c5acc"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/client-go/1.5/testing",
|
||||
"Comment": "v1.5.0",
|
||||
"Rev": "843f7c4f28b1f647f664f883697107d5c02c5acc"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/client-go/1.5/tools/auth",
|
||||
"Comment": "v1.5.0",
|
||||
|
|
|
@ -32,11 +32,10 @@ import (
|
|||
"github.com/docker/machine/libmachine/provision"
|
||||
"github.com/docker/machine/libmachine/state"
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake"
|
||||
"k8s.io/client-go/1.5/pkg/api"
|
||||
"k8s.io/client-go/1.5/pkg/api/unversioned"
|
||||
"k8s.io/client-go/1.5/pkg/api/v1"
|
||||
"k8s.io/client-go/1.5/pkg/watch"
|
||||
"k8s.io/client-go/1.5/rest"
|
||||
"k8s.io/minikube/pkg/minikube/assets"
|
||||
"k8s.io/minikube/pkg/minikube/constants"
|
||||
"k8s.io/minikube/pkg/minikube/tests"
|
||||
|
@ -817,6 +816,7 @@ func TestCheckEndpointReady(t *testing.T) {
|
|||
}
|
||||
|
||||
type ServiceInterfaceMock struct {
|
||||
fake.FakeServices
|
||||
ServiceList *v1.ServiceList
|
||||
}
|
||||
|
||||
|
@ -832,35 +832,6 @@ func (s ServiceInterfaceMock) List(opts api.ListOptions) (*v1.ServiceList, error
|
|||
}
|
||||
return serviceList, nil
|
||||
}
|
||||
func (s ServiceInterfaceMock) Get(name string) (*v1.Service, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (s ServiceInterfaceMock) Create(*v1.Service) (*v1.Service, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (s ServiceInterfaceMock) Update(*v1.Service) (*v1.Service, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (s ServiceInterfaceMock) UpdateStatus(*v1.Service) (*v1.Service, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (s ServiceInterfaceMock) Delete(string, *api.DeleteOptions) error {
|
||||
return nil
|
||||
}
|
||||
func (s ServiceInterfaceMock) Watch(opts api.ListOptions) (watch.Interface, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (s ServiceInterfaceMock) ProxyGet(scheme, name, port, path string, params map[string]string) rest.ResponseWrapper {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s ServiceInterfaceMock) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s ServiceInterfaceMock) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.Service, err error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func TestGetServiceListFromServicesByLabel(t *testing.T) {
|
||||
serviceList := &v1.ServiceList{
|
||||
|
@ -877,11 +848,11 @@ func TestGetServiceListFromServicesByLabel(t *testing.T) {
|
|||
serviceIface := ServiceInterfaceMock{
|
||||
ServiceList: serviceList,
|
||||
}
|
||||
if _, err := getServiceListFromServicesByLabel(serviceIface, "nothing", "nothing"); err != nil {
|
||||
if _, err := getServiceListFromServicesByLabel(&serviceIface, "nothing", "nothing"); err != nil {
|
||||
t.Fatalf("Service had no label match, but getServiceListFromServicesByLabel returned an error")
|
||||
}
|
||||
|
||||
if _, err := getServiceListFromServicesByLabel(serviceIface, "foo", "bar"); err != nil {
|
||||
if _, err := getServiceListFromServicesByLabel(&serviceIface, "foo", "bar"); err != nil {
|
||||
t.Fatalf("Endpoint was ready with at least one Address, but getServiceListFromServicesByLabel returned an error")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// This package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,apps/v1alpha1,authentication/v1beta1,authorization/v1beta1,autoscaling/v1,batch/v1,certificates/v1alpha1,extensions/v1beta1,policy/v1alpha1,rbac/v1alpha1,storage/v1beta1]
|
||||
|
||||
// Package fake has the automatically generated clients.
|
||||
package fake
|
109
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_componentstatus.go
generated
vendored
Normal file
109
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_componentstatus.go
generated
vendored
Normal file
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
api "k8s.io/client-go/1.5/pkg/api"
|
||||
unversioned "k8s.io/client-go/1.5/pkg/api/unversioned"
|
||||
v1 "k8s.io/client-go/1.5/pkg/api/v1"
|
||||
labels "k8s.io/client-go/1.5/pkg/labels"
|
||||
watch "k8s.io/client-go/1.5/pkg/watch"
|
||||
testing "k8s.io/client-go/1.5/testing"
|
||||
)
|
||||
|
||||
// FakeComponentStatuses implements ComponentStatusInterface
|
||||
type FakeComponentStatuses struct {
|
||||
Fake *FakeCore
|
||||
}
|
||||
|
||||
var componentstatusesResource = unversioned.GroupVersionResource{Group: "", Version: "v1", Resource: "componentstatuses"}
|
||||
|
||||
func (c *FakeComponentStatuses) Create(componentStatus *v1.ComponentStatus) (result *v1.ComponentStatus, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewRootCreateAction(componentstatusesResource, componentStatus), &v1.ComponentStatus{})
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.ComponentStatus), err
|
||||
}
|
||||
|
||||
func (c *FakeComponentStatuses) Update(componentStatus *v1.ComponentStatus) (result *v1.ComponentStatus, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewRootUpdateAction(componentstatusesResource, componentStatus), &v1.ComponentStatus{})
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.ComponentStatus), err
|
||||
}
|
||||
|
||||
func (c *FakeComponentStatuses) Delete(name string, options *api.DeleteOptions) error {
|
||||
_, err := c.Fake.
|
||||
Invokes(testing.NewRootDeleteAction(componentstatusesResource, name), &v1.ComponentStatus{})
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakeComponentStatuses) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error {
|
||||
action := testing.NewRootDeleteCollectionAction(componentstatusesResource, listOptions)
|
||||
|
||||
_, err := c.Fake.Invokes(action, &v1.ComponentStatusList{})
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakeComponentStatuses) Get(name string) (result *v1.ComponentStatus, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewRootGetAction(componentstatusesResource, name), &v1.ComponentStatus{})
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.ComponentStatus), err
|
||||
}
|
||||
|
||||
func (c *FakeComponentStatuses) List(opts api.ListOptions) (result *v1.ComponentStatusList, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewRootListAction(componentstatusesResource, opts), &v1.ComponentStatusList{})
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
label := opts.LabelSelector
|
||||
if label == nil {
|
||||
label = labels.Everything()
|
||||
}
|
||||
list := &v1.ComponentStatusList{}
|
||||
for _, item := range obj.(*v1.ComponentStatusList).Items {
|
||||
if label.Matches(labels.Set(item.Labels)) {
|
||||
list.Items = append(list.Items, item)
|
||||
}
|
||||
}
|
||||
return list, err
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested componentStatuses.
|
||||
func (c *FakeComponentStatuses) Watch(opts api.ListOptions) (watch.Interface, error) {
|
||||
return c.Fake.
|
||||
InvokesWatch(testing.NewRootWatchAction(componentstatusesResource, opts))
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched componentStatus.
|
||||
func (c *FakeComponentStatuses) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.ComponentStatus, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewRootPatchSubresourceAction(componentstatusesResource, name, data, subresources...), &v1.ComponentStatus{})
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.ComponentStatus), err
|
||||
}
|
117
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_configmap.go
generated
vendored
Normal file
117
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_configmap.go
generated
vendored
Normal file
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
api "k8s.io/client-go/1.5/pkg/api"
|
||||
unversioned "k8s.io/client-go/1.5/pkg/api/unversioned"
|
||||
v1 "k8s.io/client-go/1.5/pkg/api/v1"
|
||||
labels "k8s.io/client-go/1.5/pkg/labels"
|
||||
watch "k8s.io/client-go/1.5/pkg/watch"
|
||||
testing "k8s.io/client-go/1.5/testing"
|
||||
)
|
||||
|
||||
// FakeConfigMaps implements ConfigMapInterface
|
||||
type FakeConfigMaps struct {
|
||||
Fake *FakeCore
|
||||
ns string
|
||||
}
|
||||
|
||||
var configmapsResource = unversioned.GroupVersionResource{Group: "", Version: "v1", Resource: "configmaps"}
|
||||
|
||||
func (c *FakeConfigMaps) Create(configMap *v1.ConfigMap) (result *v1.ConfigMap, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewCreateAction(configmapsResource, c.ns, configMap), &v1.ConfigMap{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.ConfigMap), err
|
||||
}
|
||||
|
||||
func (c *FakeConfigMaps) Update(configMap *v1.ConfigMap) (result *v1.ConfigMap, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewUpdateAction(configmapsResource, c.ns, configMap), &v1.ConfigMap{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.ConfigMap), err
|
||||
}
|
||||
|
||||
func (c *FakeConfigMaps) Delete(name string, options *api.DeleteOptions) error {
|
||||
_, err := c.Fake.
|
||||
Invokes(testing.NewDeleteAction(configmapsResource, c.ns, name), &v1.ConfigMap{})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakeConfigMaps) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error {
|
||||
action := testing.NewDeleteCollectionAction(configmapsResource, c.ns, listOptions)
|
||||
|
||||
_, err := c.Fake.Invokes(action, &v1.ConfigMapList{})
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakeConfigMaps) Get(name string) (result *v1.ConfigMap, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewGetAction(configmapsResource, c.ns, name), &v1.ConfigMap{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.ConfigMap), err
|
||||
}
|
||||
|
||||
func (c *FakeConfigMaps) List(opts api.ListOptions) (result *v1.ConfigMapList, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewListAction(configmapsResource, c.ns, opts), &v1.ConfigMapList{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
label := opts.LabelSelector
|
||||
if label == nil {
|
||||
label = labels.Everything()
|
||||
}
|
||||
list := &v1.ConfigMapList{}
|
||||
for _, item := range obj.(*v1.ConfigMapList).Items {
|
||||
if label.Matches(labels.Set(item.Labels)) {
|
||||
list.Items = append(list.Items, item)
|
||||
}
|
||||
}
|
||||
return list, err
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested configMaps.
|
||||
func (c *FakeConfigMaps) Watch(opts api.ListOptions) (watch.Interface, error) {
|
||||
return c.Fake.
|
||||
InvokesWatch(testing.NewWatchAction(configmapsResource, c.ns, opts))
|
||||
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched configMap.
|
||||
func (c *FakeConfigMaps) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.ConfigMap, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewPatchSubresourceAction(configmapsResource, c.ns, name, data, subresources...), &v1.ConfigMap{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.ConfigMap), err
|
||||
}
|
97
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_core_client.go
generated
vendored
Normal file
97
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_core_client.go
generated
vendored
Normal file
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
v1 "k8s.io/client-go/1.5/kubernetes/typed/core/v1"
|
||||
rest "k8s.io/client-go/1.5/rest"
|
||||
testing "k8s.io/client-go/1.5/testing"
|
||||
)
|
||||
|
||||
type FakeCore struct {
|
||||
*testing.Fake
|
||||
}
|
||||
|
||||
func (c *FakeCore) ComponentStatuses() v1.ComponentStatusInterface {
|
||||
return &FakeComponentStatuses{c}
|
||||
}
|
||||
|
||||
func (c *FakeCore) ConfigMaps(namespace string) v1.ConfigMapInterface {
|
||||
return &FakeConfigMaps{c, namespace}
|
||||
}
|
||||
|
||||
func (c *FakeCore) Endpoints(namespace string) v1.EndpointsInterface {
|
||||
return &FakeEndpoints{c, namespace}
|
||||
}
|
||||
|
||||
func (c *FakeCore) Events(namespace string) v1.EventInterface {
|
||||
return &FakeEvents{c, namespace}
|
||||
}
|
||||
|
||||
func (c *FakeCore) LimitRanges(namespace string) v1.LimitRangeInterface {
|
||||
return &FakeLimitRanges{c, namespace}
|
||||
}
|
||||
|
||||
func (c *FakeCore) Namespaces() v1.NamespaceInterface {
|
||||
return &FakeNamespaces{c}
|
||||
}
|
||||
|
||||
func (c *FakeCore) Nodes() v1.NodeInterface {
|
||||
return &FakeNodes{c}
|
||||
}
|
||||
|
||||
func (c *FakeCore) PersistentVolumes() v1.PersistentVolumeInterface {
|
||||
return &FakePersistentVolumes{c}
|
||||
}
|
||||
|
||||
func (c *FakeCore) PersistentVolumeClaims(namespace string) v1.PersistentVolumeClaimInterface {
|
||||
return &FakePersistentVolumeClaims{c, namespace}
|
||||
}
|
||||
|
||||
func (c *FakeCore) Pods(namespace string) v1.PodInterface {
|
||||
return &FakePods{c, namespace}
|
||||
}
|
||||
|
||||
func (c *FakeCore) PodTemplates(namespace string) v1.PodTemplateInterface {
|
||||
return &FakePodTemplates{c, namespace}
|
||||
}
|
||||
|
||||
func (c *FakeCore) ReplicationControllers(namespace string) v1.ReplicationControllerInterface {
|
||||
return &FakeReplicationControllers{c, namespace}
|
||||
}
|
||||
|
||||
func (c *FakeCore) ResourceQuotas(namespace string) v1.ResourceQuotaInterface {
|
||||
return &FakeResourceQuotas{c, namespace}
|
||||
}
|
||||
|
||||
func (c *FakeCore) Secrets(namespace string) v1.SecretInterface {
|
||||
return &FakeSecrets{c, namespace}
|
||||
}
|
||||
|
||||
func (c *FakeCore) Services(namespace string) v1.ServiceInterface {
|
||||
return &FakeServices{c, namespace}
|
||||
}
|
||||
|
||||
func (c *FakeCore) ServiceAccounts(namespace string) v1.ServiceAccountInterface {
|
||||
return &FakeServiceAccounts{c, namespace}
|
||||
}
|
||||
|
||||
// GetRESTClient returns a RESTClient that is used to communicate
|
||||
// with API server by this client implementation.
|
||||
func (c *FakeCore) GetRESTClient() *rest.RESTClient {
|
||||
return nil
|
||||
}
|
117
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_endpoints.go
generated
vendored
Normal file
117
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_endpoints.go
generated
vendored
Normal file
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
api "k8s.io/client-go/1.5/pkg/api"
|
||||
unversioned "k8s.io/client-go/1.5/pkg/api/unversioned"
|
||||
v1 "k8s.io/client-go/1.5/pkg/api/v1"
|
||||
labels "k8s.io/client-go/1.5/pkg/labels"
|
||||
watch "k8s.io/client-go/1.5/pkg/watch"
|
||||
testing "k8s.io/client-go/1.5/testing"
|
||||
)
|
||||
|
||||
// FakeEndpoints implements EndpointsInterface
|
||||
type FakeEndpoints struct {
|
||||
Fake *FakeCore
|
||||
ns string
|
||||
}
|
||||
|
||||
var endpointsResource = unversioned.GroupVersionResource{Group: "", Version: "v1", Resource: "endpoints"}
|
||||
|
||||
func (c *FakeEndpoints) Create(endpoints *v1.Endpoints) (result *v1.Endpoints, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewCreateAction(endpointsResource, c.ns, endpoints), &v1.Endpoints{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.Endpoints), err
|
||||
}
|
||||
|
||||
func (c *FakeEndpoints) Update(endpoints *v1.Endpoints) (result *v1.Endpoints, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewUpdateAction(endpointsResource, c.ns, endpoints), &v1.Endpoints{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.Endpoints), err
|
||||
}
|
||||
|
||||
func (c *FakeEndpoints) Delete(name string, options *api.DeleteOptions) error {
|
||||
_, err := c.Fake.
|
||||
Invokes(testing.NewDeleteAction(endpointsResource, c.ns, name), &v1.Endpoints{})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakeEndpoints) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error {
|
||||
action := testing.NewDeleteCollectionAction(endpointsResource, c.ns, listOptions)
|
||||
|
||||
_, err := c.Fake.Invokes(action, &v1.EndpointsList{})
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakeEndpoints) Get(name string) (result *v1.Endpoints, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewGetAction(endpointsResource, c.ns, name), &v1.Endpoints{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.Endpoints), err
|
||||
}
|
||||
|
||||
func (c *FakeEndpoints) List(opts api.ListOptions) (result *v1.EndpointsList, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewListAction(endpointsResource, c.ns, opts), &v1.EndpointsList{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
label := opts.LabelSelector
|
||||
if label == nil {
|
||||
label = labels.Everything()
|
||||
}
|
||||
list := &v1.EndpointsList{}
|
||||
for _, item := range obj.(*v1.EndpointsList).Items {
|
||||
if label.Matches(labels.Set(item.Labels)) {
|
||||
list.Items = append(list.Items, item)
|
||||
}
|
||||
}
|
||||
return list, err
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested endpoints.
|
||||
func (c *FakeEndpoints) Watch(opts api.ListOptions) (watch.Interface, error) {
|
||||
return c.Fake.
|
||||
InvokesWatch(testing.NewWatchAction(endpointsResource, c.ns, opts))
|
||||
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched endpoints.
|
||||
func (c *FakeEndpoints) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.Endpoints, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewPatchSubresourceAction(endpointsResource, c.ns, name, data, subresources...), &v1.Endpoints{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.Endpoints), err
|
||||
}
|
117
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_event.go
generated
vendored
Normal file
117
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_event.go
generated
vendored
Normal file
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
api "k8s.io/client-go/1.5/pkg/api"
|
||||
unversioned "k8s.io/client-go/1.5/pkg/api/unversioned"
|
||||
v1 "k8s.io/client-go/1.5/pkg/api/v1"
|
||||
labels "k8s.io/client-go/1.5/pkg/labels"
|
||||
watch "k8s.io/client-go/1.5/pkg/watch"
|
||||
testing "k8s.io/client-go/1.5/testing"
|
||||
)
|
||||
|
||||
// FakeEvents implements EventInterface
|
||||
type FakeEvents struct {
|
||||
Fake *FakeCore
|
||||
ns string
|
||||
}
|
||||
|
||||
var eventsResource = unversioned.GroupVersionResource{Group: "", Version: "v1", Resource: "events"}
|
||||
|
||||
func (c *FakeEvents) Create(event *v1.Event) (result *v1.Event, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewCreateAction(eventsResource, c.ns, event), &v1.Event{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.Event), err
|
||||
}
|
||||
|
||||
func (c *FakeEvents) Update(event *v1.Event) (result *v1.Event, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewUpdateAction(eventsResource, c.ns, event), &v1.Event{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.Event), err
|
||||
}
|
||||
|
||||
func (c *FakeEvents) Delete(name string, options *api.DeleteOptions) error {
|
||||
_, err := c.Fake.
|
||||
Invokes(testing.NewDeleteAction(eventsResource, c.ns, name), &v1.Event{})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakeEvents) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error {
|
||||
action := testing.NewDeleteCollectionAction(eventsResource, c.ns, listOptions)
|
||||
|
||||
_, err := c.Fake.Invokes(action, &v1.EventList{})
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakeEvents) Get(name string) (result *v1.Event, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewGetAction(eventsResource, c.ns, name), &v1.Event{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.Event), err
|
||||
}
|
||||
|
||||
func (c *FakeEvents) List(opts api.ListOptions) (result *v1.EventList, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewListAction(eventsResource, c.ns, opts), &v1.EventList{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
label := opts.LabelSelector
|
||||
if label == nil {
|
||||
label = labels.Everything()
|
||||
}
|
||||
list := &v1.EventList{}
|
||||
for _, item := range obj.(*v1.EventList).Items {
|
||||
if label.Matches(labels.Set(item.Labels)) {
|
||||
list.Items = append(list.Items, item)
|
||||
}
|
||||
}
|
||||
return list, err
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested events.
|
||||
func (c *FakeEvents) Watch(opts api.ListOptions) (watch.Interface, error) {
|
||||
return c.Fake.
|
||||
InvokesWatch(testing.NewWatchAction(eventsResource, c.ns, opts))
|
||||
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched event.
|
||||
func (c *FakeEvents) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.Event, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewPatchSubresourceAction(eventsResource, c.ns, name, data, subresources...), &v1.Event{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.Event), err
|
||||
}
|
89
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_event_expansion.go
generated
vendored
Normal file
89
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_event_expansion.go
generated
vendored
Normal file
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
Copyright 2014 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
"k8s.io/client-go/1.5/pkg/api"
|
||||
"k8s.io/client-go/1.5/pkg/api/v1"
|
||||
"k8s.io/client-go/1.5/pkg/fields"
|
||||
"k8s.io/client-go/1.5/pkg/runtime"
|
||||
"k8s.io/client-go/1.5/testing"
|
||||
)
|
||||
|
||||
func (c *FakeEvents) CreateWithEventNamespace(event *v1.Event) (*v1.Event, error) {
|
||||
action := testing.NewRootCreateAction(eventsResource, event)
|
||||
if c.ns != "" {
|
||||
action = testing.NewCreateAction(eventsResource, c.ns, event)
|
||||
}
|
||||
obj, err := c.Fake.Invokes(action, event)
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return obj.(*v1.Event), err
|
||||
}
|
||||
|
||||
// Update replaces an existing event. Returns the copy of the event the server returns, or an error.
|
||||
func (c *FakeEvents) UpdateWithEventNamespace(event *v1.Event) (*v1.Event, error) {
|
||||
action := testing.NewRootUpdateAction(eventsResource, event)
|
||||
if c.ns != "" {
|
||||
action = testing.NewUpdateAction(eventsResource, c.ns, event)
|
||||
}
|
||||
obj, err := c.Fake.Invokes(action, event)
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return obj.(*v1.Event), err
|
||||
}
|
||||
|
||||
// PatchWithEventNamespace patches an existing event. Returns the copy of the event the server returns, or an error.
|
||||
func (c *FakeEvents) PatchWithEventNamespace(event *v1.Event, data []byte) (*v1.Event, error) {
|
||||
action := testing.NewRootPatchAction(eventsResource, event.Name, data)
|
||||
if c.ns != "" {
|
||||
action = testing.NewPatchAction(eventsResource, c.ns, event.Name, data)
|
||||
}
|
||||
obj, err := c.Fake.Invokes(action, event)
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return obj.(*v1.Event), err
|
||||
}
|
||||
|
||||
// Search returns a list of events matching the specified object.
|
||||
func (c *FakeEvents) Search(objOrRef runtime.Object) (*v1.EventList, error) {
|
||||
action := testing.NewRootListAction(eventsResource, api.ListOptions{})
|
||||
if c.ns != "" {
|
||||
action = testing.NewListAction(eventsResource, c.ns, api.ListOptions{})
|
||||
}
|
||||
obj, err := c.Fake.Invokes(action, &v1.EventList{})
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return obj.(*v1.EventList), err
|
||||
}
|
||||
|
||||
func (c *FakeEvents) GetFieldSelector(involvedObjectName, involvedObjectNamespace, involvedObjectKind, involvedObjectUID *string) fields.Selector {
|
||||
action := testing.GenericActionImpl{}
|
||||
action.Verb = "get-field-selector"
|
||||
action.Resource = eventsResource
|
||||
|
||||
c.Fake.Invokes(action, nil)
|
||||
return fields.Everything()
|
||||
}
|
117
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_limitrange.go
generated
vendored
Normal file
117
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_limitrange.go
generated
vendored
Normal file
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
api "k8s.io/client-go/1.5/pkg/api"
|
||||
unversioned "k8s.io/client-go/1.5/pkg/api/unversioned"
|
||||
v1 "k8s.io/client-go/1.5/pkg/api/v1"
|
||||
labels "k8s.io/client-go/1.5/pkg/labels"
|
||||
watch "k8s.io/client-go/1.5/pkg/watch"
|
||||
testing "k8s.io/client-go/1.5/testing"
|
||||
)
|
||||
|
||||
// FakeLimitRanges implements LimitRangeInterface
|
||||
type FakeLimitRanges struct {
|
||||
Fake *FakeCore
|
||||
ns string
|
||||
}
|
||||
|
||||
var limitrangesResource = unversioned.GroupVersionResource{Group: "", Version: "v1", Resource: "limitranges"}
|
||||
|
||||
func (c *FakeLimitRanges) Create(limitRange *v1.LimitRange) (result *v1.LimitRange, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewCreateAction(limitrangesResource, c.ns, limitRange), &v1.LimitRange{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.LimitRange), err
|
||||
}
|
||||
|
||||
func (c *FakeLimitRanges) Update(limitRange *v1.LimitRange) (result *v1.LimitRange, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewUpdateAction(limitrangesResource, c.ns, limitRange), &v1.LimitRange{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.LimitRange), err
|
||||
}
|
||||
|
||||
func (c *FakeLimitRanges) Delete(name string, options *api.DeleteOptions) error {
|
||||
_, err := c.Fake.
|
||||
Invokes(testing.NewDeleteAction(limitrangesResource, c.ns, name), &v1.LimitRange{})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakeLimitRanges) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error {
|
||||
action := testing.NewDeleteCollectionAction(limitrangesResource, c.ns, listOptions)
|
||||
|
||||
_, err := c.Fake.Invokes(action, &v1.LimitRangeList{})
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakeLimitRanges) Get(name string) (result *v1.LimitRange, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewGetAction(limitrangesResource, c.ns, name), &v1.LimitRange{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.LimitRange), err
|
||||
}
|
||||
|
||||
func (c *FakeLimitRanges) List(opts api.ListOptions) (result *v1.LimitRangeList, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewListAction(limitrangesResource, c.ns, opts), &v1.LimitRangeList{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
label := opts.LabelSelector
|
||||
if label == nil {
|
||||
label = labels.Everything()
|
||||
}
|
||||
list := &v1.LimitRangeList{}
|
||||
for _, item := range obj.(*v1.LimitRangeList).Items {
|
||||
if label.Matches(labels.Set(item.Labels)) {
|
||||
list.Items = append(list.Items, item)
|
||||
}
|
||||
}
|
||||
return list, err
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested limitRanges.
|
||||
func (c *FakeLimitRanges) Watch(opts api.ListOptions) (watch.Interface, error) {
|
||||
return c.Fake.
|
||||
InvokesWatch(testing.NewWatchAction(limitrangesResource, c.ns, opts))
|
||||
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched limitRange.
|
||||
func (c *FakeLimitRanges) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.LimitRange, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewPatchSubresourceAction(limitrangesResource, c.ns, name, data, subresources...), &v1.LimitRange{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.LimitRange), err
|
||||
}
|
118
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_namespace.go
generated
vendored
Normal file
118
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_namespace.go
generated
vendored
Normal file
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
api "k8s.io/client-go/1.5/pkg/api"
|
||||
unversioned "k8s.io/client-go/1.5/pkg/api/unversioned"
|
||||
v1 "k8s.io/client-go/1.5/pkg/api/v1"
|
||||
labels "k8s.io/client-go/1.5/pkg/labels"
|
||||
watch "k8s.io/client-go/1.5/pkg/watch"
|
||||
testing "k8s.io/client-go/1.5/testing"
|
||||
)
|
||||
|
||||
// FakeNamespaces implements NamespaceInterface
|
||||
type FakeNamespaces struct {
|
||||
Fake *FakeCore
|
||||
}
|
||||
|
||||
var namespacesResource = unversioned.GroupVersionResource{Group: "", Version: "v1", Resource: "namespaces"}
|
||||
|
||||
func (c *FakeNamespaces) Create(namespace *v1.Namespace) (result *v1.Namespace, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewRootCreateAction(namespacesResource, namespace), &v1.Namespace{})
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.Namespace), err
|
||||
}
|
||||
|
||||
func (c *FakeNamespaces) Update(namespace *v1.Namespace) (result *v1.Namespace, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewRootUpdateAction(namespacesResource, namespace), &v1.Namespace{})
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.Namespace), err
|
||||
}
|
||||
|
||||
func (c *FakeNamespaces) UpdateStatus(namespace *v1.Namespace) (*v1.Namespace, error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewRootUpdateSubresourceAction(namespacesResource, "status", namespace), &v1.Namespace{})
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.Namespace), err
|
||||
}
|
||||
|
||||
func (c *FakeNamespaces) Delete(name string, options *api.DeleteOptions) error {
|
||||
_, err := c.Fake.
|
||||
Invokes(testing.NewRootDeleteAction(namespacesResource, name), &v1.Namespace{})
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakeNamespaces) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error {
|
||||
action := testing.NewRootDeleteCollectionAction(namespacesResource, listOptions)
|
||||
|
||||
_, err := c.Fake.Invokes(action, &v1.NamespaceList{})
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakeNamespaces) Get(name string) (result *v1.Namespace, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewRootGetAction(namespacesResource, name), &v1.Namespace{})
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.Namespace), err
|
||||
}
|
||||
|
||||
func (c *FakeNamespaces) List(opts api.ListOptions) (result *v1.NamespaceList, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewRootListAction(namespacesResource, opts), &v1.NamespaceList{})
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
label := opts.LabelSelector
|
||||
if label == nil {
|
||||
label = labels.Everything()
|
||||
}
|
||||
list := &v1.NamespaceList{}
|
||||
for _, item := range obj.(*v1.NamespaceList).Items {
|
||||
if label.Matches(labels.Set(item.Labels)) {
|
||||
list.Items = append(list.Items, item)
|
||||
}
|
||||
}
|
||||
return list, err
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested namespaces.
|
||||
func (c *FakeNamespaces) Watch(opts api.ListOptions) (watch.Interface, error) {
|
||||
return c.Fake.
|
||||
InvokesWatch(testing.NewRootWatchAction(namespacesResource, opts))
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched namespace.
|
||||
func (c *FakeNamespaces) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.Namespace, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewRootPatchSubresourceAction(namespacesResource, name, data, subresources...), &v1.Namespace{})
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.Namespace), err
|
||||
}
|
37
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_namespace_expansion.go
generated
vendored
Normal file
37
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_namespace_expansion.go
generated
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
Copyright 2014 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
"k8s.io/client-go/1.5/pkg/api/v1"
|
||||
"k8s.io/client-go/1.5/testing"
|
||||
)
|
||||
|
||||
func (c *FakeNamespaces) Finalize(namespace *v1.Namespace) (*v1.Namespace, error) {
|
||||
action := testing.CreateActionImpl{}
|
||||
action.Verb = "create"
|
||||
action.Resource = namespacesResource
|
||||
action.Subresource = "finalize"
|
||||
action.Object = namespace
|
||||
|
||||
obj, err := c.Fake.Invokes(action, namespace)
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return obj.(*v1.Namespace), err
|
||||
}
|
118
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_node.go
generated
vendored
Normal file
118
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_node.go
generated
vendored
Normal file
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
api "k8s.io/client-go/1.5/pkg/api"
|
||||
unversioned "k8s.io/client-go/1.5/pkg/api/unversioned"
|
||||
v1 "k8s.io/client-go/1.5/pkg/api/v1"
|
||||
labels "k8s.io/client-go/1.5/pkg/labels"
|
||||
watch "k8s.io/client-go/1.5/pkg/watch"
|
||||
testing "k8s.io/client-go/1.5/testing"
|
||||
)
|
||||
|
||||
// FakeNodes implements NodeInterface
|
||||
type FakeNodes struct {
|
||||
Fake *FakeCore
|
||||
}
|
||||
|
||||
var nodesResource = unversioned.GroupVersionResource{Group: "", Version: "v1", Resource: "nodes"}
|
||||
|
||||
func (c *FakeNodes) Create(node *v1.Node) (result *v1.Node, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewRootCreateAction(nodesResource, node), &v1.Node{})
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.Node), err
|
||||
}
|
||||
|
||||
func (c *FakeNodes) Update(node *v1.Node) (result *v1.Node, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewRootUpdateAction(nodesResource, node), &v1.Node{})
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.Node), err
|
||||
}
|
||||
|
||||
func (c *FakeNodes) UpdateStatus(node *v1.Node) (*v1.Node, error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewRootUpdateSubresourceAction(nodesResource, "status", node), &v1.Node{})
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.Node), err
|
||||
}
|
||||
|
||||
func (c *FakeNodes) Delete(name string, options *api.DeleteOptions) error {
|
||||
_, err := c.Fake.
|
||||
Invokes(testing.NewRootDeleteAction(nodesResource, name), &v1.Node{})
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakeNodes) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error {
|
||||
action := testing.NewRootDeleteCollectionAction(nodesResource, listOptions)
|
||||
|
||||
_, err := c.Fake.Invokes(action, &v1.NodeList{})
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakeNodes) Get(name string) (result *v1.Node, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewRootGetAction(nodesResource, name), &v1.Node{})
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.Node), err
|
||||
}
|
||||
|
||||
func (c *FakeNodes) List(opts api.ListOptions) (result *v1.NodeList, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewRootListAction(nodesResource, opts), &v1.NodeList{})
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
label := opts.LabelSelector
|
||||
if label == nil {
|
||||
label = labels.Everything()
|
||||
}
|
||||
list := &v1.NodeList{}
|
||||
for _, item := range obj.(*v1.NodeList).Items {
|
||||
if label.Matches(labels.Set(item.Labels)) {
|
||||
list.Items = append(list.Items, item)
|
||||
}
|
||||
}
|
||||
return list, err
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested nodes.
|
||||
func (c *FakeNodes) Watch(opts api.ListOptions) (watch.Interface, error) {
|
||||
return c.Fake.
|
||||
InvokesWatch(testing.NewRootWatchAction(nodesResource, opts))
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched node.
|
||||
func (c *FakeNodes) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.Node, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewRootPatchSubresourceAction(nodesResource, name, data, subresources...), &v1.Node{})
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.Node), err
|
||||
}
|
118
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_persistentvolume.go
generated
vendored
Normal file
118
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_persistentvolume.go
generated
vendored
Normal file
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
api "k8s.io/client-go/1.5/pkg/api"
|
||||
unversioned "k8s.io/client-go/1.5/pkg/api/unversioned"
|
||||
v1 "k8s.io/client-go/1.5/pkg/api/v1"
|
||||
labels "k8s.io/client-go/1.5/pkg/labels"
|
||||
watch "k8s.io/client-go/1.5/pkg/watch"
|
||||
testing "k8s.io/client-go/1.5/testing"
|
||||
)
|
||||
|
||||
// FakePersistentVolumes implements PersistentVolumeInterface
|
||||
type FakePersistentVolumes struct {
|
||||
Fake *FakeCore
|
||||
}
|
||||
|
||||
var persistentvolumesResource = unversioned.GroupVersionResource{Group: "", Version: "v1", Resource: "persistentvolumes"}
|
||||
|
||||
func (c *FakePersistentVolumes) Create(persistentVolume *v1.PersistentVolume) (result *v1.PersistentVolume, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewRootCreateAction(persistentvolumesResource, persistentVolume), &v1.PersistentVolume{})
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.PersistentVolume), err
|
||||
}
|
||||
|
||||
func (c *FakePersistentVolumes) Update(persistentVolume *v1.PersistentVolume) (result *v1.PersistentVolume, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewRootUpdateAction(persistentvolumesResource, persistentVolume), &v1.PersistentVolume{})
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.PersistentVolume), err
|
||||
}
|
||||
|
||||
func (c *FakePersistentVolumes) UpdateStatus(persistentVolume *v1.PersistentVolume) (*v1.PersistentVolume, error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewRootUpdateSubresourceAction(persistentvolumesResource, "status", persistentVolume), &v1.PersistentVolume{})
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.PersistentVolume), err
|
||||
}
|
||||
|
||||
func (c *FakePersistentVolumes) Delete(name string, options *api.DeleteOptions) error {
|
||||
_, err := c.Fake.
|
||||
Invokes(testing.NewRootDeleteAction(persistentvolumesResource, name), &v1.PersistentVolume{})
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakePersistentVolumes) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error {
|
||||
action := testing.NewRootDeleteCollectionAction(persistentvolumesResource, listOptions)
|
||||
|
||||
_, err := c.Fake.Invokes(action, &v1.PersistentVolumeList{})
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakePersistentVolumes) Get(name string) (result *v1.PersistentVolume, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewRootGetAction(persistentvolumesResource, name), &v1.PersistentVolume{})
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.PersistentVolume), err
|
||||
}
|
||||
|
||||
func (c *FakePersistentVolumes) List(opts api.ListOptions) (result *v1.PersistentVolumeList, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewRootListAction(persistentvolumesResource, opts), &v1.PersistentVolumeList{})
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
label := opts.LabelSelector
|
||||
if label == nil {
|
||||
label = labels.Everything()
|
||||
}
|
||||
list := &v1.PersistentVolumeList{}
|
||||
for _, item := range obj.(*v1.PersistentVolumeList).Items {
|
||||
if label.Matches(labels.Set(item.Labels)) {
|
||||
list.Items = append(list.Items, item)
|
||||
}
|
||||
}
|
||||
return list, err
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested persistentVolumes.
|
||||
func (c *FakePersistentVolumes) Watch(opts api.ListOptions) (watch.Interface, error) {
|
||||
return c.Fake.
|
||||
InvokesWatch(testing.NewRootWatchAction(persistentvolumesResource, opts))
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched persistentVolume.
|
||||
func (c *FakePersistentVolumes) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.PersistentVolume, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewRootPatchSubresourceAction(persistentvolumesResource, name, data, subresources...), &v1.PersistentVolume{})
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.PersistentVolume), err
|
||||
}
|
127
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_persistentvolumeclaim.go
generated
vendored
Normal file
127
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_persistentvolumeclaim.go
generated
vendored
Normal file
|
@ -0,0 +1,127 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
api "k8s.io/client-go/1.5/pkg/api"
|
||||
unversioned "k8s.io/client-go/1.5/pkg/api/unversioned"
|
||||
v1 "k8s.io/client-go/1.5/pkg/api/v1"
|
||||
labels "k8s.io/client-go/1.5/pkg/labels"
|
||||
watch "k8s.io/client-go/1.5/pkg/watch"
|
||||
testing "k8s.io/client-go/1.5/testing"
|
||||
)
|
||||
|
||||
// FakePersistentVolumeClaims implements PersistentVolumeClaimInterface
|
||||
type FakePersistentVolumeClaims struct {
|
||||
Fake *FakeCore
|
||||
ns string
|
||||
}
|
||||
|
||||
var persistentvolumeclaimsResource = unversioned.GroupVersionResource{Group: "", Version: "v1", Resource: "persistentvolumeclaims"}
|
||||
|
||||
func (c *FakePersistentVolumeClaims) Create(persistentVolumeClaim *v1.PersistentVolumeClaim) (result *v1.PersistentVolumeClaim, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewCreateAction(persistentvolumeclaimsResource, c.ns, persistentVolumeClaim), &v1.PersistentVolumeClaim{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.PersistentVolumeClaim), err
|
||||
}
|
||||
|
||||
func (c *FakePersistentVolumeClaims) Update(persistentVolumeClaim *v1.PersistentVolumeClaim) (result *v1.PersistentVolumeClaim, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewUpdateAction(persistentvolumeclaimsResource, c.ns, persistentVolumeClaim), &v1.PersistentVolumeClaim{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.PersistentVolumeClaim), err
|
||||
}
|
||||
|
||||
func (c *FakePersistentVolumeClaims) UpdateStatus(persistentVolumeClaim *v1.PersistentVolumeClaim) (*v1.PersistentVolumeClaim, error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewUpdateSubresourceAction(persistentvolumeclaimsResource, "status", c.ns, persistentVolumeClaim), &v1.PersistentVolumeClaim{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.PersistentVolumeClaim), err
|
||||
}
|
||||
|
||||
func (c *FakePersistentVolumeClaims) Delete(name string, options *api.DeleteOptions) error {
|
||||
_, err := c.Fake.
|
||||
Invokes(testing.NewDeleteAction(persistentvolumeclaimsResource, c.ns, name), &v1.PersistentVolumeClaim{})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakePersistentVolumeClaims) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error {
|
||||
action := testing.NewDeleteCollectionAction(persistentvolumeclaimsResource, c.ns, listOptions)
|
||||
|
||||
_, err := c.Fake.Invokes(action, &v1.PersistentVolumeClaimList{})
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakePersistentVolumeClaims) Get(name string) (result *v1.PersistentVolumeClaim, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewGetAction(persistentvolumeclaimsResource, c.ns, name), &v1.PersistentVolumeClaim{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.PersistentVolumeClaim), err
|
||||
}
|
||||
|
||||
func (c *FakePersistentVolumeClaims) List(opts api.ListOptions) (result *v1.PersistentVolumeClaimList, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewListAction(persistentvolumeclaimsResource, c.ns, opts), &v1.PersistentVolumeClaimList{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
label := opts.LabelSelector
|
||||
if label == nil {
|
||||
label = labels.Everything()
|
||||
}
|
||||
list := &v1.PersistentVolumeClaimList{}
|
||||
for _, item := range obj.(*v1.PersistentVolumeClaimList).Items {
|
||||
if label.Matches(labels.Set(item.Labels)) {
|
||||
list.Items = append(list.Items, item)
|
||||
}
|
||||
}
|
||||
return list, err
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested persistentVolumeClaims.
|
||||
func (c *FakePersistentVolumeClaims) Watch(opts api.ListOptions) (watch.Interface, error) {
|
||||
return c.Fake.
|
||||
InvokesWatch(testing.NewWatchAction(persistentvolumeclaimsResource, c.ns, opts))
|
||||
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched persistentVolumeClaim.
|
||||
func (c *FakePersistentVolumeClaims) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.PersistentVolumeClaim, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewPatchSubresourceAction(persistentvolumeclaimsResource, c.ns, name, data, subresources...), &v1.PersistentVolumeClaim{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.PersistentVolumeClaim), err
|
||||
}
|
127
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_pod.go
generated
vendored
Normal file
127
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_pod.go
generated
vendored
Normal file
|
@ -0,0 +1,127 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
api "k8s.io/client-go/1.5/pkg/api"
|
||||
unversioned "k8s.io/client-go/1.5/pkg/api/unversioned"
|
||||
v1 "k8s.io/client-go/1.5/pkg/api/v1"
|
||||
labels "k8s.io/client-go/1.5/pkg/labels"
|
||||
watch "k8s.io/client-go/1.5/pkg/watch"
|
||||
testing "k8s.io/client-go/1.5/testing"
|
||||
)
|
||||
|
||||
// FakePods implements PodInterface
|
||||
type FakePods struct {
|
||||
Fake *FakeCore
|
||||
ns string
|
||||
}
|
||||
|
||||
var podsResource = unversioned.GroupVersionResource{Group: "", Version: "v1", Resource: "pods"}
|
||||
|
||||
func (c *FakePods) Create(pod *v1.Pod) (result *v1.Pod, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewCreateAction(podsResource, c.ns, pod), &v1.Pod{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.Pod), err
|
||||
}
|
||||
|
||||
func (c *FakePods) Update(pod *v1.Pod) (result *v1.Pod, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewUpdateAction(podsResource, c.ns, pod), &v1.Pod{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.Pod), err
|
||||
}
|
||||
|
||||
func (c *FakePods) UpdateStatus(pod *v1.Pod) (*v1.Pod, error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewUpdateSubresourceAction(podsResource, "status", c.ns, pod), &v1.Pod{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.Pod), err
|
||||
}
|
||||
|
||||
func (c *FakePods) Delete(name string, options *api.DeleteOptions) error {
|
||||
_, err := c.Fake.
|
||||
Invokes(testing.NewDeleteAction(podsResource, c.ns, name), &v1.Pod{})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakePods) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error {
|
||||
action := testing.NewDeleteCollectionAction(podsResource, c.ns, listOptions)
|
||||
|
||||
_, err := c.Fake.Invokes(action, &v1.PodList{})
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakePods) Get(name string) (result *v1.Pod, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewGetAction(podsResource, c.ns, name), &v1.Pod{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.Pod), err
|
||||
}
|
||||
|
||||
func (c *FakePods) List(opts api.ListOptions) (result *v1.PodList, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewListAction(podsResource, c.ns, opts), &v1.PodList{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
label := opts.LabelSelector
|
||||
if label == nil {
|
||||
label = labels.Everything()
|
||||
}
|
||||
list := &v1.PodList{}
|
||||
for _, item := range obj.(*v1.PodList).Items {
|
||||
if label.Matches(labels.Set(item.Labels)) {
|
||||
list.Items = append(list.Items, item)
|
||||
}
|
||||
}
|
||||
return list, err
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested pods.
|
||||
func (c *FakePods) Watch(opts api.ListOptions) (watch.Interface, error) {
|
||||
return c.Fake.
|
||||
InvokesWatch(testing.NewWatchAction(podsResource, c.ns, opts))
|
||||
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched pod.
|
||||
func (c *FakePods) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.Pod, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewPatchSubresourceAction(podsResource, c.ns, name, data, subresources...), &v1.Pod{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.Pod), err
|
||||
}
|
58
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_pod_expansion.go
generated
vendored
Normal file
58
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_pod_expansion.go
generated
vendored
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
Copyright 2014 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
"k8s.io/client-go/1.5/pkg/api/v1"
|
||||
"k8s.io/client-go/1.5/pkg/apis/policy/v1alpha1"
|
||||
"k8s.io/client-go/1.5/rest"
|
||||
"k8s.io/client-go/1.5/testing"
|
||||
)
|
||||
|
||||
func (c *FakePods) Bind(binding *v1.Binding) error {
|
||||
action := testing.CreateActionImpl{}
|
||||
action.Verb = "create"
|
||||
action.Resource = podsResource
|
||||
action.Subresource = "bindings"
|
||||
action.Object = binding
|
||||
|
||||
_, err := c.Fake.Invokes(action, binding)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakePods) GetLogs(name string, opts *v1.PodLogOptions) *rest.Request {
|
||||
action := testing.GenericActionImpl{}
|
||||
action.Verb = "get"
|
||||
action.Namespace = c.ns
|
||||
action.Resource = podsResource
|
||||
action.Subresource = "logs"
|
||||
action.Value = opts
|
||||
|
||||
_, _ = c.Fake.Invokes(action, &v1.Pod{})
|
||||
return &rest.Request{}
|
||||
}
|
||||
|
||||
func (c *FakePods) Evict(eviction *v1alpha1.Eviction) error {
|
||||
action := testing.CreateActionImpl{}
|
||||
action.Verb = "create"
|
||||
action.Resource = podsResource
|
||||
action.Subresource = "eviction"
|
||||
action.Object = eviction
|
||||
|
||||
_, err := c.Fake.Invokes(action, eviction)
|
||||
return err
|
||||
}
|
117
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_podtemplate.go
generated
vendored
Normal file
117
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_podtemplate.go
generated
vendored
Normal file
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
api "k8s.io/client-go/1.5/pkg/api"
|
||||
unversioned "k8s.io/client-go/1.5/pkg/api/unversioned"
|
||||
v1 "k8s.io/client-go/1.5/pkg/api/v1"
|
||||
labels "k8s.io/client-go/1.5/pkg/labels"
|
||||
watch "k8s.io/client-go/1.5/pkg/watch"
|
||||
testing "k8s.io/client-go/1.5/testing"
|
||||
)
|
||||
|
||||
// FakePodTemplates implements PodTemplateInterface
|
||||
type FakePodTemplates struct {
|
||||
Fake *FakeCore
|
||||
ns string
|
||||
}
|
||||
|
||||
var podtemplatesResource = unversioned.GroupVersionResource{Group: "", Version: "v1", Resource: "podtemplates"}
|
||||
|
||||
func (c *FakePodTemplates) Create(podTemplate *v1.PodTemplate) (result *v1.PodTemplate, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewCreateAction(podtemplatesResource, c.ns, podTemplate), &v1.PodTemplate{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.PodTemplate), err
|
||||
}
|
||||
|
||||
func (c *FakePodTemplates) Update(podTemplate *v1.PodTemplate) (result *v1.PodTemplate, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewUpdateAction(podtemplatesResource, c.ns, podTemplate), &v1.PodTemplate{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.PodTemplate), err
|
||||
}
|
||||
|
||||
func (c *FakePodTemplates) Delete(name string, options *api.DeleteOptions) error {
|
||||
_, err := c.Fake.
|
||||
Invokes(testing.NewDeleteAction(podtemplatesResource, c.ns, name), &v1.PodTemplate{})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakePodTemplates) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error {
|
||||
action := testing.NewDeleteCollectionAction(podtemplatesResource, c.ns, listOptions)
|
||||
|
||||
_, err := c.Fake.Invokes(action, &v1.PodTemplateList{})
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakePodTemplates) Get(name string) (result *v1.PodTemplate, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewGetAction(podtemplatesResource, c.ns, name), &v1.PodTemplate{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.PodTemplate), err
|
||||
}
|
||||
|
||||
func (c *FakePodTemplates) List(opts api.ListOptions) (result *v1.PodTemplateList, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewListAction(podtemplatesResource, c.ns, opts), &v1.PodTemplateList{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
label := opts.LabelSelector
|
||||
if label == nil {
|
||||
label = labels.Everything()
|
||||
}
|
||||
list := &v1.PodTemplateList{}
|
||||
for _, item := range obj.(*v1.PodTemplateList).Items {
|
||||
if label.Matches(labels.Set(item.Labels)) {
|
||||
list.Items = append(list.Items, item)
|
||||
}
|
||||
}
|
||||
return list, err
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested podTemplates.
|
||||
func (c *FakePodTemplates) Watch(opts api.ListOptions) (watch.Interface, error) {
|
||||
return c.Fake.
|
||||
InvokesWatch(testing.NewWatchAction(podtemplatesResource, c.ns, opts))
|
||||
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched podTemplate.
|
||||
func (c *FakePodTemplates) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.PodTemplate, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewPatchSubresourceAction(podtemplatesResource, c.ns, name, data, subresources...), &v1.PodTemplate{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.PodTemplate), err
|
||||
}
|
127
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_replicationcontroller.go
generated
vendored
Normal file
127
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_replicationcontroller.go
generated
vendored
Normal file
|
@ -0,0 +1,127 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
api "k8s.io/client-go/1.5/pkg/api"
|
||||
unversioned "k8s.io/client-go/1.5/pkg/api/unversioned"
|
||||
v1 "k8s.io/client-go/1.5/pkg/api/v1"
|
||||
labels "k8s.io/client-go/1.5/pkg/labels"
|
||||
watch "k8s.io/client-go/1.5/pkg/watch"
|
||||
testing "k8s.io/client-go/1.5/testing"
|
||||
)
|
||||
|
||||
// FakeReplicationControllers implements ReplicationControllerInterface
|
||||
type FakeReplicationControllers struct {
|
||||
Fake *FakeCore
|
||||
ns string
|
||||
}
|
||||
|
||||
var replicationcontrollersResource = unversioned.GroupVersionResource{Group: "", Version: "v1", Resource: "replicationcontrollers"}
|
||||
|
||||
func (c *FakeReplicationControllers) Create(replicationController *v1.ReplicationController) (result *v1.ReplicationController, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewCreateAction(replicationcontrollersResource, c.ns, replicationController), &v1.ReplicationController{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.ReplicationController), err
|
||||
}
|
||||
|
||||
func (c *FakeReplicationControllers) Update(replicationController *v1.ReplicationController) (result *v1.ReplicationController, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewUpdateAction(replicationcontrollersResource, c.ns, replicationController), &v1.ReplicationController{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.ReplicationController), err
|
||||
}
|
||||
|
||||
func (c *FakeReplicationControllers) UpdateStatus(replicationController *v1.ReplicationController) (*v1.ReplicationController, error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewUpdateSubresourceAction(replicationcontrollersResource, "status", c.ns, replicationController), &v1.ReplicationController{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.ReplicationController), err
|
||||
}
|
||||
|
||||
func (c *FakeReplicationControllers) Delete(name string, options *api.DeleteOptions) error {
|
||||
_, err := c.Fake.
|
||||
Invokes(testing.NewDeleteAction(replicationcontrollersResource, c.ns, name), &v1.ReplicationController{})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakeReplicationControllers) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error {
|
||||
action := testing.NewDeleteCollectionAction(replicationcontrollersResource, c.ns, listOptions)
|
||||
|
||||
_, err := c.Fake.Invokes(action, &v1.ReplicationControllerList{})
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakeReplicationControllers) Get(name string) (result *v1.ReplicationController, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewGetAction(replicationcontrollersResource, c.ns, name), &v1.ReplicationController{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.ReplicationController), err
|
||||
}
|
||||
|
||||
func (c *FakeReplicationControllers) List(opts api.ListOptions) (result *v1.ReplicationControllerList, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewListAction(replicationcontrollersResource, c.ns, opts), &v1.ReplicationControllerList{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
label := opts.LabelSelector
|
||||
if label == nil {
|
||||
label = labels.Everything()
|
||||
}
|
||||
list := &v1.ReplicationControllerList{}
|
||||
for _, item := range obj.(*v1.ReplicationControllerList).Items {
|
||||
if label.Matches(labels.Set(item.Labels)) {
|
||||
list.Items = append(list.Items, item)
|
||||
}
|
||||
}
|
||||
return list, err
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested replicationControllers.
|
||||
func (c *FakeReplicationControllers) Watch(opts api.ListOptions) (watch.Interface, error) {
|
||||
return c.Fake.
|
||||
InvokesWatch(testing.NewWatchAction(replicationcontrollersResource, c.ns, opts))
|
||||
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched replicationController.
|
||||
func (c *FakeReplicationControllers) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.ReplicationController, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewPatchSubresourceAction(replicationcontrollersResource, c.ns, name, data, subresources...), &v1.ReplicationController{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.ReplicationController), err
|
||||
}
|
127
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_resourcequota.go
generated
vendored
Normal file
127
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_resourcequota.go
generated
vendored
Normal file
|
@ -0,0 +1,127 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
api "k8s.io/client-go/1.5/pkg/api"
|
||||
unversioned "k8s.io/client-go/1.5/pkg/api/unversioned"
|
||||
v1 "k8s.io/client-go/1.5/pkg/api/v1"
|
||||
labels "k8s.io/client-go/1.5/pkg/labels"
|
||||
watch "k8s.io/client-go/1.5/pkg/watch"
|
||||
testing "k8s.io/client-go/1.5/testing"
|
||||
)
|
||||
|
||||
// FakeResourceQuotas implements ResourceQuotaInterface
|
||||
type FakeResourceQuotas struct {
|
||||
Fake *FakeCore
|
||||
ns string
|
||||
}
|
||||
|
||||
var resourcequotasResource = unversioned.GroupVersionResource{Group: "", Version: "v1", Resource: "resourcequotas"}
|
||||
|
||||
func (c *FakeResourceQuotas) Create(resourceQuota *v1.ResourceQuota) (result *v1.ResourceQuota, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewCreateAction(resourcequotasResource, c.ns, resourceQuota), &v1.ResourceQuota{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.ResourceQuota), err
|
||||
}
|
||||
|
||||
func (c *FakeResourceQuotas) Update(resourceQuota *v1.ResourceQuota) (result *v1.ResourceQuota, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewUpdateAction(resourcequotasResource, c.ns, resourceQuota), &v1.ResourceQuota{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.ResourceQuota), err
|
||||
}
|
||||
|
||||
func (c *FakeResourceQuotas) UpdateStatus(resourceQuota *v1.ResourceQuota) (*v1.ResourceQuota, error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewUpdateSubresourceAction(resourcequotasResource, "status", c.ns, resourceQuota), &v1.ResourceQuota{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.ResourceQuota), err
|
||||
}
|
||||
|
||||
func (c *FakeResourceQuotas) Delete(name string, options *api.DeleteOptions) error {
|
||||
_, err := c.Fake.
|
||||
Invokes(testing.NewDeleteAction(resourcequotasResource, c.ns, name), &v1.ResourceQuota{})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakeResourceQuotas) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error {
|
||||
action := testing.NewDeleteCollectionAction(resourcequotasResource, c.ns, listOptions)
|
||||
|
||||
_, err := c.Fake.Invokes(action, &v1.ResourceQuotaList{})
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakeResourceQuotas) Get(name string) (result *v1.ResourceQuota, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewGetAction(resourcequotasResource, c.ns, name), &v1.ResourceQuota{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.ResourceQuota), err
|
||||
}
|
||||
|
||||
func (c *FakeResourceQuotas) List(opts api.ListOptions) (result *v1.ResourceQuotaList, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewListAction(resourcequotasResource, c.ns, opts), &v1.ResourceQuotaList{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
label := opts.LabelSelector
|
||||
if label == nil {
|
||||
label = labels.Everything()
|
||||
}
|
||||
list := &v1.ResourceQuotaList{}
|
||||
for _, item := range obj.(*v1.ResourceQuotaList).Items {
|
||||
if label.Matches(labels.Set(item.Labels)) {
|
||||
list.Items = append(list.Items, item)
|
||||
}
|
||||
}
|
||||
return list, err
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested resourceQuotas.
|
||||
func (c *FakeResourceQuotas) Watch(opts api.ListOptions) (watch.Interface, error) {
|
||||
return c.Fake.
|
||||
InvokesWatch(testing.NewWatchAction(resourcequotasResource, c.ns, opts))
|
||||
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched resourceQuota.
|
||||
func (c *FakeResourceQuotas) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.ResourceQuota, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewPatchSubresourceAction(resourcequotasResource, c.ns, name, data, subresources...), &v1.ResourceQuota{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.ResourceQuota), err
|
||||
}
|
117
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_secret.go
generated
vendored
Normal file
117
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_secret.go
generated
vendored
Normal file
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
api "k8s.io/client-go/1.5/pkg/api"
|
||||
unversioned "k8s.io/client-go/1.5/pkg/api/unversioned"
|
||||
v1 "k8s.io/client-go/1.5/pkg/api/v1"
|
||||
labels "k8s.io/client-go/1.5/pkg/labels"
|
||||
watch "k8s.io/client-go/1.5/pkg/watch"
|
||||
testing "k8s.io/client-go/1.5/testing"
|
||||
)
|
||||
|
||||
// FakeSecrets implements SecretInterface
|
||||
type FakeSecrets struct {
|
||||
Fake *FakeCore
|
||||
ns string
|
||||
}
|
||||
|
||||
var secretsResource = unversioned.GroupVersionResource{Group: "", Version: "v1", Resource: "secrets"}
|
||||
|
||||
func (c *FakeSecrets) Create(secret *v1.Secret) (result *v1.Secret, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewCreateAction(secretsResource, c.ns, secret), &v1.Secret{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.Secret), err
|
||||
}
|
||||
|
||||
func (c *FakeSecrets) Update(secret *v1.Secret) (result *v1.Secret, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewUpdateAction(secretsResource, c.ns, secret), &v1.Secret{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.Secret), err
|
||||
}
|
||||
|
||||
func (c *FakeSecrets) Delete(name string, options *api.DeleteOptions) error {
|
||||
_, err := c.Fake.
|
||||
Invokes(testing.NewDeleteAction(secretsResource, c.ns, name), &v1.Secret{})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakeSecrets) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error {
|
||||
action := testing.NewDeleteCollectionAction(secretsResource, c.ns, listOptions)
|
||||
|
||||
_, err := c.Fake.Invokes(action, &v1.SecretList{})
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakeSecrets) Get(name string) (result *v1.Secret, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewGetAction(secretsResource, c.ns, name), &v1.Secret{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.Secret), err
|
||||
}
|
||||
|
||||
func (c *FakeSecrets) List(opts api.ListOptions) (result *v1.SecretList, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewListAction(secretsResource, c.ns, opts), &v1.SecretList{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
label := opts.LabelSelector
|
||||
if label == nil {
|
||||
label = labels.Everything()
|
||||
}
|
||||
list := &v1.SecretList{}
|
||||
for _, item := range obj.(*v1.SecretList).Items {
|
||||
if label.Matches(labels.Set(item.Labels)) {
|
||||
list.Items = append(list.Items, item)
|
||||
}
|
||||
}
|
||||
return list, err
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested secrets.
|
||||
func (c *FakeSecrets) Watch(opts api.ListOptions) (watch.Interface, error) {
|
||||
return c.Fake.
|
||||
InvokesWatch(testing.NewWatchAction(secretsResource, c.ns, opts))
|
||||
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched secret.
|
||||
func (c *FakeSecrets) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.Secret, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewPatchSubresourceAction(secretsResource, c.ns, name, data, subresources...), &v1.Secret{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.Secret), err
|
||||
}
|
127
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_service.go
generated
vendored
Normal file
127
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_service.go
generated
vendored
Normal file
|
@ -0,0 +1,127 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
api "k8s.io/client-go/1.5/pkg/api"
|
||||
unversioned "k8s.io/client-go/1.5/pkg/api/unversioned"
|
||||
v1 "k8s.io/client-go/1.5/pkg/api/v1"
|
||||
labels "k8s.io/client-go/1.5/pkg/labels"
|
||||
watch "k8s.io/client-go/1.5/pkg/watch"
|
||||
testing "k8s.io/client-go/1.5/testing"
|
||||
)
|
||||
|
||||
// FakeServices implements ServiceInterface
|
||||
type FakeServices struct {
|
||||
Fake *FakeCore
|
||||
ns string
|
||||
}
|
||||
|
||||
var servicesResource = unversioned.GroupVersionResource{Group: "", Version: "v1", Resource: "services"}
|
||||
|
||||
func (c *FakeServices) Create(service *v1.Service) (result *v1.Service, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewCreateAction(servicesResource, c.ns, service), &v1.Service{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.Service), err
|
||||
}
|
||||
|
||||
func (c *FakeServices) Update(service *v1.Service) (result *v1.Service, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewUpdateAction(servicesResource, c.ns, service), &v1.Service{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.Service), err
|
||||
}
|
||||
|
||||
func (c *FakeServices) UpdateStatus(service *v1.Service) (*v1.Service, error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewUpdateSubresourceAction(servicesResource, "status", c.ns, service), &v1.Service{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.Service), err
|
||||
}
|
||||
|
||||
func (c *FakeServices) Delete(name string, options *api.DeleteOptions) error {
|
||||
_, err := c.Fake.
|
||||
Invokes(testing.NewDeleteAction(servicesResource, c.ns, name), &v1.Service{})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakeServices) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error {
|
||||
action := testing.NewDeleteCollectionAction(servicesResource, c.ns, listOptions)
|
||||
|
||||
_, err := c.Fake.Invokes(action, &v1.ServiceList{})
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakeServices) Get(name string) (result *v1.Service, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewGetAction(servicesResource, c.ns, name), &v1.Service{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.Service), err
|
||||
}
|
||||
|
||||
func (c *FakeServices) List(opts api.ListOptions) (result *v1.ServiceList, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewListAction(servicesResource, c.ns, opts), &v1.ServiceList{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
label := opts.LabelSelector
|
||||
if label == nil {
|
||||
label = labels.Everything()
|
||||
}
|
||||
list := &v1.ServiceList{}
|
||||
for _, item := range obj.(*v1.ServiceList).Items {
|
||||
if label.Matches(labels.Set(item.Labels)) {
|
||||
list.Items = append(list.Items, item)
|
||||
}
|
||||
}
|
||||
return list, err
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested services.
|
||||
func (c *FakeServices) Watch(opts api.ListOptions) (watch.Interface, error) {
|
||||
return c.Fake.
|
||||
InvokesWatch(testing.NewWatchAction(servicesResource, c.ns, opts))
|
||||
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched service.
|
||||
func (c *FakeServices) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.Service, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewPatchSubresourceAction(servicesResource, c.ns, name, data, subresources...), &v1.Service{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.Service), err
|
||||
}
|
26
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_service_expansion.go
generated
vendored
Normal file
26
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_service_expansion.go
generated
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
Copyright 2014 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
"k8s.io/client-go/1.5/rest"
|
||||
"k8s.io/client-go/1.5/testing"
|
||||
)
|
||||
|
||||
func (c *FakeServices) ProxyGet(scheme, name, port, path string, params map[string]string) rest.ResponseWrapper {
|
||||
return c.Fake.InvokesProxy(testing.NewProxyGetAction(servicesResource, c.ns, scheme, name, port, path, params))
|
||||
}
|
117
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_serviceaccount.go
generated
vendored
Normal file
117
vendor/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/fake_serviceaccount.go
generated
vendored
Normal file
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
api "k8s.io/client-go/1.5/pkg/api"
|
||||
unversioned "k8s.io/client-go/1.5/pkg/api/unversioned"
|
||||
v1 "k8s.io/client-go/1.5/pkg/api/v1"
|
||||
labels "k8s.io/client-go/1.5/pkg/labels"
|
||||
watch "k8s.io/client-go/1.5/pkg/watch"
|
||||
testing "k8s.io/client-go/1.5/testing"
|
||||
)
|
||||
|
||||
// FakeServiceAccounts implements ServiceAccountInterface
|
||||
type FakeServiceAccounts struct {
|
||||
Fake *FakeCore
|
||||
ns string
|
||||
}
|
||||
|
||||
var serviceaccountsResource = unversioned.GroupVersionResource{Group: "", Version: "v1", Resource: "serviceaccounts"}
|
||||
|
||||
func (c *FakeServiceAccounts) Create(serviceAccount *v1.ServiceAccount) (result *v1.ServiceAccount, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewCreateAction(serviceaccountsResource, c.ns, serviceAccount), &v1.ServiceAccount{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.ServiceAccount), err
|
||||
}
|
||||
|
||||
func (c *FakeServiceAccounts) Update(serviceAccount *v1.ServiceAccount) (result *v1.ServiceAccount, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewUpdateAction(serviceaccountsResource, c.ns, serviceAccount), &v1.ServiceAccount{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.ServiceAccount), err
|
||||
}
|
||||
|
||||
func (c *FakeServiceAccounts) Delete(name string, options *api.DeleteOptions) error {
|
||||
_, err := c.Fake.
|
||||
Invokes(testing.NewDeleteAction(serviceaccountsResource, c.ns, name), &v1.ServiceAccount{})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakeServiceAccounts) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error {
|
||||
action := testing.NewDeleteCollectionAction(serviceaccountsResource, c.ns, listOptions)
|
||||
|
||||
_, err := c.Fake.Invokes(action, &v1.ServiceAccountList{})
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakeServiceAccounts) Get(name string) (result *v1.ServiceAccount, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewGetAction(serviceaccountsResource, c.ns, name), &v1.ServiceAccount{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.ServiceAccount), err
|
||||
}
|
||||
|
||||
func (c *FakeServiceAccounts) List(opts api.ListOptions) (result *v1.ServiceAccountList, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewListAction(serviceaccountsResource, c.ns, opts), &v1.ServiceAccountList{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
label := opts.LabelSelector
|
||||
if label == nil {
|
||||
label = labels.Everything()
|
||||
}
|
||||
list := &v1.ServiceAccountList{}
|
||||
for _, item := range obj.(*v1.ServiceAccountList).Items {
|
||||
if label.Matches(labels.Set(item.Labels)) {
|
||||
list.Items = append(list.Items, item)
|
||||
}
|
||||
}
|
||||
return list, err
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested serviceAccounts.
|
||||
func (c *FakeServiceAccounts) Watch(opts api.ListOptions) (watch.Interface, error) {
|
||||
return c.Fake.
|
||||
InvokesWatch(testing.NewWatchAction(serviceaccountsResource, c.ns, opts))
|
||||
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched serviceAccount.
|
||||
func (c *FakeServiceAccounts) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.ServiceAccount, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewPatchSubresourceAction(serviceaccountsResource, c.ns, name, data, subresources...), &v1.ServiceAccount{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1.ServiceAccount), err
|
||||
}
|
|
@ -0,0 +1,487 @@
|
|||
/*
|
||||
Copyright 2015 The Kubernetes Authors.
|
||||
|
||||
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 testing
|
||||
|
||||
import (
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"k8s.io/client-go/1.5/pkg/api"
|
||||
"k8s.io/client-go/1.5/pkg/api/unversioned"
|
||||
"k8s.io/client-go/1.5/pkg/fields"
|
||||
"k8s.io/client-go/1.5/pkg/labels"
|
||||
"k8s.io/client-go/1.5/pkg/runtime"
|
||||
)
|
||||
|
||||
func NewRootGetAction(resource unversioned.GroupVersionResource, name string) GetActionImpl {
|
||||
action := GetActionImpl{}
|
||||
action.Verb = "get"
|
||||
action.Resource = resource
|
||||
action.Name = name
|
||||
|
||||
return action
|
||||
}
|
||||
|
||||
func NewGetAction(resource unversioned.GroupVersionResource, namespace, name string) GetActionImpl {
|
||||
action := GetActionImpl{}
|
||||
action.Verb = "get"
|
||||
action.Resource = resource
|
||||
action.Namespace = namespace
|
||||
action.Name = name
|
||||
|
||||
return action
|
||||
}
|
||||
|
||||
func NewRootListAction(resource unversioned.GroupVersionResource, opts api.ListOptions) ListActionImpl {
|
||||
action := ListActionImpl{}
|
||||
action.Verb = "list"
|
||||
action.Resource = resource
|
||||
labelSelector := opts.LabelSelector
|
||||
if labelSelector == nil {
|
||||
labelSelector = labels.Everything()
|
||||
}
|
||||
fieldSelector := opts.FieldSelector
|
||||
if fieldSelector == nil {
|
||||
fieldSelector = fields.Everything()
|
||||
}
|
||||
action.ListRestrictions = ListRestrictions{labelSelector, fieldSelector}
|
||||
|
||||
return action
|
||||
}
|
||||
|
||||
func NewListAction(resource unversioned.GroupVersionResource, namespace string, opts api.ListOptions) ListActionImpl {
|
||||
action := ListActionImpl{}
|
||||
action.Verb = "list"
|
||||
action.Resource = resource
|
||||
action.Namespace = namespace
|
||||
labelSelector := opts.LabelSelector
|
||||
if labelSelector == nil {
|
||||
labelSelector = labels.Everything()
|
||||
}
|
||||
fieldSelector := opts.FieldSelector
|
||||
if fieldSelector == nil {
|
||||
fieldSelector = fields.Everything()
|
||||
}
|
||||
action.ListRestrictions = ListRestrictions{labelSelector, fieldSelector}
|
||||
|
||||
return action
|
||||
}
|
||||
|
||||
func NewRootCreateAction(resource unversioned.GroupVersionResource, object runtime.Object) CreateActionImpl {
|
||||
action := CreateActionImpl{}
|
||||
action.Verb = "create"
|
||||
action.Resource = resource
|
||||
action.Object = object
|
||||
|
||||
return action
|
||||
}
|
||||
|
||||
func NewCreateAction(resource unversioned.GroupVersionResource, 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 unversioned.GroupVersionResource, object runtime.Object) UpdateActionImpl {
|
||||
action := UpdateActionImpl{}
|
||||
action.Verb = "update"
|
||||
action.Resource = resource
|
||||
action.Object = object
|
||||
|
||||
return action
|
||||
}
|
||||
|
||||
func NewUpdateAction(resource unversioned.GroupVersionResource, namespace string, object runtime.Object) UpdateActionImpl {
|
||||
action := UpdateActionImpl{}
|
||||
action.Verb = "update"
|
||||
action.Resource = resource
|
||||
action.Namespace = namespace
|
||||
action.Object = object
|
||||
|
||||
return action
|
||||
}
|
||||
|
||||
func NewRootPatchAction(resource unversioned.GroupVersionResource, name string, patch []byte) PatchActionImpl {
|
||||
action := PatchActionImpl{}
|
||||
action.Verb = "patch"
|
||||
action.Resource = resource
|
||||
action.Name = name
|
||||
action.Patch = patch
|
||||
|
||||
return action
|
||||
}
|
||||
|
||||
func NewPatchAction(resource unversioned.GroupVersionResource, namespace string, name string, patch []byte) PatchActionImpl {
|
||||
action := PatchActionImpl{}
|
||||
action.Verb = "patch"
|
||||
action.Resource = resource
|
||||
action.Namespace = namespace
|
||||
action.Name = name
|
||||
action.Patch = patch
|
||||
|
||||
return action
|
||||
}
|
||||
|
||||
func NewRootPatchSubresourceAction(resource unversioned.GroupVersionResource, name string, patch []byte, subresources ...string) PatchActionImpl {
|
||||
action := PatchActionImpl{}
|
||||
action.Verb = "patch"
|
||||
action.Resource = resource
|
||||
action.Subresource = path.Join(subresources...)
|
||||
action.Name = name
|
||||
action.Patch = patch
|
||||
|
||||
return action
|
||||
}
|
||||
|
||||
func NewPatchSubresourceAction(resource unversioned.GroupVersionResource, namespace, name string, patch []byte, subresources ...string) PatchActionImpl {
|
||||
action := PatchActionImpl{}
|
||||
action.Verb = "patch"
|
||||
action.Resource = resource
|
||||
action.Subresource = path.Join(subresources...)
|
||||
action.Namespace = namespace
|
||||
action.Name = name
|
||||
action.Patch = patch
|
||||
|
||||
return action
|
||||
}
|
||||
|
||||
func NewRootUpdateSubresourceAction(resource unversioned.GroupVersionResource, subresource string, object runtime.Object) UpdateActionImpl {
|
||||
action := UpdateActionImpl{}
|
||||
action.Verb = "update"
|
||||
action.Resource = resource
|
||||
action.Subresource = subresource
|
||||
action.Object = object
|
||||
|
||||
return action
|
||||
}
|
||||
func NewUpdateSubresourceAction(resource unversioned.GroupVersionResource, subresource string, namespace string, object runtime.Object) UpdateActionImpl {
|
||||
action := UpdateActionImpl{}
|
||||
action.Verb = "update"
|
||||
action.Resource = resource
|
||||
action.Subresource = subresource
|
||||
action.Namespace = namespace
|
||||
action.Object = object
|
||||
|
||||
return action
|
||||
}
|
||||
|
||||
func NewRootDeleteAction(resource unversioned.GroupVersionResource, name string) DeleteActionImpl {
|
||||
action := DeleteActionImpl{}
|
||||
action.Verb = "delete"
|
||||
action.Resource = resource
|
||||
action.Name = name
|
||||
|
||||
return action
|
||||
}
|
||||
|
||||
func NewDeleteAction(resource unversioned.GroupVersionResource, namespace, name string) DeleteActionImpl {
|
||||
action := DeleteActionImpl{}
|
||||
action.Verb = "delete"
|
||||
action.Resource = resource
|
||||
action.Namespace = namespace
|
||||
action.Name = name
|
||||
|
||||
return action
|
||||
}
|
||||
|
||||
func NewRootDeleteCollectionAction(resource unversioned.GroupVersionResource, opts api.ListOptions) DeleteCollectionActionImpl {
|
||||
action := DeleteCollectionActionImpl{}
|
||||
action.Verb = "delete-collection"
|
||||
action.Resource = resource
|
||||
labelSelector := opts.LabelSelector
|
||||
if labelSelector == nil {
|
||||
labelSelector = labels.Everything()
|
||||
}
|
||||
fieldSelector := opts.FieldSelector
|
||||
if fieldSelector == nil {
|
||||
fieldSelector = fields.Everything()
|
||||
}
|
||||
action.ListRestrictions = ListRestrictions{labelSelector, fieldSelector}
|
||||
|
||||
return action
|
||||
}
|
||||
|
||||
func NewDeleteCollectionAction(resource unversioned.GroupVersionResource, namespace string, opts api.ListOptions) DeleteCollectionActionImpl {
|
||||
action := DeleteCollectionActionImpl{}
|
||||
action.Verb = "delete-collection"
|
||||
action.Resource = resource
|
||||
action.Namespace = namespace
|
||||
labelSelector := opts.LabelSelector
|
||||
if labelSelector == nil {
|
||||
labelSelector = labels.Everything()
|
||||
}
|
||||
fieldSelector := opts.FieldSelector
|
||||
if fieldSelector == nil {
|
||||
fieldSelector = fields.Everything()
|
||||
}
|
||||
action.ListRestrictions = ListRestrictions{labelSelector, fieldSelector}
|
||||
|
||||
return action
|
||||
}
|
||||
|
||||
func NewRootWatchAction(resource unversioned.GroupVersionResource, opts api.ListOptions) WatchActionImpl {
|
||||
action := WatchActionImpl{}
|
||||
action.Verb = "watch"
|
||||
action.Resource = resource
|
||||
labelSelector := opts.LabelSelector
|
||||
if labelSelector == nil {
|
||||
labelSelector = labels.Everything()
|
||||
}
|
||||
fieldSelector := opts.FieldSelector
|
||||
if fieldSelector == nil {
|
||||
fieldSelector = fields.Everything()
|
||||
}
|
||||
action.WatchRestrictions = WatchRestrictions{labelSelector, fieldSelector, opts.ResourceVersion}
|
||||
|
||||
return action
|
||||
}
|
||||
|
||||
func NewWatchAction(resource unversioned.GroupVersionResource, namespace string, opts api.ListOptions) WatchActionImpl {
|
||||
action := WatchActionImpl{}
|
||||
action.Verb = "watch"
|
||||
action.Resource = resource
|
||||
action.Namespace = namespace
|
||||
labelSelector := opts.LabelSelector
|
||||
if labelSelector == nil {
|
||||
labelSelector = labels.Everything()
|
||||
}
|
||||
fieldSelector := opts.FieldSelector
|
||||
if fieldSelector == nil {
|
||||
fieldSelector = fields.Everything()
|
||||
}
|
||||
action.WatchRestrictions = WatchRestrictions{labelSelector, fieldSelector, opts.ResourceVersion}
|
||||
|
||||
return action
|
||||
}
|
||||
|
||||
func NewProxyGetAction(resource unversioned.GroupVersionResource, namespace, scheme, name, port, path string, params map[string]string) ProxyGetActionImpl {
|
||||
action := ProxyGetActionImpl{}
|
||||
action.Verb = "get"
|
||||
action.Resource = resource
|
||||
action.Namespace = namespace
|
||||
action.Scheme = scheme
|
||||
action.Name = name
|
||||
action.Port = port
|
||||
action.Path = path
|
||||
action.Params = params
|
||||
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() unversioned.GroupVersionResource
|
||||
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 ProxyGetAction interface {
|
||||
Action
|
||||
GetScheme() string
|
||||
GetName() string
|
||||
GetPort() string
|
||||
GetPath() string
|
||||
GetParams() map[string]string
|
||||
}
|
||||
|
||||
type ActionImpl struct {
|
||||
Namespace string
|
||||
Verb string
|
||||
Resource unversioned.GroupVersionResource
|
||||
Subresource string
|
||||
}
|
||||
|
||||
func (a ActionImpl) GetNamespace() string {
|
||||
return a.Namespace
|
||||
}
|
||||
func (a ActionImpl) GetVerb() string {
|
||||
return a.Verb
|
||||
}
|
||||
func (a ActionImpl) GetResource() unversioned.GroupVersionResource {
|
||||
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.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 PatchActionImpl struct {
|
||||
ActionImpl
|
||||
Name string
|
||||
Patch []byte
|
||||
}
|
||||
|
||||
func (a PatchActionImpl) GetName() string {
|
||||
return a.Name
|
||||
}
|
||||
|
||||
func (a PatchActionImpl) GetPatch() []byte {
|
||||
return a.Patch
|
||||
}
|
||||
|
||||
type DeleteActionImpl struct {
|
||||
ActionImpl
|
||||
Name string
|
||||
}
|
||||
|
||||
func (a DeleteActionImpl) GetName() string {
|
||||
return a.Name
|
||||
}
|
||||
|
||||
type DeleteCollectionActionImpl struct {
|
||||
ActionImpl
|
||||
ListRestrictions ListRestrictions
|
||||
}
|
||||
|
||||
func (a DeleteCollectionActionImpl) GetListRestrictions() ListRestrictions {
|
||||
return a.ListRestrictions
|
||||
}
|
||||
|
||||
type WatchActionImpl struct {
|
||||
ActionImpl
|
||||
WatchRestrictions WatchRestrictions
|
||||
}
|
||||
|
||||
func (a WatchActionImpl) GetWatchRestrictions() WatchRestrictions {
|
||||
return a.WatchRestrictions
|
||||
}
|
||||
|
||||
type ProxyGetActionImpl struct {
|
||||
ActionImpl
|
||||
Scheme string
|
||||
Name string
|
||||
Port string
|
||||
Path string
|
||||
Params map[string]string
|
||||
}
|
||||
|
||||
func (a ProxyGetActionImpl) GetScheme() string {
|
||||
return a.Scheme
|
||||
}
|
||||
|
||||
func (a ProxyGetActionImpl) GetName() string {
|
||||
return a.Name
|
||||
}
|
||||
|
||||
func (a ProxyGetActionImpl) GetPort() string {
|
||||
return a.Port
|
||||
}
|
||||
|
||||
func (a ProxyGetActionImpl) GetPath() string {
|
||||
return a.Path
|
||||
}
|
||||
|
||||
func (a ProxyGetActionImpl) GetParams() map[string]string {
|
||||
return a.Params
|
||||
}
|
|
@ -0,0 +1,251 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
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 testing
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"k8s.io/client-go/1.5/pkg/api/unversioned"
|
||||
"k8s.io/client-go/1.5/pkg/runtime"
|
||||
"k8s.io/client-go/1.5/pkg/version"
|
||||
"k8s.io/client-go/1.5/pkg/watch"
|
||||
"k8s.io/client-go/1.5/rest"
|
||||
)
|
||||
|
||||
// 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.
|
||||
type Fake struct {
|
||||
sync.RWMutex
|
||||
actions []Action // these may be castable to other types, but "Action" is the minimum
|
||||
|
||||
// ReactionChain is the list of reactors that will be attempted for every
|
||||
// request in the order they are tried.
|
||||
ReactionChain []Reactor
|
||||
// WatchReactionChain is the list of watch reactors that will be attempted
|
||||
// for every request in the order they are tried.
|
||||
WatchReactionChain []WatchReactor
|
||||
// ProxyReactionChain is the list of proxy reactors that will be attempted
|
||||
// for every request in the order they are tried.
|
||||
ProxyReactionChain []ProxyReactor
|
||||
|
||||
Resources map[string]*unversioned.APIResourceList
|
||||
}
|
||||
|
||||
// Reactor is an interface to allow the composition of reaction functions.
|
||||
type Reactor interface {
|
||||
// Handles indicates whether or not this Reactor deals with a given
|
||||
// action.
|
||||
Handles(action Action) bool
|
||||
// React handles the action and returns results. It may choose to
|
||||
// delegate by indicated handled=false.
|
||||
React(action Action) (handled bool, ret runtime.Object, err error)
|
||||
}
|
||||
|
||||
// WatchReactor is an interface to allow the composition of watch functions.
|
||||
type WatchReactor interface {
|
||||
// Handles indicates whether or not this Reactor deals with a given
|
||||
// action.
|
||||
Handles(action Action) bool
|
||||
// React handles a watch action and returns results. It may choose to
|
||||
// delegate by indicating handled=false.
|
||||
React(action Action) (handled bool, ret watch.Interface, err error)
|
||||
}
|
||||
|
||||
// ProxyReactor is an interface to allow the composition of proxy get
|
||||
// functions.
|
||||
type ProxyReactor interface {
|
||||
// Handles indicates whether or not this Reactor deals with a given
|
||||
// action.
|
||||
Handles(action Action) bool
|
||||
// React handles a watch action and returns results. It may choose to
|
||||
// delegate by indicating handled=false.
|
||||
React(action Action) (handled bool, ret rest.ResponseWrapper, err error)
|
||||
}
|
||||
|
||||
// ReactionFunc is a function that returns an object or error for a given
|
||||
// Action. If "handled" is false, then the test client will ignore the
|
||||
// results and continue to the next ReactionFunc. A ReactionFunc can describe
|
||||
// reactions on subresources by testing the result of the action's
|
||||
// GetSubresource() method.
|
||||
type ReactionFunc func(action Action) (handled bool, ret runtime.Object, err error)
|
||||
|
||||
// WatchReactionFunc is a function that returns a watch interface. If
|
||||
// "handled" is false, then the test client will ignore the results and
|
||||
// continue to the next ReactionFunc.
|
||||
type WatchReactionFunc func(action Action) (handled bool, ret watch.Interface, err error)
|
||||
|
||||
// ProxyReactionFunc is a function that returns a ResponseWrapper interface
|
||||
// for a given Action. If "handled" is false, then the test client will
|
||||
// ignore the results and continue to the next ProxyReactionFunc.
|
||||
type ProxyReactionFunc func(action Action) (handled bool, ret rest.ResponseWrapper, err error)
|
||||
|
||||
// AddReactor appends a reactor to the end of the chain.
|
||||
func (c *Fake) AddReactor(verb, resource string, reaction ReactionFunc) {
|
||||
c.ReactionChain = append(c.ReactionChain, &SimpleReactor{verb, resource, reaction})
|
||||
}
|
||||
|
||||
// PrependReactor adds a reactor to the beginning of the chain.
|
||||
func (c *Fake) PrependReactor(verb, resource string, reaction ReactionFunc) {
|
||||
c.ReactionChain = append([]Reactor{&SimpleReactor{verb, resource, reaction}}, c.ReactionChain...)
|
||||
}
|
||||
|
||||
// AddWatchReactor appends a reactor to the end of the chain.
|
||||
func (c *Fake) AddWatchReactor(resource string, reaction WatchReactionFunc) {
|
||||
c.WatchReactionChain = append(c.WatchReactionChain, &SimpleWatchReactor{resource, reaction})
|
||||
}
|
||||
|
||||
// PrependWatchReactor adds a reactor to the beginning of the chain.
|
||||
func (c *Fake) PrependWatchReactor(resource string, reaction WatchReactionFunc) {
|
||||
c.WatchReactionChain = append([]WatchReactor{&SimpleWatchReactor{resource, reaction}}, c.WatchReactionChain...)
|
||||
}
|
||||
|
||||
// AddProxyReactor appends a reactor to the end of the chain.
|
||||
func (c *Fake) AddProxyReactor(resource string, reaction ProxyReactionFunc) {
|
||||
c.ProxyReactionChain = append(c.ProxyReactionChain, &SimpleProxyReactor{resource, reaction})
|
||||
}
|
||||
|
||||
// PrependProxyReactor adds a reactor to the beginning of the chain.
|
||||
func (c *Fake) PrependProxyReactor(resource string, reaction ProxyReactionFunc) {
|
||||
c.ProxyReactionChain = append([]ProxyReactor{&SimpleProxyReactor{resource, reaction}}, c.ProxyReactionChain...)
|
||||
}
|
||||
|
||||
// Invokes records the provided Action and then invokes the ReactionFunc that
|
||||
// handles the action if one exists. defaultReturnObj is expected to be of the
|
||||
// same type a normal call would return.
|
||||
func (c *Fake) Invokes(action Action, defaultReturnObj runtime.Object) (runtime.Object, error) {
|
||||
c.Lock()
|
||||
defer c.Unlock()
|
||||
|
||||
c.actions = append(c.actions, action)
|
||||
for _, reactor := range c.ReactionChain {
|
||||
if !reactor.Handles(action) {
|
||||
continue
|
||||
}
|
||||
|
||||
handled, ret, err := reactor.React(action)
|
||||
if !handled {
|
||||
continue
|
||||
}
|
||||
|
||||
return ret, err
|
||||
}
|
||||
|
||||
return defaultReturnObj, nil
|
||||
}
|
||||
|
||||
// InvokesWatch records the provided Action and then invokes the ReactionFunc
|
||||
// that handles the action if one exists.
|
||||
func (c *Fake) InvokesWatch(action Action) (watch.Interface, error) {
|
||||
c.Lock()
|
||||
defer c.Unlock()
|
||||
|
||||
c.actions = append(c.actions, action)
|
||||
for _, reactor := range c.WatchReactionChain {
|
||||
if !reactor.Handles(action) {
|
||||
continue
|
||||
}
|
||||
|
||||
handled, ret, err := reactor.React(action)
|
||||
if !handled {
|
||||
continue
|
||||
}
|
||||
|
||||
return ret, err
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("unhandled watch: %#v", action)
|
||||
}
|
||||
|
||||
// InvokesProxy records the provided Action and then invokes the ReactionFunc
|
||||
// that handles the action if one exists.
|
||||
func (c *Fake) InvokesProxy(action Action) rest.ResponseWrapper {
|
||||
c.Lock()
|
||||
defer c.Unlock()
|
||||
|
||||
c.actions = append(c.actions, action)
|
||||
for _, reactor := range c.ProxyReactionChain {
|
||||
if !reactor.Handles(action) {
|
||||
continue
|
||||
}
|
||||
|
||||
handled, ret, err := reactor.React(action)
|
||||
if !handled || err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ClearActions clears the history of actions called on the fake client.
|
||||
func (c *Fake) ClearActions() {
|
||||
c.Lock()
|
||||
defer c.Unlock()
|
||||
|
||||
c.actions = make([]Action, 0)
|
||||
}
|
||||
|
||||
// Actions returns a chronologically ordered slice fake actions called on the
|
||||
// fake client.
|
||||
func (c *Fake) Actions() []Action {
|
||||
c.RLock()
|
||||
defer c.RUnlock()
|
||||
fa := make([]Action, len(c.actions))
|
||||
copy(fa, c.actions)
|
||||
return fa
|
||||
}
|
||||
|
||||
// TODO: this probably should be moved to somewhere else.
|
||||
type FakeDiscovery struct {
|
||||
*Fake
|
||||
}
|
||||
|
||||
func (c *FakeDiscovery) ServerResourcesForGroupVersion(groupVersion string) (*unversioned.APIResourceList, error) {
|
||||
action := ActionImpl{
|
||||
Verb: "get",
|
||||
Resource: unversioned.GroupVersionResource{Resource: "resource"},
|
||||
}
|
||||
c.Invokes(action, nil)
|
||||
return c.Resources[groupVersion], nil
|
||||
}
|
||||
|
||||
func (c *FakeDiscovery) ServerResources() (map[string]*unversioned.APIResourceList, error) {
|
||||
action := ActionImpl{
|
||||
Verb: "get",
|
||||
Resource: unversioned.GroupVersionResource{Resource: "resource"},
|
||||
}
|
||||
c.Invokes(action, nil)
|
||||
return c.Resources, nil
|
||||
}
|
||||
|
||||
func (c *FakeDiscovery) ServerGroups() (*unversioned.APIGroupList, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *FakeDiscovery) ServerVersion() (*version.Info, error) {
|
||||
action := ActionImpl{}
|
||||
action.Verb = "get"
|
||||
action.Resource = unversioned.GroupVersionResource{Resource: "version"}
|
||||
|
||||
c.Invokes(action, nil)
|
||||
versionInfo := version.Get()
|
||||
return &versionInfo, nil
|
||||
}
|
|
@ -0,0 +1,490 @@
|
|||
/*
|
||||
Copyright 2015 The Kubernetes Authors.
|
||||
|
||||
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 testing
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"k8s.io/client-go/1.5/pkg/api/errors"
|
||||
"k8s.io/client-go/1.5/pkg/api/meta"
|
||||
"k8s.io/client-go/1.5/pkg/api/unversioned"
|
||||
"k8s.io/client-go/1.5/pkg/apimachinery/registered"
|
||||
"k8s.io/client-go/1.5/pkg/runtime"
|
||||
"k8s.io/client-go/1.5/pkg/watch"
|
||||
"k8s.io/client-go/1.5/rest"
|
||||
)
|
||||
|
||||
// ObjectTracker keeps track of objects. It is intended to be used to
|
||||
// fake calls to a server by returning objects based on their kind,
|
||||
// namespace and name.
|
||||
type ObjectTracker interface {
|
||||
// Add adds an object to the tracker. If object being added
|
||||
// is a list, its items are added separately.
|
||||
Add(obj runtime.Object) error
|
||||
|
||||
// Get retrieves the object by its kind, namespace and name.
|
||||
Get(gvk unversioned.GroupVersionKind, ns, name string) (runtime.Object, error)
|
||||
|
||||
// Update updates an existing object in the tracker.
|
||||
Update(obj runtime.Object) error
|
||||
|
||||
// List retrieves all objects of a given kind in the given
|
||||
// namespace. Only non-List kinds are accepted.
|
||||
List(gvk unversioned.GroupVersionKind, ns string) (runtime.Object, error)
|
||||
|
||||
// Delete deletes an existing object from the tracker. If object
|
||||
// didn't exist in the tracker prior to deletion, Delete returns
|
||||
// no error.
|
||||
Delete(gvk unversioned.GroupVersionKind, ns, name string) error
|
||||
}
|
||||
|
||||
// ObjectScheme abstracts the implementation of common operations on objects.
|
||||
type ObjectScheme interface {
|
||||
runtime.ObjectCreater
|
||||
runtime.ObjectCopier
|
||||
runtime.ObjectTyper
|
||||
}
|
||||
|
||||
// ObjectReaction returns a ReactionFunc that applies core.Action to
|
||||
// the given tracker.
|
||||
func ObjectReaction(tracker ObjectTracker, mapper meta.RESTMapper) ReactionFunc {
|
||||
return func(action Action) (bool, runtime.Object, error) {
|
||||
ns := action.GetNamespace()
|
||||
gvr := action.GetResource()
|
||||
|
||||
gvk, err := mapper.KindFor(gvr)
|
||||
if err != nil {
|
||||
return false, nil, fmt.Errorf("error getting kind for resource %q: %s", gvr, err)
|
||||
}
|
||||
|
||||
// This is a temporary fix. Because there is no internal resource, so
|
||||
// the caller has no way to express that it expects to get an internal
|
||||
// kind back. A more proper fix will be directly specify the Kind when
|
||||
// build the action.
|
||||
gvk.Version = gvr.Version
|
||||
if len(gvk.Version) == 0 {
|
||||
gvk.Version = runtime.APIVersionInternal
|
||||
}
|
||||
|
||||
// Here and below we need to switch on implementation types,
|
||||
// not on interfaces, as some interfaces are identical
|
||||
// (e.g. UpdateAction and CreateAction), so if we use them,
|
||||
// updates and creates end up matching the same case branch.
|
||||
switch action := action.(type) {
|
||||
|
||||
case ListActionImpl:
|
||||
obj, err := tracker.List(gvk, ns)
|
||||
return true, obj, err
|
||||
|
||||
case GetActionImpl:
|
||||
obj, err := tracker.Get(gvk, ns, action.GetName())
|
||||
return true, obj, err
|
||||
|
||||
case CreateActionImpl:
|
||||
objMeta, err := meta.Accessor(action.GetObject())
|
||||
if err != nil {
|
||||
return true, nil, err
|
||||
}
|
||||
if action.GetSubresource() == "" {
|
||||
err = tracker.Add(action.GetObject())
|
||||
} else {
|
||||
// TODO: Currently we're handling subresource creation as an update
|
||||
// on the enclosing resource. This works for some subresources but
|
||||
// might not be generic enough.
|
||||
err = tracker.Update(action.GetObject())
|
||||
}
|
||||
if err != nil {
|
||||
return true, nil, err
|
||||
}
|
||||
obj, err := tracker.Get(gvk, ns, objMeta.GetName())
|
||||
return true, obj, err
|
||||
|
||||
case UpdateActionImpl:
|
||||
objMeta, err := meta.Accessor(action.GetObject())
|
||||
if err != nil {
|
||||
return true, nil, err
|
||||
}
|
||||
err = tracker.Update(action.GetObject())
|
||||
if err != nil {
|
||||
return true, nil, err
|
||||
}
|
||||
obj, err := tracker.Get(gvk, ns, objMeta.GetName())
|
||||
return true, obj, err
|
||||
|
||||
case DeleteActionImpl:
|
||||
err := tracker.Delete(gvk, ns, action.GetName())
|
||||
if err != nil {
|
||||
return true, nil, err
|
||||
}
|
||||
return true, nil, nil
|
||||
|
||||
default:
|
||||
return false, nil, fmt.Errorf("no reaction implemented for %s", action)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type tracker struct {
|
||||
scheme ObjectScheme
|
||||
decoder runtime.Decoder
|
||||
lock sync.RWMutex
|
||||
objects map[unversioned.GroupVersionKind][]runtime.Object
|
||||
}
|
||||
|
||||
var _ ObjectTracker = &tracker{}
|
||||
|
||||
// NewObjectTracker returns an ObjectTracker that can be used to keep track
|
||||
// of objects for the fake clientset. Mostly useful for unit tests.
|
||||
func NewObjectTracker(scheme ObjectScheme, decoder runtime.Decoder) ObjectTracker {
|
||||
return &tracker{
|
||||
scheme: scheme,
|
||||
decoder: decoder,
|
||||
objects: make(map[unversioned.GroupVersionKind][]runtime.Object),
|
||||
}
|
||||
}
|
||||
|
||||
func (t *tracker) List(gvk unversioned.GroupVersionKind, ns string) (runtime.Object, error) {
|
||||
// Heuristic for list kind: original kind + List suffix. Might
|
||||
// not always be true but this tracker has a pretty limited
|
||||
// understanding of the actual API model.
|
||||
listGVK := gvk
|
||||
listGVK.Kind = listGVK.Kind + "List"
|
||||
|
||||
list, err := t.scheme.New(listGVK)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !meta.IsListType(list) {
|
||||
return nil, fmt.Errorf("%q is not a list type", listGVK.Kind)
|
||||
}
|
||||
|
||||
t.lock.RLock()
|
||||
defer t.lock.RUnlock()
|
||||
|
||||
objs, ok := t.objects[gvk]
|
||||
if !ok {
|
||||
return list, nil
|
||||
}
|
||||
|
||||
matchingObjs, err := filterByNamespaceAndName(objs, ns, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := meta.SetList(list, matchingObjs); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if list, err = t.scheme.Copy(list); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
|
||||
func (t *tracker) Get(gvk unversioned.GroupVersionKind, ns, name string) (runtime.Object, error) {
|
||||
if err := checkNamespace(gvk, ns); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
errNotFound := errors.NewNotFound(unversioned.GroupResource{Group: gvk.Group, Resource: gvk.Kind}, name)
|
||||
|
||||
t.lock.RLock()
|
||||
defer t.lock.RUnlock()
|
||||
|
||||
objs, ok := t.objects[gvk]
|
||||
if !ok {
|
||||
return nil, errNotFound
|
||||
}
|
||||
|
||||
matchingObjs, err := filterByNamespaceAndName(objs, ns, name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(matchingObjs) == 0 {
|
||||
return nil, errNotFound
|
||||
}
|
||||
if len(matchingObjs) > 1 {
|
||||
return nil, fmt.Errorf("more than one object matched gvk %s, ns: %q name: %q", gvk, ns, name)
|
||||
}
|
||||
|
||||
// Only one object should match in the tracker if it works
|
||||
// correctly, as Add/Update methods enforce kind/namespace/name
|
||||
// uniqueness.
|
||||
obj, err := t.scheme.Copy(matchingObjs[0])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if status, ok := obj.(*unversioned.Status); ok {
|
||||
if status.Details != nil {
|
||||
status.Details.Kind = gvk.Kind
|
||||
}
|
||||
if status.Status != unversioned.StatusSuccess {
|
||||
return nil, &errors.StatusError{ErrStatus: *status}
|
||||
}
|
||||
}
|
||||
|
||||
return obj, nil
|
||||
}
|
||||
|
||||
func (t *tracker) Add(obj runtime.Object) error {
|
||||
return t.add(obj, false)
|
||||
}
|
||||
|
||||
func (t *tracker) Update(obj runtime.Object) error {
|
||||
return t.add(obj, true)
|
||||
}
|
||||
|
||||
func (t *tracker) add(obj runtime.Object, replaceExisting bool) error {
|
||||
if meta.IsListType(obj) {
|
||||
return t.addList(obj, replaceExisting)
|
||||
}
|
||||
|
||||
gvks, _, err := t.scheme.ObjectKinds(obj)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(gvks) == 0 {
|
||||
return fmt.Errorf("no registered kinds for %v", obj)
|
||||
}
|
||||
|
||||
t.lock.Lock()
|
||||
defer t.lock.Unlock()
|
||||
|
||||
for _, gvk := range gvks {
|
||||
gr := unversioned.GroupResource{Group: gvk.Group, Resource: gvk.Kind}
|
||||
|
||||
// To avoid the object from being accidentally modified by caller
|
||||
// after it's been added to the tracker, we always store the deep
|
||||
// copy.
|
||||
obj, err = t.scheme.Copy(obj)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if status, ok := obj.(*unversioned.Status); ok && status.Details != nil {
|
||||
gvk.Kind = status.Details.Kind
|
||||
}
|
||||
|
||||
newMeta, err := meta.Accessor(obj)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := checkNamespace(gvk, newMeta.GetNamespace()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for i, existingObj := range t.objects[gvk] {
|
||||
oldMeta, err := meta.Accessor(existingObj)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if oldMeta.GetNamespace() == newMeta.GetNamespace() && oldMeta.GetName() == newMeta.GetName() {
|
||||
if replaceExisting {
|
||||
t.objects[gvk][i] = obj
|
||||
return nil
|
||||
}
|
||||
return errors.NewAlreadyExists(gr, newMeta.GetName())
|
||||
}
|
||||
}
|
||||
|
||||
if replaceExisting {
|
||||
// Tried to update but no matching object was found.
|
||||
return errors.NewNotFound(gr, newMeta.GetName())
|
||||
}
|
||||
|
||||
t.objects[gvk] = append(t.objects[gvk], obj)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *tracker) addList(obj runtime.Object, replaceExisting bool) error {
|
||||
list, err := meta.ExtractList(obj)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
errs := runtime.DecodeList(list, t.decoder)
|
||||
if len(errs) > 0 {
|
||||
return errs[0]
|
||||
}
|
||||
for _, obj := range list {
|
||||
err := t.add(obj, replaceExisting)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *tracker) Delete(gvk unversioned.GroupVersionKind, ns, name string) error {
|
||||
if err := checkNamespace(gvk, ns); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
t.lock.Lock()
|
||||
defer t.lock.Unlock()
|
||||
|
||||
found := false
|
||||
|
||||
for i, existingObj := range t.objects[gvk] {
|
||||
objMeta, err := meta.Accessor(existingObj)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if objMeta.GetNamespace() == ns && objMeta.GetName() == name {
|
||||
t.objects[gvk] = append(t.objects[gvk][:i], t.objects[gvk][i+1:]...)
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if found {
|
||||
return nil
|
||||
}
|
||||
|
||||
return errors.NewNotFound(unversioned.GroupResource{Group: gvk.Group, Resource: gvk.Kind}, name)
|
||||
}
|
||||
|
||||
// filterByNamespaceAndName returns all objects in the collection that
|
||||
// match provided namespace and name. Empty namespace matches
|
||||
// non-namespaced objects.
|
||||
func filterByNamespaceAndName(objs []runtime.Object, ns, name string) ([]runtime.Object, error) {
|
||||
var res []runtime.Object
|
||||
|
||||
for _, obj := range objs {
|
||||
acc, err := meta.Accessor(obj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if ns != "" && acc.GetNamespace() != ns {
|
||||
continue
|
||||
}
|
||||
if name != "" && acc.GetName() != name {
|
||||
continue
|
||||
}
|
||||
res = append(res, obj)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// checkNamespace makes sure that the scope of gvk matches ns. It
|
||||
// returns an error if namespace is empty but gvk is a namespaced
|
||||
// kind, or if ns is non-empty and gvk is a namespaced kind.
|
||||
func checkNamespace(gvk unversioned.GroupVersionKind, ns string) error {
|
||||
group, err := registered.Group(gvk.Group)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
mapping, err := group.RESTMapper.RESTMapping(gvk.GroupKind(), gvk.Version)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
switch mapping.Scope.Name() {
|
||||
case meta.RESTScopeNameRoot:
|
||||
if ns != "" {
|
||||
return fmt.Errorf("namespace specified for a non-namespaced kind %s", gvk)
|
||||
}
|
||||
case meta.RESTScopeNameNamespace:
|
||||
if ns == "" {
|
||||
// Skipping this check for Events, since
|
||||
// controllers emit events that have no namespace,
|
||||
// even though Event is a namespaced resource.
|
||||
if gvk.Kind != "Event" {
|
||||
return fmt.Errorf("no namespace specified for a namespaced kind %s", gvk)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func DefaultWatchReactor(watchInterface watch.Interface, err error) WatchReactionFunc {
|
||||
return func(action Action) (bool, watch.Interface, error) {
|
||||
return true, watchInterface, err
|
||||
}
|
||||
}
|
||||
|
||||
// SimpleReactor is a Reactor. Each reaction function is attached to a given verb,resource tuple. "*" in either field matches everything for that value.
|
||||
// For instance, *,pods matches all verbs on pods. This allows for easier composition of reaction functions
|
||||
type SimpleReactor struct {
|
||||
Verb string
|
||||
Resource string
|
||||
|
||||
Reaction ReactionFunc
|
||||
}
|
||||
|
||||
func (r *SimpleReactor) Handles(action Action) bool {
|
||||
verbCovers := r.Verb == "*" || r.Verb == action.GetVerb()
|
||||
if !verbCovers {
|
||||
return false
|
||||
}
|
||||
resourceCovers := r.Resource == "*" || r.Resource == action.GetResource().Resource
|
||||
if !resourceCovers {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (r *SimpleReactor) React(action Action) (bool, runtime.Object, error) {
|
||||
return r.Reaction(action)
|
||||
}
|
||||
|
||||
// SimpleWatchReactor is a WatchReactor. Each reaction function is attached to a given resource. "*" matches everything for that value.
|
||||
// For instance, *,pods matches all verbs on pods. This allows for easier composition of reaction functions
|
||||
type SimpleWatchReactor struct {
|
||||
Resource string
|
||||
|
||||
Reaction WatchReactionFunc
|
||||
}
|
||||
|
||||
func (r *SimpleWatchReactor) Handles(action Action) bool {
|
||||
resourceCovers := r.Resource == "*" || r.Resource == action.GetResource().Resource
|
||||
if !resourceCovers {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (r *SimpleWatchReactor) React(action Action) (bool, watch.Interface, error) {
|
||||
return r.Reaction(action)
|
||||
}
|
||||
|
||||
// SimpleProxyReactor is a ProxyReactor. Each reaction function is attached to a given resource. "*" matches everything for that value.
|
||||
// For instance, *,pods matches all verbs on pods. This allows for easier composition of reaction functions.
|
||||
type SimpleProxyReactor struct {
|
||||
Resource string
|
||||
|
||||
Reaction ProxyReactionFunc
|
||||
}
|
||||
|
||||
func (r *SimpleProxyReactor) Handles(action Action) bool {
|
||||
resourceCovers := r.Resource == "*" || r.Resource == action.GetResource().Resource
|
||||
if !resourceCovers {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (r *SimpleProxyReactor) React(action Action) (bool, rest.ResponseWrapper, error) {
|
||||
return r.Reaction(action)
|
||||
}
|
Loading…
Reference in New Issue